Skip to content

Commit

Permalink
refactor: poc-console optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
13ph03nix committed Sep 8, 2022
1 parent 93a768f commit ffaee7c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
5 changes: 2 additions & 3 deletions pocsuite3/lib/core/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,7 @@ def _attack_mode(self, mod):
else:
rhost = self.current_module.getg_option("rhost")
rport = self.current_module.getg_option("rport")
ssl = self.current_module.getg_option("ssl")
target = f"https://{rhost}:{rport}" if ssl else f"{rhost}:{rport}"
target = f"{rhost}:{rport}"
conf.mode = mod
kb.task_queue.put((target, self.current_module))
try:
Expand Down Expand Up @@ -526,7 +525,7 @@ def _show_options(self, *args, **kwargs):
if opt.require and value == "":
value = colored("*require*", "red")
tb3.add_row([name, value, opt.type, opt.description])
data_to_stdout("\nExploit payloads(using reverse tcp):\n")
data_to_stdout("\nPayload options (reverse_tcp):\n")
data_to_stdout(tb3.get_string())
data_to_stdout("\n")

Expand Down
2 changes: 1 addition & 1 deletion pocsuite3/lib/core/interpreter_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class OptPort(Option):
def __init__(self, default, description="", require=False):
super().__init__(default, description, require)
if description == "":
self.description = "Target HTTP port"
self.description = "The target port"
self.type = "Port"

def __set__(self, instance, value):
Expand Down
14 changes: 6 additions & 8 deletions pocsuite3/lib/core/poc.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,14 @@ def __init__(self):
"", "Use a proxy to connect to the target URL (protocol://host:port)")
self.global_options["timeout"] = OptInteger(10, "Seconds to wait before timeout connection (default 10)")
else:
self.global_options["rhost"] = OptString('', require=True)
self.global_options["rport"] = OptPort('', require=True)
self.global_options["ssl"] = OptBool(default=False)
self.global_options["rhost"] = OptString('', 'The target host', require=True)
self.global_options["rport"] = OptPort('', 'The target port', require=True)

# payload options for exploit
self.payload_options = OrderedDict()
if hasattr(self, "_shell"):
self.payload_options["lhost"] = OptString('', "Connect back ip", require=True)
self.payload_options["lport"] = OptPort(10086, "Connect back port")
self.payload_options["lhost"] = OptString(self.host_ip, "The listen address")
self.payload_options["lport"] = OptPort(6666, "The listen port")

self.options = OrderedDict()
# module options init
Expand Down Expand Up @@ -216,10 +215,9 @@ def build_url(self):
target = pr.geturl()
except ValueError:
pass
if self.target and self.current_protocol != POC_CATEGORY.PROTOCOL.HTTP and not conf.console_mode:
self.setg_option("rport", self.rport)
if self.target and self.current_protocol != POC_CATEGORY.PROTOCOL.HTTP and conf.console_mode:
self.setg_option("rhost", self.rhost)
self.setg_option("ssl", self.scheme == 'https')
self.setg_option("rport", self.rport)
return target.rstrip('/')

def _execute(self):
Expand Down
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
if __name__ == '__main__':
loader = TestLoader()
tests_dir = os.path.join(os.path.dirname(__file__), 'tests')
tests = loader.discover(tests_dir, pattern='test_parse_target.py')
tests = loader.discover(tests_dir, pattern='test_*.py')
runner = TextTestRunner()
result = runner.run(tests)
if result.failures or result.errors:
Expand Down

0 comments on commit ffaee7c

Please sign in to comment.