Skip to content

Commit 8115532

Browse files
committed
Implemented json feature
1 parent b9876bd commit 8115532

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

searchsploit.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,26 @@ def searchsploitout():
403403
# xx validating terms
404404
validTerm(terms)
405405
if JSON:
406-
# TODO: finish json format
406+
jsonDict = {}
407+
temp = ""
408+
for i in terms:
409+
temp += i + " "
410+
jsonDict["SEARCH"] = temp[:-1] # Adding the search terms
411+
searchs = []
412+
try:
413+
for i in range(len(files_array)):
414+
jsonDict["DB_PATH_" + name_array[i].upper()] = path_array[i]
415+
searchs.clear()
416+
query = searchdb(path_array[i] + "/" + files_array[i], terms, [2,0,3,4,5,6,1])
417+
for lines in query:
418+
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]})
419+
jsonDict["RESULTS_" + name_array[i].upper()] = searchs.copy()
420+
searchs.clear()
421+
import json.encoder
422+
jsonResult = json.dumps(jsonDict)
423+
print(jsonResult)
424+
except KeyboardInterrupt:
425+
pass
407426
return
408427

409428
# xx building terminal look

0 commit comments

Comments
 (0)