Skip to content

Commit 29b8fe9

Browse files
committed
added test_pwn_utils_lib.py
Signed-off-by: ABHIJIT SINHA <[email protected]>
1 parent cf2c10c commit 29b8fe9

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python3
2+
3+
# author: greyshell
4+
# how to use: python test_pwn_utils_lib.py -m true local -b vuln -g true
5+
6+
from pwn import *
7+
from pwn_utils import PwnUtils
8+
9+
10+
def exploit(conn):
11+
"""
12+
interact with the binary with some valid input
13+
"""
14+
print("success")
15+
16+
17+
def main():
18+
my_input = PwnUtils()
19+
arguments = my_input.parser.parse_args()
20+
connection = ""
21+
22+
# run the script without any argument
23+
if len(sys.argv) == 1:
24+
my_input.parser.print_help(sys.stderr)
25+
sys.exit(1)
26+
27+
# exploiting local binary
28+
if arguments.command == 'local':
29+
binary_name = "./"
30+
binary_name += arguments.binary
31+
connection = process([binary_name])
32+
# attach the binary with gdb in tmux session
33+
if arguments.gdb == 'true':
34+
gdb.attach(connection)
35+
36+
elif arguments.command == 'network':
37+
connection = remote(arguments.ip_address, arguments.port)
38+
39+
if arguments.debug_mode == 'true':
40+
context.log_level = 'debug'
41+
42+
# invoke the exploit function
43+
exploit(connection)
44+
45+
46+
if __name__ == '__main__':
47+
main()

0 commit comments

Comments
 (0)