Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!



   642

C# intercepting network traffic

by niggersmurfing - 14 September, 2022 - 09:36 PM
This post is by a banned member (niggersmurfing) - Unhide
29
Posts
2
Threads
2 Years of service
#1
Hey! I want to make a program which catches an applications requests in real time and auto replies to them with modified responses. Anyone got any idea how would I go with that in c#?

By this I mean something like http debugger pro's/fiddler's auto reply.
This post is by a banned member (chanchan) - Unhide
chanchan  
Supreme
235
Posts
51
Threads
5 Years of service
#2
you could setup a webserver on localhost which forwards all the traffic you arent interested in and modifies the traffic you are interested in. you could set your system proxy to point at this webserver so that most application's requests will be sent to it.

however, if an application uses https this will not work as the application will see that your webserver doesnt have trusted certificates and wont connect to it. there are work arounds for this, but it doesnt always end up working.

also, some applications bypass the system proxy so it can be harder to get them to make requests to your webserver instead of their real targets.
This post is by a banned member (niggersmurfing) - Unhide
29
Posts
2
Threads
2 Years of service
#3
(This post was last modified: 15 September, 2022 - 05:59 PM by niggersmurfing. Edited 1 time in total.)
(14 September, 2022 - 09:52 PM)chanchan Wrote: Show More
you could setup a webserver on localhost which forwards all the traffic you arent interested in and modifies the traffic you are interested in. you could set your system proxy to point at this webserver so that most application's requests will be sent to it.

however, if an application uses https this will not work as the application will see that your webserver doesnt have trusted certificates and wont connect to it. there are work arounds for this, but it doesnt always end up working.

also, some applications bypass the system proxy so it can be harder to get them to make requests to your webserver instead of their real targets.


I found fiddlercore, made some code, if i make a request manually to the target i get hte modified response, but when the software does the request it stays the same, fiddlercore got a cert, but fiddler everywhere not even showing the request meanwhile http debugger pro does, and can bypass with that, but I really need the c# way, not debuggers. Here's my code, did I fuck up the code?
Code:
using System;
using System.Text;
using System.Threading.Tasks;
using Fiddler;

namespace FiddlerCore_ModifyResponse
{
    class Program
    {
        static async Task Main(string[] args)
        {
          
            FiddlerApplication.Prefs.SetBoolPref("fiddler.certmaker.bc.Debug", true);

            BCCertMaker.BCCertMaker certProvider = new BCCertMaker.BCCertMaker();
            CertMaker.oCertProvider = certProvider;
            FiddlerApplication.ResponseHeadersAvailable += FiddlerApplication_ResponseHeadersAvailable;

            Fiddler.FiddlerApplication.BeforeResponse += FiddlerApplication_BeforeResponse;
            

        

            FiddlerCoreStartupSettings startupSettings =
                                            new FiddlerCoreStartupSettingsBuilder()
                                                .ListenOnPort(8887)
                                                .DecryptSSL()
                                                .RegisterAsSystemProxy()
                                                .Build();


            FiddlerApplication.Startup(startupSettings);
            Console.WriteLine("\nPROXY set, waiting for request");
            Console.WriteLine("enter to remove proxy");

            Console.ReadLine();
            FiddlerApplication.Shutdown();
        }


        private static void FiddlerApplication_BeforeResponse(Session oSession)
        {

          


            if (oSession.fullUrl.Contains("xyz"))
            {
                oSession.bBufferResponse = true;
                oSession.utilDecodeResponse();

              
                oSession.utilDecodeResponse();
                var oBody = System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes);
              
                oBody = "522b349923da5dc131887d";
              
                oSession.utilSetResponseBody(oBody);
            }
  
        }

        

        private static void FiddlerApplication_ResponseHeadersAvailable(Session oSession)
        {

            if (oSession.fullUrl.Contains("xyz"))
            {
                oSession.bBufferResponse = true;
            }
        }
    }
}

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 1 Guest(s)