Guest User

Untitled

a guest
Dec 31st, 2017
98
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2. import os
  3.  
  4. def flip_bytes(binary_f):
  5.     i = random.randint(0, len(binary_f))
  6.     c = chr(random.randint(0, 0xFF))
  7.     return binary_f[:i] + c + binary_f[i+1:]
  8.  
  9. def copy_binary():
  10.     with open("license", "rb") as orig_f, open("license_fuzz", "wb") as fuzz_f:
  11.         fuzz_f.write(flip_bytes(orig_f.read()))
  12.  
  13. def compare(fn1, fn2):
  14.     with open(fn1) as f1, open(fn2) as f2:
  15.         return f1.read == f2.read
  16.  
  17. def check_output():
  18.     os.system("(./license_fuzz ; ./license_fuzz unmfvsYy) > fuzz_output")
  19.     return compare("orig_ouput", "fuzz_output")    
  20.  
  21. def check_rgb():
  22.     os.system("(echo disassemble main | gdb license_fuzz) > gdb_fuzz_output")
  23.     return compare("orig_gdb", "fuzz_gdb")    
  24.  
  25. def check_r2():
  26.     os.system("(echo -e aaa\ns sym.main\npdf | r2 license_fuzz > fuzz_output")
  27.     return compare("orig_r2", "fuzz_r2")
  28.  
  29. while True:
  30.     copy_binary()
  31.     if check_output() and not check_gdb() and not check_r2:
  32.         print("POSSIBLE FAIL:\n\n")
  33.         os.system("tail fuzz_gdb fuzz_r2 fuzz ouput")
  34.         input("Enter to continute, ctrl+c to exit...")
RAW Paste Data