C++ 中的互联网使用监控工具

发布于 2024-11-18 20:40:55 字数 1435 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜雨飘雪 2024-11-25 20:40:55

您需要编写一个数据包嗅探器。如果您想编写一个好的数据包嗅探器,那么这是一个相当实用的项目。在网上搜索一下。了解 C/C++ 套接字库以开始使用。下面有一些网站。
此处
此处

You are required to write a packet sniffer. It's quite hands on project if you want a good packet sniffer written. Do a search on the net. Learn about C/C++ socket library to get started. Some website below.
here and
here

七婞 2024-11-25 20:40:55

嗯...在公司的网络代理服务器上执行该功能不是更容易吗?他们中的大多数甚至都有插件来执行这个确切的功能,因此实际上不需要编写任何代码。

Um...wouldn't it be far easier to perform that function on the company's web proxy server? Most of them even have plugins to perform this exact function, so no code would actually need to be written.

盛夏尉蓝 2024-11-25 20:40:55

您可以使用以下代码,优点是它还可以捕获隐私浏览。

CoInitialize(NULL);

LHook = SetWinEventHook(EVENT_OBJECT_FOCUS, EVENT_OBJECT_VALUECHANGE, 0, RT_Browsing_WinEventProc, 0, 0, WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);

那么回调函数将是:

void CALLBACK RT_Browsing_WinEventProc(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime)
{
    IAccessible* pAcc = NULL;
    VARIANT varChild;
    HRESULT hr = AccessibleObjectFromEvent(hwnd, idObject, idChild, &pAcc, &varChild);
    if ((hr == S_OK) && (pAcc != NULL))
    {
        BSTR bstrName, bstrValue;
        pAcc->get_accValue(varChild, &bstrValue);
        pAcc->get_accName(varChild, &bstrName);

        char className[50];
        GetClassNameA(hwnd, className, 50);

        if (bstrName && bstrValue)
        {
            if ((strcmp(className, "Internet Explorer_Server") == 0))
            {
                if (IsValidURL(NULL, bstrValue, NULL) == S_OK)
                {
                    if (bstrValue != E_LastURL)
                    {
                        // bstrValue will hold the new URL (Internet Explorer)
                        E_LastURL = bstrValue;
                    }
                }
            }

            if ((strcmp(className, "Chrome_WidgetWin_1") == 0) && (wcscmp(bstrName, L"Address and search bar") == 0))
            {
                if (IsValidURL(NULL, bstrValue, NULL) == S_OK)
                {
                    if (bstrValue != C_LastURL && bstrValue != L"")
                    {
                        // bstrValue will hold the new URL (Chrome)
                        C_LastURL = bstrValue;
                    }
                }
            }
        }
        pAcc->Release();
    }
}

You can use the following code and the advantage is that it will also capture private browsing.

CoInitialize(NULL);

LHook = SetWinEventHook(EVENT_OBJECT_FOCUS, EVENT_OBJECT_VALUECHANGE, 0, RT_Browsing_WinEventProc, 0, 0, WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);

Then the callback function will be:

void CALLBACK RT_Browsing_WinEventProc(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime)
{
    IAccessible* pAcc = NULL;
    VARIANT varChild;
    HRESULT hr = AccessibleObjectFromEvent(hwnd, idObject, idChild, &pAcc, &varChild);
    if ((hr == S_OK) && (pAcc != NULL))
    {
        BSTR bstrName, bstrValue;
        pAcc->get_accValue(varChild, &bstrValue);
        pAcc->get_accName(varChild, &bstrName);

        char className[50];
        GetClassNameA(hwnd, className, 50);

        if (bstrName && bstrValue)
        {
            if ((strcmp(className, "Internet Explorer_Server") == 0))
            {
                if (IsValidURL(NULL, bstrValue, NULL) == S_OK)
                {
                    if (bstrValue != E_LastURL)
                    {
                        // bstrValue will hold the new URL (Internet Explorer)
                        E_LastURL = bstrValue;
                    }
                }
            }

            if ((strcmp(className, "Chrome_WidgetWin_1") == 0) && (wcscmp(bstrName, L"Address and search bar") == 0))
            {
                if (IsValidURL(NULL, bstrValue, NULL) == S_OK)
                {
                    if (bstrValue != C_LastURL && bstrValue != L"")
                    {
                        // bstrValue will hold the new URL (Chrome)
                        C_LastURL = bstrValue;
                    }
                }
            }
        }
        pAcc->Release();
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文