一、抓包定位服务器IP的核心步骤
1. 环境配置
# 安装抓包工具
adb install charles-proxy-4.6.3.apk
# 开启透明代理
iptables -t nat -A OUTPUT -p tcp --dport 80 -j REDIRECT --to-port 8889
2. SSL Pinning绕过(Java代码)
// 自定义TrustManager绕过证书校验
public static SSLSocketFactory createBypassSSLFactory() {
try {
TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain, String authType) {}
public void checkServerTrusted(X509Certificate[] chain, String authType) {}
public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; }
}};
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, trustAllCerts, new SecureRandom());
return sslContext.getSocketFactory();
} catch (Exception e) { e.printStackTrace(); }
return null;
}
3. 流量分析(Python脚本)
# 提取HTTP请求中的IP地址
from scapy.all import *
def extract_ip(pkt):
if pkt.haslayer(IP) and pkt.haslayer(TCP):
if pkt[TCP].dport == 80 or pkt[TCP].dport == 443:
print(f"目标服务器IP: {pkt[IP].dst} 端口: {pkt[TCP].dport}")
sniff(filter="tcp", prn=extract_ip, store=0)
二、重打包攻击流程
-
使用Apktool反编译APK:
apktool d target_app.apk -o decompiled_dir
-
修改AndroidManifest.xml添加调试权限:
<application android:debuggable="true"...>
-
注入恶意代码后重打包:
apktool b decompiled_dir -o modified_app.apk
三、企业级防护方案
实际案例:某金融APP在接入群联AI云防护后,有效防御特征如下:
- 动态IP混淆技术:每5分钟切换真实服务器IP
- 行为AI分析引擎:实时阻断异常抓包请求
- 重打包防护:APK文件哈希值动态校验
测试数据:拦截率提升至99.8%,抓包攻击成本增加300%