@@ -113,7 +113,7 @@ def get_network_info(self):
113
113
:return: None. Updates class information
114
114
"""
115
115
LOG .debug ("Reading subnets" )
116
- self .info ['network_info' ] = \
116
+ self .info ['network_info' ] = \
117
117
{
118
118
'networks' : get_host_subnets (),
119
119
'netstat' : NetstatCollector .get_netstat_info ()
@@ -122,28 +122,38 @@ def get_network_info(self):
122
122
def get_azure_info (self ):
123
123
"""
124
124
Adds credentials possibly stolen from an Azure VM instance (if we're on one)
125
- Updates the credentials structure, creating it if neccesary (compat with mimikatz)
125
+ Updates the credentials structure, creating it if necessary (compat with mimikatz)
126
126
:return: None. Updates class information
127
127
"""
128
- from infection_monkey .config import WormConfiguration
129
- if not WormConfiguration .extract_azure_creds :
130
- return
131
- LOG .debug ("Harvesting creds if on an Azure machine" )
132
- azure_collector = AzureCollector ()
133
- if 'credentials' not in self .info :
134
- self .info ["credentials" ] = {}
135
- azure_creds = azure_collector .extract_stored_credentials ()
136
- for cred in azure_creds :
137
- username = cred [0 ]
138
- password = cred [1 ]
139
- if username not in self .info ["credentials" ]:
140
- self .info ["credentials" ][username ] = {}
141
- # we might be losing passwords in case of multiple reset attempts on same username
142
- # or in case another collector already filled in a password for this user
143
- self .info ["credentials" ][username ]['password' ] = password
144
- if len (azure_creds ) != 0 :
145
- self .info ["Azure" ] = {}
146
- self .info ["Azure" ]['usernames' ] = [cred [0 ] for cred in azure_creds ]
128
+ # noinspection PyBroadException
129
+ try :
130
+ from infection_monkey .config import WormConfiguration
131
+ if not WormConfiguration .extract_azure_creds :
132
+ return
133
+ LOG .debug ("Harvesting creds if on an Azure machine" )
134
+ azure_collector = AzureCollector ()
135
+ if 'credentials' not in self .info :
136
+ self .info ["credentials" ] = {}
137
+ azure_creds = azure_collector .extract_stored_credentials ()
138
+ for cred in azure_creds :
139
+ username = cred [0 ]
140
+ password = cred [1 ]
141
+ if username not in self .info ["credentials" ]:
142
+ self .info ["credentials" ][username ] = {}
143
+ # we might be losing passwords in case of multiple reset attempts on same username
144
+ # or in case another collector already filled in a password for this user
145
+ self .info ["credentials" ][username ]['password' ] = password
146
+ if len (azure_creds ) != 0 :
147
+ self .info ["Azure" ] = {}
148
+ self .info ["Azure" ]['usernames' ] = [cred [0 ] for cred in azure_creds ]
149
+ except Exception :
150
+ # If we failed to collect azure info, no reason to fail all the collection. Log and continue.
151
+ LOG .error ("Failed collecting Azure info." , exc_info = True )
147
152
148
153
def get_aws_info (self ):
149
- self .info ['aws' ] = AwsCollector ().get_aws_info ()
154
+ # noinspection PyBroadException
155
+ try :
156
+ self .info ['aws' ] = AwsCollector ().get_aws_info ()
157
+ except Exception :
158
+ # If we failed to collect aws info, no reason to fail all the collection. Log and continue.
159
+ LOG .error ("Failed collecting AWS info." , exc_info = True )
0 commit comments