Changeset 709
- Timestamp:
- 07/20/07 15:58:14 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
honeyclient/branches/exp/kindlund-firefox/bin/StartManager.pl
r701 r709 24 24 # They can however supply multiple urls which will be processed in order 25 25 26 my $driver = "FF"; 26 # Change to 'Browser::IE' or 'Browser::FF' 27 my $driver = "Browser::IE"; 27 28 my $config = "/vm/master-vms/Agent.Master-23/winXPPro.cfg"; 28 29 my $maxrel = 10; … … 60 61 61 62 my $agentState = HoneyClient::Manager->run( 62 driver => $driver, # Change to 'IE' or 'FF'63 driver => $driver, 63 64 master_vm_config => $config, 64 65 agent_state => encode_base64(nfreeze({ 65 $driver => { # Change to 'IE' or 'FF'66 $driver => { 66 67 next_link_to_visit => $firsturl, 67 68 # Enable this line, if you want to only go to the honeyclient/branches/exp/kindlund-firefox/lib/HoneyClient/Agent.pm
r701 r709 113 113 # TODO: Eventually, make this more dynamic, based upon the presence of HoneyClient::Agent::Driver::* elements 114 114 # within the global configuration file. Or, feed the initialization logic through init() as part of the arguments. 115 @DRIVERS = ( ' FF' );115 @DRIVERS = ( 'Browser::IE' ); 116 116 foreach (@DRIVERS) { 117 eval "use HoneyClient::Agent::Driver:: Browser::$_";117 eval "use HoneyClient::Agent::Driver::$_"; 118 118 if ($@) { 119 119 Carp::croak "$@"; … … 150 150 use HoneyClient::Util::Config qw(getVar); 151 151 152 # TODO: Change Driver::IE to Driver::Browser::IE153 # Make sure HoneyClient::Agent::Driver::IE loads. 154 BEGIN { use_ok('HoneyClient::Agent::Driver::IE') or diag("Can't load HoneyClient::Agent::Driver::IE package. Check to make sure the package library is correctly listed within the path."); } 155 require_ok('HoneyClient::Agent::Driver::IE'); 156 can_ok('HoneyClient::Agent::Driver:: IE', 'new');157 can_ok('HoneyClient::Agent::Driver:: IE', 'drive');158 can_ok('HoneyClient::Agent::Driver:: IE', 'getNextLink');159 can_ok('HoneyClient::Agent::Driver:: IE', 'next');160 can_ok('HoneyClient::Agent::Driver:: IE', 'isFinished');161 can_ok('HoneyClient::Agent::Driver:: IE', 'status');162 use HoneyClient::Agent::Driver:: IE;152 # Make sure HoneyClient::Agent::Driver::Browser::IE loads. 153 BEGIN { use_ok('HoneyClient::Agent::Driver::Browser::IE') or diag("Can't load HoneyClient::Agent::Driver::Browser::IE package. Check to make sure the package library is correctly listed within the path."); } 154 require_ok('HoneyClient::Agent::Driver::Browser::IE'); 155 # TODO: Update this list of function names. 156 can_ok('HoneyClient::Agent::Driver::Browser::IE', 'new'); 157 can_ok('HoneyClient::Agent::Driver::Browser::IE', 'drive'); 158 can_ok('HoneyClient::Agent::Driver::Browser::IE', 'getNextLink'); 159 can_ok('HoneyClient::Agent::Driver::Browser::IE', 'next'); 160 can_ok('HoneyClient::Agent::Driver::Browser::IE', 'isFinished'); 161 can_ok('HoneyClient::Agent::Driver::Browser::IE', 'status'); 162 use HoneyClient::Agent::Driver::Browser::IE; 163 163 164 164 # Make sure Storable loads. … … 630 630 =pod 631 631 632 =head1 EX PORTS633 634 =head2 run( )632 =head1 EXTERNAL SOAP FUNCTIONS 633 634 =head2 run(driver_name => $driverName) 635 635 636 636 =over 4 637 637 638 Runs the Agent for one cycle. In this cycle, the following happens: 639 640 =over 4 641 642 =item 1) 643 644 The specified Driver is driven for multiple work units, where each 645 consecutive drive operation contacts the same network resources 646 (aka. "targets"). The Driver ceases its operation, as soon as 647 it has exhausted all targets or until it is ready to contact a 648 different set of targets. 649 650 =item 2) 651 652 Once the specified driver has stopped, the Agent performs a corresponding 653 Integrity check. 654 655 =back 656 638 657 # XXX: Fill this in. 639 658 640 659 I<Inputs>: 641 B<$ arg> is an optional argument.642 SOAP server to listen on.660 B<$driverName> is the name of the Driver to use, when running this 661 cycle. 643 662 644 I<Output>: XXX: Fill this in. 663 I<Output>: Returns true if the Agent successfully started a new cycle; 664 returns false, if the Agent is still running an existing cycle and 665 has not finished yet. 666 667 I<Notes>: 668 During a single run() cycle, it is expected that the driven application 669 will only contact the same targets. This allows the Manager to update 670 firewall rules between cycles. 645 671 646 672 =back 647 673 648 =begin testing649 674 #=begin testing 675 # 650 676 # XXX: Fill this in. 651 1; 652 653 =end testing 677 # 678 #=end testing 654 679 655 680 =cut … … 657 682 sub run { 658 683 # Extract arguments. 684 my ($class, %args) = @_; 685 686 # XXX: Change this to debug, eventually. 687 # Log resolved arguments. 688 $LOG->info(sub { 689 # Make Dumper format more terse. 690 $Data::Dumper::Terse = 1; 691 $Data::Dumper::Indent = 0; 692 Dumper(\%args); 693 }); 694 695 # Sanity check. Make sure we get a valid argument. 696 my $argsExist = scalar(%args); 697 if (!$argsExist || 698 !exists($args{'driver_name'}) || 699 !defined($args{'driver_name'})) { 700 701 # Die if no valid argument is supplied. 702 $LOG->warn("No Driver name specified."); 703 die SOAP::Fault->faultcode(__PACKAGE__ . "->run()") 704 ->faultstring("No Driver name specified."); 705 } 659 706 660 707 # Temporary variable, used to hold thawed driver data. … … 678 725 679 726 # XXX: Delete this, eventually. 680 print "Checking TID = " . Dumper($tid) . "\n";727 print $driverName . ": Checking TID = " . Dumper($tid) . "\n"; 681 728 if (defined(threads->object($tid))) { 682 print "Thread defined.\n";729 print $driverName . ": Thread defined.\n"; 683 730 if (threads->object($tid)->is_running()) { 684 print "Thread is running.\n";731 print $driverName . ": Thread is running.\n"; 685 732 } else { 686 print "Thread is NOT running.\n";733 print $driverName . ": Thread is NOT running.\n"; 687 734 } 688 735 } else { 689 print "Thread NOT defined.\n";736 print $driverName . ": Thread NOT defined.\n"; 690 737 } 691 738 … … 702 749 } else { 703 750 # XXX: Remove this, eventually. 704 print "Creating a new run() child thread...\n";751 print $driverName . ": Creating a new run() child thread...\n"; 705 752 } 706 753 … … 736 783 if ($thread->is_running()) { 737 784 # XXX: Debugging, remove eventually. 738 print "Thread ID = " . $thread->tid() . "\n";785 print $driverName . ": Thread ID = " . $thread->tid() . "\n"; 739 786 } else { 740 787 # XXX: Debugging, remove eventually. 741 print "Thread ID = " . $thread->tid() . " (NOT RUNNING)\n";788 print $driverName . ": Thread ID = " . $thread->tid() . " (NOT RUNNING)\n"; 742 789 } 743 790 … … 747 794 748 795 # XXX: Debugging, remove eventually. 749 print "Run thread initialized.\n";796 print $driverName . ": Run thread initialized.\n"; 750 797 751 798 # At this point, the driver thread is initialized and running, … … 801 848 # Now, initialize each driver object. 802 849 # Figure out which $driver object to use... 803 my $driverClass = 'HoneyClient::Agent::Driver:: Browser::' . $driverName;850 my $driverClass = 'HoneyClient::Agent::Driver::' . $driverName; 804 851 805 852 if (!defined($data->{$driverName}->{'state'})) { … … 848 895 # We assume $driver->next() returns defined data. 849 896 foreach my $resource (keys %{$driver->next()->{resources}}) { 850 $LOG->info( "Driving To Resource: " . $resource);897 $LOG->info($driverName . " - Driving To Resource: " . $resource); 851 898 $lastResource = $resource; 852 899 } … … 866 913 # XXX: Delete this, eventually. 867 914 if ($driverTargetsChanged) { 868 $LOG->info( "Driver targets have changed.");915 $LOG->info($driverName . " - Driver targets have changed."); 869 916 #$Data::Dumper::Terse = 0; 870 917 #$Data::Dumper::Indent = 1; … … 884 931 } 885 932 886 # TODO: Perform Integrity Check 933 # Perform Integrity Check 934 # XXX: We may want this logic moved out of the child thread, 935 # in case we ever have more than one worker thread simultaneously going. 936 # (We wouldn't want to have 2 worker threads simultaneously performing 937 # this check, as VM performance would slow to a crawl.) 887 938 my $isCompromised = 0; 888 939 my $changes = undef; … … 890 941 # For now, we update a scalar called 'is_compromised' within 891 942 # the $data->{$driverName}->{'status'} sub-hashtable. 892 $LOG->info( "Performing Integrity Checks.");943 $LOG->info($driverName . " - Performing Integrity Checks."); 893 944 $changes = $integrity->check(); 894 945 if (scalar(@{$changes->{registry}}) || 895 946 scalar(@{$changes->{filesystem}})) { 896 $LOG->warn( "Integrity Check: FAILED");947 $LOG->warn($driverName . " - Integrity Check: FAILED"); 897 948 $isCompromised = 1; 898 949 $changes->{'last_resource'} = $lastResource; 899 950 } else { 900 $LOG->info( "Integrity Check: PASSED");951 $LOG->info($driverName . " - Integrity Check: PASSED"); 901 952 } 902 953 } … … 936 987 937 988 # TODO: Do proper fault queuing. 938 $LOG->error( "FAULT: " . $@);989 $LOG->error($driverName . " - FAULT: " . $@); 939 990 } 940 991 941 992 # XXX: Debugging, remove eventually. 942 print "About to return out of child thread.\n";993 print $driverName . ": About to return out of child thread.\n"; 943 994 if (!threads->is_detached()) { 944 995 threads->detach(); … … 1034 1085 # Initialize the driver object. 1035 1086 # Figure out which $driver object to use... 1036 my $driverClass = 'HoneyClient::Agent::Driver:: Browser::' . $driverName;1087 my $driverClass = 'HoneyClient::Agent::Driver::' . $driverName; 1037 1088 1038 1089 if (!defined($data->{$driverName}->{'state'})) { honeyclient/branches/exp/kindlund-firefox/lib/HoneyClient/Manager.pm
r696 r709 749 749 750 750 print "Calling run()...\n"; 751 $som = $stubAgent->run( );751 $som = $stubAgent->run(driver_name => $args{'driver'})); 752 752 } 753 753 }
