Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ redirect outgoing connections

Is there any way in C++ on windows to monitor a program and redirect any outgoing requests it makes on a specific port? I have a simple C++ http proxy and want it to be able to automatically redirect all browser requests on port 80 through itself.

like image 608
Ilia Choly Avatar asked Feb 06 '10 17:02

Ilia Choly


1 Answers

The simple way to do it is to create a Windows kernel hook to trap socket requests and reroute them to your proxy.

Some useful documentation on this is:

http://www.internals.com/articles/apispy/apispy.htm

If you're using Windows Vista or better, consider Windows Filtering Platform (WFP):

http://www.microsoft.com/whdc/device/network/wfp.mspx

Also consider looking at Detours (commercial) and EasyHook (free). They significantly simplify the process of writing hooks and redirecting API calls (both Win32 and Application).

like image 78
0xfe Avatar answered Sep 24 '22 13:09

0xfe