@@ -35,6 +35,7 @@ def parseCommandLineArguments():
35
35
parser .add_argument ("--relocations" , help = "Show the relocations." , action = "store_true" , dest = "relocations" )
36
36
parser .add_argument ("-s" , "--signatures" , help = "Check for known signatures (e.g. packers)." , action = "store_true" , dest = "signatures" )
37
37
parser .add_argument ("--strings" , help = "Check the strings in the PE file." , action = "store_true" , dest = "strings" )
38
+ parser .add_argument ("-u" , "--urls" , help = "List all URLs found in the PE file" , action = "store_true" , dest = "urls" )
38
39
parser .add_argument ("-x" , "--xml" , help = "Format output as xml." , action = "store_true" , dest = "xml" )
39
40
parser .add_argument ("-j" , "--json" , help = "Format output as JSON." , action = "store_true" , dest = "json" )
40
41
parser .add_argument ("--interactive" , help = "Use the tool in interactive mode." , action = "store_true" , dest = "interactive" )
@@ -230,7 +231,14 @@ def interactiveMode(file = None):
230
231
print ("Entering interactive mode..." )
231
232
if file is None :
232
233
print ("Please specify file to analyze or type help" )
233
-
234
+ else :
235
+ file = file .replace ("~" , os .path .expanduser ("~" ))
236
+ if not os .path .isfile (file ):
237
+ print (constants .BLUE + "Could not find the specified file %s" % file + constants .RESET )
238
+ else :
239
+ peAnalyzer = PeAnalyzer (file )
240
+ matcher = SignatureMatcher (file )
241
+ vt = VirusTotalClient (file )
234
242
235
243
def complete (text , state ):
236
244
text = text .replace ("~" , os .path .expanduser ("~" ))
@@ -309,6 +317,14 @@ def complete(text, state):
309
317
collectIndicators (vt , peAnalyzer , matcher )
310
318
elif user_in == "indicators -a" :
311
319
collectIndicators (vt , peAnalyzer , matcher , all )
320
+ elif user_in == "urls" or user_in == "u" :
321
+ urls = peAnalyzer .findURLS ()
322
+ if len (urls ) > 0 :
323
+ print ("The following (maybe non-malicious) URLs have been found:" )
324
+ for url in urls :
325
+ print ("\t " + url )
326
+ else :
327
+ print ("No URL found in the file's strings" )
312
328
else :
313
329
if user_in != "help" :
314
330
print ("Command '" + user_in + "' is unknown." )
@@ -329,6 +345,7 @@ def complete(text, state):
329
345
print ("\t sections - show all sections in the file" )
330
346
print ("\t strings -a - show all strings we can find in the PE file" )
331
347
print ("\t strings -b - show blacklisted strings we can find in the PE file" )
348
+ print ("\t u/urls - list all URLs found in the PE file" )
332
349
print ("\t help - print this help text" )
333
350
334
351
no_user_in = True
@@ -455,6 +472,22 @@ def checkFile(args):
455
472
else :
456
473
print (constants .GREEN + "No packer signature was found in the PE file" + constants .RESET )
457
474
475
+ if args .urls :
476
+ urls = peAnalyzer .findURLS ()
477
+ if args .xml :
478
+ urlsXml = ET .SubElement (root , "URLs" )
479
+ for url in urls :
480
+ ET .SubElement (urlsXml , "url" ).text = url
481
+ elif args .json :
482
+ jsonDict ["URLs" ] = urls
483
+ else :
484
+ if len (urls ) > 0 :
485
+ print ("The following (maybe non-malicious) URLs have been found:" )
486
+ for url in urls :
487
+ print ("\t " + url )
488
+ else :
489
+ print ("No URL found in the file's strings" )
490
+
458
491
if not args .yara is None :
459
492
if args .xml :
460
493
root = checkYara (args .file , args .yara , root = root )
0 commit comments