lw_build_req

Download
Version 1.00: lw_build_req

Description
lw_build_req creates a simple LibWhisker script from raw HTTP headers. This is useful for writing quick, on-the-fly tests that need some degree of customization.

Options

  • -r : request_file (required)
  • -p : proxy:port to use
  • -l : loop -- this will wrap the HTTP request code in a loop
  • -s : Use SSL

    Assumptions
    The script assumes the first line is the request, and a blank line preceeds the data portion (and any line after the blank is data). Other than these restrictions, any line will be assumed to be a valid header and split on the : character for header:value pairs.

    Example
    Create a file with your raw HTTP headers in it. For example, the file cnn.txt is created with this content:

     GET /search.jsp?query=nikto&type=web&sortBy=date&intl=false HTTP/1.1
     Host: search.cnn.com
     User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.5) Gecko/20070713 Firefox/2.0.0.5
     Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
     Accept-Language: en-us,en;q=0.5
     Accept-Encoding: gzip,deflate
     Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
     Keep-Alive: 300
     Connection: keep-alive
     Referer: http://www.cnn.com/
     Cookie: s_pers=%20s_lastvisit%3D1185301982545%7C1279909982545%3B%20s_vnum%3D118615882%2526vn%253D15%7C11861588%3B%20s_invisit%3Dtrue%7C1185304277738%3B; SelectedEdition=www; cnnUEPCookie=domestic; cnnUDFCookie=1; cnnVidPlug=native; CNNid=Ga50a1f13-87293-1871594817-240; s_sess=%20s_dslv%3DLess%2520than%25207%2520days%3B%20s_cc%3Dtrue%3B%20s_sq%3D%3B;  adDEon=true; JSESSIONID=8A23C1F1EBB06A862DC485D701732DDB
     Cache-Control: max-age=0
    

    After creating the header file, run the script with the file passed to the -r option, and redirect to a new file:
      $ perl lw_build_req -r cnn.txt > myreq.pl

    This will create the 'myreq.pl' with all the code needed to recreate the HTTP request using LibWhisker. This is the portion of output which sets the values from the input file:

    ...
    	$request{'whisker'}->{'keep-alive'}='300';
            $request{'whisker'}->{'accept-charset'}='ISO-8859-1,utf-8;q=0.7,*;q=0.7';
            $request{'User-Agent'}='Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.5) Gecko/20070713 Firefox/2.0.0.5';
            $request{'whisker'}->{'version'}='1.1';
            $request{'whisker'}->{'accept'}='text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5';
            $request{'whisker'}->{'uri'}='/search.jsp?query=nikto&type=web&sortBy=date&intl=false';
            $request{'whisker'}->{'connection'}='keep-alive';
            $request{'whisker'}->{'referer'}='http://www.cnn.com/';
            $request{'whisker'}->{'cache-control'}='max-age=0';
            $request{'whisker'}->{'accept-encoding'}='gzip,deflate';
            $request{'Cookie'}='s_pers=%20s_lastvisit%3D1185301982545%7C1279909982545%3B%20s_vnum%3D118615882%2526vn%253D15%7C11861588%3B%20s_invisit%3Dtrue%7C1185304277
    738%3B; SelectedEdition=www; cnnUEPCookie=domestic; cnnUDFCookie=1; cnnVidPlug=native; CNNid=Ga50a1f13-87293-1871594817-240; s_sess=%20s_dslv%3DLess%2520than%25207%2
    520days%3B%20s_cc%3Dtrue%3B%20s_sq%3D%3B;  adDEon=true; JSESSIONID=8A23C1F1EBB06A862DC485D701732DDB';
            $request{'whisker'}->{'method'}='GET';
            $request{'whisker'}->{'accept-language'}='en-us,en;q=0.5';
            $request{'whisker'}->{'host'}='search.cnn.com';
            $request{'whisker'}->{'port'}='80';
    ...
    

    Edit the script to suit your needs. Run. Profit.