How to intercept Http traffic [closed]
Asked Answered
R

5

5

I am trying to develop a C# application that will intercept an outgoing Http request and return a result to an old system. We have a legacy system that makes an Http request to a discontinued web service. I need to intercept the out going request and send it to a new web service. When the response comes back I need to manipulate it then send it on to the legacy system. All the code needs to sit on the client machine. I thought something along the lines of http listener would work but I am not getting anywhere with that, any suggestions would be greatly appreciated.

Revenuer answered 23/9, 2009 at 10:6 Comment(0)
R
5

Thanks everyone for your suggestions, here is the answer.

I have used Fiddler2 from Eric Lawrence to act as a proxy for me. I then wrote a Fiddler extension which intercepted the particular Http request I was interested in and voila.

Revenuer answered 23/9, 2009 at 22:35 Comment(1)
I'd be freakin' interested in how do you do that in pure C# and not with any 3rd party tools. But cool solution.Wellread
A
2

If this is running on a Windows server, you can edit the 'hosts'-file, in order to redirect the request to some other server, including the same host (localhost) if you want. There, you can have the intermediate web service translating the request and the response.

Alidia answered 23/9, 2009 at 11:25 Comment(4)
You are right that is an option although I want to do the translating on the PC not the web.Revenuer
Ah, so this legacy application, it is not a server app, but a client app installed on people's pc's?Alidia
Yes that is right, it is an old program that we do not have the source code to so we need to spoof the app into thinking it is connected to the original web serviceRevenuer
If your users are limited in number, and all trust you (such as if you're the IT department, and users are in the same organization), your could do what I proposed, and install the translation-service on each client PC. If not, hacking users' 'hosts'-files probably isn't very popular...Alidia
I
1

Does the legacy system support the specification of an http proxy? If so, that's probably what you want to do - write something that acts as a proxy, and point the old system at it.

Irizarry answered 23/9, 2009 at 10:8 Comment(1)
I know the Http request that is sent but do not have access to modify the old code which why I was thinking of capturing the outgoing request.Revenuer
P
1

If your legacy system can use a proxy as Dav suggests, you might be able to use something like Foxy to do the redirect. I'm not sure, but I believe some software uses IE for HTTP transport so try setting the HTTP proxy in IE on the client machine?

If not I think this a tough problem, as essentially you are trying to intercept and modify TCP/IP traffic, whic I think might only be possible with an advanced firewall or router.

Pryer answered 23/9, 2009 at 10:35 Comment(0)
B
0

tcpmon is an open-source utility for monitoring the data flowing on a TCP connection. tcpmon is used by placing it in-between a client and a server. The client is made to connect to tcpmon, and tcpmon forwards the data to server along-with displaying it in its GUI. https://tcpmon.dev.java.net/

Bonzer answered 9/8, 2010 at 9:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.