Python3-菜刀脚本优化

时间:2022-07-23
本文章向大家介绍Python3-菜刀脚本优化,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

抽空优化了一下脚本,优化的点有以下两点:

  • 将原来 input的操作改为了选项,看起来更专业了
  • 把原来大杂烩一样的数据显示优化了一下,起码是人看的

首先是第一点吧,原本Input的改为了选项

原本的代码是这样的:

url=str(input("木马url: "))
parameter=str(input("木马参数: "))

运行之后的效果是

捞的不行,所以就改了一下

from optparse import OptionParser
use="Usage: Python <filename> -u <url> -p <passwd>"
optParser = OptionParser(usage=use)
optParser.add_option('-u','--url',action='store',type = "string" ,default=False,dest = 'url',help='Enter the url here')
optParser.add_option('-p','--passwd',action='store',type = "string" ,default=False,dest = 'passwd',help='Enter the file password here')
options,args = optParser.parse_args()
if options.url!=False and options.passwd!=False:
    url=options.url
    parameter=options.passwd

运行后感觉就很棒了

其次就是,数据显示的问题,原本的回显是长这样的

辣眼睛,简直不是给人看的,所以就改了一下

优好了很多,再试一下cat文件

无敌

那么抱着无聊找事干的心态,链接还是不贴出来,有需要的后台回复 python菜刀就有了

这垃圾微信公众平台又不允许原创申明了,字数哪里少了