Skip to content

Commit 8b4ddb9

Browse files
committed
Added stdin global for use with multiple functions
1 parent 83fc0f5 commit 8b4ddb9

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

searchsploit.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
IGNORE = False
2121
CASE = False
2222
COL = 0
23+
STDIN = "" # made to hold standard input for multiple functions
2324

2425
# get column length
2526
try:
@@ -452,18 +453,24 @@ def nmapxml(file=""):
452453
@return: returns true if it fails
453454
"""
454455
global terms
456+
global STDIN
455457

456458
# First check whether file exists or use stdin
457459
try:
458460
content = open(file, "r").read()
459461
except:
460462
if(not os.sys.stdin.isatty()):
461463
content = os.sys.stdin.read()
464+
if content == "" and STDIN != "":
465+
content = STDIN
466+
elif content == "" and STDIN == "":
467+
return False
462468
else:
463-
return True
469+
return False
464470

465471
# stope if blank or not an xml sheet
466472
if content == "" or content[:5] != "<?xml":
473+
STDIN = content
467474
return False
468475
# making sure beautiful soup is importable first
469476
try:
@@ -511,18 +518,24 @@ def nmapgrep(file=""):
511518
512519
"""
513520
global terms
521+
global STDIN
514522

515523
# First check whether file exists or use stdin
516524
try:
517525
content = open(file, "r").read()
518526
except:
519527
if(not os.sys.stdin.isatty()):
520528
content = os.sys.stdin.read()
529+
if content == "" and STDIN != "":
530+
content = STDIN
531+
elif content == "" and STDIN == "":
532+
return False
521533
else:
522534
return False
523535

524536
# Check whether its grepable
525-
if (content.find("Host: ") == -1 and "-oG" in content.split("\n")[0]):
537+
if (content.find("Host: ") == -1 or not "-oG" in content.split("\n")[0] or content == ""):
538+
STDIN = content
526539
return False
527540

528541
# making a matrix to contain necessary strings
@@ -537,7 +550,7 @@ def nmapgrep(file=""):
537550
nmatrix[lines][1] = nmatrix[lines][1][7:].split(", ")
538551
for j in range(len(nmatrix[lines][1])):
539552
nmatrix[lines][1][j] = nmatrix[lines][1][j].replace("/", " ").split()[3:]
540-
print(nmatrix)
553+
541554
# Outputing results from matrix
542555
for host in nmatrix:
543556
tmpaddr = highlightTerm(host[0][0], host[0][0], True)

0 commit comments

Comments
 (0)