Guest User

canon picturestyle decode

a guest
Sep 29th, 2016
192
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function read_as_byte($filename){
  4.     $handle = fopen($filename, "rb");
  5.     $fsize = filesize($filename);
  6.     $contents = fread($handle, $fsize);
  7.     $byteArray = unpack("C*",$contents);
  8.     return $byteArray;
  9. }
  10. function saveFile($a, $fn){
  11.     $str = "";
  12.     foreach($a as $k){
  13.         $str.=chr($k); 
  14.     }
  15.     $fp = fopen($fn,'w');
  16.     fwrite($fp,$str);
  17.     fclose($fp);
  18. }
  19.  
  20. $dec_key = read_as_byte("./canon_ps.key");
  21. $enc_file = read_as_byte("./PictureStyle.pf2");
  22.  
  23. $i = -11;
  24. $dec = array();
  25.  
  26. foreach($enc_file as $ef){
  27.     if($i>-1){
  28.         $dec[] = $ef^$dec_key[$i];
  29.         $i = $i%(512*513);
  30.     }
  31.     else
  32.     {
  33.         $dec[] = $ef;
  34.     }
  35.     $i++;
  36. }
  37. saveFile($dec, "./PictureStyle.decoded.pf2");
RAW Paste Data