line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RAPNAP::client; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
8586
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
78
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use vars qw/$VERSION $key/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
111
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.02'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
2806
|
use Socket; |
|
1
|
|
|
|
|
5658
|
|
|
1
|
|
|
|
|
1165
|
|
10
|
|
|
|
|
|
|
my $eol = "\015\012"; |
11
|
|
|
|
|
|
|
sub rapnap_check{ # RA, PNA, optional Subject Line, optional Target Address |
12
|
0
|
|
|
0
|
0
|
0
|
my ($remote,$port, $iaddr, $paddr, $proto, $line); |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
0
|
$remote = 'www.pay2send.com'; |
15
|
0
|
|
|
|
|
0
|
$port = 80; # http |
16
|
0
|
|
0
|
|
|
0
|
$iaddr = inet_aton($remote) || die "no host: $remote"; |
17
|
0
|
|
|
|
|
0
|
$paddr = sockaddr_in($port, $iaddr); |
18
|
0
|
|
|
|
|
0
|
$proto = getprotobyname('tcp'); |
19
|
0
|
0
|
|
|
|
0
|
socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die "socket: $!"; |
20
|
0
|
0
|
|
|
|
0
|
connect(SOCK, $paddr) || die "connect: $!"; |
21
|
0
|
|
|
|
|
0
|
my $S = select SOCK; |
22
|
0
|
|
|
|
|
0
|
$| = 1; |
23
|
0
|
|
|
|
|
0
|
select $S; |
24
|
0
|
|
|
|
|
0
|
my $query="key=$key&ra=$_[0]&pna=$_[1]"; |
25
|
0
|
0
|
|
|
|
0
|
$_[2] and $query .= "&sl=$_[2]"; |
26
|
0
|
0
|
|
|
|
0
|
$_[3] and $query .= "&ta=$_[3]"; |
27
|
0
|
|
|
|
|
0
|
$query =~ s/([^\w\.\=\&])/sprintf('%%%02X',ord($1))/ge; |
|
0
|
|
|
|
|
0
|
|
28
|
|
|
|
|
|
|
# print "DEBUG: QUERY: $query\n\n"; |
29
|
0
|
|
|
|
|
0
|
my $length = length $query; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
0
|
print SOCK join $eol, |
32
|
|
|
|
|
|
|
'POST /cgi/rapnap/check HTTP/1.1', |
33
|
|
|
|
|
|
|
'Host: www.pay2send.com', |
34
|
|
|
|
|
|
|
"User-Agent: RAPNAP::client $VERSION", |
35
|
|
|
|
|
|
|
# 'Transfer-Encoding:', |
36
|
|
|
|
|
|
|
'Connection: close', |
37
|
|
|
|
|
|
|
"Content-length: $length", |
38
|
|
|
|
|
|
|
'', |
39
|
|
|
|
|
|
|
$query, |
40
|
|
|
|
|
|
|
'' |
41
|
|
|
|
|
|
|
; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
0
|
my $response = join '', (); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# print "DEBUG: FULL RESPONSE:\n$response\nEND FULL RESPONSE\n\n"; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
0
|
$response =~ m#Content-Type: \S+\s+([0-9a-fA-F]+)\s+(.+)#s; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
0
|
return substr($2,0,hex($1)); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub import{ |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
1
|
|
9
|
no strict 'refs'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
76
|
|
58
|
1
|
|
|
1
|
|
9
|
*{caller() . '::rapnap_check'} = \&rapnap_check; |
|
1
|
|
|
|
|
6
|
|
59
|
1
|
|
50
|
|
|
3049
|
$key = $_[1] || 'ipv4'; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
__END__ |