-
Notifications
You must be signed in to change notification settings - Fork 750
03 编写脚本
cdxy edited this page Sep 8, 2016
·
2 revisions
编写自定义脚本,只需要声明一个函数作为接口,没有其他任何限制.
从此告别文档,无需记忆函数名和模板调用,使效率最大化.
- 进入
./script
目录 - 在此目录下新建Python文件
poctest.py
- 在代码中添加函数 poc()
- 添加逻辑使验证成功(漏洞存在)时
return True
,验证失败时return False
- (程序运行时,每个子线程调用该文件的
poc()
方法,并将队列中的取出的字符串传入该方法)
def poc(input_str):
return True or false
-
python POC-T.py --show
查看./script
文件夹下全部脚本名称 - 在命令行中使用
-s poctest
可加载script
文件夹下的poctest.py
脚本,或者-s /home/xy/xxx/poctest.py
加载任意路径的脚本
针对一些复杂的需求,poc()
函数可以使用多种返回值来控制验证状态和输出。
以下模拟一个简单的密码爆破脚本代码
def poc(input_str):
url = 'http://xxx.com/login.php?pass=' + input_str
try:
c = requests.get(url).content
except ConnectionError:
return 2 # 把input_str再次加入任务队列重新验证(本次验证作废)
if 'success' in c:
return True # 验证成功,屏幕结果输出为123456
return 1 # 同上
return url # 验证成功,屏幕结果输出为"http://xxx.com/login.php?pass=123456"
else
return False # 验证失败,无输出
return 0 # 同上
建议在脚本中处理Exception,如果线程运行中发现Exception,将使框架终止全部任务并打印错误信息。
由于网络请求中经常出现连接中断等错误,一种简单的做法是:
def poc(input_str)
try:
...全部脚本逻辑...
except:
return False