最近在研究https加密通信的android端的数据包抓取研究
有两个思路:
1.通过taintdroid在相应的https请求java调用接口处打印log日志方法;编写https请求demo apk,验证日志输出
2.通过源码级工具调试,在https请求相应地方下断点,进行数据追踪
目前,研究taintdroid基础上,做了一些尝试:
1.首先熟悉下载和编译taintdroid步骤,以下为官方网站:
http://appanalysis.org/download.html
编译之前的环境配置工作参照android官方网站:http://source.android.com/source/initializing.html
建议:ubuntu12.04 64位,swap空间设置12G以上,硬盘空间50G以上
2.查看源码,在https调用api处,打印日志,打印出通信内容;
根据taintdroid中的追踪ssl加密通信代码,可知通信使用的类如下:
\libcore\luni\src\main\java\org\apache\harmony\xnet\provider\jsse\OpenSSLSocketImpl.java
具体taintdroid代码如下:
public void write(byte[] buf, int offset, int byteCount) throws IOException {
BlockGuard.getThreadPolicy().onNetwork();
synchronized (writeLock) {
checkOpen();
Arrays.checkOffsetAndCount(buf.length, offset, byteCount);
if (byteCount == 0) {
return;
}
// begin WITH_TAINT_TRACKING
int tag = Taint.getTaintByteArray(buf);
FileDescriptor fd = socket.getFileDescriptor$();
if (tag != Taint.TAINT_CLEAR) {
int disLen = byteCount;
if (byteCount > Taint.dataBytesToLog) {
disLen = Taint.dataBytesToLog;
}
// We only display at most Taint.dataBytesToLog characters in logcat
String dstr = new String(buf, offset, disLen);
// replace non-printable characters
dstr = dstr.replaceAll("\\p{C}", ".");
String addr = (fd.hasName) ? fd.name : "unknown";
String tstr = "0x" + Integer.toHexString(tag);
Taint.log("SSLOutputStream.write(" + addr + ") received data with tag " + tstr + " data=[" + dstr + "]");
}
// end WITH_TAINT_TRACKING
NativeCrypto.SSL_write(sslNativePointer, socket.getFileDescriptor$(),
OpenSSLSocketImpl.this, buf, offset, byteCount);
}
}
代码中if (tag != Taint.TAINT_CLEAR)判断是否为污点标记数据,是,则通过Taint.log()来实现logcat日志输出,这里为了实现所有的输出打印,删除判断条件,打印所有数据:
String dstr = new String(buf, offset, byteCount);
dstr = dstr.replaceAll("\\p{C}", ".");
Taint.log("SSLOutputStream.write(1111) received data with tag 2222 data=[" + dstr + "]");
3.编译相应ROM,刷机到相应手机,此处使用的nexus4
4.编写https请求apk demo
参照博客,代码完全相同,修改url地址即可
http://blog.csdn.net/yzwlord/article/details/9565821
5.在刷好rom的运行APK,打开logcat日志,查看打印输出
使用如下命令
adb shell logcat -v time *:S TaintLog:*
注:笔者认为此方法应该完全可行,但是实际效果却是没有ssloutput日志输出。此处记录一下我的实践过程,供大家参考!