Android networked surveillance capture kit maker (Tcpdump use)

Source: Internet
Author: User

Recently made an Android networking grab kit

I've been searching the internet for a long time

There's still no clue.

So think about the Linux layer.

So the tcpdump of Linux is used to realize the function of grasping packet.

The simple definition of tcpdump is: The dump the traffic on a network, based on the user's definition of the packet interception of packets on the Data Packet Analysis tool.

As the Classic System Administrator tool on the Internet, tcpdump is one of the necessary things for each advanced system administrator to analyze the network, troubleshoot problems and so on with its powerful function and flexible interception strategy.

For tcpdump detailed can refer to http://baike.baidu.com/view/76504.htm?fr=ala0_1_1 Baidu Encyclopedia introduction

I'm here to focus on how to use Tcpdump on Android

The test machine I used was cracked version G2 and simulator

The specific thing is to execute the Linux command in the APK program.

[C-sharp]View Plaincopy
    1. Tcpdump-p-vv-s 0-w/sdcard/capture.pcap

This will allow you to write a capture.pcap file on the sdcard of the captured bag.

And this file can be opened with Wireshark on the PC to view very convenient

The specific source code is as follows

Mainhook.java

[C-sharp]View Plaincopy
  1. Package Zy.hook;
  2. Import java.io.IOException;
  3. Import android.app.Activity;
  4. Import Android.os.Bundle;
  5. Import Android.util.Log;
  6. Public class Mainhook extends Activity {
  7. /** Called when the activity is first created. * /
  8. @Override
  9. public void OnCreate (Bundle savedinstancestate) {
  10. Super.oncreate (savedinstancestate);
  11. Setcontentview (R.layout.main);
  12. try {
  13. //runtime.getruntime (). EXEC ("su");
  14. //runtime.getruntime (). EXEC ("dd if=/sdcard/tcpdump of=/data/local/tcpdump");
  15. //runtime.getruntime (). EXEC ("chmod 6755/data/local/tcpdump");
  16. Runtime.getruntime (). EXEC ("tcpdump-p-vv-s 0-w/sdcard/capture.pcap");
  17. LOG.I ("Run","success!!!!!!!!!");
  18. } catch (IOException e) {
  19. //TODO auto-generated catch block
  20. E.printstacktrace ();
  21. LOG.I ("Run", e.tostring ());
  22. }
  23. }
  24. }

Androidmanifest.xml

[XHTML]View Plaincopy
  1. <? XML version= "1.0" encoding="Utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="Zy.hook"
  4. android:versioncode="1"
  5. android:versionname="1.0">
  6. <application android:icon="@drawable/icon" android:label="@string/app_name" >
  7. <activity android:name=". Mainhook "
  8. android:label="@string/app_name">
  9. <intent-filter>
  10. <action android:name="Android.intent.action.MAIN" />
  11. <category android:name="Android.intent.category.LAUNCHER" />
  12. </intent-filter>
  13. </Activity>
  14. </Application>
  15. <uses-sdk android:minsdkversion="7" />
  16. <uses-permission android:name="Android.permission.WRITE_EXTERNAL_STORAGE" />
  17. </manifest>

In particular, don't forget the permissions <uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/>

The statement

Run the program so we can grab the bag.

The Capture.pcap file is generated on the SDcard

After a while, export the file from the SDcard

Then we open it with Wireshark.

can be very convenient to view the bags we have caught

Hope to be useful to everyone

The copyright of this article belongs to csdn Bo Master Zeng All

Http://blog.csdn.net/Zengyangtech/archive/2010/08/31/5853366.aspx

Reprint Please specify this sentence

Android networked surveillance capture kit maker (Tcpdump use)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.