Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`)

Expand Down
7 changes: 7 additions & 0 deletions pwnlib/commandline/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
29 changes: 26 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -78,6 +102,5 @@
] + templates,
},
entry_points = {'console_scripts': console_scripts},
scripts = glob.glob("bin/*"),
**compat
)
Loading