public static String decode(String encryptedStr) throws Exception { byte[] decodedData = decryptByPublicKey(Base64.decode(encryptedStr, 1), publicKeyInner); return new String(decodedData); }
public static byte[] decryptByPublicKey(byte[] encryptedData, String publicKey) throws Exception { byte[] cache; byte[] keyBytes = Base64.decode(publicKey, 1); X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes); KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); Key publicK = keyFactory.generatePublic(x509KeySpec); Cipher cipher = Cipher.getInstance(KEY_CIPHER_ALGORITHM); cipher.init(2, publicK); int inputLen = encryptedData.length; ByteArrayOutputStream out = new ByteArrayOutputStream(); int offSet = 0; int i = 0; while (inputLen - offSet > 0) { if (inputLen - offSet > 128) { cache = cipher.doFinal(encryptedData, offSet, 128); } else { cache = cipher.doFinal(encryptedData, offSet, inputLen - offSet); } out.write(cache, 0, cache.length); i++; offSet = i * 128; } byte[] decryptedData = out.toByteArray(); out.close(); return decryptedData; } }
先尝试frida的方法
1 2 3 4 5 6 7 8 9 10
Java.perform(function() { let WeiboSecurityUtils = Java.use("com.sina.weibo.security.WeiboSecurityUtils"); let current_application = Java.use('android.app.ActivityThread').currentApplication(); let arg1 = current_application.getApplicationContext(); let arg2 = "hello world"; let arg3 = "123456"; let ret = WeiboSecurityUtils.$new().calculateS(arg1, arg2, arg3); console.log("ret:"+ret); })
这里使用的是frida附加进程来进行一个主动调用
1 2 3 4
[AOSP on Oriole::com.weico.international ]-> ret:d74a75bb ret:d74a75bb
public static void main(String[] args) { WeiBo wb = new WeiBo(); } }
这里选择32位是以为在lib文件夹里面他就写了一个armeabi
创建虚拟机
1
vm = emulator.createDalvikVM(new File("F:\\repwn\\unidbg-master\\unidbg-master\\unidbg-android\\src\\test\\java\\com\\unidbgtest2\\sinaInternational.apk"));