http webrequest interception

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kevinyy
    New Member
    • Jul 2008
    • 77

    http webrequest interception

    How would i go about intercepting a httpwebrequest sent from a browser (firefox/IE mainly) and then applying some code, then pass it through back to the browser for it to receive the altered request.
    -Kevin
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    What have you tried so far?

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      That sounds like the task of a proxy server.
      Investigate creating your own proxy servers and you will get lots of good ideas on how to do it.

      Comment

      • Kevinyy
        New Member
        • Jul 2008
        • 77

        #4
        Originally posted by Plater
        That sounds like the task of a proxy server.
        Investigate creating your own proxy servers and you will get lots of good ideas on how to do it.
        No, i would like to avoid proxy server, what im trying to do is intercept a httpwebrequest call from a browser for example, i type in www.google.com in my browser and my program catches the request processes it, and then sends the httpwebrequest( as if it were the browser sending the request originally.

        I trying to draw out a plan, b4 investing time into to something that isnt rationale.

        Using VC# w/ .NET 2.0 for this project.

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          Hmm, well you're going to have to use some Win32_API to do that I think.
          You can either try at the network card level, like the way a packet sniffer would work, or you can try at the process level and find out what handles/tcp connections the desired program (IE, FF, etc) have active and try to attach onto them. I have no idea how to do either, I only know about the proxy server idea.

          Comment

          • Kevinyy
            New Member
            • Jul 2008
            • 77

            #6
            Originally posted by Plater
            Hmm, well you're going to have to use some Win32_API to do that I think.
            You can either try at the network card level, like the way a packet sniffer would work, or you can try at the process level and find out what handles/tcp connections the desired program (IE, FF, etc) have active and try to attach onto them. I have no idea how to do either, I only know about the proxy server idea.
            Yeah i was thinking about something like this, thanks

            Any more input from other parties is welcome :D

            Comment

            • Kevinyy
              New Member
              • Jul 2008
              • 77

              #7
              Is system.net.sock ets namespace the lower level of the httpwebrequest? and if so, would i be able to use that instead of some win32API?

              Comment

              • Plater
                Recognized Expert Expert
                • Apr 2007
                • 7872

                #8
                Well a socket is lower then httpwebrequest. Not sure its low enough to be usefull, but you might be able to attach onto other sockets with it.

                Comment

                • Kevinyy
                  New Member
                  • Jul 2008
                  • 77

                  #9
                  Originally posted by Plater
                  Well a socket is lower then httpwebrequest. Not sure its low enough to be usefull, but you might be able to attach onto other sockets with it.
                  Anything lower that comes to mind? for API use, Ive looked through pinvoke.net and i cant seem to find anything particular.

                  Comment

                  • Frinavale
                    Recognized Expert Expert
                    • Oct 2006
                    • 9749

                    #10
                    Originally posted by Kevinyy
                    Anything lower that comes to mind? for API use, Ive looked through pinvoke.net and i cant seem to find anything particular.
                    I would look into IIS ISAPI Filters....I seem to remember that you could implement one of these to modify requests sent to the server before it gets to your ASP.NET application.

                    This kind of thing is usually used for encrypting/decrypting data being sent between server and client...Since the ISAPI Filters sit between your application and the outside world, it leaves it up to them to do all of the heavy work.

                    There was an article on MSDN that explained how to do this...I don't have it bookmarked any more though. I think it falls under building secure web applications... or secure web services or something.

                    -Frinny

                    Comment

                    • Kevinyy
                      New Member
                      • Jul 2008
                      • 77

                      #11
                      Originally posted by Frinavale
                      I would look into IIS ISAPI Filters....I seem to remember that you could implement one of these to modify requests sent to the server before it gets to your ASP.NET application.

                      This kind of thing is usually used for encrypting/decrypting data being sent between server and client...Since the ISAPI Filters sit between your application and the outside world, it leaves it up to them to do all of the heavy work.

                      There was an article on MSDN that explained how to do this...I don't have it bookmarked any more though. I think it falls under building secure web applications... or secure web services or something.

                      -Frinny
                      Oh, im not trying to alter requests sent to my asp server, im trying to modify regualr http request sent by a browser. Trying to catch the request as it is being sent out, alter it, then, resume the send.

                      Comment

                      • Plater
                        Recognized Expert Expert
                        • Apr 2007
                        • 7872

                        #12
                        Originally posted by Kevinyy
                        Oh, im not trying to alter requests sent to my asp server, im trying to modify regualr http request sent by a browser. Trying to catch the request as it is being sent out, alter it, then, resume the send.
                        And this boggles my mind that you don't want to be a proxy server.
                        Do you not want the browsers to have to be configured?
                        You could look into creating a plugin for FF and a browser helper object for IE?

                        Comment

                        • Frinavale
                          Recognized Expert Expert
                          • Oct 2006
                          • 9749

                          #13
                          Originally posted by Kevinyy
                          Oh, im not trying to alter requests sent to my asp server, im trying to modify regualr http request sent by a browser. Trying to catch the request as it is being sent out, alter it, then, resume the send.
                          It's confusing me as well....
                          You could look into using Tamper Data that is a plugin for FireFox....I use this all the time to test my websites.

                          I don't know what's out there for IE....

                          I didn't recommend this before because I'm not exactly sure what you are trying to do....

                          Comment

                          • Kevinyy
                            New Member
                            • Jul 2008
                            • 77

                            #14
                            Originally posted by Plater
                            And this boggles my mind that you don't want to be a proxy server.
                            Do you not want the browsers to have to be configured?
                            You could look into creating a plugin for FF and a browser helper object for IE?
                            Originally posted by Frinavale
                            It's confusing me as well....
                            You could look into using Tamper Data that is a plugin for FireFox....I use this all the time to test my websites.

                            I don't know what's out there for IE....

                            I didn't recommend this before because I'm not exactly sure what you are trying to do....
                            Ok all im trying to do is have my program delopy on a pc and Catch webrequest sent out by browsers, when it catches the request my program will do w/e to the requested address and continue to send the request as if the browser itself was sending it, then have the altered address show up in browser. ex. get ip from the address requested etc.....
                            No plugin's or anything like that, im trying to program this to work "out of the box" for the user.

                            Comment

                            • Kevinyy
                              New Member
                              • Jul 2008
                              • 77

                              #15
                              Hmm, ive been thinking about this all day, and here's an idea,
                              1. still need to intercept the URL requested by browsers and stop the request.
                              2. then i plan to get the ip of the request URL, add it to the hosts file (window>system3 2>drivers>etc>h osts) assigning a "new URL" name in the hosts file,
                              3. then shove that "new" URL into the browsers address bar send the new request.

                              Mainly, well, so far im like killing myself on finding a way to accomplish step 1. :[

                              Comment

                              Working...