1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| from pwn import * import threading context(arch='amd64', log_level='debug', os='linux')
def thread_function(portstart, keyword, cishu, timeout,pinglv): rec = '' for j in range(cishu): try: p = remote("ctf.qwq.cc", portstart + j * pinglv, timeout=timeout) sleep(0.1) t = p.recvline(timeout=timeout) rec=t except: continue pass print(rec) if rec != b'': with open("ports_of_cc2" + ".txt", 'a+') as f: f.write("ports:"+str(portstart + j * pinglv)+ str(rec)+'\n') f.close()
pinglv = 5000 # 这里是pl,可以自定义 keyword = b'.' start_port = 10000 end_port = 20000
cishu = (end_port - start_port) // pinglv
threads = [] # 循环创建并启动线程 for i in range(0, pinglv): thread = threading.Thread(target=thread_function, args=(start_port+i, keyword, cishu,5,pinglv)) threads.append(thread) thread.start()
# 等待所有线程结束 for thread in threads: thread.join()
|