Link to home
Start Free TrialLog in
Avatar of Bharpinder Singh
Bharpinder Singh

asked on

c# Record outgoing http(s) requests from system/browser

I want a simple c# code which logs or retrieve last requested url by any of browser in the system.
As per my knowledge (correct me if its wrong) any url requested in browser went to TCP , so any way we tracked before initiated by TCP.
ASKER CERTIFIED SOLUTION
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bharpinder Singh
Bharpinder Singh

ASKER

i used socket
 try
        {
            byte[] input = BitConverter.GetBytes(1);
            byte[] buffer = new byte[4096];
            Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
            s.Bind(new IPEndPoint(IPAddress.Parse(GetLocalIPAddress()), 0));
            s.IOControl(IOControlCode.ReceiveAll, input, null);

            int bytes = 0;
            do
            {
                bytes = s.Receive(buffer);
                if (bytes > 0)
                {

      if(Encoding.UTF8.GetString(buffer, 0, bytes).Contains(WEBSITEURLHERE)){

}
}
 } while (bytes > 0);
        }
        catch (Exception ex)
        {
              File.WriteAllText("C:/Hlogs/DeviceNotFound/httplistner.txt", ex.ToString());
             
        }