diff options
author | Malfurious <m@lfurio.us> | 2025-01-04 23:57:16 -0500 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2025-01-04 23:57:16 -0500 |
commit | 23c750d2edc712c4a37e0774049a1a0f9a966009 (patch) | |
tree | e16b9f6495776dccc2c8e39d29b66d28d94b3448 | |
parent | 640726aa11369d328c1cdfe00b4344b6a925729c (diff) | |
parent | 831fd7402cd357a79b76007471722a243ec60c8d (diff) | |
download | nsploit-23c750d2edc712c4a37e0774049a1a0f9a966009.tar.gz nsploit-23c750d2edc712c4a37e0774049a1a0f9a966009.zip |
Merge branch 'nsploit'
Rename fork to nsploit and touch up project files. We switch from
automatically obtaining version via git-describe to a static definition
in pyproject.toml, to support more install use-cases.
* nsploit:
Update pyproject file for nsploit
Don't rely on git for version information
main: Update ASCII banner for nsploit
Rename sploit package to nsploit
-rw-r--r-- | hooks/bake_version.py | 26 | ||||
-rwxr-xr-x | nsploit.py | 3 | ||||
-rw-r--r-- | nsploit/__init__.py | 19 | ||||
-rw-r--r-- | nsploit/__main__.py (renamed from sploit/__main__.py) | 14 | ||||
-rw-r--r-- | nsploit/arch.py (renamed from sploit/arch.py) | 0 | ||||
-rw-r--r-- | nsploit/comm/__init__.py (renamed from sploit/comm/__init__.py) | 0 | ||||
-rw-r--r-- | nsploit/comm/comm.py (renamed from sploit/comm/comm.py) | 4 | ||||
-rw-r--r-- | nsploit/payload/__init__.py (renamed from sploit/payload/__init__.py) | 0 | ||||
-rw-r--r-- | nsploit/payload/fmtstring.py (renamed from sploit/payload/fmtstring.py) | 6 | ||||
-rw-r--r-- | nsploit/payload/gadhint.py (renamed from sploit/payload/gadhint.py) | 4 | ||||
-rw-r--r-- | nsploit/payload/payload.py (renamed from sploit/payload/payload.py) | 10 | ||||
-rw-r--r-- | nsploit/payload/payload_entry.py (renamed from sploit/payload/payload_entry.py) | 4 | ||||
-rw-r--r-- | nsploit/payload/ret2dlresolve.py (renamed from sploit/payload/ret2dlresolve.py) | 12 | ||||
-rw-r--r-- | nsploit/payload/rop.py (renamed from sploit/payload/rop.py) | 8 | ||||
-rw-r--r-- | nsploit/rev/__init__.py (renamed from sploit/rev/__init__.py) | 0 | ||||
-rw-r--r-- | nsploit/rev/elf.py (renamed from sploit/rev/elf.py) | 4 | ||||
-rw-r--r-- | nsploit/rev/gadget.py (renamed from sploit/rev/gadget.py) | 2 | ||||
-rw-r--r-- | nsploit/rev/ldd.py (renamed from sploit/rev/ldd.py) | 4 | ||||
-rw-r--r-- | nsploit/rev/r2.py (renamed from sploit/rev/r2.py) | 10 | ||||
-rw-r--r-- | nsploit/symtbl.py (renamed from sploit/symtbl.py) | 4 | ||||
-rw-r--r-- | nsploit/types/__init__.py (renamed from sploit/types/__init__.py) | 0 | ||||
-rw-r--r-- | nsploit/types/index_entry.py (renamed from sploit/types/index_entry.py) | 0 | ||||
-rw-r--r-- | nsploit/types/indextbl.py (renamed from sploit/types/indextbl.py) | 2 | ||||
-rw-r--r-- | nsploit/types/lict.py (renamed from sploit/types/lict.py) | 0 | ||||
-rw-r--r-- | nsploit/until.py (renamed from sploit/until.py) | 0 | ||||
-rw-r--r-- | nsploit/util/__init__.py (renamed from sploit/util/__init__.py) | 0 | ||||
-rw-r--r-- | nsploit/util/cmd.py | 14 | ||||
-rw-r--r-- | nsploit/util/log.py (renamed from sploit/util/log.py) | 0 | ||||
-rw-r--r-- | pyproject.toml | 36 | ||||
-rwxr-xr-x | sploit.py | 3 | ||||
-rw-r--r-- | sploit/__init__.py | 6 | ||||
-rw-r--r-- | sploit/util/cmd.py | 26 |
32 files changed, 90 insertions, 131 deletions
diff --git a/hooks/bake_version.py b/hooks/bake_version.py deleted file mode 100644 index 4d43228..0000000 --- a/hooks/bake_version.py +++ /dev/null @@ -1,26 +0,0 @@ -from hatchling.builders.hooks.plugin.interface import BuildHookInterface - -import os -import re - -filename = os.path.normpath(os.path.join("sploit","__init__.py")) - -#put the file back when the build ends -class RestoreVersionFile: - def __init__(self,contents): - self.contents = contents - def __del__(self): - with open(filename,"w") as f: - f.write(self.contents) - -class BakeVersionBuildHook(BuildHookInterface): - def initialize(self,version,build_data): - with open(filename,"r") as f: - self.restore = RestoreVersionFile(f.read()) - pattern = r'(?i)^__version__ *= *(?P<version>.+?)$' - match = re.search(pattern, self.restore.contents, flags=re.MULTILINE) - if not match: - raise ValueError("regex of version file failed") - span = match.span('version') - with open(filename,"w") as f: - f.write(f'{self.restore.contents[:span[0]]}"v{self.metadata.version}"{self.restore.contents[span[1]:]}') diff --git a/nsploit.py b/nsploit.py new file mode 100755 index 0000000..222df10 --- /dev/null +++ b/nsploit.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python3 +from nsploit.__main__ import main +main() diff --git a/nsploit/__init__.py b/nsploit/__init__.py new file mode 100644 index 0000000..aef38c4 --- /dev/null +++ b/nsploit/__init__.py @@ -0,0 +1,19 @@ +from nsploit.arch import * +from nsploit.symtbl import * +from nsploit.until import * + +# Shout out: https://stackoverflow.com/questions/67085041 +def __extract_version(): + import importlib.metadata + from contextlib import suppress + from pathlib import Path + + with suppress(FileNotFoundError, StopIteration): + pyproject = Path(__file__).parent.parent / "pyproject.toml" + with open(pyproject, "r") as f: + option = [ line for line in f if line.startswith("version") ] + version = next(iter(option)).split("=")[1].strip("'\"\n ") + return f"{version}-uninstalled" + return importlib.metadata.version(__package__ or __name__) + +__version__ = f"v{__extract_version()}" diff --git a/sploit/__main__.py b/nsploit/__main__.py index 5d53ca6..5f326ef 100644 --- a/sploit/__main__.py +++ b/nsploit/__main__.py @@ -4,17 +4,17 @@ from os.path import isdir import tempfile import traceback -from sploit.comm.comm import * -from sploit.util.log import * -from sploit import __version__ +from nsploit.comm.comm import * +from nsploit.util.log import * +from nsploit import __version__ def print_banner(color, line1=__version__, line2='', line3=''): ilog() - ilog(' ░▒█▀▀▀█░▒█▀▀█░▒█░░░░▒█▀▀▀█░▀█▀░▀▀█▀▀ ', end='', color=ALT) + ilog(' ░█▀█░█▀▀░█▀█░█░░░█▀█░▀█▀░▀█▀ ', end='', color=ALT) ilog(line1, color=ALT) - ilog(' ░░▀▀▀▄▄░▒█▄▄█░▒█░░░░▒█░░▒█░▒█░░░▒█░░ ', end='', color=color) + ilog(' ░█░█░▀▀█░█▀▀░█░░░█░█░░█░░░█░ ', end='', color=color) ilog(line2, color=ALT) - ilog(' ░▒█▄▄▄█░▒█░░░░▒█▄▄█░▒█▄▄▄█░▄█▄░░▒█░░ ', end='', color=ALT) + ilog(' ░▀░▀░▀▀▀░▀░░░▀▀▀░▀▀▀░▀▀▀░░▀░ ', end='', color=ALT) ilog(line3, color=ALT) ilog() @@ -47,7 +47,7 @@ def target(script, target): runscript(script, Comm(Process(target))) def user_scope(comm): - import sploit as lib + import nsploit as lib scope = { name: getattr(lib, name) for name in dir(lib) } scope['__version__'] = __version__ scope['print'] = elog diff --git a/sploit/arch.py b/nsploit/arch.py index a9dea61..a9dea61 100644 --- a/sploit/arch.py +++ b/nsploit/arch.py diff --git a/sploit/comm/__init__.py b/nsploit/comm/__init__.py index ffbc402..ffbc402 100644 --- a/sploit/comm/__init__.py +++ b/nsploit/comm/__init__.py diff --git a/sploit/comm/comm.py b/nsploit/comm/comm.py index 3bc448e..fe23f25 100644 --- a/sploit/comm/comm.py +++ b/nsploit/comm/comm.py @@ -4,8 +4,8 @@ import os import sys import select -from sploit.until import bind -from sploit.util.log import * +from nsploit.until import bind +from nsploit.util.log import * class Comm: logonread = True diff --git a/sploit/payload/__init__.py b/nsploit/payload/__init__.py index da47cc1..da47cc1 100644 --- a/sploit/payload/__init__.py +++ b/nsploit/payload/__init__.py diff --git a/sploit/payload/fmtstring.py b/nsploit/payload/fmtstring.py index 54da6f2..1ec4609 100644 --- a/sploit/payload/fmtstring.py +++ b/nsploit/payload/fmtstring.py @@ -29,9 +29,9 @@ function. Interesting formatters include: See `man 3 printf` for more details. """ -from sploit.arch import arch, btoi, itob -from sploit.payload.payload import Payload -from sploit.payload.payload_entry import padalign, padrel +from nsploit.arch import arch, btoi, itob +from nsploit.payload.payload import Payload +from nsploit.payload.payload_entry import padalign, padrel _FMTSTR_MAGIC = b"\xcd" diff --git a/sploit/payload/gadhint.py b/nsploit/payload/gadhint.py index 1bef9f0..1918a79 100644 --- a/sploit/payload/gadhint.py +++ b/nsploit/payload/gadhint.py @@ -1,8 +1,8 @@ import copy from dataclasses import dataclass, field -from sploit.rev.gadget import Gadget -from sploit.types.index_entry import IndexEntry +from nsploit.rev.gadget import Gadget +from nsploit.types.index_entry import IndexEntry @dataclass class GadHint(IndexEntry): diff --git a/sploit/payload/payload.py b/nsploit/payload/payload.py index 2a9521f..295e3c8 100644 --- a/sploit/payload/payload.py +++ b/nsploit/payload/payload.py @@ -1,8 +1,8 @@ -from sploit.arch import itob -from sploit.payload.payload_entry import PayloadEntry -from sploit.types.indextbl import IndexTbl -from sploit.types.index_entry import IndexEntry -from sploit.types.lict import Lict +from nsploit.arch import itob +from nsploit.payload.payload_entry import PayloadEntry +from nsploit.types.indextbl import IndexTbl +from nsploit.types.index_entry import IndexEntry +from nsploit.types.lict import Lict _REPR_DATA_LEN = 64 diff --git a/sploit/payload/payload_entry.py b/nsploit/payload/payload_entry.py index 2f8dbdd..31eb4f8 100644 --- a/sploit/payload/payload_entry.py +++ b/nsploit/payload/payload_entry.py @@ -1,5 +1,5 @@ -from sploit.arch import arch, itob -from sploit.types.index_entry import IndexEntry +from nsploit.arch import arch, itob +from nsploit.types.index_entry import IndexEntry _PLACEHOLDER_MAGIC = b"\xef" diff --git a/sploit/payload/ret2dlresolve.py b/nsploit/payload/ret2dlresolve.py index 8862e22..3dbd2ed 100644 --- a/sploit/payload/ret2dlresolve.py +++ b/nsploit/payload/ret2dlresolve.py @@ -72,12 +72,12 @@ Elf64_Rel.r_info = 0xAAAAAAAABBBBBBBB symidx type """ -from sploit.arch import arch, itob -from sploit.payload.gadhint import GadHint -from sploit.payload.payload import Payload -from sploit.payload.payload_entry import padalign, padlen, pointer -from sploit.payload.rop import ROP -from sploit.rev.r2 import run_cmd +from nsploit.arch import arch, itob +from nsploit.payload.gadhint import GadHint +from nsploit.payload.payload import Payload +from nsploit.payload.payload_entry import padalign, padlen, pointer +from nsploit.payload.rop import ROP +from nsploit.rev.r2 import run_cmd _JMP_SLOT = 0x07 diff --git a/sploit/payload/rop.py b/nsploit/payload/rop.py index 30467de..78f9950 100644 --- a/sploit/payload/rop.py +++ b/nsploit/payload/rop.py @@ -1,9 +1,9 @@ from graphlib import TopologicalSorter -from sploit.arch import arch, btoi, itob -from sploit.payload.gadhint import GadHint -from sploit.payload.payload import Payload -from sploit.payload.payload_entry import padalign, padlen +from nsploit.arch import arch, btoi, itob +from nsploit.payload.gadhint import GadHint +from nsploit.payload.payload import Payload +from nsploit.payload.payload_entry import padalign, padlen _POP_MAGIC = 0xdead _SPM_MAGIC = b"\x69" diff --git a/sploit/rev/__init__.py b/nsploit/rev/__init__.py index 42e2f5b..42e2f5b 100644 --- a/sploit/rev/__init__.py +++ b/nsploit/rev/__init__.py diff --git a/sploit/rev/elf.py b/nsploit/rev/elf.py index b1479d6..6b30492 100644 --- a/sploit/rev/elf.py +++ b/nsploit/rev/elf.py @@ -2,8 +2,8 @@ Definition of the ELF class """ -from sploit.rev import ldd, r2 -from sploit.arch import lookup_arch +from nsploit.rev import ldd, r2 +from nsploit.arch import lookup_arch from itertools import zip_longest class ELF: diff --git a/sploit/rev/gadget.py b/nsploit/rev/gadget.py index cc69723..bba5e15 100644 --- a/sploit/rev/gadget.py +++ b/nsploit/rev/gadget.py @@ -1,5 +1,5 @@ from dataclasses import dataclass, field -from sploit.types.index_entry import IndexEntry +from nsploit.types.index_entry import IndexEntry @dataclass class Gadget(IndexEntry): diff --git a/sploit/rev/ldd.py b/nsploit/rev/ldd.py index b773abf..f0e5988 100644 --- a/sploit/rev/ldd.py +++ b/nsploit/rev/ldd.py @@ -1,5 +1,5 @@ -from sploit.util.cmd import run_cmd_cached -from sploit.util.log import ilog +from nsploit.util.cmd import run_cmd_cached +from nsploit.util.log import ilog import re from collections import namedtuple as nt diff --git a/sploit/rev/r2.py b/nsploit/rev/r2.py index e81adc9..5f20f0a 100644 --- a/sploit/rev/r2.py +++ b/nsploit/rev/r2.py @@ -1,8 +1,8 @@ -from sploit.arch import arch -from sploit.rev.gadget import Gadget -from sploit.symtbl import Symtbl -from sploit.util.cmd import run_cmd_cached -from sploit.util.log import ilog +from nsploit.arch import arch +from nsploit.rev.gadget import Gadget +from nsploit.symtbl import Symtbl +from nsploit.util.cmd import run_cmd_cached +from nsploit.util.log import ilog from collections import namedtuple as nt from functools import cache diff --git a/sploit/symtbl.py b/nsploit/symtbl.py index 86800f5..e171986 100644 --- a/sploit/symtbl.py +++ b/nsploit/symtbl.py @@ -73,8 +73,8 @@ with the Symtbl base address. print(s.a, s.b, s.c, s.d) # "998 999 1000 1001" """ -from sploit.types.indextbl import IndexTbl -from sploit.types.index_entry import IndexEntry +from nsploit.types.indextbl import IndexTbl +from nsploit.types.index_entry import IndexEntry def Symtbl(*, base=0, **symbols): """ diff --git a/sploit/types/__init__.py b/nsploit/types/__init__.py index a618162..a618162 100644 --- a/sploit/types/__init__.py +++ b/nsploit/types/__init__.py diff --git a/sploit/types/index_entry.py b/nsploit/types/index_entry.py index a03ab92..a03ab92 100644 --- a/sploit/types/index_entry.py +++ b/nsploit/types/index_entry.py diff --git a/sploit/types/indextbl.py b/nsploit/types/indextbl.py index 4f57a59..43fca78 100644 --- a/sploit/types/indextbl.py +++ b/nsploit/types/indextbl.py @@ -1,7 +1,7 @@ from abc import abstractmethod from collections.abc import Collection -from sploit.types.index_entry import IndexEntry +from nsploit.types.index_entry import IndexEntry class IndexTbl(IndexEntry, Collection): """ diff --git a/sploit/types/lict.py b/nsploit/types/lict.py index ab6cb1f..ab6cb1f 100644 --- a/sploit/types/lict.py +++ b/nsploit/types/lict.py diff --git a/sploit/until.py b/nsploit/until.py index b4f390f..b4f390f 100644 --- a/sploit/until.py +++ b/nsploit/until.py diff --git a/sploit/util/__init__.py b/nsploit/util/__init__.py index 32a079b..32a079b 100644 --- a/sploit/util/__init__.py +++ b/nsploit/util/__init__.py diff --git a/nsploit/util/cmd.py b/nsploit/util/cmd.py new file mode 100644 index 0000000..5025a55 --- /dev/null +++ b/nsploit/util/cmd.py @@ -0,0 +1,14 @@ +from subprocess import run + +def run_cmd(cmd,cwd=None): + return run(cmd,cwd=cwd,capture_output=True,text=True,check=True).stdout.split('\n')[:-1] + +__RUN_CACHE__ = {} +def run_cmd_cached(cmd,cwd=None): + key = ''.join(cmd) + if key in __RUN_CACHE__: + return __RUN_CACHE__[key] + else: + result = run_cmd(cmd,cwd) + __RUN_CACHE__[key] = result + return result diff --git a/sploit/util/log.py b/nsploit/util/log.py index 823b252..823b252 100644 --- a/sploit/util/log.py +++ b/nsploit/util/log.py diff --git a/pyproject.toml b/pyproject.toml index 5ac11e8..f6f29b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,31 +1,15 @@ -[project] -name = "sploit" -description = "sploit is a process interaction automation tool with software exploitation focused utilities." -readme = "README.txt" -requires-python = ">=3.9" -license = "Unlicense" -license-files.paths = ["UNLICENSE"] -authors = [ - {name="dusoleil",email="howcansocksbereal@gmail.com"}, - {name="Malfurious",email="m@lfurio.us"}, -] -dynamic = ["version"] - -[project.urls] -"Homepage" = "https://github.com/dusoleil/sploit" - -[project.scripts] -sploit = "sploit.__main__:main" - [build-system] requires = ["hatchling"] build-backend = "hatchling.build" -[tool.hatch.version] -source = "code" -path = "sploit/__init__.py" -search-paths = ["."] -expression = "__version__" +[project] +name = "nsploit" +version = "0.4.0" +requires-python = ">=3.9" +description = "(n)sploit is a process interaction tool with software exploitation utilities" +readme = "README.txt" +license = {file = "UNLICENSE"} +maintainers = [{email = "nsploit-devl@normalmode.org"}] -[tool.hatch.build.hooks.custom] -path = "hooks/bake_version.py" +[project.scripts] +nsploit = "nsploit.__main__:main" diff --git a/sploit.py b/sploit.py deleted file mode 100755 index 419f9b1..0000000 --- a/sploit.py +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env python3 -from sploit.__main__ import main -main() diff --git a/sploit/__init__.py b/sploit/__init__.py deleted file mode 100644 index dc5943f..0000000 --- a/sploit/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from sploit.arch import * -from sploit.symtbl import * -from sploit.until import * - -from sploit.util import git_version as __git_version -__version__ = __git_version() diff --git a/sploit/util/cmd.py b/sploit/util/cmd.py deleted file mode 100644 index 3a2b842..0000000 --- a/sploit/util/cmd.py +++ /dev/null @@ -1,26 +0,0 @@ -from os import path -from subprocess import run - -def run_cmd(cmd,cwd=None): - return run(cmd,cwd=cwd,capture_output=True,text=True,check=True).stdout.split('\n')[:-1] - -__RUN_CACHE__ = {} -def run_cmd_cached(cmd,cwd=None): - key = ''.join(cmd) - if key in __RUN_CACHE__: - return __RUN_CACHE__[key] - else: - result = run_cmd(cmd,cwd) - __RUN_CACHE__[key] = result - return result - -#try to get the version through git -def git_version(): - try: - cwd = path.dirname(path.realpath(__file__)) - version = run_cmd(["git","describe","--always","--first-parent","--dirty"],cwd=cwd)[0] - #PEP440 compliance - version = version.replace('-','+',1).replace('-','.') - return version - except: - return "0+unknown.version" |