vendredi 23 septembre 2016

how can I linearize this recursive decryption script into another language?

background: I have access to a SWF that uses encrypted data and I want to make a different application on a better platform than Flash. I have the keys, the encrypted data, and the SWF that does stuff with it.

my goal: to write a small program in another language (Python would be nice, but really ANYTHING but Flash) that will output the decrypted data so I can use it elsewhere.

my problem: I cannot figure out exactly what this bloody Flash file is doing when it decrypts, so I can't reproduce it.

Sample encrypted data:

QpzoMekuKadBaZLp5IfQoQJ2JTl91y1yAsARHN4p5JA\/Ilf9CwQVsgtVEQ6QaG7dkgYi77NGrA+\/9Hv1dB0i0iuf77bEWqyWqqufhPrYaIlH3nOaaP8yl5ubIyn9\/+Cb

The actionscript I cannot translate:

package crypto
{
   import com.hurlant.util.Hex;
   import flash.utils.ByteArray;
   import com.hurlant.util.Base64;
   import com.hurlant.crypto.symmetric.PKCS5;
   import com.hurlant.crypto.symmetric.IPad;
   import com.hurlant.crypto.Crypto;
   import com.hurlant.crypto.symmetric.ICipher;
   import com.hurlant.crypto.symmetric.IVMode;
   import utils.JsonUtils;
   public class ImAES
   {
      private static var key:String = "F1BBCA4A0CFF8151";
      private static var B64IV:String = "29148FB1C5639A22";
      public static var jsonDecode:Boolean;
      public static var gzipped:Boolean = true;
      public function ImAES()
      {
         super();
      }
      public static function setKey(param1:String) : void
      {
         ImAES.key = param1;
      }
      public static function setIV(param1:String) : void
      {
         ImAES.B64IV = param1;
      }
      public static function init(param1:String) : void
      {
      }
      public static function decrypt(param1:String) : Object
      {
         var _loc6_:* = null;
         var _loc5_:ByteArray = Hex.toArray(Hex.fromString(key));
         var _loc4_:ByteArray = Base64.decodeToByteArray(param1);
         var _loc3_:IPad = new PKCS5();
         var _loc2_:ICipher = Crypto.getCipher("aes-cbc",_loc5_,_loc3_);
         if(_loc2_ is IVMode)
         {
            _loc6_ = _loc2_ as IVMode;
            _loc6_.IV = Hex.toArray(Hex.fromString(B64IV));
         }
         _loc3_.setBlockSize(_loc2_.getBlockSize());
         _loc2_.decrypt(_loc4_);
         if(gzipped)
         {
            _loc4_.uncompress();
         }
         var _loc7_:String = _loc4_.toString();
         if(jsonDecode)
         {
            return JsonUtils.decode(_loc7_);
         }
         return _loc7_;
      }
   }
}

My specific question: how can I recreate these decryption steps in a more usable programming language? If the actionscript was linear I think I could figure it out, but the recursion (decrypt calls decrypt) has me stumped.

Aucun commentaire:

Enregistrer un commentaire