| 
 
TA的每日心情|  | 开心 2023-9-4 15:59
 | 
|---|
 签到天数: 445 天 [LV.9]以坛为家II | 
 
 
 楼主|
发表于 2022-7-1 00:17:39
|
显示全部楼层 
| 复制代码int pafish_exists_file(char * filename) {
    DWORD res = INVALID_FILE_ATTRIBUTES;
    if (pafish_iswow64() == TRUE) {
        void *old = NULL;
        // Disable redirection immediately prior to calling GetFileAttributes.
        if (pafish_disable_wow64_fs_redirection(&old) ) {
            res = GetFileAttributes(filename);
            // Ignoring MSDN recommendation of exiting if this call fails.
            pafish_revert_wow64_fs_redirection(old);
        }
    }
    else {
        res = GetFileAttributes(filename);
    }
    return (res != INVALID_FILE_ATTRIBUTES) ? TRUE : FALSE;
}
int gensandbox_common_names() {
    DWORD dwSize = MAX_PATH;
    char szLogicalDrives[MAX_PATH] = {0};
    DWORD dwResult = GetLogicalDriveStrings(dwSize,szLogicalDrives);
    BOOL exists;
    if (dwResult > 0 && dwResult <= MAX_PATH)
    {
        char* szSingleDrive = szLogicalDrives;
        char filename[MAX_PATH] = {0};
        while(*szSingleDrive)
        {
            if (GetDriveType(szSingleDrive) != DRIVE_REMOVABLE ) {
                snprintf(filename, MAX_PATH, "%ssample.exe",szSingleDrive);
                exists = pafish_exists_file(filename);
                if (exists) return TRUE;
                
                snprintf(filename, MAX_PATH, "%smalware.exe",szSingleDrive);
                exists = pafish_exists_file(filename);
                if (exists) return TRUE;
            }
            szSingleDrive += strlen(szSingleDrive) + 1;
        }
    }
    return FALSE;
}
 | 
 |