int _tmain(int argc, _TCHAR* argv[])
{

	PWTS_SESSION_INFO pSessionInfo;
	DWORD dwSessionInfo=0;
	WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,0,1,&pSessionInfo,&dwSessionInfo);
	
	printf("[*] Windows DACL Enumeration Project - https://github.com/nccgroup/WindowsDACLEnumProject - WinStationsAndDesktopsPerms\n");
	printf("[*] NCC Group Plc - http://www.nccgroup.com/ \n");
	printf("[*] -h for help \n");

	SetPrivilege(GetCurrentProcess(),SE_DEBUG_NAME);
	
	DWORD dwSessID = 0;
	ProcessIdToSessionId(GetCurrentProcessId(),&dwSessID);
	fprintf(stdout,"[i] Running in session %d\n",dwSessID);

	EnumWindowStations(&EnumWindowStationProc,NULL);

	
	return 0;
}
int WINAPI
wWinMain(__in HINSTANCE, __in_opt HINSTANCE, __in wchar_t*, __in int)
{
    // usage is:
    //   condor_softkill.exe <target_pid> [debug_output_file]
    //
    // so ensure we have at least one argument
    //
    if (__argc < 2) {
        return SOFTKILL_INVALID_INPUT;
    }

    // get the pid and verify its not bogus input or a zero
    //
    target_pid = _wtoi(__wargv[1]);
    if (target_pid == 0) {
        return SOFTKILL_INVALID_INPUT;
    }

    // see if a debug output file was given
    //
    if (__argc > 2) {
        wchar_t * opt = L"a";
        wchar_t * pszFile = __wargv[2];
        debug_fp = _wfopen(pszFile, opt);
        if (debug_fp == NULL) {
            return SOFTKILL_INVALID_INPUT;
        }

        // if we have a debug log, print out the time and pid of the softkill request
        SYSTEMTIME tim;
        GetLocalTime(&tim);
        debug(L"%02d/%02d/%02d %02d:%02d:%02d ****** Softkill requested for pid=%d\n",
              tim.wMonth, tim.wDay, tim.wYear % 100,
              tim.wHour, tim.wMinute, tim.wSecond,
              target_pid);
    }

    // first look for the window in the current window station, if that doesn't
    // work, try enumerating all window stations
    if ( ! check_this_winsta()) {
        if ((EnumWindowStations(check_winsta, NULL) == FALSE) && (GetLastError() != ERROR_SUCCESS)) {
            debug(L"EnumWindowStations error: %u\n", GetLastError());
        }
    }

    if (!window_found) {
        return SOFTKILL_WINDOW_NOT_FOUND;
    }
    else if (!message_posted) {
        return SOFTKILL_POST_MESSAGE_FAILED;
    }
    else {
        return SOFTKILL_SUCCESS;
    }
}
Example #3
0
VOID
GetWindowTitles(
    PTASK_LIST_ENUM te
    )
{
    //
    // enumerate all windows and try to get the window
    // titles for each task
    //
    EnumWindowStations( EnumWindowStationsFunc, (LPARAM)te );
}
Example #4
0
BOOL
vncService::SelectInputWinStation()
{
	home_window_station = GetProcessWindowStation();
	return EnumWindowStations(&WinStationEnumProc, NULL);
}