root/honeyclient/tags/exp/UP2-flindiakos-multi_urls/lib/HoneyClient/Manager.pm

Revision 197, 24.4 kB (checked in by kindlund, 2 years ago)

Version bump.

  • Property svn:keywords set to Id "$file"
Line 
1 #######################################################################
2 # Created on:  May 11, 2006
3 # Package:     HoneyClient::Manager
4 # File:        Manager.pm
5 # Description: Central library used for manager-based operations.
6 #
7 # CVS: $Id$
8 #
9 # @author knwang, ttruong, jdurick, kindlund
10 #
11 # Copyright (C) 2006 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 =pod
31
32 =head1 NAME
33
34 # XXX: Fill this in.
35
36 =head1 VERSION
37
38 This documentation refers to HoneyClient::Manager version 0.94.
39
40 =head1 SYNOPSIS
41
42 =head2 CREATING THE SOAP SERVER
43
44 # XXX: Fill this in.
45
46 =head2 INTERACTING WITH THE SOAP SERVER
47
48 # XXX: Fill this in.
49
50 =head1 DESCRIPTION
51
52 # XXX: Fill this in.
53
54 =cut
55
56 package HoneyClient::Manager;
57
58 # XXX: Disabled version check, Honeywall does not have Perl v5.8 installed.
59 #use 5.008006;
60 use strict;
61 use warnings FATAL => 'all';
62 use Config;
63 use Carp ();
64
65 #######################################################################
66 # Module Initialization                                               #
67 #######################################################################
68
69 BEGIN {
70     # Defines which functions can be called externally.
71     require Exporter;
72     our (@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $VERSION, @DRIVERS);
73
74     # Set our package version.
75     $VERSION = 0.94;
76
77     @ISA = qw(Exporter);
78
79     # Symbols to export on request
80     @EXPORT = qw(init destroy);
81
82     # Items to export into callers namespace by default. Note: do not export
83     # names by default without a very good reason. Use EXPORT_OK instead.
84     # Do not simply export all your public functions/methods/constants.
85
86     # This allows declaration use HoneyClient::Manager ':all';
87     # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
88     # will save memory.
89
90     %EXPORT_TAGS = (
91         'all' => [ qw(init destroy) ],
92     );
93
94     # Symbols to autoexport (:DEFAULT tag)
95     @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
96
97     # Check to see if ithreads are compiled into this version of Perl.
98     $Config{useithreads} or Carp::croak "Error: Recompile Perl with ithread support, in order to use this module.\n";
99
100     $SIG{PIPE} = 'IGNORE'; # Do not exit on broken pipes.
101 }
102 our (@EXPORT_OK, $VERSION);
103
104 =pod
105
106 =begin testing
107
108 # Make sure the module loads properly, with the exportable
109 # functions shared.
110 BEGIN { use_ok('HoneyClient::Manager', qw(init destroy)) or diag("Can't load HoneyClient::Manager package.  Check to make sure the package library is correctly listed within the path."); }
111 require_ok('HoneyClient::Manager');
112 can_ok('HoneyClient::Manager', 'init');
113 can_ok('HoneyClient::Manager', 'destroy');
114 use HoneyClient::Manager qw(init destroy);
115
116 # Make sure HoneyClient::Util::SOAP loads.
117 BEGIN { use_ok('HoneyClient::Util::SOAP', qw(getServerHandle getClientHandle)) or diag("Can't load HoneyClient::Util::SOAP package.  Check to make sure the package library is correctly listed within the path."); }
118 require_ok('HoneyClient::Util::SOAP');
119 can_ok('HoneyClient::Util::SOAP', 'getServerHandle');
120 can_ok('HoneyClient::Util::SOAP', 'getClientHandle');
121 use HoneyClient::Util::SOAP qw(getServerHandle getClientHandle);
122
123 # Make sure HoneyClient::Util::Config loads.
124 BEGIN { use_ok('HoneyClient::Util::Config', qw(getVar)) or diag("Can't load HoneyClient::Util::Config package.  Check to make sure the package library is correctly listed within the path."); }
125 require_ok('HoneyClient::Util::Config');
126 can_ok('HoneyClient::Util::Config', 'getVar');
127 use HoneyClient::Util::Config qw(getVar);
128
129 # Make sure Storable loads.
130 BEGIN { use_ok('Storable', qw(nfreeze thaw)) or diag("Can't load Storable package.  Check to make sure the package library is correctly listed within the path."); }
131 require_ok('Storable');
132 can_ok('Storable', 'nfreeze');
133 can_ok('Storable', 'thaw');
134 use Storable qw(nfreeze thaw);
135
136 # Make sure MIME::Base64 loads.
137 BEGIN { use_ok('MIME::Base64', qw(encode_base64 decode_base64)) or diag("Can't load MIME::Base64 package.  Check to make sure the package library is correctly listed within the path."); }
138 require_ok('MIME::Base64');
139 can_ok('MIME::Base64', 'encode_base64');
140 can_ok('MIME::Base64', 'decode_base64');
141 use MIME::Base64 qw(encode_base64 decode_base64);
142
143 =end testing
144
145 =cut
146
147 #######################################################################
148
149 # Include the SOAP Utility Library
150 use HoneyClient::Util::SOAP qw(getClientHandle getServerHandle);
151
152 # Include Thread Libraries
153 use threads;
154 use threads::shared;
155 use Thread::Semaphore;
156 use Thread::Queue;
157
158 # Include utility access to global configuration.
159 use HoneyClient::Util::Config qw(getVar);
160
161 # Include the VM Utility Library
162 # TODO: Include unit tests.
163 use HoneyClient::Manager::VM qw();
164
165 # XXX: Remove this, eventually.
166 use Data::Dumper;
167
168 # Make Dumper format more verbose.
169 $Data::Dumper::Terse = 0;
170 $Data::Dumper::Indent = 2;
171
172 # Include Hash Serialization Utility Libraries
173 use Storable qw(nfreeze thaw);
174
175 # Include Base64 Libraries
176 use MIME::Base64 qw(encode_base64 decode_base64);
177
178 # Include FW Utility Library
179 # TODO: Include unit tests.
180 use HoneyClient::Manager::FW;
181
182 # Include Hash Serialization Utility Libraries
183 # TODO: Include unit tests.
184 use Storable qw(nfreeze thaw);
185
186 # Include VmPerl Constants.
187 # TODO: Include unit tests.
188 use VMware::VmPerl qw(VM_EXECUTION_STATE_ON
189                       VM_EXECUTION_STATE_OFF
190                       VM_EXECUTION_STATE_STUCK
191                       VM_EXECUTION_STATE_SUSPENDED);
192
193 # TODO: Include unit tests.
194 use IO::File;
195
196 # Complete URL of SOAP server, when initialized.
197 our $URL_BASE       : shared = undef;
198 our $URL            : shared = undef;
199
200 # The process ID of the SOAP server daemon, once created.
201 our $DAEMON_PID     : shared = undef;
202
203 # XXX: These will be migrated somewhere else, eventually.
204 our $vmStateTable = { };
205 our $vmCloneConfig      = undef;
206 our $stubVM             = undef;
207 our $stubAgent          = undef;
208 our $stubFW             = undef;
209
210 # This is a temporary, shared variable, used to print out the
211 # state of the agent, when _cleanup() occurs.
212 # XXX: This variable and all reference to it will be deleted,
213 # eventually.
214 our $globalAgentState   = undef;
215
216 # This static variable may contain a filename that the Manager
217 # would use to dump its entire state information, upon termination.
218 # XXX: May want to change this format/usage, eventually.
219 our $STATE_FILE = getVar(name => "manager_state");
220
221 #######################################################################
222 # Daemon Initialization / Destruction                                 #
223 #######################################################################
224
225 =pod
226
227 =head1 EXPORTED FUNCTIONS
228
229 The following init() and destroy() functions are the only direct
230 calls required to startup and shutdown the SOAP server.
231
232 All other interactions with this daemon should be performed as
233 C<SOAP::Lite> function calls, in order to ensure consistency across
234 client sessions.  See the L<"EXTERNAL SOAP FUNCTIONS"> section, for
235 more details.
236
237 =head2 HoneyClient::Manager->init()
238
239 =over 4
240
241 Starts a new SOAP server, within a child process.
242
243 I<Inputs>:
244
245 # XXX: Finish this.
246
247 I<Output>:
248
249 # XXX: Finish this.
250
251 =back
252
253 =begin testing
254
255 # XXX: Test init() method.
256
257 =end testing
258
259 =cut
260
261 sub init {
262     # Extract arguments.
263     # Hash-based arguments are used, since HoneyClient::Util::SOAP is unable to handle
264     # hash references directly.  Thus, flat hashtables are used throughout the code
265     # for consistency.
266     my ($class, %args) = @_;
267    
268     # XXX: Finish this.
269 }
270
271 =pod
272
273 =head2 HoneyClient::Manager->destroy()
274
275 =over 4
276
277 Terminates the SOAP server within the child process.
278
279 I<Output>: True if successful, false otherwise.
280
281 =back
282
283 =begin testing
284
285 # XXX: Test destroy() method.
286
287 # TODO: delete this.
288 #exit;
289
290 =end testing
291
292 =cut
293
294 sub destroy {
295     my $ret = undef;
296    
297     # XXX: Finish this.
298     
299     return $ret;
300 }
301
302 #######################################################################
303 # Private Methods Implemented                                         #
304 #######################################################################
305
306 sub _handleFault {
307
308     # Extract arguments.
309     my ($class, $res) = @_;
310
311     # Construct error message.
312     # Figure out if the error occurred in transport or over
313     # on the other side.
314     my $errMsg = $class->transport->status; # Assume transport error.
315
316     if (ref $res) {
317         $errMsg = $res->faultcode . ": ".  $res->faultstring . "\n";
318     }
319
320     Carp::carp __PACKAGE__ . "->_handleFault(): Error occurred during processing.\n" . $errMsg;
321 }
322
323 sub _handleFaultAndCleanup {
324
325     # Extract arguments.
326     my ($class, $res) = @_;
327
328     # Print fault.
329     _handleFault($class, $res);
330    
331     # Cleanup before dying.
332     _cleanup();
333 }
334
335 sub _cleanup {
336
337     print "Cleaning up...\n";
338
339     # Mask all possible signals, so that we don't call this function multiple times.
340     $SIG{HUP}     = sub { };
341     $SIG{INT}     = sub { };
342     $SIG{QUIT}    = sub { };
343     $SIG{ABRT}    = sub { };
344     $SIG{PIPE}    = sub { };
345     $SIG{TERM}    = sub { };
346
347     HoneyClient::Manager::VM->destroy();
348
349     # XXX: Need to clean this up.
350     my $stubFW = getClientHandle(namespace     => "HoneyClient::Manager::FW");
351
352     # XXX: Change this to fwInit(), eventually.
353     # Reset the firewall, to allow everything open.
354     $stubFW->testConnect();
355
356     # Check to see if a clone was created...
357     if (defined($vmCloneConfig)) {
358         # We sleep for a bit, to make sure that the previous VM daemon was
359         # properly destroyed and released the previous port that was in use.
360         sleep (10);
361
362         # We reinstantiate a new VM daemon, because if the user had hit CTRL-C
363         # or called any other signal, then that signal would propagate to all
364         # processes, causing the VM daemon's signal handler to self terminate.
365         #
366         # Hence, rather than fight the VM daemon's natural self termination,
367         # we let the daemon die, but the create a new one, for the sole purpose
368         # of cleanup up the clones.
369         HoneyClient::Manager::VM->init();
370         print "Calling suspendVM(config => $vmCloneConfig)...\n";
371         my $stubVM = getClientHandle(namespace     => "HoneyClient::Manager::VM");
372         $stubVM->suspendVM(config => $vmCloneConfig);
373         print "Done!\n";
374         HoneyClient::Manager::VM->destroy();
375     }
376
377     # XXX: May want to change this format/usage, eventually.
378     if (length($STATE_FILE) > 0 &&
379         defined($globalAgentState)) {
380         print "Saving state to '" . $STATE_FILE . "'...\n";
381         my $dump_file = new IO::File($STATE_FILE, "w");
382
383         # XXX: Delete this block, eventually.
384         $Data::Dumper::Terse = 0;
385         $Data::Dumper::Indent = 2;
386         print $dump_file Dumper(thaw(decode_base64($globalAgentState)));
387     }
388
389     exit;
390 }
391
392 # XXX: Install the cleanup handler, in case the parent process dies
393 # unexpectedly.
394 $SIG{HUP} = sub { _cleanup(); };
395 $SIG{INT}   = sub { _cleanup(); };
396 $SIG{QUIT}  = sub { _cleanup(); };
397 $SIG{ABRT}  = sub { _cleanup(); };
398 $SIG{PIPE}  = sub { _cleanup(); };
399 $SIG{TERM}  = sub { _cleanup(); };
400
401 #######################################################################
402 # Public Methods Implemented                                          #
403 #######################################################################
404
405 =pod
406
407 =head1 EXPORTS
408
409 =head2 run()
410
411 =over 4
412
413 # XXX: Fill this in.
414
415 I<Inputs>:
416  B<$arg> is an optional argument.
417
418 driver
419 master_vm_config
420 start_state
421  
422 I<Output>: XXX: Fill this in.
423
424 =back
425
426 =begin testing
427
428 # XXX: Fill this in.
429
430 =end testing
431
432 =cut
433
434 sub run {
435     # Extract arguments.
436     # Hash-based arguments are used, since HoneyClient::Util::SOAP is unable to handle
437     # hash references directly.  Thus, flat hashtables are used throughout the code
438     # for consistency.
439     my ($class, %args) = @_;
440     my $agentState = undef;
441
442     for (;;) {
443         print "Starting new session...\n";
444         $agentState = $class->runSession(%args);
445         $args{'agent_state'} = $agentState;
446
447         # XXX: Delete this, eventually.
448         $globalAgentState = $agentState;
449
450         #$Data::Dumper::Terse = 0;
451         #$Data::Dumper::Indent = 2;
452         #print Dumper(thaw(decode_base64($agentState)));
453     }
454 }
455
456 sub runSession {
457
458     # Extract arguments.
459     # Hash-based arguments are used, since HoneyClient::Util::SOAP is unable to handle
460     # hash references directly.  Thus, flat hashtables are used throughout the code
461     # for consistency.
462     my ($class, %args) = @_;
463
464     my $som       = undef;
465     my $ret       = undef;
466     my $vmIP      = undef;
467     my $vmMAC     = undef;
468     my $vmName    = undef;
469     my $URL       = undef;
470     my $vmState   = undef;
471     my $vmCompromised = 0;
472
473     # Get a stub connection to the firewall.
474     $stubFW = getClientHandle(namespace     => "HoneyClient::Manager::FW",
475                               fault_handler => \&_handleFaultAndCleanup);
476
477     # Open up the firewall initially, to allow the Agent to do an SVN update.
478     $stubFW->testConnect();
479
480     $URL = HoneyClient::Manager::VM->init();
481     print "VM Daemon Listening On: " . $URL . "\n";
482    
483     $stubVM = getClientHandle(namespace     => "HoneyClient::Manager::VM",
484                               fault_handler => \&_handleFaultAndCleanup);
485    
486     print "Calling setMasterVM()...\n";
487     $som = $stubVM->setMasterVM(config => $args{'master_vm_config'});
488     print "Result: " . $som->result() . "\n";
489
490     print "Calling quickCloneVM()...\n";
491     $som = $stubVM->quickCloneVM();
492     print "Result: " . $som->result() . "\n";
493     $vmCloneConfig = $som->result();
494
495     # Make sure the VM is fully cloned, before trying to make any subsequent calls.
496     print "Calling isRegisteredVM()...\n";
497     $som = $stubVM->isRegisteredVM(config => $vmCloneConfig);
498     $ret = $som->result();
499
500     if (defined($ret)) {
501         print "Result: " . $ret . "\n";
502     }
503
504     while (!defined($ret)) {
505         sleep (3);
506         print "Calling isRegisteredVM()...\n";
507         $som = $stubVM->isRegisteredVM(config => $vmCloneConfig);
508         $ret = $som->result();
509         if (defined($ret)) {
510             print "Result: " . $ret . "\n";
511         }
512     }
513
514     print "Calling getStateVM()...\n";
515     $som = $stubVM->getStateVM(config => $vmCloneConfig);
516     $vmState = $som->result();
517
518     if ($som->result() == VM_EXECUTION_STATE_ON) {
519         print "ON\n";
520     } elsif ($som->result() == VM_EXECUTION_STATE_OFF) {
521         print "OFF\n";
522     } elsif ($som->result() == VM_EXECUTION_STATE_SUSPENDED) {
523         print "SUSPENDED\n";
524     } elsif ($som->result() == VM_EXECUTION_STATE_STUCK) {
525         print "STUCK\n";
526     } else {
527         print "UNKNOWN\n";
528     }
529
530     while ($vmState != VM_EXECUTION_STATE_ON) {
531         sleep (3);
532
533         print "Calling getStateVM()...\n";
534         $som = $stubVM->getStateVM(config => $vmCloneConfig);
535         $vmState = $som->result();
536
537         if ($som->result() == VM_EXECUTION_STATE_ON) {
538             print "ON\n";
539         } elsif ($som->result() == VM_EXECUTION_STATE_OFF) {
540             print "OFF\n";
541         } elsif ($som->result() == VM_EXECUTION_STATE_SUSPENDED) {
542             print "SUSPENDED\n";
543         } elsif ($som->result() == VM_EXECUTION_STATE_STUCK) {
544             print "STUCK\n";
545         } else {
546             print "UNKNOWN\n";
547         }
548     }
549
550     print "Calling getMACaddrVM()...\n";
551     $som = $stubVM->getMACaddrVM(config => $vmCloneConfig);
552     print "Result: " . $som->result() . "\n";
553     $vmMAC = $som->result();
554
555     # Figure out when the Agent on the VM is alive and well.
556     $ret = undef;
557     while (!$ret) {
558         sleep (3);
559         print "Calling getIPaddrVM()...\n";
560         $som = $stubVM->getIPaddrVM(config => $vmCloneConfig);
561         if (defined($som->result())) {
562             print "Result: " . $som->result() . "\n";
563         }
564         $vmIP = $som->result();
565
566         if (defined($vmIP)) {
567
568             # Try contacting the Agent; ignore any faults.
569             $stubAgent = getClientHandle(namespace     => "HoneyClient::Agent",
570                                          address       => $vmIP,
571                                          fault_handler => \&_handleFault);
572
573             eval {
574                 print "Calling getStatus()...\n";
575                 $som = $stubAgent->getStatus();
576                 $ret = thaw(decode_base64($som->result()));
577                 print "Result:\n";
578                 # Make Dumper format more verbose.
579                 $Data::Dumper::Terse = 0;
580                 $Data::Dumper::Indent = 2;
581                 print Dumper($ret);
582
583                 print "Calling getNameVM()...\n";
584                 $som = $stubVM->getNameVM(config => $vmCloneConfig);
585                 print "Result: " . $som->result() . "\n";
586                 $vmName = $som->result();
587             };
588             # Clear returned state, if any fault occurs.
589             if ($@) {
590                 $ret = undef;
591             }
592         }
593     }
594
595     # Build our VM's connection table.
596     # Note: We assume our VM has a single MAC address
597     # and a single IP address.
598     $vmStateTable->{$vmName}->{sources}->{$vmMAC}->{$vmIP} = {
599         # XXX: We assume we can't pinpoint what source TCP ports the
600         # corresponding driver will need.  (We may want to get this
601         # information eventually from the Agent, as part of Driver::next().)
602         'tcp' => undef,
603     };
604
605     print "VM State Table:\n";
606     # Make Dumper format more verbose.
607     $Data::Dumper::Terse = 0;
608     $Data::Dumper::Indent = 2;
609     print Dumper($vmStateTable) . "\n";
610  
611     # Initialize the firewall.
612     $stubFW->fwInit();
613
614     # Add new chain, per cloned VM.
615     $stubFW->addChain($vmStateTable);
616    
617     sleep (2);
618
619     # Recreate the client stub; ignore faults.
620     $stubAgent = getClientHandle(namespace     => "HoneyClient::Agent",
621                                  address       => $vmIP,
622                                  fault_handler => \&_handleFault);
623
624     # Recreate the firewall stub; ignore faults.
625     $stubFW = getClientHandle(namespace     => "HoneyClient::Manager::FW",
626                               fault_handler => \&_handleFault);
627
628     for (my $counter = 1;; $counter++) {
629
630         # From this point on, catch all errors generated and
631         # assume that the Agent's watchdog process will recover.
632         eval {
633             print "Calling getStatus()...\n";
634             $som = $stubAgent->getStatus();
635             print "Result:\n";
636             my $ret = thaw(decode_base64($som->result()));
637             # Make Dumper format more verbose.
638             $Data::Dumper::Terse = 0;
639             $Data::Dumper::Indent = 2;
640             print Dumper($ret->{$args{'driver'}}->{status});
641             #print Dumper($ret);
642
643             # Check to see if Agent::run() thread has stopped
644             # and that a compromise was detected.
645             if (!defined($ret->{$args{'driver'}}->{thread_id})) {
646                 if ($ret->{$args{'driver'}}->{status}->{is_compromised}) {
647                     print "Calling getState()...\n";
648                     $som = $stubAgent->getState();
649                     $args{'agent_state'} = $som->result();
650
651                     # XXX: Delete this, eventually.
652                     $globalAgentState = $args{'agent_state'};
653
654                     # Check to see if the VM has been compromised.
655                     print "WARNING: VM HAS BEEN COMPROMISED!\n";
656                     print "Suspending: (" . $vmCloneConfig . ")...\n";
657                     print "Calling suspendVM()...\n";
658                     $som = $stubVM->suspendVM(config => $vmCloneConfig);
659                     HoneyClient::Manager::VM->destroy();
660                     $vmCompromised = 1;
661                     return; # Return out of eval block.
662                 } else {
663                     print "VM Integrity Check: OK!\n";
664                 }
665             }
666            
667             # Only call updateState() on the first iteration.
668             # TODO: Need to support asynchronous updates (url adding)
669             # from user input.
670             if ($counter == 1) {
671                 print "Calling updateState()...\n";
672                 $som = $stubAgent->updateState($args{'agent_state'});
673             }
674            
675             print "Calling getState()...\n";
676             $som = $stubAgent->getState();
677             $args{'agent_state'} = $som->result();
678
679             # XXX: Delete this, eventually.
680             $globalAgentState = $args{'agent_state'};
681
682             print "Calling getStatus()...\n";
683             $som = $stubAgent->getStatus();
684             print "Result:\n";
685             $ret = thaw(decode_base64($som->result()));
686             # Make Dumper format more verbose.
687             $Data::Dumper::Terse = 0;
688             $Data::Dumper::Indent = 2;
689             #print Dumper($ret->{$args{'driver'}}->{status});
690             print Dumper($ret);
691
692             # The Agent::run() thread has stopped; we assume
693             # it's because the Agent is waiting for the firewall
694             # to allow access to the new targets.
695             # TODO: Need to distinguish between run() stopping because
696             # of firewall mods, or if the Agent is completely finished
697             # and needs more input to continue.
698             if (!defined($ret->{$args{'driver'}}->{thread_id})) {
699
700
701                 # Delete the old firewall rules, based upon existing
702                 # targets.
703                 $stubFW->deleteRules($vmStateTable);
704
705                 # Get the new targets from the Agent.
706                 $vmStateTable->{$vmName}->{targets} = $ret->{$args{'driver'}}->{next}->{targets};
707
708                 print "VM State Table:\n";
709                 # Make Dumper format more verbose.
710                 $Data::Dumper::Terse = 0;
711                 $Data::Dumper::Indent = 2;
712                 print Dumper($vmStateTable) . "\n";
713
714                 # Add the new targets from the Agent.
715                 $stubFW->addRules($vmStateTable);
716
717                 print "Calling run()...\n";
718                 $som = $stubAgent->run();
719             }
720         };
721         if ($@) {
722             my $resetSuccessful = 0;
723             while (!$resetSuccessful) {
724                 print "Resetting firewall...\n";
725                 eval {
726                     # We assume the error was caused by some sort of communications
727                     # problem with the Agent.  Assume the Agent's watchdog will restart
728                     # the daemon, in which case, we indefinately try to reset the
729                     # firewall accordingly.
730                     $stubFW->fwInit();
731                     $stubFW->addChain($vmStateTable);
732                     $stubFW->addRules($vmStateTable);
733                 };
734                 if (!$@) {
735                     $resetSuccessful = 1;
736                 } else {
737                     sleep (3);
738                 }
739             }   
740         }
741         if ($vmCompromised) {
742             return $args{'agent_state'};
743         }
744         sleep (10);
745     }
746 }
747
748 #######################################################################
749
750 1;
751
752 #######################################################################
753 # Additional Module Documentation                                     #
754 #######################################################################
755
756 __END__
757
758 =head1 BUGS & ASSUMPTIONS
759
760 # XXX: Fill this in.
761
762 =head1 SEE ALSO
763
764 L<http://www.honeyclient.org/trac>
765
766 =head1 REPORTING BUGS
767
768 L<http://www.honeyclient.org/trac/newticket>
769
770 =head1 ACKNOWLEDGEMENTS
771
772 Paul Kulchenko for developing the SOAP::Lite module.
773
774 =head1 AUTHORS
775
776 Kathy Wang, E<lt>knwang@mitre.orgE<gt>
777
778 Thanh Truong, E<lt>ttruong@mitre.orgE<gt>
779
780 Darien Kindlund, E<lt>kindlund@mitre.orgE<gt>
781
782 =head1 COPYRIGHT & LICENSE
783
784 Copyright (C) 2006 The MITRE Corporation.  All rights reserved.
785
786 This program is free software; you can redistribute it and/or
787 modify it under the terms of the GNU General Public License
788 as published by the Free Software Foundation, using version 2
789 of the License.
790  
791 This program is distributed in the hope that it will be useful,
792 but WITHOUT ANY WARRANTY; without even the implied warranty of
793 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
794 GNU General Public License for more details.
795  
796 You should have received a copy of the GNU General Public License
797 along with this program; if not, write to the Free Software
798 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
799 02110-1301, USA.
800
801
802 =cut
Note: See TracBrowser for help on using the browser.