python写的Android的 tcpdump 数据实时发送到wireshark
2017-09-13 15:51
471 查看
import signal import sys import subprocess import os import time global forward_status global adb_root forward_cmd = "adb forward tcp:2015 tcp:2015" tcpdump_cmd = 'adb shell "tcpdump -n -s 0 -w - | busybox nc -l -p 2015"' wire_cmd = "nc 127.0.0.1 2015| wireshark -k -S -i -" os.chdir(r'C:\Users\lvbiao\Desktop\adb') def adb_root( ): os.chdir(r'C:\Users\lvbiao\Desktop\adb') re_forward = subprocess.call('adb root',shell=True) print(re_forward) global adb if re_forward ==0 : print('ADB root') adb= 0 else: adb = 1 print('ADB root failed ') sys.exit() print("=======================") def exit(signum, frame): print('You choose to stop me.') #fhandle.close(); sys.exit() def forward( ): os.chdir(r'C:\Users\lvbiao\Desktop\adb') re_forward = subprocess.call(forward_cmd,shell=True) global forward_status print(re_forward) if re_forward ==0 : forward_status= 0 else: forward_status = 1 print('ADB NOT CONNECT') sys.exit() print("=======================") def tcpdump(): print("======start tcpdump=======") os.chdir(r'C:\Users\lvbiao\Desktop\adb') tcpdump_pipe = subprocess.Popen(tcpdump_cmd, shell=True, stdout=subprocess.PIPE).stdout; ''' while wifi_pipe.readline() != ' ': line = tcpdump_pipe.readline().decode('UTF-8','strict') #line = line.strip() fhandle.write(line) print (line) else : sys.exit() print("=======================") ''' def open_Wireshark(): os.chdir(r'D:\Wireshark') print("======start wire=======") wire_pipe = subprocess.Popen(wire_cmd, shell=True, stdout=subprocess.PIPE).stdout; ''' while wifi_pipe.readline() != ' ': line = tcpdump_pipe.readline().decode('UTF-8','strict') #line = line.strip() fhandle.write(line) print (line) else : sys.exit() ''' adb_root( ) forward() tcpdump() time.sleep(2) open_Wireshark()
只要打开这个脚本就会主动连接adb connect Android设备。并执行tcpdump 数据发送到pc 端的wireshark 。 实时数据传送。相当方便
这里面需要的nc可以到我附件下载 不懂的可以留言
nc工具下载
如果想下载Wireshark 的
Wireshark
相关文章推荐
- ping 原理与ICMP协议 && Android利用tcpdump和wireshark抓取网络数据包 && Android利用Fiddler进行网络数据抓包
- android平台tcpdump wireshark 网络数据抓包(综合)
- Android下使用TCPDUMP抓包Wireshark分析数据
- Android利用tcpdump和wireshark抓取网络数据包
- Android端通过Usb建立Socket通讯(实时发送视频数据)
- Android下使用TCPDUMP抓包Wireshark分析数据啦。
- Android下使用TCPDUMP抓包Wireshark分析数据啦。
- android平台tcpdump wireshark 网络数据抓包
- Android实时监控项目第四篇:后台线程发送预览帧视频数据
- Android下使用TCPDUMP抓包Wireshark分析数据啦
- Android实时监控项目第四篇:后台线程发送预览帧视频数据
- Android下使用TCPDUMP抓包Wireshark分析数据啦。
- Android Tcpdump抓包WireShark解码数据
- Android利用tcpdump和wireshark抓取网络数据包
- android平台tcpdump wireshark 网络数据抓包(综合)
- Android 用 adb forword + Tcpdump + Wireshark 实时抓包的方法
- Android利用tcpdump和wireshark抓取网络数据包
- Android下使用TcpDump抓包Wireshark分析数据
- 【Android Training - 06】分享数据内容 [Lesson 1 - 发送分享的数据到其他App]
- 6.2、Android中向Internet发送xml数据