mirror of https://github.com/pwndbg/pwndbg.git
Add version command (#227)
* Add commit id to pwndbg banner * Add version command and pwndbg.version * Fix importspull/238/head
parent
e9443fdd5f
commit
6a1fdb282e
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Displays gdb, python and pwndbg versions.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import sys
|
||||
|
||||
import gdb
|
||||
|
||||
import pwndbg
|
||||
import pwndbg.color
|
||||
import pwndbg.commands
|
||||
|
||||
|
||||
def _gdb_version():
|
||||
return gdb.execute('show version', to_string=True).split('\n')[0]
|
||||
|
||||
|
||||
def _py_version():
|
||||
return sys.version.replace('\n', ' ')
|
||||
|
||||
|
||||
@pwndbg.commands.Command
|
||||
def version():
|
||||
"""
|
||||
Displays gdb, python and pwndbg versions.
|
||||
"""
|
||||
gdb_str = 'Gdb: %s' % _gdb_version()
|
||||
py_str = 'Python: %s' % _py_version()
|
||||
pwndbg_str = 'Pwndbg: %s' % pwndbg.__version__
|
||||
|
||||
print('\n'.join(map(pwndbg.color.light_red, (gdb_str, py_str, pwndbg_str))))
|
||||
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
|
||||
def build_id():
|
||||
"""
|
||||
Returns pwndbg commit id if git is available.
|
||||
"""
|
||||
try:
|
||||
git_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), '.git')
|
||||
commit_id = subprocess.check_output(['git', '--git-dir', git_path, 'rev-parse', 'HEAD'])
|
||||
commit_id = commit_id[:8].decode('utf-8')
|
||||
|
||||
return 'build: %s' % commit_id
|
||||
except:
|
||||
return ''
|
||||
|
||||
__version__ = '1.0.0'
|
||||
|
||||
b_id = build_id()
|
||||
|
||||
if b_id:
|
||||
__version__ += ' %s' % b_id
|
||||
|
||||
Loading…
Reference in new issue