ntlogon.cpp
6.68 KB
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
typedef BOOL (*CheckUserGroupPasswordFn)( char * userin,char *password,char *machine,char *group,int lodom);
CheckUserGroupPasswordFn CheckUserGroupPassword = 0;
bool CheckAD()
{
HMODULE hModule = LoadLibrary("Activeds.dll");
if (hModule)
{
FreeLibrary(hModule);
return true;
}
return false;
}
bool CheckNetapi95()
{
HMODULE hModule = LoadLibrary("netapi32.dll");
if (hModule)
{
FreeLibrary(hModule);
return true;
}
return false;
}
bool CheckDsGetDcNameW()
{
HMODULE hModule = LoadLibrary("netapi32.dll");
if (hModule)
{
FARPROC test=NULL;
test=GetProcAddress( hModule, "DsGetDcNameW" );
FreeLibrary(hModule);
if (test) return true;
}
return false;
}
bool CheckNetApiNT()
{
HMODULE hModule = LoadLibrary("radmin32.dll");
if (hModule)
{
FreeLibrary(hModule);
return true;
}
return false;
}
int main(int argc, char* argv[])
{
char pszBuffer[256];
char pszBuffer2[256];
char pszBuffer3[256];
char pszBuffer4[256];
int locdom;
if (argc<5)
{
printf("Enter user name : ");
gets(pszBuffer);
printf("\nEnter password : ");
gets(pszBuffer2);
printf("\n");
printf("Enter group : ");
gets(pszBuffer3);
printf("\n");
printf("loc=1 dom=3 local+domain=3 : ");
gets(pszBuffer4);
printf("\n");
if (0==strcmp("", pszBuffer))
{
return 0;
}
if (0==strcmp("", pszBuffer2))
{
return 0;
}
if (0==strcmp("", pszBuffer3))
{
return 0;
}
if (0==strcmp("", pszBuffer4))
{
return 0;
}
}
else
{
strcpy(pszBuffer,argv[1]);
strcpy(pszBuffer2,argv[2]);
strcpy(pszBuffer3,argv[3]);
strcpy(pszBuffer4,argv[4]);
}
locdom=atoi(pszBuffer4);
if (!CheckNetapi95() && !CheckNetApiNT())
{
printf("Netapi not found,radmin32.dll is missing \n");
}
///////////////////////////////////////
////// BASIC LOCAL GROUPS
BOOL returnvalue;
{
returnvalue=false;
printf("\nTrying authlogonuser.dll \n");
printf("This only works on XP> \n");
printf("test is runnning as application and not a service \n");
printf("------------------------ \n");
printf("------------------------ \n");
HMODULE hModule = LoadLibrary("authlogonuser.dll");
if (hModule)
{
CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" );
HRESULT hr = CoInitialize(NULL);
returnvalue=CheckUserGroupPassword(pszBuffer,pszBuffer2,"test",pszBuffer3,locdom);
CoUninitialize();
FreeLibrary(hModule);
}
else printf("authlogonuser.dll not found");
if (returnvalue==1) printf("based on auth.dll user has access ");
else printf("based on authlogonuser.dll user has NO access ");
}
if (returnvalue==1) printf("\n-------------------------\n");
if (returnvalue==1) printf("For testing we cont, but access was already granted\n");
if (returnvalue==1) printf("-------------------------\n");
returnvalue=false;
printf("\nTrying auth.dll \n");
printf("------------------------ \n");
printf("------------------------ \n");
HMODULE hModule = LoadLibrary("auth.dll");
if (hModule)
{
CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" );
HRESULT hr = CoInitialize(NULL);
returnvalue=CheckUserGroupPassword(pszBuffer,pszBuffer2,"test",pszBuffer3,locdom);
CoUninitialize();
FreeLibrary(hModule);
}
else printf("auth.dll not found");
if (returnvalue==1) printf("based on auth.dll user has access ");
else printf("based on auth.dll user has NO access ");
if (returnvalue==1) printf("\n-------------------------\n");
if (returnvalue==1) printf("For testing we cont, but access was already granted\n");
if (returnvalue==1) printf("-------------------------\n");
returnvalue=false;
if (CheckAD())
{
printf("\nTrying authaddll \n");
printf("------------------------ \n");
printf("------------------------ \n");
HMODULE hModule = LoadLibrary("authad.dll");
if (hModule)
{
CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" );
HRESULT hr = CoInitialize(NULL);
returnvalue=CheckUserGroupPassword(pszBuffer,pszBuffer2,"test",pszBuffer3,locdom);
CoUninitialize();
FreeLibrary(hModule);
}
else printf("authad.dll not found");
if (returnvalue==1) printf("based on authad.dll user has access ");
else printf("based on authad.dll user has NO access ");
}
if (returnvalue==1) printf("\n-------------------------\n");
if (returnvalue==1) printf("For testing we cont, but access was already granted\n");
if (returnvalue==1) printf("-------------------------\n");
if (locdom==2 || locdom==3)
{
returnvalue=false;
OSVERSIONINFO VerInfo;
VerInfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (!GetVersionEx (&VerInfo)) // If this fails, something has gone wrong
{
return FALSE;
}
if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && VerInfo.dwMajorVersion == 4)
{
if (CheckAD() && CheckDsGetDcNameW())
{
printf("\nTrying ldapauthNT4 .dll \n");
printf("------------------------ \n");
printf("------------------------ \n");
HMODULE hModule = LoadLibrary("ldapauthnt4.dll");
if (hModule)
{
CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" );
HRESULT hr = CoInitialize(NULL);
returnvalue=CheckUserGroupPassword(pszBuffer,pszBuffer2,"test",pszBuffer3,locdom);
CoUninitialize();
FreeLibrary(hModule);
}
else printf("ldapauthnt4.dll not found");
if (returnvalue==1) printf("based on ldapauthnt4.dll user has access ");
else printf("based on ldapauthnt4.dll user has NO access ");
}
}
if (returnvalue==1) printf("\n-------------------------\n");
if (returnvalue==1) printf("For testing we cont, but access was already granted\n");
if (returnvalue==1) printf("-------------------------\n");
returnvalue=false;
if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && VerInfo.dwMajorVersion >= 5)
{
if (CheckAD())
{
printf("\nTrying ldapauth .dll \n");
printf("------------------------ \n");
printf("------------------------ \n");
HMODULE hModule = LoadLibrary("ldapauth.dll");
if (hModule)
{
CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" );
HRESULT hr = CoInitialize(NULL);
returnvalue=CheckUserGroupPassword(pszBuffer,pszBuffer2,"test",pszBuffer3,locdom);
CoUninitialize();
FreeLibrary(hModule);
}
else printf("ldapauth.dll not found");
if (returnvalue==1) printf("based on ldapauth.dll user has access ");
else printf("based on ldapauth.dll user has NO access ");
}
}
}
printf("Enter to quit ");
gets(pszBuffer);
return 0;
}