Advertisement
The_KGB

[Python]PHP Base 64 Encoder

Apr 3rd, 2012
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. import base64, sys, os
  2.  
  3. def main() :
  4.  
  5.   try :
  6.     Input = str(sys.argv[1])
  7.     Output = str(sys.argv[2])
  8.   except:
  9.     print "\n[*]Usage: %s <Input file> <Output file>" % os.path.basename(sys.argv[0])
  10.     exit()
  11.  
  12.   try :
  13.     ifile = open(Input, "rb").read()
  14.   except :
  15.     print "\n[-]Sorry, couldn't open input file"
  16.     exit()
  17.  
  18.   try :
  19.     if "<?php" in ifile :
  20.       ifile = ifile.replace("<?php", "")
  21.  
  22.     if "<?" in ifile :
  23.       ifile = ifile.replace("<?", "")
  24.  
  25.     ifile = ifile.replace("?>", "")
  26.   except :
  27.     pass
  28.  
  29.   x = "<?php\neval(base64_decode('"
  30.   y = base64.b64encode(ifile)
  31.   z = "'));\n?>"
  32.  
  33.   try :
  34.     ofile = open(Output, "w")
  35.     ofile.write(x + y + z)
  36.     ofile.close()
  37.     print "\n[+]Done ;)"
  38.   except :
  39.     print "\n[-]Sorry, couldn't make output file"
  40.  
  41. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement