root/honeyclient/branches/exp/bhenderson-browser_automation/bin/StartManager.pl

Revision 1499, 5.7 kB (checked in by kindlund, 9 months ago)

Merging simpler_agent branch into trunk.

  • Property svn:executable set to *
  • Property svn:keywords set to Id "$file"
Line 
1 #!perl -Ilib
2 #######################################################################
3 # Created on:  Apr 08, 2008
4 # File:        StartManager.pl
5 # Description: Start up script for manager-based operations.
6 #
7 # CVS: $Id$
8 #
9 # @author knwang, kindlund
10 #
11 # Copyright (C) 2007-2008 The MITRE Corporation.  All rights reserved.
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License
15 # as published by the Free Software Foundation, using version 2
16 # of the License.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 # 02110-1301, USA.
27 #
28 #######################################################################
29
30 BEGIN {
31     our $VERSION = 1.02;
32 }
33 our ($VERSION);
34
35 =pod
36
37 =head1 NAME
38
39 StartManager.pl - Perl script to start the Manager on the
40 host system.
41
42 =head1 SYNOPSIS
43
44  StartManager.pl [options] [http://www.google.com http://www.cnn.com ...]
45
46  Options:
47  --help               This help message.
48  --man                Print full man page.
49  --driver_name=       Name of driver to use.
50  --master_vm_config=  Absolute path to the master VM configuration to use.
51  --url_list=          File containing newline separated URLs to use.
52
53 =head1 OPTIONS
54
55 =over 4
56
57 =item B<--help>
58
59 Print a brief help message and exits.
60
61 =item B<--driver_name=>
62
63 Specifies the driver name to use.  If none is specified, the
64 default will be used.
65
66 =item B<--master_vm_config=>
67
68 Specifies the master VM configuration file to use.  If none
69 is specified, the default will be used.
70
71 =item B<--url_list=>
72
73 If specified, the newline separated URLs inside this file will
74 be parsed and fed into the Manager upon startup.
75
76 =back
77
78 =head1 DESCRIPTION
79
80 This program starts the Manager on the host system.  If URLs
81 are specified on the command-line, the program will
82 assign a base priority to each URL and feed them into the Manager
83 for additional processing.
84
85 This program will run until manually terminated by the user, by
86 pressing CTRL-C.
87
88 =head1 SEE ALSO
89
90 L<http://www.honeyclient.org/trac>
91
92 =head1 REPORTING BUGS
93
94 L<http://www.honeyclient.org/trac/newticket>
95
96 =head1 AUTHORS
97
98 Darien Kindlund, E<lt>kindlund@mitre.orgE<gt>
99
100 Kathy Wang, E<lt>knwang@mitre.orgE<gt>
101
102 =head1 COPYRIGHT & LICENSE
103
104 Copyright (C) 2007-2008 The MITRE Corporation.  All rights reserved.
105
106 This program is free software; you can redistribute it and/or
107 modify it under the terms of the GNU General Public License
108 as published by the Free Software Foundation, using version 2
109 of the License.
110  
111 This program is distributed in the hope that it will be useful,
112 but WITHOUT ANY WARRANTY; without even the implied warranty of
113 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
114 GNU General Public License for more details.
115  
116 You should have received a copy of the GNU General Public License
117 along with this program; if not, write to the Free Software
118 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
119 02110-1301, USA.
120
121 =cut
122
123 use strict;
124 use warnings;
125 use Carp ();
126
127 # Include Pod Library
128 use Pod::Usage;
129
130 # Include Dumper Library
131 use Data::Dumper;
132
133 # Include Hash Serialization Utility Libraries
134 use Storable qw(nfreeze thaw);
135
136 # Include Base64 Libraries
137 use MIME::Base64 qw(encode_base64 decode_base64);
138
139 # Include Getopt Parser
140 use Getopt::Long qw(:config auto_help ignore_case_always);
141
142 # Include utility access to global configuration.
143 use HoneyClient::Util::Config qw(getVar);
144
145
146 # Include Logging Library
147 use Log::Log4perl qw(:easy);
148
149 # The global logging object.
150 our $LOG = get_logger();
151
152 # We expect that the user will supply a single argument to this script.
153 # Namely, the initial set of URLs that they want the Agent to use.
154
155 # Inputs.
156 my $driver_name = undef;
157 my $master_vm_config = undef;
158 my $url_list= "";
159
160 GetOptions('driver_name=s'        => \$driver_name,
161            'master_vm_config=s'   => \$master_vm_config,
162            'url_list=s'           => \$url_list,
163            'man'                  => sub { pod2usage(-exitstatus => 0, -verbose => 2) },
164            'version'              => sub {
165                                         print "MITRE HoneyClient Project (http://www.honeyclient.org)\n" .
166                                               "------------------------------------------------------\n" .
167                                               $0  . " (v" . $VERSION . ")\n";
168                                         exit(0);
169                                      }) or pod2usage(2);
170
171 # Go through the list of urls to create the array
172 # Anything not associated with an option is a URL
173 # Grab those first and then get the ones from the file specified
174 my @urls;
175 push( @urls, @ARGV );
176 if( -e $url_list ){
177     open URL, $url_list;
178     push(@urls, <URL>);
179 }
180
181 # Get the base priority.
182 my $priority = getVar(name      => "command_line_base_priority",
183                       namespace => "HoneyClient::Manager");
184
185 # Create a hashtable in the form: url => priority.
186 my $work = {};
187 foreach(@urls){
188     # We assign our initial list of URLs a priority of 1000, so that
189     # they'll be (likely to be) selected first, before going to any other
190     # external URLs found from subsequent drive operations.
191     chomp;
192     if ($_ ne "") {
193         $work->{$_} = $priority;
194     }
195 }
196
197 # Start the Manager.
198 require HoneyClient::Manager;
199 HoneyClient::Manager->run(
200     driver_name      => $driver_name,
201     master_vm_config => $master_vm_config,
202     work             => $work,
203 );
Note: See TracBrowser for help on using the browser.