line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: SinFP4.pm 2236 2015-02-15 17:03:25Z gomor $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::SinFP::SinFP4; |
5
|
1
|
|
|
1
|
|
1158
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
36
|
|
|
1
|
|
|
|
|
132
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Net::SinFP; |
9
|
|
|
|
|
|
|
our @ISA = qw(Net::SinFP); |
10
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require Net::Packet::Frame; |
13
|
|
|
|
|
|
|
require Net::Packet::IPv4; |
14
|
|
|
|
|
|
|
require Net::Packet::TCP; |
15
|
1
|
|
|
1
|
|
968
|
use Net::Packet::Consts qw(:tcp); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Net::Packet::Env qw($Env); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub getIpVersion { 'IPv4' } |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _getFilterPassive { |
21
|
|
|
|
|
|
|
'(ip and tcp and '. |
22
|
|
|
|
|
|
|
'((tcp[tcpflags] & tcp-syn != 0) and'. |
23
|
|
|
|
|
|
|
' (tcp[tcpflags] & tcp-ack != 0)) or'. |
24
|
|
|
|
|
|
|
' (tcp[tcpflags] & tcp-syn != 0))'. |
25
|
|
|
|
|
|
|
' and (not src host '.$Env->ip.')'; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _getFilterActive { |
29
|
|
|
|
|
|
|
my $self = shift; |
30
|
|
|
|
|
|
|
'host '.$self->target->ip.' and host '.$Env->ip; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _getFileNamePassive { 'sinfp4-passive.pcap' } |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _getFileNameActive { |
36
|
|
|
|
|
|
|
my $self = shift; |
37
|
|
|
|
|
|
|
'sinfp4-'.$self->target->ip.'.'.$self->target->port.'.pcap'; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub getOfflineProbes { |
41
|
|
|
|
|
|
|
my $self = shift; |
42
|
|
|
|
|
|
|
my ($targetIp) = @_; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
for ($self->_dump->frames) { |
45
|
|
|
|
|
|
|
next unless $_->isIpv4 && $_->isTcp; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
if ($self->doP1 |
48
|
|
|
|
|
|
|
&& $_->getLength == 40 && $_->l4->haveFlagSyn && ! $_->l4->haveFlagAck |
49
|
|
|
|
|
|
|
&& ! $self->pktP1) { |
50
|
|
|
|
|
|
|
$self->pktP1($_); |
51
|
|
|
|
|
|
|
next; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
if ($self->doP2 |
55
|
|
|
|
|
|
|
&& $_->getLength == 60 && $_->l4->haveFlagSyn && ! $_->l4->haveFlagAck |
56
|
|
|
|
|
|
|
&& ! $self->pktP2) { |
57
|
|
|
|
|
|
|
$self->pktP2($_); |
58
|
|
|
|
|
|
|
next; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
if ($self->doP3 |
62
|
|
|
|
|
|
|
&& $_->getLength == 40 && $_->l4->haveFlagSyn && $_->l4->haveFlagAck |
63
|
|
|
|
|
|
|
&& ! $self->pktP3) { |
64
|
|
|
|
|
|
|
$self->pktP3($_); |
65
|
|
|
|
|
|
|
next; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub getResponseIpTtl { shift; shift->reply->l3->ttl } |
71
|
|
|
|
|
|
|
sub getResponseIpId { shift; shift->reply->l3->id } |
72
|
|
|
|
|
|
|
sub getResponseIpDfBit { shift; shift->reply->l3->haveFlagDf } |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub getProbeIpId { shift; shift->l3->id } |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub getP1 { |
77
|
|
|
|
|
|
|
my $self = shift; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my $ip4 = Net::Packet::IPv4->new( |
80
|
|
|
|
|
|
|
tos => 0, |
81
|
|
|
|
|
|
|
id => $self->_pIpId, |
82
|
|
|
|
|
|
|
flags => 0, |
83
|
|
|
|
|
|
|
offset => 0, |
84
|
|
|
|
|
|
|
ttl => 255, |
85
|
|
|
|
|
|
|
protocol => 6, |
86
|
|
|
|
|
|
|
dst => $self->target->ip, |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $tcp = Net::Packet::TCP->new( |
90
|
|
|
|
|
|
|
src => $self->_pTcpSrc, |
91
|
|
|
|
|
|
|
seq => $self->_pTcpSeq, |
92
|
|
|
|
|
|
|
ack => $self->_pTcpAck, |
93
|
|
|
|
|
|
|
dst => $self->target->port, |
94
|
|
|
|
|
|
|
x2 => 0, |
95
|
|
|
|
|
|
|
flags => NP_TCP_FLAG_SYN, |
96
|
|
|
|
|
|
|
win => 5840, |
97
|
|
|
|
|
|
|
); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Net::Packet::Frame->new(l3 => $ip4, l4 => $tcp), |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub getP2 { |
103
|
|
|
|
|
|
|
my $self = shift; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my $ip4 = Net::Packet::IPv4->new( |
106
|
|
|
|
|
|
|
tos => 0, |
107
|
|
|
|
|
|
|
id => $self->_pIpId + 1, |
108
|
|
|
|
|
|
|
flags => 0, |
109
|
|
|
|
|
|
|
offset => 0, |
110
|
|
|
|
|
|
|
ttl => 255, |
111
|
|
|
|
|
|
|
protocol => 6, |
112
|
|
|
|
|
|
|
dst => $self->target->ip, |
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $tcp = Net::Packet::TCP->new( |
116
|
|
|
|
|
|
|
src => $self->_pTcpSrc + 1, |
117
|
|
|
|
|
|
|
seq => $self->_pTcpSeq + 1, |
118
|
|
|
|
|
|
|
ack => $self->_pTcpAck + 1, |
119
|
|
|
|
|
|
|
dst => $self->target->port, |
120
|
|
|
|
|
|
|
x2 => 0, |
121
|
|
|
|
|
|
|
flags => NP_TCP_FLAG_SYN, |
122
|
|
|
|
|
|
|
win => 5840, |
123
|
|
|
|
|
|
|
options => |
124
|
|
|
|
|
|
|
"\x02\x04\x05\xb4". |
125
|
|
|
|
|
|
|
"\x08\x0a\x44\x45". |
126
|
|
|
|
|
|
|
"\x41\x44\x00\x00". |
127
|
|
|
|
|
|
|
"\x00\x00\x03\x03". |
128
|
|
|
|
|
|
|
"\x01\x04\x02\x00". |
129
|
|
|
|
|
|
|
"", |
130
|
|
|
|
|
|
|
); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Net::Packet::Frame->new(l3 => $ip4, l4 => $tcp) |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub getP3 { |
136
|
|
|
|
|
|
|
my $self = shift; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
my $ip4 = Net::Packet::IPv4->new( |
139
|
|
|
|
|
|
|
tos => 0, |
140
|
|
|
|
|
|
|
id => $self->_pIpId + 2, |
141
|
|
|
|
|
|
|
flags => 0, |
142
|
|
|
|
|
|
|
offset => 0, |
143
|
|
|
|
|
|
|
ttl => 255, |
144
|
|
|
|
|
|
|
protocol => 6, |
145
|
|
|
|
|
|
|
dst => $self->target->ip, |
146
|
|
|
|
|
|
|
); |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
my $tcp = Net::Packet::TCP->new( |
149
|
|
|
|
|
|
|
src => $self->_pTcpSrc + 2, |
150
|
|
|
|
|
|
|
seq => $self->_pTcpSeq + 2, |
151
|
|
|
|
|
|
|
ack => $self->_pTcpAck + 2, |
152
|
|
|
|
|
|
|
dst => $self->target->port, |
153
|
|
|
|
|
|
|
x2 => 0, |
154
|
|
|
|
|
|
|
flags => NP_TCP_FLAG_SYN | NP_TCP_FLAG_ACK, |
155
|
|
|
|
|
|
|
win => 5840, |
156
|
|
|
|
|
|
|
); |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Net::Packet::Frame->new(l3 => $ip4, l4 => $tcp) |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
1; |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 NAME |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Net::SinFP::SinFP4 - IPv4 operating system fingerprinting |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 DESCRIPTION |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Go to http://www.gomor.org/sinfp to know more. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 AUTHOR |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Patrice EGomoRE Auffret |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Copyright (c) 2005-2015, Patrice EGomoRE Auffret |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
You may distribute this module under the terms of the Artistic license. |
182
|
|
|
|
|
|
|
See LICENSE.Artistic file in the source distribution archive. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=cut |