Changeset 1201

Show
Ignore:
Timestamp:
02/15/08 17:44:59 (7 months ago)
Author:
kindlund
Message:

Updated support for database integration. Can pull URLs from centralized database, as well as push histories back onto the database.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • honeyclient/trunk/lib/HoneyClient/Manager.pm

    r1200 r1201  
    754754                                 fault_handler => \&_handleFaultAndCleanup); 
    755755 
    756     # TODO XXX: Get URL list from database. 
     756    # If supported, get a URL list from the database. 
    757757    if ($DB_ENABLE && ($vm->database_id > 0)) { 
    758758        $args{'agent_state'} = get_urls($vm, $args{'agent_state'}, $args{'driver'}); 
     
    780780        # assume that the Agent's watchdog process will recover. 
    781781        eval { 
    782             #print "Calling getState()...\n"; 
    783             #$som = $stubAgent->getState(); 
    784             #$args{'agent_state'} = $som->result(); 
    785  
    786             # XXX: Delete this, eventually. 
    787             #$globalAgentState = $args{'agent_state'}; 
    788             #print "Result:\n"; 
    789             #print Dumper(thaw(decode_base64($globalAgentState))); 
    790  
    791782            print "Calling getStatus()...\n"; 
    792783            $som = $stubAgent->getStatus(); 
     
    799790            #print Dumper($ret); 
    800791 
    801             # Extract current agent state
     792            # Derive current agent state from full status
    802793            my @driverNames = keys(%{$ret}); 
    803794            my $state = {}; 
     
    807798            $args{'agent_state'} = encode_base64(nfreeze($state)); 
    808799            $globalAgentState = $args{'agent_state'}; 
    809             print "GlobalAgentState:\n"; 
    810             print Dumper(thaw(decode_base64($globalAgentState))); 
     800            #print "GlobalAgentState:\n"; 
     801            #print Dumper(thaw(decode_base64($globalAgentState))); 
    811802 
    812803            # Check to see if Agent::run() thread has stopped 
     
    881872                    if (!$ret->{$args{'driver'}}->{status}->{links_remaining}) { 
    882873     
    883                         # TODO XXX: Get URL list from database. 
    884  
    885                         $LOG->info("All URLs exhausted.  Shutting down Manager."); 
    886                         $vm = undef; 
    887                         print "Done!\n"; 
    888                         _cleanup(); 
    889  
     874                        # If supported, get more URLs from the database. 
     875                        if ($DB_ENABLE && ($vm->database_id > 0)) { 
     876                            # Put URL History in database. 
     877                            $LOG->info("Saving URL History to Database."); 
     878                            insert_url_history(agent_state => $args{'agent_state'}, 
     879                                               client_id   => $vm->database_id); 
     880 
     881                            $args{'agent_state'} = get_urls($vm, $args{'agent_state'}, $args{'driver'}); 
     882                            print "Calling updateState()...\n"; 
     883                            $som = $stubAgent->updateState($args{'agent_state'}); 
     884                        } else { 
     885                            $LOG->info("All URLs exhausted.  Shutting down Manager."); 
     886                            $vm = undef; 
     887                            print "Done!\n"; 
     888                            _cleanup(); 
     889                        } 
    890890                    } else { 
    891891                        # The Agent::run() thread has stopped; we assume 
     
    988988        cid => $vm->name, 
    989989        status => 'running', 
    990         # TODO: Collect host,application, and config through automation/config files 
     990        # TODO: Collect host, application, and config through automation/config files 
    991991        host => { 
    992992            org => 'MITRE', 
     
    10321032        # XXX: Hardcoded timeout. 
    10331033        sleep (2); 
    1034         $LOG->info("Retrieving new URLs from database."); 
     1034        #$LOG->info("Retrieving new URLs from database."); 
    10351035        $queue_url_list = HoneyClient::Manager::Database::get_queue_urls(10, $vm->database_id); 
    10361036        $remoteLinksExist = scalar(%{$queue_url_list}); 
  • honeyclient/trunk/lib/HoneyClient/Manager/VM.pm

    r1040 r1201  
    825825    # the parent process... 
    826826    if (defined($DAEMON_PID) && $DAEMON_PID) { 
     827        # XXX: Delete this, eventually. 
     828        $LOG->info("Destroying VM daemon at PID: " . $DAEMON_PID); 
    827829        $ret = kill("QUIT", $DAEMON_PID); 
    828830