HackDig : Dig high-quality web security articles for hackers

Running System Commands Against Multiple SSH Servers With Metasploit

2015-04-07 00:20

Want:
To run a command against multiple SSH servers and you want to use metasploit to do it


How:
There doesn't exist a multi_ssh_exec type aux module to run commands. Luckily ? the ssh_login module creates a command shell session for you, on successful logins. You can use the builtin sessions functionality to run a command against all your (SSH) sessions.

msf auxiliary(ssh_login) > sessions -h
Usage: sessions [options]

Active session manipulation and interaction.

OPTIONS:

    -K        Terminate all sessions
    -c  Run a command on the session given with -i, or all
    -d  Detach an interactive session
    -h        Help banner
    -i  Interact with the supplied session ID
    -k  Terminate sessions by session ID and/or range
    -l        List all active sessions
    -q        Quiet mode
    -r        Reset the ring buffer for the session given with -i, or all
    -s  Run a script on the session given with -i, or all
    -t  Set a response timeout (default: 15)
    -u  Upgrade a shell to a meterpreter session on many platforms
    -v        List verbose fields


Many options allow specifying session ranges using commas and dashes.
For example:  sessions -s checkvm -i 1,3-5  or  sessions -k 1-2,5,6

So given some sessions, you can pass a

sessions -c 'command' all 

against all the sessions or a

sessions -c 'command' -i 2,4,5 

against specified sessions.

Example:






Source: lmth.tsniaga-sdnammoc-metsys-gninnur/40/5102/moc.hcraeserkcatta.eganw0lanrac

Read:3958 | Comments:0 | Tags:automation Metasploit Pentesting

“Running System Commands Against Multiple SSH Servers With Metasploit”0 Comments

Submit A Comment

Name:

Email:

Blog :

Verification Code:

Tools

Tag Cloud