diff options
author | Malfurious <m@lfurio.us> | 2025-01-01 06:51:10 -0500 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2025-01-01 06:51:10 -0500 |
commit | f01ec45e773291c3659a1dcaf8cd9a51ece19823 (patch) | |
tree | 0db3ef432a6f3b06c07060bdb0dd61c7fd164ad2 /sploit/main.py | |
parent | 3f5532857807d628a5dadaf5c30a384f873878ea (diff) | |
parent | 221742f7c5c89dc50ec4374bed5d2ccc0d7534bf (diff) | |
download | nsploit-f01ec45e773291c3659a1dcaf8cd9a51ece19823.tar.gz nsploit-f01ec45e773291c3659a1dcaf8cd9a51ece19823.zip |
Merge branch 'pkg-reorg'
This branch is a rework of nsploit's intended package imports. User
scripts need only import a given nsploit subpackage to obtain that
package's full collection of classes, functions, etc. This is the new
intended style for exploit scripts.
Along the way, some modules are reorganized into different packages, the
"builder" package is renamed to "payload", and some unnecessary files
are consolidated.
* pkg-reorg:
main: Automatically provide top-level sploit modules to user scripts
sploit: Expose modules' contents through package
Remove extra "main.py" file
comm: Promote from module to package
log: Move to sploit.util package
util: Promote from module to package
builder: Rename package to payload and expose contents
rev: Expose modules' contents through package
Remove outer __init__.py file
Diffstat (limited to 'sploit/main.py')
-rw-r--r-- | sploit/main.py | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/sploit/main.py b/sploit/main.py deleted file mode 100644 index 6d71196..0000000 --- a/sploit/main.py +++ /dev/null @@ -1,65 +0,0 @@ -from argparse import ArgumentParser, REMAINDER -import gc -from os.path import isdir -import tempfile -import traceback - -from sploit.comm import * -from sploit.log import * -from sploit import __version__ - -def print_banner(color, line1=__version__, line2='', line3=''): - ilog() - ilog(' ░▒█▀▀▀█░▒█▀▀█░▒█░░░░▒█▀▀▀█░▀█▀░▀▀█▀▀ ', end='', color=ALT) - ilog(line1, color=ALT) - ilog(' ░░▀▀▀▄▄░▒█▄▄█░▒█░░░░▒█░░▒█░▒█░░░▒█░░ ', end='', color=color) - ilog(line2, color=ALT) - ilog(' ░▒█▄▄▄█░▒█░░░░▒█▄▄█░▒█▄▄▄█░▄█▄░░▒█░░ ', end='', color=ALT) - ilog(line3, color=ALT) - ilog() - -def main(): - parser = ArgumentParser(description='Execute Sploit script against target') - parser.add_argument('script', help='Exploit script to run') - parser.add_argument('target', nargs=REMAINDER, help='Target cmdline or pipes directory') - args = parser.parse_args() - - if len(args.target) == 0: - with tempfile.TemporaryDirectory() as tmpdir: - pipe(args.script, tmpdir) - elif len(args.target) == 1 and isdir(args.target[0]): - pipe(args.script, args.target[0]) - else: - target(args.script, args.target) - -def pipe(script, tmpdir): - print_banner(ERROR, line3='Pipe Mode') - while True: - try: - p = Pipes(tmpdir) - except KeyboardInterrupt: - break - runscript(script, Comm(p)) - del p - -def target(script, target): - print_banner(STATUS, line3='Subprocess Mode') - runscript(script, Comm(Process(target))) - -def runscript(script, comm): - try: - ilog("Running Script...") - code = compile(open(script).read(), script, 'exec') - exec(code, {'io': comm, 'print': elog}) - ilog("Script Finished!") - return - except KeyboardInterrupt: - pass - except: - ilog(traceback.format_exc(), end='', color=ERROR) - finally: - comm.shutdown() - comm.readall() - gc.collect() - - ilog("Script Ended Early!", color=WARNING) |