| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Webservice::InternetDB::API; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
342172
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
81
|
|
|
5
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
82
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
749
|
use Feature::Compat::Class; |
|
|
1
|
|
|
|
|
564
|
|
|
|
1
|
|
|
|
|
6
|
|
|
8
|
1
|
|
|
1
|
|
821
|
use Feature::Compat::Try; |
|
|
1
|
|
|
|
|
417
|
|
|
|
1
|
|
|
|
|
6
|
|
|
9
|
1
|
|
|
1
|
|
88
|
use feature 'signatures'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
67
|
|
|
10
|
1
|
|
|
1
|
|
6
|
no warnings 'experimental::signatures'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
75
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '1.005'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
class Webservice::InternetDB::API; |
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
1012
|
use HTTP::Tiny; |
|
|
1
|
|
|
|
|
70352
|
|
|
|
1
|
|
|
|
|
69
|
|
|
17
|
1
|
|
|
1
|
|
10
|
use JSON::PP; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
93
|
|
|
18
|
1
|
|
|
1
|
|
9
|
use Carp; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
587
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
field $ua = HTTP::Tiny->new(timeout => 7); |
|
21
|
|
|
|
|
|
|
field $base = "https://internetdb.shodan.io/"; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
method get ($address //= ""){ |
|
25
|
|
|
|
|
|
|
my $response = $ua->get("$base$address"); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# croak on errors with nice error messages |
|
28
|
|
|
|
|
|
|
if( !$response->{success} ){ |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
if( $response->{'headers'}{'content-type'} =~ /json/ ){ |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
croak $response->{status}." ".decode_json($response->{content})->{detail} ; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
}else{ |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
croak $response->{status}." ".$response->{content} ; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
try{ |
|
42
|
|
|
|
|
|
|
$response->{content} = decode_json($response->{content}); |
|
43
|
|
|
|
|
|
|
}catch($e){ |
|
44
|
|
|
|
|
|
|
croak "unable to decode message from API ".$e; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
return $response->{content}; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
1; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |