diff --git a/CHANGELOG.md b/CHANGELOG.md index ff68e4081..ecaac64d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -88,6 +88,7 @@ The table below shows which release corresponds to each branch, and what date th - [#2410][2410] Add `tube.upload_manually` to upload files in chunks - [#2502][2502] Fix loading ELF files without valid .dynamic section - [#2476][2476] Deprecate 'keepends' argument in favor of 'drop' in `tube.recvline*` +- [#2364][2364] Deprecate direct commandline scripts invocation and exclude nonsense ones [2471]: https://github.com/Gallopsled/pwntools/pull/2471 [2358]: https://github.com/Gallopsled/pwntools/pull/2358 @@ -104,6 +105,7 @@ The table below shows which release corresponds to each branch, and what date th [2410]: https://github.com/Gallopsled/pwntools/pull/2410 [2502]: https://github.com/Gallopsled/pwntools/pull/2502 [2476]: https://github.com/Gallopsled/pwntools/pull/2476 +[2364]: https://github.com/Gallopsled/pwntools/pull/2364 ## 4.14.0 (`beta`) diff --git a/pwnlib/commandline/common.py b/pwnlib/commandline/common.py index 3ce0a0fad..b3d96e0c9 100644 --- a/pwnlib/commandline/common.py +++ b/pwnlib/commandline/common.py @@ -33,6 +33,13 @@ def main(file=sys.argv[0], command_main=None): sys.argv.insert(1, name) entrypoint({name: command_main}) +def deprecated_main(): + file=sys.argv[0] + name = os.path.splitext(os.path.basename(file))[0] + import warnings + warnings.warn("The '%s' command is deprecated and will be removed in a future version. Please use 'pwn %s' instead." % (name, name), DeprecationWarning, stacklevel=2) + main(file) + def entrypoint(commands): if len(sys.argv) < 2: parser.print_usage() diff --git a/setup.py b/setup.py index 637f5cd7a..df97d887b 100755 --- a/setup.py +++ b/setup.py @@ -31,14 +31,38 @@ else: flag = False +DEPRECATED_SCRIPTS= [ + 'asm', + # 'checksec', + # 'constgrep', + 'cyclic', + 'debug', + 'disablenx', + 'disasm', + 'elfdiff', + 'elfpatch', + 'errno', + 'hex', + # 'libcdb', + # 'phd', + # 'pwnstrip', + 'scramble', + # 'shellcraft', + 'template', + 'unhex', +] + for filename in glob.glob('pwnlib/commandline/*'): filename = os.path.basename(filename) filename, ext = os.path.splitext(filename) - if ext != '.py' or '__init__' in filename: + if ext != '.py' or filename in ('__init__', 'common', 'main', 'update', 'version'): continue - script = '%s=pwnlib.commandline.common:main' % filename + if filename in DEPRECATED_SCRIPTS: + script = '%s=pwnlib.commandline.common:deprecated_main' % filename + else: + script = '%s=pwnlib.commandline.common:main' % filename if not flag: console_scripts.append(script) @@ -78,6 +102,5 @@ ] + templates, }, entry_points = {'console_scripts': console_scripts}, - scripts = glob.glob("bin/*"), **compat )