import socket
import sys
import time

def main():
    if len(sys.argv) != 4:
        print("Usage: %s <proxy_list> <destination_ip> <destination_port>" % sys.argv[0])
        sys.exit(1)

    proxy_list = sys.argv[1]
    destination_ip = sys.argv[2]
    destination_port = int(sys.argv[3])

    with open(proxy_list, 'r') as f:
        for proxy in f:
            proxy = proxy.strip()
            if len(proxy) == 0:
                continue

            print("[*] Connecting to %s:%d" % (proxy, destination_port))
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            sock.settimeout(5)
            try:
                sock.connect((proxy, destination_port))
                sock.sendall(b'GET / HTTP/1.1\r\n\r\n')
                data = sock.recv(1024)
                print("[*] Received %d bytes" % len(data))
                sock.close()
            except:
                print("[*] Error connecting to %s:%d" % (proxy, destination_port))
                sock.close()
            time.sleep(1)

if __name__ == "__main__":
    main()