Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

调用cannon API 尝试集成pocsuite的时候遇到错误 #120

Closed
bit4woo opened this issue Oct 17, 2016 · 5 comments
Closed

调用cannon API 尝试集成pocsuite的时候遇到错误 #120

bit4woo opened this issue Oct 17, 2016 · 5 comments
Assignees

Comments

@bit4woo
Copy link

bit4woo commented Oct 17, 2016

我使用了以下代码调用 cannon API :

#!/usr/bin/python
# coding:utf-8

from pocsuite.api.cannon import Cannon
info = {"pocname": "modules\dlink_command_php_exec_noauth.py", #应该是py文件名
        "pocstring": "dlink_command_php_exec_noauth.py",
        "mode": "verify"
        }
target = "www.baidu.com"
invoker = Cannon(target, info) # 生成用来引用 Pocsuite 的实例
result = invoker.run() # 调用 Pocsuite, result 保存了 Pocsuite 执行的返回结果
print result

遇到的错误如下:

Traceback (most recent call last):
dlink_command_php_exec_noauth.py
  File "D:/BitTorrentSync/Python_Code/scoutproject/scout/callpocsuite.py", line 9, in <module>
    invoker = Cannon(target, info) # 生成用来引用 Pocsuite 的实例
<code object <module> at 025185C0, file "dlink_command_php_exec_noauth.py", line 1>
  File "C:\Python27\lib\site-packages\pocsuite-2.0.4.1-py2.7.egg\pocsuite\api\cannon.py", line 45, in __init__
    self.registerPoc()
  File "C:\Python27\lib\site-packages\pocsuite-2.0.4.1-py2.7.egg\pocsuite\api\cannon.py", line 62, in registerPoc
    importer.load_module(self.moduleName)
  File "C:\Python27\lib\site-packages\pocsuite-2.0.4.1-py2.7.egg\pocsuite\lib\core\common.py", line 60, in load_module
    exec code in mod.__dict__   #exec语句将字符串str当成有效Python代码来执行 ,in后边的内容是指定该语句的全局和局部命名空间。
  File "dlink_command_php_exec_noauth.py", line 1, in <module>
NameError: name 'dlink_command_php_exec_noauth' is not defined
@nixawk
Copy link
Contributor

nixawk commented Oct 17, 2016

Thanks @bit4woo, A single comprehensive wiki page is needed. Please try the following demo:

#!/usr/bin/python
# coding:utf-8

from pocsuite.api.cannon import Cannon
info = {"pocname": "dlink_command_php_exec_noauth",
        "pocstring": open("./modules/dlink_command_php_exec_noauth.py").read(),
        "mode": "verify"}

target = "www.justfordemo.com"
invoker = Cannon(target, info)
result = invoker.run()
print result

@nixawk
Copy link
Contributor

nixawk commented Oct 17, 2016

@nixawk
Copy link
Contributor

nixawk commented Oct 18, 2016

@bit4woo Is it OK for you ?

@nixawk
Copy link
Contributor

nixawk commented Oct 19, 2016

Thanks @bit4woo. The issue is closed.

@nixawk nixawk closed this as completed Oct 19, 2016
@bit4woo
Copy link
Author

bit4woo commented Oct 19, 2016

It works! Thanks! @nixawk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants