-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbad_dump.cgi
executable file
·70 lines (57 loc) · 1.93 KB
/
bad_dump.cgi
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
66
67
68
69
70
#!/usr/bin/perl
use Digest::SHA qw(hmac_sha1_hex);
use POSIX qw(strftime);
$timestamp = strftime "%Y-%m-%d %H:%M:%S", localtime;
open(OUTFILE, ">>dump.out");
print OUTFILE "============================================================\n";
print OUTFILE "$timestamp $ENV{'SCRIPT_URI'}\n";
open(KEYFILE, "github.secret");
chomp($secret = <KEYFILE>);
close(KEYFILE);
print STDOUT "Status: 500 Internal Server Error\n";
print STDOUT "Content-type: text/plain\n";
print STDOUT "\n";
print STDOUT "REQUEST_METHOD: $ENV{'REQUEST_METHOD'}\n";
print OUTFILE "REQUEST_METHOD: $ENV{'REQUEST_METHOD'}\n";
if (defined $ENV{'QUERY_STRING'}) {
print STDOUT "QUERY_STRING: $ENV{'QUERY_STRING'}\n";
print OUTFILE "QUERY_STRING: $ENV{'QUERY_STRING'}\n";
}
if (defined $ENV{'CONTENT_TYPE'}) {
print STDOUT "CONTENT_TYPE: $ENV{'CONTENT_TYPE'}\n";
print OUTFILE "CONTENT_TYPE: $ENV{'CONTENT_TYPE'}\n";
}
if (defined $ENV{'CONTENT_LENGTH'}) {
print STDOUT "CONTENT_LENGTH: $ENV{'CONTENT_LENGTH'}\n";
print OUTFILE "CONTENT_LENGTH: $ENV{'CONTENT_LENGTH'}\n";
}
print STDOUT "\n";
print OUTFILE "\n";
print STDOUT "Headers:\n";
print OUTFILE "Headers:\n";
foreach $key (sort(keys(%ENV))) {
if ($key =~ /^HTTP_(.*)/) {
print STDOUT "$1: $ENV{$key}\n";
print OUTFILE "$1: $ENV{$key}\n";
}
}
if (defined $ENV{'CONTENT_LENGTH'}) {
$contents = "";
read (STDIN, $contents, $ENV{'CONTENT_LENGTH'});
print OUTFILE "\n";
print OUTFILE "Contents:\n";
print OUTFILE "\n";
print OUTFILE "$contents\n";
$digest = hmac_sha1_hex($contents, $secret);
print OUTFILE "\n";
print OUTFILE "Digest: sha1=" . $digest . "\n";
print STDOUT "\n";
print STDOUT "Contents:\n";
print STDOUT "\n";
print STDOUT "$contents\n";
print STDOUT "\n";
print STDOUT "Digest: sha1=" . $digest . "\n";
}
print OUTFILE "\n";
print OUTFILE "============================================================\n";
close(OUTFILE);