User input passed as a variable to subprocess.call

Question:

Im trying to pass a variable into another program that is being launched. I having issues with the variable working

here is the code
It all works up until the passing of RHOST, metasploit takes it as %RHOST

I need to pass the RHOST variable straight after set RHOSTS . Help please 🙂

#!/usr/bin/python
import os,sys,re,subprocess
RHOST=raw_input("Enter ipaddress range:")
print ("Your Address range isn" + RHOST + "!")
subprocess.call("xterm -e msfconsole -x 'sleep 2; use auxiliary/scanner/discovery/arp_sweep; set RHOSTS '%RHOST'; exploit'",shell=True)
end = raw_input('Hit Enter to Exit.')
Asked By: Resistance802.11

||

Answers:

use string format:

"xterm -e msfconsole -x 'sleep 2; use auxiliary/scanner/discovery/arp_sweep; set RHOSTS '%{0}'; exploit'".format(RHOST)
Answered By: midori
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.