feat(cli): poc exec for repeatable command execution; document one-shot primitive and connection semantics
This commit is contained in:
@@ -65,3 +65,32 @@ class UrlTargetTest(unittest.TestCase):
|
||||
def test_explicit_flags_win_over_url(self):
|
||||
ns = cli.resolve_target(parse(["exploit", "--url", "http://a:1/x.php", "--port", "7000"]))
|
||||
self.assertEqual(ns.port, 7000)
|
||||
|
||||
|
||||
class ExecWrapperTest(unittest.TestCase):
|
||||
def test_wrapper_redirects_output_to_mount(self):
|
||||
wrapped = cli.exec_wrapper("id")
|
||||
self.assertIn("id", wrapped)
|
||||
self.assertIn("/out/.poc-exec", wrapped)
|
||||
self.assertTrue(wrapped.endswith("2>&1"))
|
||||
self.assertIn(chr(10), wrapped)
|
||||
|
||||
def test_wrapper_survives_multiple_commands(self):
|
||||
wrapped = cli.exec_wrapper("id; uname -a")
|
||||
self.assertIn("id; uname -a", wrapped)
|
||||
|
||||
def test_fits_boundary(self):
|
||||
self.assertTrue(cli.exec_fits("A" * 150))
|
||||
self.assertFalse(cli.exec_fits("A" * 300))
|
||||
|
||||
def test_limit_matches_forge_carrier(self):
|
||||
from poc import forge
|
||||
self.assertEqual(cli.CARRIER_LIMIT, 200)
|
||||
with self.assertRaises(ValueError):
|
||||
forge.build_ht(0, 0, b"A" * (cli.CARRIER_LIMIT + 1))
|
||||
|
||||
def test_exec_command_parses_and_resolves(self):
|
||||
ns = cli.resolve_target(parse(["exec", "--cmd", "id", "--url", "http://h:9/x.php"]))
|
||||
self.assertIs(ns.func, cli.cmd_exec)
|
||||
self.assertEqual(ns.cmd, "id")
|
||||
self.assertEqual((ns.host, ns.port, ns.path), ("h", 9, "/x.php"))
|
||||
|
||||
Reference in New Issue
Block a user