3636
3737# RC info
3838
39- progname = argv [0 ]. split ( "/" )[ - 1 ]
39+ progname = os . path . basename ( argv [0 ])
4040files_array = [] # Array options with file names
4141name_array = [] # Array options with database names
4242path_array = [] # Array options with paths to database files
@@ -50,25 +50,19 @@ def scrapeRC():
5050
5151 try :
5252 if (SETTINGS_LOC != "" ): # Checks if the variable is empty
53- settingsFile = open (SETTINGS_LOC , "r" )
53+ settingsFile = open (os . path . relpath ( SETTINGS_LOC ) , "r" )
5454 else :
5555 settingsFile = open (".searchsploit_rc" , "r" )
5656 except :
5757 try :
58- settingsFile = open ("/etc/.searchsploit_rc" , "r" )
58+ settingsFile = open (os . path . abspath ( "/etc/.searchsploit_rc" ) , "r" )
5959 except :
60- try :
61- settingsFile = open (os .path .expanduser ("~" ).replace (
62- "\\ " , "/" ) + "/.searchsploit_rc" , "r" )
63- # Checks for home directory in linux/mac
64- except :
65- settingsFile = open (os .getenv ("userprofile" ).replace (
66- "\\ " , "/" ) + "/.searchsploit_rc" , "r" )
67- # Checks for home directory in windows
60+ settingsFile = open (os .path .expanduser ("~/.searchsploit_rc" ), "r" )
61+ # Checks for config in home directory
6862
6963 settings = settingsFile .read ().split ("\n " )
7064 settingsFile .close ()
71-
65+
7266 for i in settings :
7367 if (i == "" or i [0 ] == "#" ):
7468 continue # Ignores lines that are empty or are just comments
@@ -86,7 +80,7 @@ def scrapeRC():
8680 larray = len (files_array )
8781 for i in range (larray - 1 , 0 , - 1 ):
8882 try :
89- tempRead = open (os .path .abspath (path_array [i ] + "/" + files_array [i ]),
83+ tempRead = open (os .path .abspath (os . path . join ( path_array [i ], files_array [i ]) ),
9084 "r" , encoding = "utf8" )
9185 tempRead .read ()
9286 tempRead .close ()
@@ -319,7 +313,7 @@ def findExploit(id):
319313 """
320314 exploit = []
321315 for i in range (len (files_array )):
322- exploit = cpFromDb (path_array [i ] + "/" + files_array [i ], id )
316+ exploit = cpFromDb (os . path . abspath ( os . path . join ( path_array [i ], files_array [i ])) , id )
323317 if exploit == []:
324318 continue
325319 else :
@@ -423,7 +417,7 @@ def searchsploitout():
423417 for i in range (len (files_array )):
424418 jsonDict ["DB_PATH_" + name_array [i ].upper ()] = path_array [i ]
425419 searchs .clear ()
426- query = searchdb (path_array [i ] + "/" + files_array [i ], terms , [2 ,0 ,3 ,4 ,5 ,6 ,1 ])
420+ query = searchdb (os . path . abspath ( os . path . join ( path_array [i ], files_array [i ])) , terms , [2 ,0 ,3 ,4 ,5 ,6 ,1 ])
427421 for lines in query :
428422 searchs .append ({"Title" : lines [0 ].replace ('"' , "" ), "EDB-ID" :int (lines [1 ]), "Date" : lines [2 ], "Author" :lines [3 ].replace ('"' , "" ), "Type" :lines [4 ], "Platform" : lines [5 ], "Path" :path_array [i ] + "/" + lines [6 ]})
429423 jsonDict ["RESULTS_" + name_array [i ].upper ()] = searchs .copy ()
@@ -442,21 +436,18 @@ def searchsploitout():
442436 try :
443437 for i in range (len (files_array )):
444438 if EDBID :
445- query = searchdb (path_array [i ] + "/" +
446- files_array [i ], terms , [2 , 0 ])
439+ query = searchdb (os .path .abspath (os .path .join (path_array [i ], files_array [i ])), terms , [2 , 0 ])
447440 elif WEBLINK :
448- query = searchdb (path_array [i ] + "/" +
449- files_array [i ], terms , [2 , 1 , 0 ])
441+ query = searchdb (os .path .abspath (os .path .join (path_array [i ], files_array [i ])), terms , [2 , 1 , 0 ])
450442 else :
451- query = searchdb (path_array [i ] + "/" +
452- files_array [i ], terms , [2 , 1 ])
443+ query = searchdb (os .path .abspath (os .path .join (path_array [i ], files_array [i ])), terms , [2 , 1 ])
453444
454445 if len (query ) == 0 : # is the search results came up with nothing
455446 print (name_array [i ] + ": No Results" )
456447 continue
457448 drawline (lim )
458449 separater (COL / 4 , name_array [i ] + " Title" , "Path" )
459- separater (COL / 4 , "" , path_array [i ])
450+ separater (COL / 4 , "" , os . path . abspath ( path_array [i ]) )
460451 drawline (lim ) # display title for every database
461452 for lines in query :
462453 if WEBLINK : # if requesting weblinks. shapes the output for urls
@@ -613,7 +604,7 @@ def path(id):
613604 """
614605 try :
615606 file , exploit = findExploit (id )
616- print (path_array [file ] + "/" + exploit [1 ])
607+ print (os . path . abspath ( os . path . join ( path_array [file ], exploit [1 ])) )
617608 except TypeError :
618609 print ("%s does not exist. Please double check that this is the correct id." % id )
619610
@@ -629,8 +620,8 @@ def mirror(id):
629620 absfile = path_array [ind ]
630621
631622 currDir = os .getcwd ()
632- inp = open (absfile + "/" + exploit [1 ], "rb" )
633- out = open (currDir + "/" + exploit [ 1 ]. split ( "/" )[ - 1 ] , "wb" )
623+ inp = open (os . path . normpath ( os . path . join ( absfile , exploit [1 ])) , "rb" )
624+ out = open (os . path . join ( currDir , os . path . basename ( exploit [ 1 ])) , "wb" )
634625 out .write (inp .read ())
635626 inp .close ()
636627 out .close ()
@@ -647,14 +638,14 @@ def examine(id):
647638 return
648639 if exploit [1 ].endswith (".pdf" ):
649640 import webbrowser
650- webbrowser .open ("file:///" + path_array [ind ] + "/" + exploit [1 ], autoraise = True )
641+ webbrowser .open ("file:///" + os . path . abspath ( os . path . join ( path_array [ind ], exploit [1 ])) , autoraise = True )
651642 elif (os .sys .platform == "win32" ):
652- os .system ("notepad " + path_array [ind ] + "/" + exploit [1 ])
643+ os .system ("notepad " + os . path . relpath ( os . path . join ( path_array [ind ], exploit [1 ])) )
653644 else :
654- os .system ("pager " + path_array [ind ] + "/" + exploit [1 ])
655- print ("[EDBID]:" + exploit [0 ])
645+ os .system ("pager " + os . path . relpath ( os . path . join ( path_array [ind ], exploit [1 ])) )
646+ print ("[EDBID]:" + exploit [0 ])
656647 print ("[Exploit]:" + exploit [2 ])
657- print ("[Path]:" + path_array [ind ] + "/" + exploit [1 ])
648+ print ("[Path]:" + os . path . abspath ( os . path . join ( path_array [ind ], exploit [1 ])) )
658649 print ("[URL]:https://www.exploit-db.com/" +
659650 exploit [1 ].split ("/" )[0 ] + "/" + exploit [0 ])
660651 print ("[Date]:" + exploit [3 ])
0 commit comments