Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
287 views
in Technique[技术] by (71.8m points)

android - Possible to use VpnService implementation to capture and send packets?

I'm considering the possibility of using the new android (4.0) VpnService interface to implement simple packet capture and analysis. Does anyone know if it's possible to take the packets you receive in a VpnService implementation and simply write them out to the active/default network device? To receive data, I'd have to be able to read from the network device as well, of course. If it is possible, what APIs can be used to write to the network device(s)?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

tPacketCapture creates a second socket to the remote machine to forward the packets. I have looked at tPacketCapture using adb shell netstat:

Proto Recv-Q Send-Q Local Address              Foreign Address            State 
tcp        0      0 192.168.1.126:49828        97.74.42.79:80             ESTABLISHED
tcp6       0      0 ::ffff:127.0.0.1:5000      :::*                       LISTEN
tcp6       0    522 ::ffff:10.8.0.1:50294      ::ffff:97.74.42.79:80      ESTABLISHED
tcp6       0      0 ::ffff:192.168.1.126:34210 ::ffff:74.125.141.188:5228 ESTABLISHED
tcp6       0      1 ::ffff:192.168.1.126:43379 ::ffff:74.125.224.174:80   CLOSE_WAIT
tcp6       0      1 ::ffff:192.168.1.126:60217 ::ffff:74.125.239.14:443   CLOSE_WAIT

Note 97.74.42.79:80 twice.

Guess I'll have to do the same unless someone has a better idea.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...