2

(programmatically in c#) Hi, I want to track and log all web activity and web URL fired on any browser. I know we can do this while using Local proxy server and routing but I want to know that how can we do that without the Local proxy server without the routing.

What i exactly want to develop:- C# wpf Application track all web activity and dump all the data(URL name + Time + Duration) inside the database.

Ankur Tripathi
  • 671
  • 9
  • 35
  • 2
    `What i exactly want to develop:- C# wpf Application track all web activity and dump all the data(URL name + Time + Duration) inside the database.` An application that intercepts traffic and then forwards it to it's destination is called a proxy server. – Joels Elf Apr 08 '16 at 06:12
  • yes but i want to do this without proxy server. – Ankur Tripathi Apr 08 '16 at 06:14
  • What you are describing ***is*** a proxy server. It would probably be easiest to [script wireshark to capture the data you want and dump it into a database](https://wiki.wireshark.org/Tools#Intrusion_Analysis_.2F_SQL_Database_Support). – Joels Elf Apr 08 '16 at 06:20
  • you may find this url usefull [a Link]http://stackoverflow.com/questions/5405895/how-to-check-internet-connection-with-net-c-wpf [a] – Bhavin Jani Apr 08 '16 at 06:45
  • @BhavinJani please read question carefully .. – Ankur Tripathi Apr 08 '16 at 06:51
  • get browser history http://stackoverflow.com/questions/2562092/how-to-access-google-chrome-browser-history-programmatically-on-local-machine this might help – noob Apr 20 '16 at 11:58

1 Answers1

1

class browserlocation { public struct URLDetails {

        public String URL;


        public String Title;
    }
    public static URLDetails[] InternetExplorer()
    {
        Process[] pname = Process.GetProcessesByName("iexplore");
        if (pname.Length == 0) {
            Console.Write("Process is not running ");
        }

        System.Collections.Generic.List<URLDetails> URLs = new System.Collections.Generic.List<URLDetails>();
        var shellWindows = new SHDocVw.ShellWindows();
        foreach (SHDocVw.InternetExplorer ie in shellWindows)
            URLs.Add(new URLDetails() { URL = ie.LocationURL, Title = ie.LocationName });
        return URLs.ToArray();
    }
    public static string GetChromeUrl(Process process)
    {
        if (process == null)
            throw new ArgumentNullException("process");

        if (process.MainWindowHandle == IntPtr.Zero)
            return null;

        AutomationElement element = AutomationElement.FromHandle(process.MainWindowHandle);
        if (element == null)
            return null;

        AutomationElement edit = element.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit));
        return ((ValuePattern)edit.GetCurrentPattern(ValuePattern.Pattern)).Current.Value as string;


    }

}

class program

{

    static void Main(string[] args)
    {
        Console.WriteLine("Internet Explorer: ");
        (new List<browserlocation.URLDetails>(browserlocation.InternetExplorer())).ForEach(u =>
        {
            Console.WriteLine("[{0}]\r\n{1}\r\n", u.Title, u.URL);
        });

        Console.Write("\n press enter to view Chrome current tab URL");
        Console.ReadLine();

        foreach (Process process in Process.GetProcessesByName("chrome"))
        {
            string url = browserlocation.GetChromeUrl(process);
            if (url == null)
                continue;

            Console.WriteLine("CH Url for '" + process.MainWindowTitle + "' is " + url);
            Console.ReadLine();
        } 
    }
}
noob
  • 11
  • 3