Skip to content

Commit

Permalink
Add SSL support
Browse files Browse the repository at this point in the history
Add proxy support (for HTTP only, not SSL)
Add support for a basepath added to URLs' paths
  • Loading branch information
Aorimn committed May 24, 2013
1 parent 169b63b commit f175246
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions run-test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use IO::Socket;

$USAGE = "Usage: $0 host[:port] [-d] testfile1, testfile2, ...\n";
$USAGE = "Usage: $0 host[:port] [-d] [-ssl] [-p proxyhost[:proxyport]] [-b path] testfile1, testfile2, ...\n";
$USERAGENT = "HTTP test utility";

$debug = 0;
Expand All @@ -18,6 +18,13 @@

$encode_payloads = 0;

my $SSL = 0;
my $PROXY_host = "";
my $PROXY_port = 0;

my $BASEPATH = "";


sub trim {
@_ = $_ if not @_ and defined wantarray;
@_ = @_ if defined wantarray;
Expand Down Expand Up @@ -47,7 +54,18 @@ sub perform_test {
return;
}

$socket = IO::Socket::INET->new(Proto => 'tcp', PeerAddr => $server, PeerPort => $port, Timeout => 10);
my $socket = undef;
if ($PROXY_host && $PROXY_port) {
$socket = IO::Socket::INET->new(Proto => 'tcp', PeerAddr => $PROXY_host, PeerPort => $PROXY_port, Timeout => 10);
if ($debug) { print "Connected to proxy $PROXY_host:$PROXY_port" . $line_terminator }
} else {
if ($SSL) {
require IO::Socket::SSL;
$socket = IO::Socket::SSL->new(Proto => 'tcp', PeerAddr => $server, PeerPort => $port, Timeout => 10);
} else {
$socket = IO::Socket::INET->new(Proto => 'tcp', PeerAddr => $server, PeerPort => $port, Timeout => 10);
}
}

if(!$socket) {
# this is treated as a serious problem and we
Expand Down Expand Up @@ -142,6 +160,14 @@ sub perform_test {

# Insert attack payload
$_ =~ s/\$PAYLOAD/$PAYLOAD_ENCODED/;

if ($BASEPATH) {
$_ =~ s# /# $BASEPATH#;
}

if ($PROXY_host && $PROXY_port) {
$_ =~ s# /# http://$server:$port/#;
}

print $socket $_ . $line_terminator;
if ($debug) { print "> $_" . $line_terminator; }
Expand Down Expand Up @@ -306,6 +332,23 @@ sub perform_test {

close(PFILE);
}
elsif ((defined $proxy) && ($proxy eq "proxy")) {
if ($filename =~ /(.+):(.+)/) {
$PROXY_host = $1;
$PROXY_port = $2;
} else {
$PROXY_host = $_;
$PROXY_port = 80;
}

$proxy = undef;
}
elsif ((defined $path) && ($path eq "basepath")) {
$BASEPATH = $filename;
$BASEPATH =~ s#^/*(.*?)/*$#/$1/#;

$path = undef;
}
elsif ($filename =~ /^-d$/) {
$debug = 1;
}
Expand All @@ -315,6 +358,15 @@ sub perform_test {
elsif ($filename =~ /^-x$/) {
$payload_file = "next";
}
elsif ($filename =~ /^-s(?:sl)?$/) {
$SSL = 1;
}
elsif ($filename =~ /^-p$/) {
$proxy = "proxy";
}
elsif ($filename =~ /^-b$/) {
$path = "basepath";
}
else {
if (defined $payload_file) {
foreach $PAYLOAD (@all_payloads) {
Expand Down

0 comments on commit f175246

Please sign in to comment.