document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. namespace DexerPOC
  2. {
  3.     enum State: int
  4.     {
  5.         ERROR_CONTACTING_SERVER = 0x101,
  6.         ERROR_INVALID_PACKAGE_NAME = 0x102,
  7.         ERROR_NON_MATCHING_UID = 0x103,
  8.         ERROR_NOT_MARKET_MANAGED = 0x3,
  9.         ERROR_SERVER_FAILURE = 0x4,
  10.         ERROR_OVER_QUOTA = 0x5,
  11.         LICENSED = 0x0,
  12.         LICENSED_OLD_KEY = 0x2,
  13.         NOT_LICENSED = 0x1
  14.     }
  15.  
  16.     class Program
  17.     {
  18.         static void Main(string[] args)
  19.         {
  20.             Dex dex = Dex.Read("classes.dex");
  21.  
  22.             Console.WriteLine("Dexer Licensing POC - Scanning instructions...");
  23.             foreach (ClassDefinition cdef in dex.Classes)
  24.                 foreach (MethodDefinition mdef in cdef.Methods)
  25.                     if (mdef.Body != null)
  26.                         foreach (Instruction ins in mdef.Body.Instructions)
  27.                             if (ins.OpCode == OpCodes.Sparse_switch)
  28.                             {
  29.                                 SparseSwitchData data = ins.Operand as SparseSwitchData;
  30.                                 if (data.Targets.Keys.All(key => Enum.IsDefined(typeof(State), key) ))
  31.                                 {
  32.                                     Console.WriteLine("SparseSwitch found! - {0}", mdef);
  33.                                     data.Targets[(int) State.NOT_LICENSED] = data.Targets[(int) State.LICENSED];
  34.                                 }
  35.                             }
  36.             Console.WriteLine("Done!");
  37.            
  38.             dex.Write("output.dex");
  39.         }
  40.     }
  41. }
');