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