1

Hi I want to do this in my lab environment:

When meterpreter shell is gained, automatically I want to execute console commands such as route add, jobs -K or use some other exploit or auxiliary modules. There is multicommand , multi_console_command and other ruby scripts to do that using AutoRunScript option in msf handler. Unfortunately all of those scripts only run commands in meterpreter session and I want to change this logic. I want to run them in console. Consider this scenario, you want to kill job when session is come and add route then run another auxiliary module.

How to do that?

2
  • In that link, only shown running commands using resource scripts in meterpreter session context. I want to run commands in metasploit console context.
    – Its 2013
    Commented Jan 12, 2018 at 21:53
  • Ask mubix, he probably knows twitter.com/mubix Commented Jul 12, 2018 at 14:18

2 Answers 2

1

multi_console_command.rb (by darkoperator) uses the meterpreter APi cmd_exec() to execute a list of commands.

The metasploit API that allows us to use the shell interpreter is: session.shell_command()

Option 1: build your own multi_console_command.rb module with session.shell_command() API
Option 2: build one resource file with those post-exploitation commands

My metasploit API cheat sheet list: https://github.com/r00t-3xp10it/hacking-material-books/blob/master/metasploit-RC%5BERB%5D/metasploit-API/my-API-Cheat-sheet.md

My metasploit resource files cheat sheet: https://github.com/r00t-3xp10it/hacking-material-books/blob/master/metasploit-RC%5BERB%5D/metasploit_resource_files.md

-1

When you're in the meterpreter console you need to use the background command to return to the msfconsole screen.

meterpreter > background
[*] Backgrounding session 2...
msf > route add 10.10.0.0/24 2
[*] Route added
msf > sessions -l

Active sessions
===============

  Id  Name  Type                     Information                 Connection
  --  ----  ----                     -----------                 ----------
  2         meterpreter x86/windows  test\test @ test  192.168.15.58:443 -> 192.168.15.180:49271 (192.168.15.180)

msf > sessions -i 2
[*] Starting interaction with 2...
1
  • I think you didn't get the point. I want to automate this process. When meterpreter shell is gained, automatically I want to execute console commands such as route add, jobs -K or use some other exploit or auxiliary modules. There is multicommand,multi_console_command and other ruby scripts to do that using AutoRunScript option in msf handler. Unfortunately all of those scripts only run commands in meterpreter session and I want to change this logic. I want to run them in console. Consider this scenario, you want to kill job when session is come and add route then run another auxiliary module.
    – Its 2013
    Commented Jan 12, 2018 at 21:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .