#!/usr/bin/perl # # Custom HTTP request sender... man I got to think of cooler names for my scripts. # Usage: open with perl, has a GUI # Functions: some default options to make it really look like you are a person and not a bot, save configuration option, plain text output, # POST/GET option, custom fields # # I'm aware of the sucky code at some parts, don't cry about it. # # Iron # IronWarez.info use Tk; use Tk::Adjuster; use Tk::BrowseEntry; use IO::Socket; $conf = "custom_r_opts.txt"; #Config file if(-e $conf) { open(DEF, $conf); while($line = ) { chomp($line); push(@defaults,$line); } $i = 0; } else { reset_to_def(); } $mw = new MainWindow; $mw->title("Custom HTTP request sender"); $extras_right = $mw->Frame()->pack(-side => 'right', -fill => 'y'); $extras_left = $mw->Frame()->pack(-side => 'right', -fill => 'y'); $frame_left = $mw->Frame()->pack(-side => 'left', -fill => 'y'); $frame_right = $mw->Frame()->pack(-side => 'right', -fill => 'y'); $but = $frame_right -> Button(-text=>"Save configuration", -command =>\&save_config) -> pack(); $lab = $frame_left -> Label(-text=>"") -> pack(); $b = $frame_left->BrowseEntry(-variable => \@defaults[0],-width=>7,-command =>\&change_type); $b->insert("end", "GET"); $b->insert("end", "POST"); $b->pack; #Very ugly code ahead, I know $ent = $frame_right -> Entry(-textvariable => \@defaults[1],-width=>60) -> pack(); $lab = $frame_left -> Label(-text=>"Host:") -> pack(); $ent = $frame_right -> Entry(-textvariable => \@defaults[2],-width=>60) -> pack(); $lab = $frame_left -> Label(-text=>"User-Agent:") -> pack(); $ent = $frame_right -> Entry(-textvariable => \@defaults[3],-width=>60) -> pack(); $lab = $frame_left -> Label(-text=>"Accept:") -> pack(); $ent = $frame_right -> Entry(-textvariable => \@defaults[4],-width=>60) -> pack(); $lab = $frame_left -> Label(-text=>"Accept-Language:") -> pack(); $ent = $frame_right -> Entry(-textvariable => \@defaults[5],-width=>60) -> pack(); $lab = $frame_left -> Label(-text=>"Accept-Encode:") -> pack(); $ent = $frame_right -> Entry(-textvariable => \@defaults[6],-width=>60) -> pack(); $lab = $frame_left -> Label(-text=>"Accept-Charset:") -> pack(); $ent = $frame_right -> Entry(-textvariable => \@defaults[7],-width=>60) -> pack(); $lab = $frame_left -> Label(-text=>"Cookie:") -> pack(); $ent = $frame_right -> Entry(-textvariable => \@defaults[10],-width=>60) -> pack(); $but = $frame_left-> Button(-text=>"Add custom field", -command =>\&add_custom) -> pack(); $but = $frame_right-> Button(-text=>"Make request", -command =>\&request) -> pack(); MainLoop; sub change_type() { if(@defaults[0] eq "POST") { $extr = $frame_left -> Label(-text=>"POST content:") -> pack(); $txt = $frame_right -> Text(-width=>70, -height=>10) -> pack(); } } sub add_custom() { $ent = $extras_left -> Entry(-textvariable => \@custom_name[$i],-width=>10) -> pack(); $ent = $extras_right -> Entry(-textvariable => \@custom_val[$i],-width=>40) -> pack(); $i++; } sub request() { $socket = IO::Socket::INET->new( Proto=>"tcp", PeerAddr=>@defaults[2], PeerPort=>80 ) || die "Cannot connect to host ! (".$!.")"; print $socket @defaults[0]." ". @defaults[1] ." HTTP/1.1\r\n"; print $socket "Host: ".@defaults[2]."\r\n"; print $socket "User-Agent: ".@defaults[3]."\r\n"; print $socket "Accept: ".@defaults[4]."\r\n"; print $socket "Accept-language: ".@defaults[5]."\r\n"; print $socket "Accept-Encoding: ".@defaults[6]."\r\n"; print $socket "Accept-Charset: ".@defaults[7]."\r\n"; print $socket "Cookie: ".@defaults[10]."\r\n"; if($i != 0) { $d = 0; while($d != scalar(@custom_name)-1) #Last element is empty { if(@custom_name[$d] !~ /:$/) { @custom_name[$d] .= ":"; } print $socket @custom_name[$d]." ".@custom_value[$d]."\r\n"; $d++; } } if(@defaults[0] eq "POST") { @defaults[12] = $txt->get('1.0','end'); print $socket "Content-Type: application/x-www-form-urlencoded\r\n"; print $socket "Content-Length: ". length(@defaults[12])."\r\n"; print $socket "Connection: close\r\n\r\n"; print $socket @defaults[12]."\r\n"; } else { print $socket "Connection: close\r\n\r\n"; print $socket "\r\n\r\n"; } $top = $mw -> Toplevel(); $top->title("Output"); $top->Label(-text => "This is the output of your HTTP Request")->pack(); $txt_top = $top -> Text(-width=>90, -height=>40); $txt_top = $top -> Scrolled("Text",-scrollbars=>'e')-> pack(); while($rep = <$socket>) { $txt_top -> insert('end',$rep); } close($socket); } sub save_config() { open(CONF,">$conf"); foreach $line(@defaults) { print CONF $line."\n"; } } sub reset_to_def() { @defaults = ( "GET", "/someform.php", "localhost", "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3", "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5", "nl,en-us;q=0.7,en;q=0.3", "gzip,deflate", "ISO-8859-1,utf-8;q=0.7,*;q=0.7", 0, "close", "some_cookie_name=some_cookie_value;other_c=other_c_value", 0, "blah=blaaag" ); open(CONFIG,">$conf"); foreach $confline(@defaults) { print CONFIG $confline."\n"; } }