Welcome to the exciting world of Proxyee, an HTTP proxy server library written in Java! Whether you want to capture HTTP/HTTPS packets or implement a Man-in-the-Middle (MITM) attack, Proxyee has got you covered. This blog post serves as a user-friendly guide on setting up and using Proxyee effectively.

Introduction

Proxyee is a powerful Java library that supports various protocols, including HTTP, HTTPS, and WebSockets, while allowing you to modify packet data. This makes it a great tool for developers who want to analyze web traffic or implement security features.

Setting Up Proxyee

To use Proxyee in your Java project, you need to add the following dependency to your Maven configuration:



    com.github.monkeywie
    proxyee
    1.7.6

Basic Usage

  • Starting a Simple HTTP Proxy:
  • You can start a simple HTTP proxy server with the following line of code:

    
      new HttpProxyServer().start(9999);
      
  • Implementing MITM Proxy:
  • To capture and modify responses from specific websites like Baidu, you would set up a MITM proxy as follows:

    
      HttpProxyServerConfig config =  new HttpProxyServerConfig();
      config.setHandleSsl(true);
      new HttpProxyServer()
          .serverConfig(config)
          .proxyInterceptInitializer(new HttpProxyInterceptInitializer() {
              @Override
              public void init(HttpProxyInterceptPipeline pipeline) {
                  pipeline.addLast(new FullResponseIntercept() {
                      @Override
                      public boolean match(HttpRequest httpRequest, HttpResponse httpResponse, HttpProxyInterceptPipeline pipeline) {
                          return HttpUtil.checkUrl(pipeline.getHttpRequest(), "^www.baidu.com$") && isHtml(httpRequest, httpResponse);
                      }
                      @Override
                      public void handleResponse(HttpRequest httpRequest, FullHttpResponse httpResponse, HttpProxyInterceptPipeline pipeline) {
                          System.out.println(httpResponse.toString());
                          System.out.println(httpResponse.content().toString(Charset.defaultCharset()));
                          httpResponse.headers().set("handel", "edit head");
                          httpResponse.content().writeBytes("script>alert('hello proxyee')/script".getBytes());
                      }
                  });
              }
          })
          .start(9999);
      

Understanding the Code: An Analogy

Imagine you are a waiter at a restaurant, and your job is to take orders from customers and relay them to the kitchen. The customers are the HTTP requests, and the kitchen is the web server. In a typical scenario, you simply take the order and bring back the food (responses) as is. However, in a MITM situation, you can also peek at what’s being prepared and even modify the dish before serving it. That’s what Proxyee allows you to do with web traffic!

HTTPS Support

To capture HTTPS traffic, you need to import a CA certificate (found at src/resources/ca.crt) into your trusted root certification authorities. Follow these notes:

  • For Android devices, you may need to enter your lock screen password when installing the certificate.
  • If using Android version 7 or above, you’ll need to generate your own certificates, as user-installed certificates will not be trusted.

Troubleshooting Tips

If you face issues while using Proxyee, consider the following troubleshooting ideas:

  • Make sure that the CA certificates are correctly imported into your trusted list.
  • When modifying code, ensure that you handle the SSL aspects carefully to avoid connection drops.
  • Check your firewall settings if the proxy doesn’t seem to work.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Additional Features

Proxyee allows for customizable authentication and pre-proxy support. You can set up basic authentication or create your own authentication method by implementing the HttpProxyAuthenticationProvider interface.

Conclusion

Proxyee opens the door to powerful web traffic manipulation and analysis. With its easy setup and a robust set of features, you can significantly enhance the capabilities of your Java applications.

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

×