.Net / C # application to directly read the local Cookies files (WinXP SP2 call API: InternetGetCookie no avail) using System; using System.IO; using System.Text; using System.Text.RegularExpressions; using Microsoft.Win32; public class Class1 {Static void main (string [] args) {system.console.writeline ("ET8")); // Support WinXP SP2 System.Console.writeline ("http://bbs.et8.net") System.console.readline ();
[System.Runtime.InteropServices.DllImport ( "wininet.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)] public static extern bool InternetGetCookie (string lpszUrlName, string lpszCookieName, StringBuilder lpszCookieData, ref int lpdwSize );
[System.Runtime.InteropServices.dllimport ("kernel32.dll")] INTERNAL Static Extern Int32 getLastError ();
Public Static String getCookie (String URL) // Win32 API {Int size = 1000; StringBuilder SB = New StringBuilder (size); if (! InternetGetCookie (URL, ", SB, Ref size) {Console.WriteLine (" Error " Code: {0} ", getLastError ());} return sb.tostring ();
public static string GetCookiesFromFiles (string MasterDomain) // Cookies File {string S = null; RegistryKey key = Registry.CurrentUser.OpenSubKey (@ "Software / Microsoft / Windows / CurrentVersion / Explorer / Shell Folders", false); if (key! = NULL) {string val = null; // foreach (string s in key.getvaluenames ()) // {// if (S.toupper () == "cookies") // {// VAL = (string) Key.getValue (s); // Break; ///} //} Val = (String) Key.GetValue ("cookies"); val = system.environment.GetFolderPath (System.Environment.SpecialFolder.cookies); if ( Val! = null) {system.console.writeline ("User Cookies File Directory:" VAL); String [] f = Directory.GetFiles (VAL); string s = null; int i; regex r = new regex (@ "* @" MASTERDOMAIN @ "(/ [/ d /])? /. Txt"); for (i = 0; i