简体   繁体   中英

Python - error with a simple socket script

So I wrote a script in Python with the module socket but finally he doesn't work. After searching a few hours for an error (I'm new in Python so it's long for me), I didn't find any so instead I wrote another simple script which works with netcat to have a reverse shell between my host machin (Linux) and my VM (Windows).

My command netcat with Linux :

nc -nvlp 4444

My script in Windows :

import socket
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
connection.connect(("192.168.1.81", 4444))

And after start the listener (netcat), he's listening and after a few seconds, in my Windows machin, the scripts closed itself because he doesn't find anything connection.

I don't know where is the problem, my VM is on the same subnet than my host, I've flushed my iptables in Linux just in case, I'm lost :)

Thanks for your answers !

我只是将脚本发送给朋友进行尝试并且它正在运行,所以我认为问题出在我的设置或其他地方。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM