You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
run_all_tests.sh should be replaced with a simple scandown for unit tests. For example, pytest or nosetests scans for all files which start with test, and executes all functions whose name start with test.
harness.py can then be renamed to test.py and replaced with a simple wrapper script that does something like what's shown below.
Example test.py
#!/usr/bin/env python2
from pwn import *
def run_exploit(**kwargs):
# set up the flag and target file
write('flag', randoms(20, string.ascii_letters))
saveflag = tempfile.NamedTemporaryFile()
# Set up arguments
global args
args['SAVEFLAG'] = saveflag.name
args['FLAG'] = 'flag'
args.update(**kwargs)
exploit = __import__('exploit', level=0)
del sys.modules['exploit']
del exploit
# verify
assert read(saveflag.name) == read('flag')
def test_local():
'Run the exploit locally'
run_exploit()
def test_remote():
l = listen(0)
l.spawn_process('pwnme')
run_exploit(REMOTE='localhost', PORT=l.lport)
if __name__ == '__main__':
test_local()
test_remote()
run_all_tests.sh
should be replaced with a simple scandown for unit tests. For example,pytest
ornosetests
scans for all files which start withtest
, and executes all functions whose name start withtest
.harness.py
can then be renamed totest.py
and replaced with a simple wrapper script that does something like what's shown below.Example
test.py
py.test and nosetest example
Given this input script
py.test output
nosetests output
The text was updated successfully, but these errors were encountered: