How to use pocsuite3 - 10 common examples

To help you get started, we’ve selected a few pocsuite3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github knownsec / pocsuite3 / tests / test_httpserver.py View on Github external
def test_ipv4_https(self):
        try:
            logger.info('Test https server in ipv4')
            PHTTPServer._instance = None
            httpd = PHTTPServer(bind_ip='0.0.0.0', bind_port=666, use_https=True,
                                requestHandler=BaseRequestHandler)
            httpd.start()
            url = '{}://{}:{}/'.format('https', get_host_ip(), 666)
            requests.get(url)
        except requests.exceptions.SSLError:
            url = '{}://{}:{}/'.format('https', get_host_ip(), 666)
            resp = requests.get(url, verify=False)
            self.assertEqual(resp.status_code, 200)
        except Exception:
            assert False
        finally:
            httpd.stop()
github knownsec / pocsuite3 / tests / login_demo.py View on Github external
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
            result['VerifyInfo']['Postdata'] = payload

        return self.parse_output(result)
github knownsec / pocsuite3 / tests / login_demo.py View on Github external
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2019/2/26 2:33 PM
# @Author  : chenghsm
# @File    : login_demo.py
# @Descript: 自定义命令参数登录例子

from collections import OrderedDict

from pocsuite3.api import Output, POCBase, POC_CATEGORY, register_poc, requests
from pocsuite3.api import OptString


class DemoPOC(POCBase):
    vulID = '00000'  # ssvid
    version = '1.0'
    author = ['chenghs']
    vulDate = '2019-2-26'
    createDate = '2019-2-26'
    updateDate = '2019-2-25'
    references = ['']
    name = '自定义命令参数登录例子'
    appPowerLink = 'http://www.knownsec.com/'
    appName = 'test'
    appVersion = 'test'
    vulType = 'demo'
    desc = '''这个例子说明了你可以使用console模式设置一些参数或者使用命令中的'--'来设置自定义的参数'''
    samples = []
    category = POC_CATEGORY.EXPLOITS.WEBAPP
github knownsec / pocsuite3 / pocsuite3 / lib / core / register.py View on Github external
requires = get_poc_requires(data)
        requires = [i.strip().strip('"').strip("'") for i in requires.split(',')] if requires else ['']
        if requires[0]:
            poc_name = get_poc_name(data)
            info_msg = 'PoC script "{0}" requires "{1}" to be installed'.format(poc_name, ','.join(requires))
            logger.info(info_msg)
            try:
                for r in requires:
                    if ":" in r:
                        r, module = r.split(":")
                        __import__(module)
                    else:
                        __import__(r)
            except ImportError:
                err_msg = 'try install with "python -m pip install {0}"'.format(r)
                logger.error(err_msg)
                raise SystemExit
github knownsec / pocsuite3 / pocsuite3 / lib / core / option.py View on Github external
message += "{0}    {1}\n".format(i, desensitization(ip) if conf.ppt else ip)
        data_to_stdout(message)
        while True:
            choose = None
            choose = input('Choose>: ').strip()
            if not choose:
                continue
            try:
                if choose.isdigit():
                    choose = int(choose)
                    conf.connect_back_host = kb.data.local_ips[choose]
                    data_to_stdout("you choose {0}\n".format(
                        desensitization(conf.connect_back_host) if conf.ppt else conf.connect_back_host))
                    break
            except Exception:
                data_to_stdout("wrong number, choose again\n")
github knownsec / pocsuite3 / pocsuite3 / lib / core / option.py View on Github external
def _set_network_proxy():
    if conf.proxy:
        debug_msg = "setting the HTTP/SOCKS proxy for all network requests"
        logger.debug(debug_msg)

        try:
            _ = urlsplit(conf.proxy)
        except Exception as ex:
            err_msg = "invalid proxy address '{0}' ('{1}')".format(conf.proxy, str(ex))
            raise PocsuiteSyntaxException(err_msg)

        hostname_port = _.netloc.split(":")
        scheme = _.scheme.upper()
        hostname = hostname_port[0]
        port = None
        username = None
        password = None

        if len(hostname_port) == 2:
            try:
github knownsec / pocsuite3 / pocsuite3 / lib / core / register.py View on Github external
def check_requires(data):
        requires = get_poc_requires(data)
        requires = [i.strip().strip('"').strip("'") for i in requires.split(',')] if requires else ['']
        if requires[0]:
            poc_name = get_poc_name(data)
            info_msg = 'PoC script "{0}" requires "{1}" to be installed'.format(poc_name, ','.join(requires))
            logger.info(info_msg)
            try:
                for r in requires:
                    if ":" in r:
                        r, module = r.split(":")
                        __import__(module)
                    else:
                        __import__(r)
            except ImportError:
                err_msg = 'try install with "python -m pip install {0}"'.format(r)
                logger.error(err_msg)
                raise SystemExit
github knownsec / pocsuite3 / pocsuite3 / pocs / ftp_burst.py View on Github external
def ftp_burst(host, port):
    if not port_check(host, port):
        return

    if anonymous_login(host, port):
        logger.info('try burst {}:{} use username:{} password:{}'.format(
            host, port, 'anonymous', ''))
        result_queue.put(('anonymous', ''))
        return

    try:
        task_init(host, port)
        run_threads(4, task_thread)
    except Exception:
        pass
github shadowsock5 / Poc / Nexus / Nexus_poc.py View on Github external
def get_vul_url(self, p_url, p_headers):
        r = req.get(p_url, verify=False, headers=p_headers, allow_redirects=False)
        capa_id = ""
    
        if r.status_code == 200:
            if r.json():
                for j in r.json():
                    if j['capability']['typeId'] == "yum":
                        print("[*] Vulnerable id is: {0}".format(j['capability']['id']))
                        capa_id = j['capability']['id']

        elif r.status_code == 401:
            print("[!] User credentials wrong! Quit!")
            sys.exit()

        p_vul_url = p_url + "/" + capa_id
        return p_vul_url
github knownsec / pocsuite3 / pocsuite3 / lib / core / option.py View on Github external
def _set_plugins():
    # TODO
    # load plugin scripts .pyc file support
    if conf.plugins:
        founds = []
        cache_plugins = copy.deepcopy(conf.plugins)

        for found in glob.glob(os.path.join(paths.POCSUITE_PLUGINS_PATH, "*.py*")):
            dirname, filename = os.path.split(found)
            plugin_name = os.path.splitext(filename)[0]
            if found.endswith(('__init__.py', '__init__.pyc')):
                continue
            if plugin_name not in conf.plugins:
                continue
            cache_plugins.remove(plugin_name)
            founds.append(found)
        if len(cache_plugins) > 0:
            for file in cache_plugins:
                if os.path.exists(file):
                    founds.append(file)

        for file in founds:
            debug_msg = "loading plugin script '{0}'".format(file)
            logger.debug(debug_msg)