Skip to content

Instantly share code, notes, and snippets.

@TheFlash2k
Last active July 3, 2023 14:55
Show Gist options
  • Save TheFlash2k/198bb805b3591e27b9bf9fc17bee4c4a to your computer and use it in GitHub Desktop.
Save TheFlash2k/198bb805b3591e27b9bf9fc17bee4c4a to your computer and use it in GitHub Desktop.
Removed the arch option and switched to context.binary and pack
#!/usr/bin/env python3
'''
pip3 install pwntools
pip3 install argparse
'''
from pwn import *
from sys import argv, stderr, stdout
import argparse
context.log_level = 'error'
my_parser = argparse.ArgumentParser(description='A Python3 Based Binary Function Address Extractor using PWNTOOLS by @TheFlash2k')
my_parser.add_argument(
'--binary',
'-b',
metavar='bin',
type=str,
help='The name of the binary from which the function is to be extracted',
required=True,
)
my_parser.add_argument(
'--func',
'-f',
metavar='func',
type=str,
help='The name of the function that is to be extracted from the binary',
required=True,
)
args = my_parser.parse_args()
binary_name = args.binary
func_name = args.func
e = context.binary = ELF(binary_name)
try:
addr = e.symbols[func_name]
except KeyError:
print("Invalid function name!", file=stderr)
exit(1)
val = pack(addr)
print(f"Address of {func_name}: {val}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment