Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. def testProxy(host, port):
  2.     try:
  3.         s = socket.socket()
  4.         s.connect((host, int(port)))
  5.     except:
  6.         s.close()
  7.         return False
  8.    
  9.     s.send(b"CONNECT %s:%s HTTP/1.0\r\n\r\n" % (host.encode('utf-8'), port.encode('utf-8')))
  10.    
  11.     try:
  12.         buff = s.recv(128)
  13.     except:
  14.         s.close()
  15.         return False
  16.    
  17.     if b"200 OK" in buff or b"200 Connection established" in buff:
  18.         sendData(s, "NICK %s\r\n" % randNick())
  19.         sendData(s, "USER x localhost %s :test\r\n" % targetHost)
  20.        
  21.         while 1:
  22.             try:
  23.                 buff = s.recv(128)
  24.             except Exception as err:
  25.                 print(err)
  26.            
  27.             if not buff:
  28.                 s.close()
  29.                 break
  30.            
  31.             for line in buff.split(b'\r\n'):
  32.                 words = line.split()
  33.                    
  34.                 if len(words) < 2:
  35.                     continue
  36.                
  37.                 if words[0] == "PING":
  38.                     sendData(s, "PONG %s\r\n" % words[1])
  39.                    
  40.             buff = ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement