コード例 #1
0
ファイル: __init__.py プロジェクト: songofhack/pocsuite3
    def start(self, daemon=True):
        # Http server can only allow start once in pocsuite3, avoid muti-threading start muti-times
        if self.server_locked:
            logger.info('Httpd serve has been started on {}://{}:{}, '.format(
                self.scheme, self.bind_ip, self.bind_port))
            return

        if check_port(self.host_ip, self.bind_port):
            logger.error(
                'Port {} has been occupied, start Httpd serve failed!'.format(
                    self.bind_port))
            return

        self.server_locked = True
        self.setDaemon(daemon)
        threading.Thread.start(self)
        # Detect http server is started or not
        logger.info('Detect {} server is runing or not...'.format(self.scheme))
        detect_count = 10
        while detect_count:
            try:
                if check_port(self.host_ip, self.bind_port):
                    break
            except Exception as ex:
                logger.error(str(ex))
            time.sleep(random.random())
            detect_count -= 1
コード例 #2
0
def bind_tcp_shell(host, port, check=True):
    if not check_port(host, port):
        return False
    try:
        s = socket.socket()
        s.connect((host, port))
        if check:
            flag = random_str(6).encode()
            if flag not in read_results(s, b'echo %s' % flag):
                return False
        start_listener(s)
    except Exception as e:
        logger.error(str(e))
コード例 #3
0
def bind_telnet_shell(host, port, user, pwd, check=True):
    if not check_port(host, port):
        return False
    try:
        tn = telnetlib.Telnet(host, port)
        tn.expect([b'Login: '******'login: '******'\n')
        tn.expect([b'Password: '******'password: '******'\n')
        tn.write(b'\n')
        if check:
            flag = random_str(6).encode()
            if flag not in read_results(tn, b'echo %s' % flag):
                return False
        start_listener(tn)
    except Exception as e:
        logger.error(str(e))