Charles
:
is commonly used in MAC interception of network packets, in the development of iOS, in order to debug and server-side network communication protocols, often need to intercept network packets to analyze. By setting himself up as a network Access Proxy for the system, Charles enables all network access requests to be done through it, enabling the interception and analysis of network packets.
Charles ' main features include:
- Support SSL Proxy. You can intercept requests that analyze SSL.
- Supports flow control. You can simulate slow networks and long wait times (latency) of requests.
- Supports Ajax debugging. JSON or XML data can be automatically formatted for easy viewing.
- Supports AMF debugging. The flash Remoting or Flex Remoting information can be formatted for easy viewing.
- Support to re-send network requests, convenient back-end debugging.
- Support for modifying network request parameters.
- Supports interception and dynamic modification of network requests.
- Check whether Html,css and RSS content meet the standards.
Install Charles & Introduction:
1, the official website (http://www.charlesproxy.com) Download the latest version of the Charles installation package;
2, if you need to intercept the analysis of the SSL protocol related content. Then you need to install Charles's CA certificate. The steps are as follows:
- Go to Http://www.charlesproxy.com/ssl.zip to download the CA certificate file.
- After extracting the zip file, double-click the. crt file in it, and then select "Always Trust" in the popup menu.
3. Charles Packet View: "Structure" & "Sequence"
- The structure view classifies network requests by the domain name that is accessed.
- The sequence view sorts network requests by the time they are accessed.
Original link: http://www.devtang.com/blog/categories/ios/
-------------
TODO:
--Collection & Sharing
1. Download Charles Grab Bag tool (IOS):-- has cracked, can be used directly!
: Http://yun.baidu.com/s/1GvxaY
2. intercept the network packet on the iphone: "- -Main
1.[clarles Settings] Opens the agent function for Charles. On Charles's menu bar, choose "Proxy", "proxy Settings"
Fill in the proxy port 8888, and tick "Enable transparent HTTP proxying" to complete the setup on Charles.
2.[iphone Settings] will get to the computer IP address (terminal $ifconfig en0-- View the IP address of the NIC En0 ), under the same LAN of the iphone, set the HTTP proxy protocol
Fill in the IP of the computerand write to Port 8888.
3. Intercepting SSL information:
Charles does not intercept SSL by default, and if you want to intercept all SSL network requests on a Web site, you can right-click on the request and select SSL Proxy.
4, analog slow network to obtain data:
Why: When it comes to iphone development, we often need to simulate a slow network or a high-latency network to test whether the application behaves properly under the mobile network.
TODO: In Charles's menu, select "Proxy", "throttle Setting", tick "Enable throttling", and you can set the throttle The type of preset.
5. Modify the contents of the network request :
Sometimes in order to debug the server interface, we need to repeatedly try different parameters of the network request.
Charles provides: "Modification of Network Requests" and "re-send" functions. Simply right-click on a previous network request and select "Edit" to create an editable network request.
PS: We can modify any information about the request, including the URL address, port, parameters, etc., then click "Execute" to send the modified network request (as shown in).
Charles supports us in modifying and sending this request several times, which is very convenient for us and the server-side debugging interface.
6, Filter Network Request "----Main
Typically, we need to filter the network requests and only monitor requests sent to the specified directory server. We have 2 ways to do this.
Fill in the filter bar in the middle of the main interface with keywords that need to be filtered out. For example, the address of our server is: http://www.baidu.com, then only need to fill in the filter bar Baidu.
In Charles's menu bar, select "Proxy", "Recording Settings", then select the Include column, select Add an item, and then fill in the protocol, host address, port number you want to monitor. This allows you to intercept only the packets of the target site.
TODO: ["Proxy", "recording Setting", "Include", "Add") What to fill in: http, baidu.com
--------------------
"NetEase News"--data interception:
[C.m.163.com/nc/article/headline/t1348647853363/0-100.html]
- (void) LoadData {nsurl*url = [Nsurl urlwithstring:@"http://c.m.163.com/nc/article/headline/T1348647853363/0-20.html"]; Nsurlrequest*request =[Nsurlrequest Requestwithurl:url]; [Nsurlconnection sendasynchronousrequest:request queue:[nsoperationqueue Mainqueue] CompletionHandler:^ (Nsurlresponse *response, NSData *data, Nserror *connectionerror) {Nsdictionary*dict = [nsjsonserialization jsonobjectwithdata:data options:0Error:null];//NSLog (@ "%@", dict); //get the array of the first item in the dictionary//use Keyenumerator.nextobject to quickly traverse a dictionary's key valuesNSLog (@"%@", Dict.keyEnumerator.nextObject); //Dictionary key value of the tips, for NetEase news, you can directly filter out the first layer of the DictionaryNsarray *array =Dict[dict.keyenumerator.nextobject]; NSLog (@"%@", array); //iterate through arrays, dictionary to modelNsmutablearray *arraym =[Nsmutablearray ArrayWithCapacity:array.count]; [Array Enumerateobjectsusingblock:^ (nsdictionary *dict, Nsuinteger idx, BOOL *stop) {News*news =[News newswithdict:dict]; [Arraym Addobject:news]; NSLog (@"%@", News.objectinfo); }]; }];}
|--> Copyright (c) Bing Ma.
|--> GitHub RUL: https://github.com/SpongeBob-GitHub
IOS # Charles intercepts network data