首页 > 系统相关 >Android利用tcpdump抓包

Android利用tcpdump抓包

时间:2023-06-02 19:32:22浏览次数:44  
标签:capture shell http url adb Android tcpdump 抓包


[b]Instructions[/b]
[url]http://source.android.com/porting/tcpdump.html[/url]
[b]Source Code and Documents[/b]
[url]http://www.tcpdump.org/[/url]
[b]Compiled Binary Download[/b]
[url]http://www.strazzere.com/android/tcpdump[/url]
[b]数据包分析工具Wireshark[/b]
[url]http://www.wireshark.org/download.html[/url]

[b]
Installing tcpdump[/b]
[b]Pushing the binary to an existing device[/b]
Download tcpdump from [url]http://www.tcpdump.org/[/url], then execute:

adb root
adb remount
adb push /wherever/you/put/tcpdump /system/xbin/tcpdump
adb shell chmod 6755 /data/local/tmp/tcpdump




[b]Running tcpdump[/b]


You need to have root access on your device.


[b]Batch mode capture[/b]


The typical procedure is to capture packets to a file and then examine the file on the desktop, as illustrated below:


adb shell tcpdump -i any -p -s 0 -w /sdcard/capture.pcap
# "-i any": listen on any network interface
# "-p": disable promiscuous mode (doesn't work anyway)
# "-s 0": capture the entire packet
# "-w": write packets to a file (rather than printing to stdout)

   ... do whatever you want to capture, then ^C to stop it ...

adb pull /sdcard/capture.pcap .
sudo apt-get install wireshark  # or ethereal, if you're still on dapper
wireshark capture.pcap          # or ethereal

   ... look at your packets and be wise ...




You can run tcpdump in the background from an interactive shell or from Terminal. By default, tcpdump captures all traffic without filtering. If you prefer, add an expression like port 80 to the tcpdump command line.



[b]Real time packet monitoring[/b]


Execute the following if you would like to watch packets go by rather than capturing them to a file (-n skips DNS lookups. -s 0 captures the entire packet rather than just the header):


adb shell tcpdump -n -s 0




Typical tcpdump options apply. For example, if you want to see HTTP traffic:


adb shell tcpdump -X -n -s 0 port 80

标签:capture,shell,http,url,adb,Android,tcpdump,抓包
From: https://blog.51cto.com/u_16125990/6404597

相关文章

  • android: workaround for slow ‘building workspace’ problem in eclipse
    Whiledevelopingforandroidoneclipse3.6ihadtheproblemthateachtimeisavedafile,eclipseblockedmeseveralsecondswith‘buildingworkspace…’.Similartothese:stackoverflow–android-compilation-is-slow-using-eclipsestackoverflow–android-......
  • Android通过 SharedPreference 实现用户名与密码的存储与调用
    注:Android实验课(一)的内容一、实验原理1.1实验目标编程实现用户名与密码的存储与调用。1.2实验要求设计用户登录界面、登录成功界面、用户注册界面,用户注册时,将其用户名、密码保存到SharedPreference中,登录时输入用户名、密码,读取SharedPreference,读取不到该用户名提示用户不存在,用......
  • Android中实现ContentResolver对系统中所有联系人的访问
    一、实现方法思路:朝着实验要求和目的去想,要想访问系统中的联系人,可以利用ContentResolver类来访问,使用ContentResolver类可以访问别的应用程序通过ContentProvider提供的数据,这里可以用Android系统提供的标准的ContentProvider来对手机联系人进行访问。还有要想实现长......
  • Android中实现网络图片的获取
    在Android中要想获取网络资源,可以使用HttpURLConnection和HttpsURLConnection来实现相关功能。下面案例实现了基于URL的简单请求响应,通过HttpURLConnection获取连接,通过InputStream获取输入流,BitmapFactory将数据流转换为Bitmap,再将Bitmap通过线程的Message发送出去,Handl......
  • python mitmproxy抓包库
    一.简介mitmproxy是一款用Python编写的支持HTTP(S)的中间人代理工具。它可以拦截、查看、修改、重放和保存HTTP/HTTPS流量,支持命令行界面和图形界面,可用于安全测试、网络调试、API开发和反向工程等场景。mitmproxy具有很高的灵活性和扩展性,可以通过插件机制进行定制化开发和功能......
  • Android优秀开源项目
    203.208.46.146www.google.com74.125.113.121developer.android.com203.208.46.146dl.google.com203.208.46.146dl-ssl.google.comAndroid经典的开源项目其实非常多,但是国内的博客总是拿着N年前的一篇复制来复制去,实在是不利于新手学习。今天爬爬把自己熟悉的一些开源......
  • Android 的一些提示框
    1.在测试时,如何实现一个提示可以使用Toast.makeText(this,"这是一个提示",Toast.LENGTH_SHORT).show();//从资源文件string.xml里面取提示信息Toast.makeText(this,getString(R.string.welcome),Toast.LENGTH_SHORT).show();这个提示会几秒钟后消失2.可以使用AlertDialog......
  • Android 12 Window ViewRootImpl Activity的关系
    1Window和ViewRootImpl有什么关系?看右侧流程图,上层的UI大体分成两大类,一是Activity,另一类是CustomWindow(如状态栏、toast等)。但是他们都要经过WindowManager.addView这个接口添加到系统中。经过WindowManagerGlobal,会new一个ViewRootImpl,ViewRootImpl会申请server端的Sessio......
  • Android strings.xml按照key修改
    strings.xml匹配替换将两个Android项目中的多语言字符串文件(strings.xml)进行比较,如果其中一个项目中包含另一个项目没有的字符,则合并到单一的输出文件,并以key在原始XML文件中更新value值。如果key匹配不准确则忽略它。具体来说:引入re,xml.etree.ElementTree和argpar......
  • Android获取当前系统日期和时间的三种方法
    第一种方法SimpleDateFormatsimpleDateFormat=newSimpleDateFormat("yyyy年MM月dd日HH:mm:ss");//HH:mm:ss//获取当前时间Datedate=newDate(System.currentTimeMillis());time1.setText("Date获取当前日期时间"+simpleDateFormat.format(date)); ......