forked from stealth/qdns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acid.pl
executable file
·66 lines (53 loc) · 1.25 KB
/
acid.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/perl
# FoxAcid template for QDNS case
use IO::Socket::INET;
use MIME::Base64;
use Term::ANSIColor;
# needs to bind to a local IP, so the QI redirector can
# filter out such connections. This is only necessary in a local LAN
# test setup, as ITW, the QI will probably not see FoxAcid's requests
my $sock = IO::Socket::INET->new(LocalAddr => '192.168.0.253',
LocalPort => 80,
Proto => 'tcp',
ReuseAddr => 1,
Listen => 12) or die $!;
my $req = "";
my $host = "";
my $path = "";
my $redir_base=<<EOR;
HTTP/1.1 200 OK\r
Server: FoxAcid 0.1\r
Content-Type: text/html\r
\r
<html>
<head>
<meta http-equiv="refresh" content="0; URL=http://NOACID">
</head>
<body>
<script>
alert("EGOTISTICAL GIRAFFE!");
</script>
</body>
</html>
EOR
for (;;) {
$req = "";
my $peer = $sock->accept();
$peer->recv($req, 1024);
next if length($req) == 0;
print color 'green';
print "$req\n";
if ($req =~ /^(GET|POST)\s+([^ ]+)/) {
$path = $2;
$req =~ /Host: ([^\r]+)/;
$host = $1.$path;
$redir = $redir_base;
$redir =~ s/NOACID/$host/;
} else {
next;
}
print $peer $redir;
print color 'red';
print "\n$redir\n";
$peer->close();
}