Changeset 1200
- Timestamp:
- 02/15/08 15:59:44 (6 months ago)
- Files:
-
- honeyclient/trunk/lib/HoneyClient/Manager.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
honeyclient/trunk/lib/HoneyClient/Manager.pm
r1140 r1200 755 755 756 756 # TODO XXX: Get URL list from database. 757 if ($DB_ENABLE && ($vm->database_id > 0)) { 758 $args{'agent_state'} = get_urls($vm, $args{'agent_state'}, $args{'driver'}); 759 } 757 760 758 761 # Call updateState() first, to seed initial data. … … 777 780 # assume that the Agent's watchdog process will recover. 778 781 eval { 779 print "Calling getState()...\n";780 $som = $stubAgent->getState();781 $args{'agent_state'} = $som->result();782 #print "Calling getState()...\n"; 783 #$som = $stubAgent->getState(); 784 #$args{'agent_state'} = $som->result(); 782 785 783 786 # XXX: Delete this, eventually. 784 $globalAgentState = $args{'agent_state'}; 787 #$globalAgentState = $args{'agent_state'}; 788 #print "Result:\n"; 789 #print Dumper(thaw(decode_base64($globalAgentState))); 785 790 786 791 print "Calling getStatus()...\n"; … … 794 799 #print Dumper($ret); 795 800 801 # Extract current agent state. 802 my @driverNames = keys(%{$ret}); 803 my $state = {}; 804 foreach my $driverName (@driverNames) { 805 $state->{$driverName} = $ret->{$driverName}->{'state'}; 806 } 807 $args{'agent_state'} = encode_base64(nfreeze($state)); 808 $globalAgentState = $args{'agent_state'}; 809 print "GlobalAgentState:\n"; 810 print Dumper(thaw(decode_base64($globalAgentState))); 811 796 812 # Check to see if Agent::run() thread has stopped 797 813 # and that a compromise was detected. … … 850 866 $LOG->info("Database Insert Successful."); 851 867 } 868 # The VM should be suspended, at this point. Clear out the global DB ID, so 869 # that our cleanup code doesn't re-mark the VM as suspended. 870 $clientDbId = 0; 871 852 872 # Make sure VM is suspended. 853 873 $vm = undef; … … 992 1012 } 993 1013 1014 sub get_urls { 1015 my $vm = shift; 1016 my $agent_state = shift; 1017 my $driver = shift; 1018 1019 # Decode and thaw the initial agent state. 1020 my $state = thaw(decode_base64($agent_state)); 1021 1022 # XXX: We hardcode the value of 10 URLs to request; this will change, eventually. 1023 my $queue_url_list = {}; 1024 $LOG->info("Retrieving new URLs from database."); 1025 $queue_url_list = HoneyClient::Manager::Database::get_queue_urls(10, $vm->database_id); 1026 my $remoteLinksExist = scalar(%{$queue_url_list}); 1027 1028 # While we have no local URLs and no URLs from the database, re-query the database. 1029 while (!defined($state->{$driver}->{next_link_to_visit}) && 1030 !$remoteLinksExist) { 1031 1032 # XXX: Hardcoded timeout. 1033 sleep (2); 1034 $LOG->info("Retrieving new URLs from database."); 1035 $queue_url_list = HoneyClient::Manager::Database::get_queue_urls(10, $vm->database_id); 1036 $remoteLinksExist = scalar(%{$queue_url_list}); 1037 } 1038 1039 # If we do have URLs from the database, then merge them into the agent state. 1040 # Note: Priorities specified in the database take precedent over any URLs specified locally. 1041 if ($remoteLinksExist) { 1042 $state->{$driver}->{links_to_visit} = { %{$state->{$driver}->{links_to_visit}}, 1043 %{$queue_url_list} }; 1044 $agent_state = encode_base64(nfreeze($state)); 1045 } 1046 1047 return $agent_state; 1048 } 1049 994 1050 ####################################################################### 995 1051
