这几天再看python黑帽,顺手把上面的代码实现一遍。分享下心得了~大致的代码和书上的一样,不过书上的代码有点问题。我折腾了很久,在client_handler的if len(upload_destination)函数中如果使用书上的代码,会发现它停留在while循环里面出不来了,所以我稍微改了下。但是遗憾的是,这个自制的netcat不能传文件,而且那个传输command的命令我也觉得很鸡肋,都能在服务器运行这个py文件了,干嘛还用在客户端输入command传过去。不过这个训练对我来说,倒是锻炼了我对TCP,Netcat等的认识,受益匪浅!import sys import socket import getopt import threading import subprocess listen = False command = False upload = False execute = '' target = '' upload_destination = '' port = 0 #提示信息 def usage(): print('BHP Net Tool') print('Usage: bhpnet.py -t target_host -p port') print('-l --listen - listen on [host]:[port] for incoming connections') print('-e --execute=file_to_run - execute the given file upon receiving a connection') print('-c --command - initialize a command shell')
python连接netcat监听的端口_[分享]用python实现简单的netcat
最新推荐文章于 2023-06-22 00:50:27 发布