然后打开apk抓包
虽然app走的是http,但是抓到的包全是乱码,所以app在内部肯定对流量进行了加密操作成功后这样的:
现在我的app的状态是:然后
houstname 填的是我mac的地址,port是mac监听的端口,点击一直点ok,然后成功进入
下面我来寻找动态链接库的基地址,因为我调制的pid是2166,所以,我查看proc的maps文件来找动态链接库的基地址,在终端中运行adb shell cat /proc/2166/maps | grep libAes,解密程序如下
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.IO;
namespace aes
{
class AESHelper
{
///
/// AES解密
///
/// 被解密的密文
/// 密钥
/// 向量
/// 明文
public static String AESDecrypt(String Data, byte[] Key, byte[] Vector)
{
Byte[] encryptedBytes = Convert.FromBase64String(Data);
Byte[] bKey = Key;
Byte[] bVector = Vector;
Byte[] original = null; // 解密后的明文
Rijndael Aes = Rijndael.Create();
Aes.Mode = CipherMode.CBC;
Aes.Padding= PaddingMode.Zeros;
Aes.BlockSize = 128;
try
{
// 开辟一块内存流,存储密文
using (MemoryStream Memory = new MemoryStream(encryptedBytes))
{
// 把内存流对象包装成加密流对象
using (CryptoStream Decryptor = new CryptoStream(Memory,
Aes.CreateDecryptor(bKey, bVector),
CryptoStreamMode.Read))
{
// 明文存储区
using (MemoryStream originalMemory = new MemoryStream())
{
Byte[] Buffer = new Byte[1024];
Int32 readBytes = 0;
while ((readBytes = Decryptor.Read(Buffer, 0, Buffer.Length)) > 0)
{
originalMemory.Write(Buffer, 0, readBytes);
}
original = originalMemory.ToArray();
}
}
}
}
catch(Exception e)
{
Console.WriteLine("失败"+e.ToString());
original = null;
return null;
}
return Encoding.UTF8.GetString(original);
}
// 把十六进制字符串转换成字节型
public static byte[] StringToByte(string InString)
{
string[] ByteStrings;
ByteStrings = InString.Split(' ');
byte[] ByteOut;
ByteOut = new byte[ByteStrings.Length];
for (int i = 0; i < ByteStrings.Length; i++)
{
ByteOut[i] = Convert.ToByte("0x"+ByteStrings[i],16);
}
return ByteOut;
}
public static byte[] GetPictureData(string imagepath)
{
根据图片文件的路径使用文件流打开,并保存为byte[]
FileStream fs = new FileStream(imagepath, FileMode.Open);//可以是其他重载方法
byte[] byData = new byte[fs.Length];
fs.Read(byData, 0, byData.Length);
fs.Close();
return byData;
}
static void Main(string[] args)
{
string strkey = "95 8A FA EB CA EF A4 96 EC 7B 7E 97 D0 75 EA 48";
string striv = "E0 A4 14 94 34 3A 26 1A 35 64 C6 3C 3A F0 43 57";
byte[] key = StringToByte(strkey);
byte[] iv = StringToByte(striv);
byte[] bfile = new byte[2048];
bfile=GetPictureData(@"C:\Users\hehe\apk\333");
string pic = Convert.ToBase64String(bfile);
string ok = AESDecrypt(pic, key, iv);
Console.WriteLine(ok);
}
}
}