Guest User

Untitled

a guest
Aug 10th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. import time
  2. from datetime import datetime
  3. import paramiko
  4.  
  5. a1 = 'version3'
  6. a2 = 'version5'
  7.  
  8. client = paramiko.SSHClient()
  9. client.set_missing_host_key_policy(paramiko.AutoAddPolicy)
  10. file = open('/etc/openvpn/client.addr', 'r')
  11. for line in file:
  12. timestamps = str(datetime.now())
  13. #print('Timestamp:', timestamps)
  14. info = {}
  15. info['ip'] = line.split(',')[1]
  16. info['mac'] = line.split(',')[0]
  17.  
  18. def connector():
  19.  
  20. ip_log = 'Connecting to IP: ' + info['ip']
  21. print(ip_log)
  22.  
  23. client.connect(info['ip'], username='', port=22, password='', timeout=12)
  24. stdin1, stdout, stderr = client.exec_command('cat /proc/cpuinfo')
  25. data = stdout.read() + stderr.read()
  26.  
  27. try:
  28. connector()
  29. if a1 in str(data):
  30. filename = open('log.txt', 'w')
  31. filename.write(info['mac'] + ' - version 3')
  32. if a2 in str(data):
  33. filename = open('log.txt', 'w')
  34. filename.write(info['mac'] + ' - version 5')
  35.  
  36. except Exception as e:
  37. error_log = str(e)
  38. print('error_log')
  39.  
  40. file.close()
Add Comment
Please, Sign In to add comment