| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# see POD at the bottom for documentation |
|
2
|
|
|
|
|
|
|
package Net::Wigle; |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
18100
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
40
|
|
|
6
|
1
|
|
|
1
|
|
873
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
10715
|
|
|
|
1
|
|
|
|
|
74
|
|
|
7
|
1
|
|
|
1
|
|
816
|
use JSON; |
|
|
1
|
|
|
|
|
14103
|
|
|
|
1
|
|
|
|
|
6
|
|
|
8
|
1
|
|
|
1
|
|
1538405
|
use LWP::UserAgent; |
|
|
1
|
|
|
|
|
91901
|
|
|
|
1
|
|
|
|
|
52
|
|
|
9
|
1
|
|
|
1
|
|
988
|
use Params::Validate qw(:all); |
|
|
1
|
|
|
|
|
11550
|
|
|
|
1
|
|
|
|
|
244
|
|
|
10
|
1
|
|
|
1
|
|
21
|
use 5.010000; |
|
|
1
|
|
|
|
|
4
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require Exporter; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @ISA = qw( |
|
15
|
|
|
|
|
|
|
Exporter |
|
16
|
|
|
|
|
|
|
LWP::UserAgent |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
|
20
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
|
21
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# This allows declaration use Net::Wigle ':all'; |
|
24
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
|
25
|
|
|
|
|
|
|
# will save memory. |
|
26
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
|
27
|
|
|
|
|
|
|
) ] ); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
|
35
|
|
|
|
|
|
|
our $url_query_base = 'https://wigle.net/api/v1/jsonSearch'; |
|
36
|
|
|
|
|
|
|
our $url_login = 'https://wigle.net/api/v1/jsonUser'; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub new { |
|
39
|
1
|
|
|
1
|
1
|
9
|
my $proto = shift; |
|
40
|
1
|
|
33
|
|
|
6
|
my $class = ref $proto || $proto; |
|
41
|
1
|
|
|
|
|
2
|
my $self = {}; |
|
42
|
1
|
|
|
|
|
2
|
bless $self, $class; |
|
43
|
1
|
|
|
|
|
13
|
$self->requests_redirectable(['GET', 'HEAD', 'POST']); |
|
44
|
1
|
|
|
|
|
23
|
return $self; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# purpose : login to wigle.net |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub log_in { |
|
50
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
51
|
0
|
|
|
|
|
|
my %args = validate @_, { |
|
52
|
|
|
|
|
|
|
user => { type => SCALAR, }, |
|
53
|
|
|
|
|
|
|
pass => { type => SCALAR, }, |
|
54
|
|
|
|
|
|
|
}; |
|
55
|
0
|
0
|
|
|
|
|
unless ($self->cookie_jar) { |
|
56
|
0
|
|
|
|
|
|
$self->cookie_jar({}); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
my $form = { |
|
59
|
|
|
|
|
|
|
credential_0 => $args{user}, |
|
60
|
|
|
|
|
|
|
credential_1 => $args{pass}, |
|
61
|
0
|
|
|
|
|
|
destination => '/https://wigle.net', |
|
62
|
|
|
|
|
|
|
noexpire => 'checked', |
|
63
|
|
|
|
|
|
|
}; |
|
64
|
0
|
|
|
|
|
|
my $response = $self->post($url_login, $form); |
|
65
|
0
|
0
|
|
|
|
|
unless ($response->is_success) { |
|
66
|
0
|
|
|
|
|
|
return undef; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
0
|
|
|
|
|
|
return $self->cookie_jar; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# purpose : used to return a parsed/scraped html table |
|
72
|
|
|
|
|
|
|
# now it just returns the parsed json |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub query { |
|
75
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
76
|
0
|
|
|
|
|
|
my %args = validate @_, { |
|
77
|
|
|
|
|
|
|
user => { |
|
78
|
|
|
|
|
|
|
type => SCALAR, |
|
79
|
|
|
|
|
|
|
}, |
|
80
|
|
|
|
|
|
|
pass => { |
|
81
|
|
|
|
|
|
|
type => SCALAR, |
|
82
|
|
|
|
|
|
|
}, |
|
83
|
|
|
|
|
|
|
variance => { |
|
84
|
|
|
|
|
|
|
default => '0.010', |
|
85
|
|
|
|
|
|
|
}, |
|
86
|
|
|
|
|
|
|
latrange1 => { |
|
87
|
|
|
|
|
|
|
optional => 1, |
|
88
|
|
|
|
|
|
|
}, |
|
89
|
|
|
|
|
|
|
latrange2 => { |
|
90
|
|
|
|
|
|
|
optional => 1, |
|
91
|
|
|
|
|
|
|
}, |
|
92
|
|
|
|
|
|
|
longrange1 => { |
|
93
|
|
|
|
|
|
|
optional => 1, |
|
94
|
|
|
|
|
|
|
}, |
|
95
|
|
|
|
|
|
|
longrange2 => { |
|
96
|
|
|
|
|
|
|
optional => 1, |
|
97
|
|
|
|
|
|
|
}, |
|
98
|
|
|
|
|
|
|
addresscode => { |
|
99
|
|
|
|
|
|
|
optional => 1, |
|
100
|
|
|
|
|
|
|
}, |
|
101
|
|
|
|
|
|
|
statecode => { |
|
102
|
|
|
|
|
|
|
optional => 1, |
|
103
|
|
|
|
|
|
|
}, |
|
104
|
|
|
|
|
|
|
zipcode => { |
|
105
|
|
|
|
|
|
|
optional => 1, |
|
106
|
|
|
|
|
|
|
}, |
|
107
|
|
|
|
|
|
|
pagestart => { |
|
108
|
|
|
|
|
|
|
optional => 1, |
|
109
|
|
|
|
|
|
|
}, |
|
110
|
|
|
|
|
|
|
lastupdt => { |
|
111
|
|
|
|
|
|
|
optional => 1, |
|
112
|
|
|
|
|
|
|
}, |
|
113
|
|
|
|
|
|
|
netid => { |
|
114
|
|
|
|
|
|
|
optional => 1, |
|
115
|
|
|
|
|
|
|
}, |
|
116
|
|
|
|
|
|
|
ssid => { |
|
117
|
|
|
|
|
|
|
optional => 1, |
|
118
|
|
|
|
|
|
|
}, |
|
119
|
|
|
|
|
|
|
freenet => { |
|
120
|
|
|
|
|
|
|
optional => 1, |
|
121
|
|
|
|
|
|
|
}, |
|
122
|
|
|
|
|
|
|
paynet => { |
|
123
|
|
|
|
|
|
|
optional => 1, |
|
124
|
|
|
|
|
|
|
}, |
|
125
|
|
|
|
|
|
|
dhcp => { |
|
126
|
|
|
|
|
|
|
optional => 1, |
|
127
|
|
|
|
|
|
|
}, |
|
128
|
|
|
|
|
|
|
onlymine => { |
|
129
|
|
|
|
|
|
|
optional => 1, |
|
130
|
|
|
|
|
|
|
}, |
|
131
|
|
|
|
|
|
|
Query => { |
|
132
|
|
|
|
|
|
|
default => 'Query', |
|
133
|
|
|
|
|
|
|
}, |
|
134
|
|
|
|
|
|
|
}; |
|
135
|
|
|
|
|
|
|
my $cookie_jar = $self->log_in( |
|
136
|
|
|
|
|
|
|
user => $args{user}, |
|
137
|
|
|
|
|
|
|
pass => $args{pass}, |
|
138
|
0
|
|
|
|
|
|
); |
|
139
|
0
|
0
|
|
|
|
|
unless ($cookie_jar) { |
|
140
|
0
|
|
|
|
|
|
return undef; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
0
|
|
|
|
|
|
delete $args{user}; |
|
143
|
0
|
|
|
|
|
|
delete $args{pass}; |
|
144
|
0
|
|
|
|
|
|
my $response = $self->query_raw(%args); |
|
145
|
0
|
0
|
|
|
|
|
unless ($response->is_success) { |
|
146
|
0
|
|
|
|
|
|
return undef; |
|
147
|
|
|
|
|
|
|
} |
|
148
|
0
|
|
|
|
|
|
return from_json($response->decoded_content); |
|
149
|
0
|
|
|
|
|
|
my $string_search_response = $response->as_string; |
|
150
|
0
|
|
|
|
|
|
my @records; |
|
151
|
|
|
|
|
|
|
#$string_search_response =~ qr/.*\ |
(.*?)\<\/tr.*/xmsi;
|
152
|
0
|
|
|
|
|
|
while ($string_search_response =~ m{ |
|
153
|
|
|
|
|
|
|
\ |
|
154
|
|
|
|
|
|
|
(.*?) |
|
155
|
|
|
|
|
|
|
\ |
|
156
|
|
|
|
|
|
|
}xmsgi) { |
|
157
|
0
|
|
|
|
|
|
my $row_raw = $1; |
|
158
|
0
|
|
|
|
|
|
$row_raw =~ m{ |
|
159
|
|
|
|
|
|
|
| (.*?) | \s* # map link
|
160
|
|
|
|
|
|
|
| (.*?) | \s* # netid
|
161
|
|
|
|
|
|
|
| (.*?) | \s* # ssid
|
162
|
|
|
|
|
|
|
| (.*?) | \s* # comment
|
163
|
|
|
|
|
|
|
| (.*?) | \s* # name
|
164
|
|
|
|
|
|
|
| (.*?) | \s* # type
|
165
|
|
|
|
|
|
|
| (.*?) | \s* # freenet
|
166
|
|
|
|
|
|
|
| (.*?) | \s* # paynet
|
167
|
|
|
|
|
|
|
| (.*?) | \s* # firsttime
|
168
|
|
|
|
|
|
|
| (.*?) | \s* # lasttime
|
169
|
|
|
|
|
|
|
| (.*?) | \s* # flags
|
170
|
|
|
|
|
|
|
| (.*?) | \s* # wep
|
171
|
|
|
|
|
|
|
| (.*?) | \s* # trilat
|
172
|
|
|
|
|
|
|
| (.*?) | \s* # trilong
|
173
|
|
|
|
|
|
|
| (.*?) | \s* # dhcp
|
174
|
|
|
|
|
|
|
| (.*?) | \s* # lastupdt
|
175
|
|
|
|
|
|
|
| (.*?) | \s* # channel
|
176
|
|
|
|
|
|
|
| (.*?) | \s* # active
|
177
|
|
|
|
|
|
|
| (.*?) | \s* # bcninterval
|
178
|
|
|
|
|
|
|
| (.*?) | \s* # qos
|
179
|
|
|
|
|
|
|
}xmsgi; |
|
180
|
0
|
|
|
|
|
|
push @records, { |
|
181
|
|
|
|
|
|
|
netid => $2, |
|
182
|
|
|
|
|
|
|
ssid => $3, |
|
183
|
|
|
|
|
|
|
comment => $4, |
|
184
|
|
|
|
|
|
|
name => $5, |
|
185
|
|
|
|
|
|
|
type => $6, |
|
186
|
|
|
|
|
|
|
freenet => $7, |
|
187
|
|
|
|
|
|
|
paynet => $8, |
|
188
|
|
|
|
|
|
|
firsttime => $9, |
|
189
|
|
|
|
|
|
|
lasttime => $10, |
|
190
|
|
|
|
|
|
|
flags => $11, |
|
191
|
|
|
|
|
|
|
wep => $12, |
|
192
|
|
|
|
|
|
|
trilat => $13, |
|
193
|
|
|
|
|
|
|
trilong => $14, |
|
194
|
|
|
|
|
|
|
dhcp => $15, |
|
195
|
|
|
|
|
|
|
lastupdt => $16, |
|
196
|
|
|
|
|
|
|
channel => $17, |
|
197
|
|
|
|
|
|
|
active => $18, |
|
198
|
|
|
|
|
|
|
bcninterval => $19, |
|
199
|
|
|
|
|
|
|
qos => $20, |
|
200
|
|
|
|
|
|
|
userfound => $21, |
|
201
|
|
|
|
|
|
|
}; |
|
202
|
|
|
|
|
|
|
} |
|
203
|
0
|
|
|
|
|
|
return \@records; |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
# purpose : query wigle, trying to keep this simple |
|
207
|
|
|
|
|
|
|
# usage : args are optional, just provided for informational purposes |
|
208
|
|
|
|
|
|
|
# comments : returns an HTTP::Response object |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
sub query_raw { |
|
211
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
212
|
0
|
|
|
|
|
|
my %args = @_; |
|
213
|
0
|
|
|
|
|
|
return $self->post($url_query_base, \%args); |
|
214
|
|
|
|
|
|
|
} |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
1; |
|
217
|
|
|
|
|
|
|
__END__ |