HTTP proxy for interception and tampering of request packets 2-function introduction + Source Code download

Source: Internet
Author: User

ReturnDirectory

Now we have a good idea. The following is how to implement it. Here we use what we are familiar.C #To achieve,C #There is a completeWeb Debugger(Including proxy server implementationHTTPRequest Interception and tampering)Implementation-- Fiddler, FiddlerIt is a free software, so it does not confuse and encrypt the source code.CodeGood readability. All the code below is implemented by referring to his code. Of course, his function is very powerful. We just want to demonstrate it.HTTPThe implementation of the request and interception technology does not need to be fully simulated. Therefore, we simulate the principle of manually simulating a class, a class, a method, and a method, in the simulation process, we can simplify it as much as possible. Some ideas are not clear, or we are indeed repeating the wheel part, so we can directly use his code. If there is time in the future, then we will conduct a detailed analysis and research on its source code. This time, we will not go into some details.

  • HTTP proxy for interception and tampering of request packets
  • HTTP proxy for interception and tampering of request packets 2-function introduction + Source Code download
  • HTTP proxy for interception and tampering of request packets 3-code analysis started
  • HTTP proxy for interception and tampering of request packets 4-read and encapsulate request packets from the client
  • HTTP proxy for interception and tampering of request packets 5-forward request packets to the target server
  • HTTP proxy to intercept and tamper with request packets. 6. Receive and encapsulate response packets from the target server.
  • HTTP proxy to intercept and tamper with request packets. 7. Return the received response packet to the client.
  • HTTP proxy for interception and tampering of request packets 8-automatically set and cancel proxy + Source Code download
  • HTTP proxy for interception and tampering of request packets 8-automatic configuration and cancellation of ADSL dial-up connection proxy + Source Code download
  • HTTP proxy for interception and tampering of request packets 9-demonstration + Source Code download after tampering
  • HTTP proxy for interception and tampering of request packets 10-code analysis of the tampering part of the finale 

First, we will implement a proxy server to completeHTTPRequest Interception

Let's take a look at the implementation to help you understand the code.

CompiledProgram, I copied a copy and put it in the root directory of the appendix.BuildFolder

InBuildFindIcon, double-click to start

Yes. NET Framework 4.0. No download to Microsoft Official Website

Http://www.microsoft.com/zh-cn/download/details.aspx? Id = 17718

After startup

 

At this time, we open the browser, chrome, FirefoxOrIE,Enter www.baidu.com and press Enter.(Enter)

Let's take a look at our main interface without any response. This is normal because we have not set a proxy server.:)

Any browser has a proxy server.IEUsage, hereIE.

OpenIE --Tools-- InternetOption--Connection--LAN Settings

 

Check(Do not select this option for the proxy server that skips the local address),Click Advanced

 

Set according to, httpsAndFTPDo not set it. (The proxy server does not process the two protocols), IPYes127.0.0.1Indicates that the proxy server is on the local machine and the listening port is set8888The current Code is dead.

InIEAfter setting, we will find that other browsers also automatically start to use the proxy server. This is because setting the proxy server is a system function, and each browser opens the same program that sets the proxy server.

Do you find any problems. We don't need to manually set up a proxy server every time we intercept it ,-_-!!! Of course, this is impossible. At the beginning of the tampering section, we will implement the function of automatically setting the proxy server. In this way, when our proxy server is started, then, the proxy server of the local machine is automatically set to itself. When you exit, It is restored to its original state, so that you do not need to manually set it as above.

 

Okay,Everything is ready. At this time, enter the URL in the browser again:Http://www.baidu.com

Check the main interface

On the left side, the session has been monitored. We click the number in the first column1Session,The interface is as follows::

 

View Right

Check the text box above.HTTPRequest Header information.

Check the text box below.HTTPThe response header.

From the two shards, we can clearly see that all the request and response information has been monitored by us.

Let's take a look at the browser. The webpage is opened normally, and the speed is not very slow. It seems that our proxy server is running properly.:).

Appendix (source code + Program)

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.