Pwndbg: subprocess.CalledProcessError: Command '['/home/ubuntu/.local/bin/checksec', '--file', '/home/ubuntu/Desktop/pwn2']' returned non-zero exit status 2

Created on 28 Jan 2020  路  6Comments  路  Source: pwndbg/pwndbg

Description

pwndbg> checksec
Traceback (most recent call last):
  File "/home/ubuntu/pwndbg/pwndbg/commands/__init__.py", line 136, in __call__
    return self.function(*args, **kwargs)
  File "/home/ubuntu/pwndbg/pwndbg/commands/__init__.py", line 216, in _OnlyWithFile
    return function(*a, **kw)
  File "/home/ubuntu/pwndbg/pwndbg/commands/checksec.py", line 16, in checksec
    print(pwndbg.wrappers.checksec.get_raw_out())
  File "/home/ubuntu/pwndbg/pwndbg/commands/__init__.py", line 216, in _OnlyWithFile
    return function(*a, **kw)
  File "/home/ubuntu/pwndbg/pwndbg/wrappers/__init__.py", line 28, in _OnlyWithCommand
    return function(*a, **kw)
  File "/home/ubuntu/pwndbg/pwndbg/memoize.py", line 48, in __call__
    value = self.func(*args, **kwargs)
  File "/home/ubutnu/pwndbg/pwndbg/wrappers/checksec.py", line 31, in get_raw_out
    return pwndbg.wrappers.call_cmd([get_raw_out.cmd_path, "--file", local_path])
  File "/home/ubuntu/pwndbg/pwndbg/wrappers/__init__.py", line 35, in call_cmd
    return subprocess.check_output(cmd, stderr=STDOUT).decode('utf-8')
  File "/usr/lib/python3.5/subprocess.py", line 626, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.5/subprocess.py", line 708, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/home/ubuntu/.local/bin/checksec', '--file', '/home/ubuntu/Desktop/pwn2']' returned non-zero exit status 2

But if I use checksec outside pwndgb锛宼here will be no errors

$ checksec pwn2
[*] '/home/ubuntu/Desktop/pwn2'
    Arch:     i386-32-little
    RELRO:    Partial RELRO
    Stack:    No canary found
    NX:       NX enabled
    PIE:      No PIE

My setup

Platform: Linux-4.4.0-171-generic-x86_64-with-Ubuntu-16.04-xenial
Gdb:      7.11.1
Python:   3.5.2 (default)  [GCC 5.4.0]
Pwndbg:   1.1.0 build: b2f7f90
Capstone: 4.0.1024
Unicorn:  1.0.1

This GDB was configured as follows:
   configure --host=x86_64-linux-gnu --target=x86_64-linux-gnu
             --with-auto-load-dir=$debugdir:$datadir/auto-load
             --with-auto-load-safe-path=$debugdir:$datadir/auto-load
             --with-expat
             --with-gdb-datadir=/usr/share/gdb (relocatable)
             --with-jit-reader-dir=/usr/lib/gdb (relocatable)
             --without-libunwind-ia64
             --with-lzma
             --with-python=/usr (relocatable)
             --without-guile
             --with-separate-debug-dir=/usr/lib/debug (relocatable)
             --with-system-gdbinit=/etc/gdb/gdbinit
             --with-babeltrace
bug

All 6 comments

@At0mn which checksec are you using and what does checksec --version say?

@At0mn which checksec are you using and what does checksec --version say?

checksec was installed via python3-pwntools(https://github.com/arthaud/python3-pwntools)

# ubuntu @ ubuntu in ~/.local/bin [3:00:34]
$ ls
2to3         chardetect  disasm            hex          miniterm.pyc  pydoc3          python3.6          pyvenv-3.6  tox-quickstart
2to3-3.6     checksec    easy_install-3.6  idle3        phd           pydoc3.6        python3.6-config   readelf.py  unhex
ROPgadget    common      elfdiff           idle3.6      pip3          pygmentize      python3.6m         scramble    virtualenv
__pycache__  constgrep   elfpatch          mako-render  pip3.6        python3         python3.6m-config  shellcraft  wheel
asm          cyclic      errno             miniterm.py  pwnstrip      python3-config  pyvenv             tox

@At0mn I will create a fix to detect and work with pwntools checksec in the evening

I found that I replaced pwntools(https://github.com/arthaud/python3-pwntools) with pwntools(https://github.com/Gallopsled/pwntools) and it works fine.

```
pwndbg> checksec
[*] '/home/liqingyuan/Desktop/pwn2'
Arch: i386-32-little
RELRO: Partial RELRO
Stack: No canary found
NX: NX enabled
PIE: No PIE (0x8048000)

pwndbg> Quit
``

oh yes, the official pwntools has python3 support and the latest checksec also has the --file parameter available. So i believe there is nothing to adjust here for checksec command so far (at least if we don't want to support ancient versions of pwntools's checksec, do we?).

However i will still create a PR that also supports using it via the pwn command when building pwntools via --only-use-pwn-command

fixed by 355c09e329e907f723d89dd038f983e568c2f29f
can be closed

Was this page helpful?
0 / 5 - 0 ratings

Related issues

plusls picture plusls  路  5Comments

disconnect3d picture disconnect3d  路  5Comments

carstein picture carstein  路  9Comments

danielnehrig picture danielnehrig  路  4Comments

disconnect3d picture disconnect3d  路  9Comments