#!/usr/bin/env python3

import pyperclip
import re
import subprocess
import sys

def usage():
    print("pwn-summary.py <file>")

if len(sys.argv) < 2:
    usage()
    sys.exit()

summary = ""
output = subprocess.check_output("file " + sys.argv[1], shell=True)
if any(x in output for x in [b"x86-64", b"64-bit", b"aarch64"]):
    summary += "64-bit executable\n"
elif any(x in output for x in [b"i386", b"32-bit"]):
    summary += "32-bit executable\n"
else:
    summary += "unknown executable\n"

output = subprocess.check_output("pwn checksec " + sys.argv[1], shell=True, stderr=subprocess.STDOUT)
if output == b"":
    print("error: pwn checksec failed with no output")
    sys.exit()

vuln = ""
secure = ""
if b"Partial RELRO" in output:
    vuln += "Partial RELRO, "
elif b"Full RELRO" in output:
    secure += "Full RELRO, "
else:
    vuln += "No RELRO, "

if b"No canary found" in output:
    vuln += "no canary, "
else:
    secure += "has canary, "

if b"NX enabled" in output:
    secure += "NX enabled, "
else:
    vuln += "no NX enabled, "

if b"No PIE" in output:
    vuln += "no PIE"
    subprocess.run("bash -ic 'set_bp_type b'", shell=True)
else:
    secure += "PIE enabled"
    subprocess.run("bash -ic 'set_bp_type brva'", shell=True)

vuln = vuln.rstrip().strip(",")
secure = secure.rstrip().strip(",")
summary += vuln + "\n" + secure + "\n"

output = subprocess.check_output("strings libc* 2>/dev/null | grep version | grep -i glibc | head -n1", shell=True)
if b"glibc" in output.lower():
    match = re.search(b"2\.[0-9][0-9].*\)", output)
    summary += "glibc " + match[0].strip(b")").decode()
print("\n" + summary)
pyperclip.copy(summary)

73fd3dabc8ac9e2738b7247cf0202c02cb6b002f
<mask token>


def usage():
    print('pwn-summary.py <file>')


<mask token>

<mask token>


def usage():
    print('pwn-summary.py <file>')


if len(sys.argv) < 2:
    usage()
    sys.exit()
<mask token>
if any(x in output for x in [b'x86-64', b'64-bit', b'aarch64']):
    summary += '64-bit executable\n'
elif any(x in output for x in [b'i386', b'32-bit']):
    summary += '32-bit executable\n'
else:
    summary += 'unknown executable\n'
<mask token>
if output == b'':
    print('error: pwn checksec failed with no output')
    sys.exit()
<mask token>
if b'Partial RELRO' in output:
    vuln += 'Partial RELRO, '
elif b'Full RELRO' in output:
    secure += 'Full RELRO, '
else:
    vuln += 'No RELRO, '
if b'No canary found' in output:
    vuln += 'no canary, '
else:
    secure += 'has canary, '
if b'NX enabled' in output:
    secure += 'NX enabled, '
else:
    vuln += 'no NX enabled, '
if b'No PIE' in output:
    vuln += 'no PIE'
    subprocess.run("bash -ic 'set_bp_type b'", shell=True)
else:
    secure += 'PIE enabled'
    subprocess.run("bash -ic 'set_bp_type brva'", shell=True)
<mask token>
summary += vuln + '\n' + secure + '\n'
<mask token>
if b'glibc' in output.lower():
    match = re.search(b'2\\.[0-9][0-9].*\\)', output)
    summary += 'glibc ' + match[0].strip(b')').decode()
print('\n' + summary)
pyperclip.copy(summary)

<mask token>


def usage():
    print('pwn-summary.py <file>')


if len(sys.argv) < 2:
    usage()
    sys.exit()
summary = ''
output = subprocess.check_output('file ' + sys.argv[1], shell=True)
if any(x in output for x in [b'x86-64', b'64-bit', b'aarch64']):
    summary += '64-bit executable\n'
elif any(x in output for x in [b'i386', b'32-bit']):
    summary += '32-bit executable\n'
else:
    summary += 'unknown executable\n'
output = subprocess.check_output('pwn checksec ' + sys.argv[1], shell=True,
    stderr=subprocess.STDOUT)
if output == b'':
    print('error: pwn checksec failed with no output')
    sys.exit()
vuln = ''
secure = ''
if b'Partial RELRO' in output:
    vuln += 'Partial RELRO, '
elif b'Full RELRO' in output:
    secure += 'Full RELRO, '
else:
    vuln += 'No RELRO, '
if b'No canary found' in output:
    vuln += 'no canary, '
else:
    secure += 'has canary, '
if b'NX enabled' in output:
    secure += 'NX enabled, '
else:
    vuln += 'no NX enabled, '
if b'No PIE' in output:
    vuln += 'no PIE'
    subprocess.run("bash -ic 'set_bp_type b'", shell=True)
else:
    secure += 'PIE enabled'
    subprocess.run("bash -ic 'set_bp_type brva'", shell=True)
vuln = vuln.rstrip().strip(',')
secure = secure.rstrip().strip(',')
summary += vuln + '\n' + secure + '\n'
output = subprocess.check_output(
    'strings libc* 2>/dev/null | grep version | grep -i glibc | head -n1',
    shell=True)
if b'glibc' in output.lower():
    match = re.search(b'2\\.[0-9][0-9].*\\)', output)
    summary += 'glibc ' + match[0].strip(b')').decode()
print('\n' + summary)
pyperclip.copy(summary)

import pyperclip
import re
import subprocess
import sys


def usage():
    print('pwn-summary.py <file>')


if len(sys.argv) < 2:
    usage()
    sys.exit()
summary = ''
output = subprocess.check_output('file ' + sys.argv[1], shell=True)
if any(x in output for x in [b'x86-64', b'64-bit', b'aarch64']):
    summary += '64-bit executable\n'
elif any(x in output for x in [b'i386', b'32-bit']):
    summary += '32-bit executable\n'
else:
    summary += 'unknown executable\n'
output = subprocess.check_output('pwn checksec ' + sys.argv[1], shell=True,
    stderr=subprocess.STDOUT)
if output == b'':
    print('error: pwn checksec failed with no output')
    sys.exit()
vuln = ''
secure = ''
if b'Partial RELRO' in output:
    vuln += 'Partial RELRO, '
elif b'Full RELRO' in output:
    secure += 'Full RELRO, '
else:
    vuln += 'No RELRO, '
if b'No canary found' in output:
    vuln += 'no canary, '
else:
    secure += 'has canary, '
if b'NX enabled' in output:
    secure += 'NX enabled, '
else:
    vuln += 'no NX enabled, '
if b'No PIE' in output:
    vuln += 'no PIE'
    subprocess.run("bash -ic 'set_bp_type b'", shell=True)
else:
    secure += 'PIE enabled'
    subprocess.run("bash -ic 'set_bp_type brva'", shell=True)
vuln = vuln.rstrip().strip(',')
secure = secure.rstrip().strip(',')
summary += vuln + '\n' + secure + '\n'
output = subprocess.check_output(
    'strings libc* 2>/dev/null | grep version | grep -i glibc | head -n1',
    shell=True)
if b'glibc' in output.lower():
    match = re.search(b'2\\.[0-9][0-9].*\\)', output)
    summary += 'glibc ' + match[0].strip(b')').decode()
print('\n' + summary)
pyperclip.copy(summary)

#!/usr/bin/env python3

import pyperclip
import re
import subprocess
import sys

def usage():
    print("pwn-summary.py <file>")

if len(sys.argv) < 2:
    usage()
    sys.exit()

summary = ""
output = subprocess.check_output("file " + sys.argv[1], shell=True)
if any(x in output for x in [b"x86-64", b"64-bit", b"aarch64"]):
    summary += "64-bit executable\n"
elif any(x in output for x in [b"i386", b"32-bit"]):
    summary += "32-bit executable\n"
else:
    summary += "unknown executable\n"

output = subprocess.check_output("pwn checksec " + sys.argv[1], shell=True, stderr=subprocess.STDOUT)
if output == b"":
    print("error: pwn checksec failed with no output")
    sys.exit()

vuln = ""
secure = ""
if b"Partial RELRO" in output:
    vuln += "Partial RELRO, "
elif b"Full RELRO" in output:
    secure += "Full RELRO, "
else:
    vuln += "No RELRO, "

if b"No canary found" in output:
    vuln += "no canary, "
else:
    secure += "has canary, "

if b"NX enabled" in output:
    secure += "NX enabled, "
else:
    vuln += "no NX enabled, "

if b"No PIE" in output:
    vuln += "no PIE"
    subprocess.run("bash -ic 'set_bp_type b'", shell=True)
else:
    secure += "PIE enabled"
    subprocess.run("bash -ic 'set_bp_type brva'", shell=True)

vuln = vuln.rstrip().strip(",")
secure = secure.rstrip().strip(",")
summary += vuln + "\n" + secure + "\n"

output = subprocess.check_output("strings libc* 2>/dev/null | grep version | grep -i glibc | head -n1", shell=True)
if b"glibc" in output.lower():
    match = re.search(b"2\.[0-9][0-9].*\)", output)
    summary += "glibc " + match[0].strip(b")").decode()
print("\n" + summary)
pyperclip.copy(summary)
