Changeset 202

Show
Ignore:
Timestamp:
03/06/07 23:52:27 (1 year ago)
Author:
flindiakos
Message:

Added the ability to specify a urllist of urls
Also added getopts for processing command line arguments

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • honeyclient/branches/exp/flindiakos-multi_urls/bin/StartManager.pl

    r131 r202  
    1515use MIME::Base64 qw(encode_base64 decode_base64); 
    1616 
     17# Include Getoptions parser 
     18use Getopt::Long; 
     19 
    1720use HoneyClient::Manager; 
    1821 
    1922# We expect that the user will supply a single argument to this script. 
    2023# Namely, the initial URL that they want the Agent to use. 
     24# They can however supply multiple urls which will be processed in order 
     25 
     26my $driver = "IE"; 
     27my $config = "/vm/Agent.Master-7/winXPPro.cfg"; 
     28my $maxrel = 5; 
     29my $nexturl = ""; 
     30my $urllist= ""; 
     31 
     32GetOptions( 'driver=s'  => \$driver, 
     33                        'config=s'  => \$config, 
     34                        'urllist=s' => \$urllist, 
     35                        'maxrel=i'  => \$maxrel ); 
     36 
     37# Go through the list of urls to create the array 
     38# Anything not associated with an option is a URL 
     39# Grab those first and then get the ones from the file specified 
     40my @urls; 
     41push( @urls, @ARGV );  
     42if( -e $urllist ){ 
     43    open URL, $urllist; 
     44    push(@urls, <URL>); 
     45} 
     46 
     47# Get the first url from the list 
     48# Create an array in the form: url => 1 for links_to_visit  
     49# I did it this way to keep the same order 
     50chomp @urls; 
     51my $firsturl = shift @urls; 
     52my @remaining_urls; 
     53foreach(@urls){ 
     54    push(@remaining_urls,($_,1));    
     55} 
    2156 
    2257my $agentState = HoneyClient::Manager->run( 
    23                     driver           => 'IE', # Change to 'IE' or 'FF' 
    24                     master_vm_config => '/vm/Agent.Master-7/winXPPro.cfg'
     58                    driver           => $driver, # Change to 'IE' or 'FF' 
     59                    master_vm_config => $config
    2560                    agent_state      => encode_base64(nfreeze({ 
    26                         IE => { # Change to 'IE' or 'FF' 
    27                             next_link_to_visit => $ARGV[0]
     61                        $driver => { # Change to 'IE' or 'FF' 
     62                            next_link_to_visit => $firsturl
    2863                            # Enable this line, if you want to only go to the 
    2964                            # first 5 links for each domain. 
    30                             max_relative_links_to_visit => 5, 
     65                            max_relative_links_to_visit => $maxrel, 
     66                                                        links_to_visit => { @remaining_urls } 
    3167                         }, 
    3268                    })),