tags:

views:

64

answers:

2

I need to write an application that will proxify some other application (redirect all network traffic to other proxy server). Just like FreeCap, ProxyCap, etc. Can anyone here points me to API I should be using? Preferably the API that will work under 2k, XP, Vista and W7.

A: 

Can't you use some routing rules for that? If not, write some simple server application in the technology You're in. I'm sure you'll find many examples in the network.

bua
Unfortunately my app should work with various applications and only some of them should be proxified (so I can't make some global proxy for the system). Also it's quite possible that applications I should work with does not has proxy support.There should be some easy way. I mean ProxyCap is only one single .exe file and I see no drivers being installed by it...
FuriCuri
A: 

There are couple of APIs that you may use for this task.

One is LSP (Layered Service Providers) which is a Winsock2 API for writing Service Provider DLLs that can intercept all Winsock calls, like connect() or WSAConnect(). Read more on this here: www.komodia.com

Another is "detours" which is Microsoft's library for intercepting any API call. More on this here: research.microsoft.com/en-us/projects/detours/

Another is so-called IAT (Import Address Table) patching. Don't have a link for this.

Another approach is to write a DLL, name it "wsock32.dll", implement all Winsock2 calls that your target app uses, and simply place it to the folder with the target app. When the app will start, it will use the local "wsock32.dll" instead of the system one.

In general, you want to use some of these APIs to intercept the Winsock's connect() or WSAConnect() calls, do the connection thru the proxy in your code, and return your connected socked to the caller.

You probably want to read about DLL injection as well.

Wizzard