@ -5,6 +5,10 @@ from __future__ import division
from __future__ import print_function
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import unicode_literals
import subprocess
from re import search
from subprocess import STDOUT
import pwndbg . commands
import pwndbg . commands
import pwndbg . memoize
import pwndbg . memoize
import pwndbg . wrappers
import pwndbg . wrappers
@ -14,10 +18,17 @@ cmd_name = "checksec"
@pwndbg.wrappers.OnlyWithCommand ( cmd_name )
@pwndbg.wrappers.OnlyWithCommand ( cmd_name )
@pwndbg.memoize.reset_on_objfile
@pwndbg.memoize.reset_on_objfile
def get_raw_out ( ) :
def get_raw_out ( ) :
local_path = pwndbg . file . get_file ( pwndbg . proc . exe )
local_path = pwndbg . file . get_file ( pwndbg . proc . exe )
cmd = [ get_raw_out . cmd_path , " --file " , local_path ]
try :
return pwndbg . wrappers . call_cmd ( cmd )
version_output = subprocess . check_output ( [ get_raw_out . cmd_path , " --version " ] , stderr = STDOUT ) . decode ( ' utf-8 ' )
match = search ( ' checksec v([ \\ w.]+), ' , version_output )
if match :
version = tuple ( map ( int , ( match . group ( 1 ) . split ( " . " ) ) ) )
if version > = ( 2 , 0 ) :
return pwndbg . wrappers . call_cmd ( [ get_raw_out . cmd_path , " --file= " + local_path ] )
except Exception :
pass
return pwndbg . wrappers . call_cmd ( [ get_raw_out . cmd_path , " --file " , local_path ] )
@pwndbg.wrappers.OnlyWithCommand ( cmd_name )
@pwndbg.wrappers.OnlyWithCommand ( cmd_name )
def relro_status ( ) :
def relro_status ( ) :