Capture app LAN communication packets under MAC OS X

Source: Internet
Author: User

Capture the app LAN communication packet under MAC OS X. Clutch mode

Because of the working relationship, we often have to analyze the app WiFi communication protocol. My development computer is MAC book.
There are generally several modes:
+ App HTTP communication with the server, in which case the HTTP debugging artifact Charles comes in handy. (See my other blog posts)
+ Apps and smart devices for WiFi devices, usually TCP packets are mostly, often do not need to be connected to the Internet, just local communications. It needs to be wireshark with the catch package software.

This is the LAN TCP mode, this mode can not use the Charles Agent mode, directly on the computer can only grab their own WiFi packet, unable to catch the phone and smart device communication.

Later, a comprehensive approach was found, that is, Mac OS x turns on internet Sharing to act as a router. The phone and smart devices are then connected to the virtual router to communicate, running Wireshark on Mac OS X to capture all packets that pass through the virtual router.

Two. Turn on Mac OS X Internet Sharing

The English version is also known as air port sharing.
It requires several conditions:
1. Ethernet needs to be connected to the Internet, usually using a network cable to the real router, even if the communication does not require the Internet, it is not possible to bring up Internet sharing mode.

    1. Smart devices can use router communication (typically this is a standard feature)

Open the method as follows:

Open System Preferences –> share

In the Internet share, make the following settings
1. Select Ethernet as the router WAN port connection.
2. Select "Wi-Fi" to share to other devices
3. Click "Wifi Options" to set the hotspot name of this virtual router, password
4. Click "Internet Sharing" to open the virtual router

After startup, a small arrow appears in the WiFi sign in the upper left corner, indicating access to WiFi sharing mode

Three. Installing Wireshark

Wireshark is a powerful web tool based on the Linux X11 graphical interface, so it's natural to support Linux. With X11 migrated to Windows and Mac OS X. Wireshark also supports multiple operating systems.

Mac OS X 10.10 Install X11 application Xquartz

Apple first joined the X11 support Library at 10.3, but in 10.10 it removed support for X11, so developers had to install X11 support Library Xquartz manually.

Download First
Http://xquartz.macosforge.org/downloads/SL/XQuartz-2.7.7.dmg
Run the DMG installation, but it is strange that the icon does not appear in the application bar. Restart the machine.
But it is installed under/applications/utilities/xquartz.app, so you can manually open this application and it will appear in a terminal window.

Installing Wireshark

Here https://www.wireshark.org/download.html
Download the Mac version of the installation

Execution is performed under the Xquartz terminal

sudo wireshark

Note that sudo here is required, otherwise there is no permission to use the WiFi device node.

This is the run interface.

Note that under Mac book, the actual WiFi device node is EN1. Only the packet that captures this NIC is the one between the phone and the smart device.

Start grabbing the bag!

So when your phone is operating, then you can see it's communication package!

Four. PostScript

This architecture can also capture app mobile Internet HTTP communication packets. But this architecture is too complex, requiring Ethernet, WiFi, and Wireshark interfaces to be overly complex. So when using the app for HTTP communication, grab the bag or use Charles Easy (just WiFi)

Windows7 can also implement the same mechanism via virtual WiFi, see
Http://www.cnblogs.com/94YY/archive/2012/03/03/2378865.html

Capture app LAN communication packets under MAC OS X

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.