Results 1 to 2 of 2

Thread: NSALogger.exe

  1. #1
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts

    NSALogger.exe

    First I had the idea of a webcam watching myself, analyzing my behaviour, which would then eventually scream "stop procrastinating" at me, but I realized it should way simpler to detect procrastination without an AI + webcam (lol).

    Kinda simply by checking the foreground window on Windows Desktop, writing the title of the active window it to a file and then let a process like B3 parse/analyze the output:

    Code:
    01.04.2016 05:56:45:182 window=0000000000550A72 process_id= 3292 processImageName=C:\Users\lama1_000\Desktop\ActiveWindowLogger\activeWindowLogger.exe title=C:\Users\lama1_000\Desktop\ActiveWindowLogger\activeWindowLogger.exe
    01.04.2016 05:57:43:285 window=0000000000060758 process_id= 4156 processImageName=C:\Program Files (x86)\Notepad++\notepad++.exe title=C:\Users\lama1_000\Desktop\ActiveWindowLogger\ActiveWindowLogger.cpp - Notepad++
    01.04.2016 05:57:46:111 window=0000000000060758 process_id= 4156 processImageName=C:\Program Files (x86)\Notepad++\notepad++.exe title=C:\Users\lama1_000\Desktop\ActiveWindowLogger\build.bat - Notepad++
    01.04.2016 05:57:47:374 window=0000000000060758 process_id= 4156 processImageName=C:\Program Files (x86)\Notepad++\notepad++.exe title=C:\Users\lama1_000\Desktop\SoftEngineJSPart2\index.html - Notepad++
    01.04.2016 05:57:47:778 window=0000000000060758 process_id= 4156 processImageName=C:\Program Files (x86)\Notepad++\notepad++.exe title=C:\Users\lama1_000\Desktop\SoftEngineJSPart2\SoftEngine.js - Notepad++
    01.04.2016 05:57:50:050 window=0000000000060758 process_id= 4156 processImageName=C:\Program Files (x86)\Notepad++\notepad++.exe title=C:\Users\lama1_000\Desktop\SoftEngineJSPart2\babylon.math.js - Notepad++
    01.04.2016 05:57:51:212 window=0000000000550A72 process_id= 3292 processImageName=C:\Users\lama1_000\Desktop\ActiveWindowLogger\activeWindowLogger.exe title=C:\Users\lama1_000\Desktop\ActiveWindowLogger\activeWindowLogger.exe
    01.04.2016 05:57:59:420 window=000000000006097C process_id= 6980 processImageName=C:\Users\LAMA1_~1\AppData\Local\Temp\Process Explorer64.exe title=Process Explorer - Sysinternals: www.sysinternals.com [ADMIN\lama1_000]
    01.04.2016 05:58:06:575 window=00000000002F09E0 process_id= 6980 processImageName=C:\Users\LAMA1_~1\AppData\Local\Temp\Process Explorer64.exe title=i_view32.exe:108 Properties
    01.04.2016 05:58:15:898 window=000000000006097C process_id= 6980 processImageName=C:\Users\LAMA1_~1\AppData\Local\Temp\Process Explorer64.exe title=Process Explorer - Sysinternals: www.sysinternals.com [ADMIN\lama1_000]
    01.04.2016 05:58:20:388 window=0000000000030254 process_id= 6004 processImageName=C:\Program Files (x86)\Mozilla Firefox\firefox.exe title=lied_17.mp3 - Mozilla Firefox
    01.04.2016 05:58:22:055 window=000000000006097C process_id= 6980 processImageName=C:\Users\LAMA1_~1\AppData\Local\Temp\Process Explorer64.exe title=Process Explorer - Sysinternals: www.sysinternals.com [ADMIN\lama1_000]
    01.04.2016 05:58:27:651 window=0000000000030254 process_id= 6004 processImageName=C:\Program Files (x86)\Mozilla Firefox\firefox.exe title=lied_17.mp3 - Mozilla Firefox
    01.04.2016 05:58:30:731 window=0000000000030254 process_id= 6004 processImageName=C:\Program Files (x86)\Mozilla Firefox\firefox.exe title=A Sci-Fi Short Film HD: "At the End" - by Jason J. Whitmore - YouTube - Mozilla Firefox
    01.04.2016 05:58:38:049 window=0000000000010106 process_id= 1056 processImageName=C:\Windows\explorer.exe title=
    01.04.2016 05:58:38:151 window=0000000000070710 process_id= 1056 processImageName=C:\Windows\explorer.exe title=ActiveWindowLogger
    01.04.2016 05:58:39:060 window=0000000000010106 process_id= 1056 processImageName=C:\Windows\explorer.exe title=
    01.04.2016 05:58:40:924 window=000000000004007E process_id= 1056 processImageName=C:\Windows\explorer.exe title=Dieser PC
    01.04.2016 05:58:42:031 window=0000000000550A72 process_id= 3292 processImageName=C:\Users\lama1_000\Desktop\ActiveWindowLogger\activeWindowLogger.exe title=C:\Users\lama1_000\Desktop\ActiveWindowLogger\activeWindowLogger.exe
    It could even make statistics like "Your day on PC: 40% Hackernews, 30% Steam Chat, 10% 4Chan, 10% Visual Studio, ...". Which would show on a glance how much time you wasted. I don't know about you all, but I mostly just can't get shit done.

    So I started just wrote a bit Win32 code to log the window titles, which is only about 50 lines of C code:

    PHP Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <windows.h>
    #include <Winternl.h>
    #define SLEEPTIME 50 // in milliseconds

    // my gcc didn't know about QueryFullProcessImageNameA(), prolly remove in some other gcc versions or Visual Studio
    extern "C" WINBASEAPI BOOL WINAPI QueryFullProcessImageNameA(HANDLE hProcessDWORD dwFlagsLPSTR lpExeNamePDWORD lpdwSize);

    int main() {
        
    HWND windowoldWindow;
        
    char title[4096], oldTitle[sizeof(title)]; // whatever the fuckin limit is, i dont wanna hit one
        
    SYSTEMTIME lt;
        
    int first 1;
        while (
    1) {
            
    window GetForegroundWindow();
            if (
    window == NULL) { // happens when focusing the taskbar
                
    Sleep(SLEEPTIME);
                continue;
            }
            
    int ret GetWindowText(windowtitlesizeof(title));
            if (
    ret == 0) {
                
    //printf("NO WINDOW TEXT!\n");
            
    }
            if ( ! 
    first) { // don't compare against uninitialized oldWindow and oldTitle
                
    int windowTitleChanged strcmp(titleoldTitle) != 0;
                
    int hwndChanged window != oldWindow;
                
    //printf("titleChanged = %d hwndChanged  = %d\n", windowTitleChanged, hwndChanged);
                
    if ( !windowTitleChanged && !hwndChanged ) {
                    
    Sleep(SLEEPTIME);
                    continue;
                }
            }
            
    //HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTONULL);
            
    GetLocalTime(&lt);
            
    DWORD windowProcessID;
            
    GetWindowThreadProcessId(window, &windowProcessID);
            
    HANDLE windowProcess OpenProcess(PROCESS_QUERY_INFORMATION PROCESS_VM_READFALSEwindowProcessID);
            
    char processImageName[4096];
            
    DWORD stringSize sizeof(processImageName);
            
    QueryFullProcessImageNameA(windowProcess0processImageName, &stringSize);        
            
    printf("%.2d.%02d.%02d %02d:%02d:%02d:%03d window=%p process_id=%5d processImageName=%s title=%s\n",
                
    lt.wDaylt.wMonthlt.wYearlt.wHourlt.wMinutelt.wSecondlt.wMilliseconds,
                
    windowwindowProcessID,
                
    processImageName,
                
    title
            
    );
            
    strncpy(oldTitletitlesizeof(title));
            
    oldWindow window;
            
    first 0;
            
    Sleep(SLEEPTIME);
        }

    Compiling: g++ NSALogger.cpp -o NSALogger.exe
    pause



    Maybe somebody wants to push the idea further, I imagined stuff like:
    - if serious procrastination is detected (e.g. playing Agar.io for 2 hours), then firefox.exe will be terminated
    - have some computer voice commenting on your interactions, kinda as fun gag
    - having a website where this data gets send to, with a search function through the window titles to find ppl to chat with
    timescale 0.01

  2. The Following 3 Users Say Thank You to kung foo man For This Useful Post:

    Jared (26th June 2016),Mitch (1st April 2016),voron00 (1st April 2016)

  3. #2
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Oh oh no self control!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •