Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
boy-hack authored Sep 18, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 7759adb + 7cc561e commit 76bbf8c
Showing 5 changed files with 54 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pocsuite3/lib/core/enums.py
Original file line number Diff line number Diff line change
@@ -133,7 +133,7 @@ class POC_CATEGORY:
PROTOCOL.HTTP = "Http"
PROTOCOL.FTP = "Ftp"
PROTOCOL.SSH = "Ssh"
PROTOCOL.TALENT = "Telent"
PROTOCOL.TELENT = "Telent"
PROTOCOL.REDIS = "Redis"


4 changes: 4 additions & 0 deletions pocsuite3/lib/core/exception.py
Original file line number Diff line number Diff line change
@@ -60,3 +60,7 @@ class PocsuitePluginBaseException(PocsuiteBaseException):

class PocsuitePluginDorkException(PocsuitePluginBaseException):
pass


class PocsuiteHeaderTypeException(PocsuiteBaseException):
pass
15 changes: 9 additions & 6 deletions pocsuite3/lib/core/option.py
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
from pocsuite3.lib.core.data import paths
from pocsuite3.lib.core.datatype import AttribDict
from pocsuite3.lib.core.enums import HTTP_HEADER, CUSTOM_LOGGING, PROXY_TYPE
from pocsuite3.lib.core.exception import PocsuiteSyntaxException, PocsuiteSystemException
from pocsuite3.lib.core.exception import PocsuiteSyntaxException, PocsuiteSystemException, PocsuiteHeaderTypeException
from pocsuite3.lib.core.log import FORMATTER
from pocsuite3.lib.core.register import load_file_to_module
from pocsuite3.lib.core.settings import DEFAULT_USER_AGENT, DEFAULT_LISTENER_PORT, CMD_PARSE_WHITELIST
@@ -316,7 +316,8 @@ def _set_pocs_modules():
# load poc scripts .pyc file support
if conf.poc:
# step1. load system packed poc from pocsuite3/pocs folder
exists_poc_with_ext = list(filter(lambda x: x not in ['__init__.py', '__init__.pyc'], os.listdir(paths.POCSUITE_POCS_PATH)))
exists_poc_with_ext = list(
filter(lambda x: x not in ['__init__.py', '__init__.pyc'], os.listdir(paths.POCSUITE_POCS_PATH)))
exists_pocs = dict([os.path.splitext(x) for x in exists_poc_with_ext])
for poc in conf.poc:
load_poc_sucess = False
@@ -325,7 +326,7 @@ def _set_pocs_modules():
if poc_ext in ['.py', '.pyc']:
file_path = os.path.join(paths.POCSUITE_POCS_PATH, poc)
else:
file_path = os.path.join(paths.POCSUITE_POCS_PATH, poc+exists_pocs.get(poc))
file_path = os.path.join(paths.POCSUITE_POCS_PATH, poc + exists_pocs.get(poc))
if file_path:
info_msg = "loading PoC script '{0}'".format(file_path)
logger.info(info_msg)
@@ -401,9 +402,11 @@ def _cleanup_options():
conf.agent = re.sub(r"[\r\n]", "", conf.agent)

if conf.cookie:
conf.cookie = re.sub(r"[\r\n]", "", conf.cookie)
conf.cookie = extract_cookies(conf.cookie)

if isinstance(conf.cookie, str):
conf.cookie = re.sub(r"[\r\n]", "", conf.cookie)
conf.cookie = extract_cookies(conf.cookie)
elif not isinstance(conf.cookie, dict):
raise PocsuiteHeaderTypeException('Does not support type for cookie')
if conf.delay:
conf.delay = float(conf.delay)

1 change: 1 addition & 0 deletions tests/login_demo.py
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@ def _verify(self):
result = {}
payload = "username={0}&password={1}".format(self.get_option("username"), self.get_option("password"))
r = requests.post(self.url, data=payload)
print(r.text)
if r.status_code == 200:
result['VerifyInfo'] = {}
result['VerifyInfo']['URL'] = self.url
45 changes: 39 additions & 6 deletions tests/test_api_diy_options.py
Original file line number Diff line number Diff line change
@@ -8,23 +8,56 @@

class TestCase(unittest.TestCase):
def setUp(self):
self.config = {
pass

def tearDown(self):
pass

def verify_result(self):
config = {
'url': ['https://www.baidu.com/'],
'poc': [os.path.join(paths.POCSUITE_ROOT_PATH, "../tests/login_demo.py")],
'username': "asd",
'password': 'asdss',
'verbose': 0,
"timeout": 10,
}
init_pocsuite(self.config)
init_pocsuite(config)
start_pocsuite()
result = get_results().pop()
self.assertTrue(result.status == 'success')

def tearDown(self):
pass
def test_cookie(self):
config = {
'url': ['http://httpbin.org/post'],
'poc': [os.path.join(paths.POCSUITE_ROOT_PATH, "../tests/login_demo.py")],
'username': "asd",
'password': 'asdss',
'cookie': 'test=1',
'verbose': 0,
"timeout": 10,
}
init_pocsuite(config)
start_pocsuite()
result = get_results().pop()
self.assertTrue(result.status == 'success')

def verify_result(self):
def test_cookie_dict_params(self):
config = {
'url': ['http://httpbin.org/post'],
'poc': [os.path.join(paths.POCSUITE_ROOT_PATH, "../tests/login_demo.py")],
'username': "asd",
'password': 'asdss',
'cookie': {
"test": '123'
},
'verbose': 0,
"timeout": 10,
}
init_pocsuite(config)
start_pocsuite()
result = get_results().pop()
self.assertTrue(result.status == 'success')

def test_import_run(self):
start_pocsuite()
self.verify_result()

0 comments on commit 76bbf8c

Please sign in to comment.