#0x1
工具准备:rvictl、wireshark、charles
#0x2
1、手机USB连上mac后,使用指令rvictl -s xxxx68a776da7d40789adcbf2f991c8e9345xxxx
打开虚拟网络接口rvi。
2、mac共享wifi网络,手机链接共享后的wifi,访问APP任意接口wireshark开始抓包,此步骤用来获取APP API接口域名地址。
3、获取到域名后,修改手机HOSTS,将该域名解析指向mac。
4、mac启动charles,打开菜单Proxy->Reverse Proxies Settings,打开反向代理设置,添加之前wireshark抓到域名。
5、开始愉快的抓包吧!
#0x3 frida脚本(无需手动改手机hosts)
/*
*
* @creantan
*
* Example usage:
* # frida -U -f com.xxx.yyy -l flutter_connect_.js --no-pause
*
*/
var sIP = 'xxx.xxx.xxx.xxx' //目标IP地址
var xIP = '192.168.2.1'//代理电脑IP地址
//IP字符串转int
function ipToInt(ip){
var result = ip.split('.');
return (parseInt(result[3]) << 24
| parseInt(result[2]) << 16
| parseInt(result[1]) << 8
| parseInt(result[0]));
}
//int转IP字符串
function parseIp (number) {
var ip = ''
if (number <= 0) {
return ip
}
const ip3 = (number << 0) >>> 24
const ip2 = (number << 8) >>> 24
const ip1 = (number << 16) >>> 24
const ip0 = (number << 24) >>> 24
ip += ip0 + '.' + ip1 + '.' + ip2 + '.' + ip3
return ip
}
function parsePort(number) {
return ((number & 0xFF) << 8) | ((number & 0xFF00) >> 8);
}
Interceptor.attach(Module.findExportByName(null, "connect"), {
onEnter: function(args) {
var fd = args[0].toInt32()
if (Socket.type(fd) !== 'tcp')
return;
var ipAddr = args[1].add(4)
var ip = parseIp(Memory.readU32(ipAddr))
var portAddr = args[1].add(2)
var port = parsePort(Memory.readUShort(portAddr));
//判断是否为目标地址
if (ip === sIP) {
console.log("[+] connect: " +ip+ ':'+ port);
//替换IP地址为代理主机
Memory.writeU32(ipAddr,ipToInt(xIP))
//打印替换后地址
console.log(hexdump(ptr(args[1]), {
length: 32,
header: true,
ansi: true
}))
}
}
})