# Windows 不可能提供这种函数

Posted by Honey on July 08, 1999 at 08:13:49:

In Reply to: SOS-有谁知道如何取得Windows Login的密码？ posted by 融融 on July 06, 1999 at 19:57:29:

: 我对API的运用不熟，十分感谢前辈已有Login 的User Name的范例，但才输学浅的我，
: 还想知道如何才可取得密码，感激不尽！
Win32 API不可能提供这种函数 否则哪有安全性可言
这种东西一定得自己写 我只解过Windows 95
Windows 98 解法不一定是这样 我现在用的是Windows 95
也没办法去试试98 ,NT 编码方式又更烦 懒得去解
只提供你95的解法 你可以用RegEdit.exe 之类的编辑器去
开启Windows的登录资料库
在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
\CurrentVersion\Network\LanMan
取得两个Parm开头enc结尾的16进位值 将这个值交给底下程式解码 便可得到答案
若真的要用vb做 读取登录资料库应该会吧
底下这些 你可以把他翻成Basic 或把他编译成dll用vb去link
老实讲 这种问题用C会比Basic好解多了

#include
#define BUFFER 30
int DeCode1(unsigned char *);
int DeCode2(unsigned char *);
int DeCode3(unsigned char *);
int DeCode4(unsigned char *);
int DeCode5(unsigned char *);
int DeCode6(unsigned char *);
int DeCode7(unsigned char *);
int DeCode8(unsigned char *);

main() {

int i;
int te = 0;
unsigned char Demp[] = { 0x15, 0xba, 0x6d, 0x86, 0x73, 0x89, 0xf4, 0x4a };
unsigned short tempshort;
int j = 0;
char hputin[BUFFER];
char *bputin;
printf("Input the byte code (16bit): ");
fgets(hputin, BUFFER, stdin);
bputin = strtok(hputin, " ");
if (hputin[0] != '\n')/*这时密码是""*/
while ((bputin != NULL) && (j < 8)) {
sscanf(bputin, "%hx", &tempshort);
Demp[j++] = tempshort;
bputin = strtok(NULL, " ");
}
/* 开始解码 */
if (!DeCode1(&Demp[0])) te = 1;
if (!DeCode2(&Demp[1])) te = 1;
if (!DeCode3(&Demp[2])) te = 1;
if (!DeCode4(&Demp[3])) te = 1;
if (!DeCode5(&Demp[4])) te = 1;
if (!DeCode6(&Demp[5])) te = 1;
if (!DeCode7(&Demp[6])) te = 1;
if (!DeCode8(&Demp[7])) te = 1;

/* If the password could be decoded, print it */
if (te) printf("The encrypted password is invalid.\n");
else {
printf("The decoded password is: \"");
for (i = 0; i < j; i++)
printf("%c",Demp[i]);
printf("\"\n");
}
}

int DeCode1(unsigned char *mychar) {
int i = 0;
int cletter = 1;
int blockl1 = 1;
int blockl2 = 1;
int retval = 1;
unsigned char code = 0x15;
while((i<256) && (code != *mychar)) {
switch (cletter) {
case 1:
code--; cletter++; break;
case 2:
code += 3; cletter++; break;
case 3:
code--; cletter++; break;
case 4:
code -= 5; cletter++; break;
case 5:
code--; cletter++; break;
case 6:
code+=3; cletter++; break;
case 7:
code--; cletter++; break;
case 8:
cletter = 1;
switch (blockl1) {
case 1:
code += 11; blockl1++; break;
case 2:
code -= 21; blockl1++; break;
case 3:
code += 11; blockl1++; break;
case 4:
blockl1 = 1;
switch (blockl2) {
case 1:
code = 0x75; blockl2++; break;
case 2:
code = 0x55; blockl2++; break;
case 3:
code = 0xb5; blockl2++; break;
case 4:
code = 0x15; blockl2 = 1; break;
}
break;
}
break;
}
i++;
}
if (i == 256) retval = 0;
else *mychar = i + 32;
return retval;
}

int DeCode2(unsigned char *mychar) {
int i = 0;
int cletter = 1;
int blockl1 = 1;
int blockl2 = 1;
int retval = 1;
unsigned char code = 0xba; /* The code for a space */
while((i<256) && (code != *mychar)) {
switch (cletter) {
case 1:
code++; cletter++; break;
case 2:
code -= 3; cletter++; break;
case 3:
code++; cletter++; break;
case 4:
code += 5; cletter++; break;
case 5:
code++; cletter++; break;
case 6:
code -= 3; cletter++; break;
case 7:
code++; cletter++; break;
case 8:
cletter = 1;
switch (blockl1) {
case 1:
code -= 11; blockl1++; break;
case 2:
code -= 11; blockl1++; break;
case 3:
code -= 11; blockl1++; break;
case 4:
blockl1 = 1;
switch (blockl2) {
case 1:
code = 0xda; blockl2++; break;
case 2:
code = 0xfa; blockl2++; break;
case 3:
code = 0x1a; blockl2++; break;
case 4:
code = 0xba;
blockl2 = 1;
break;
}
break;
}
break;
}
i++;
}
if (i == 256) retval = 0;
else *mychar = i + 32;
return retval;
}

int DeCode3(unsigned char *mychar) {
int i = 0;
int cletter = 1;
int blockl1 = 1;
int blockl2 = 1;
int retval = 1;
unsigned char code = 0x6d; /* The code for a space */
while((i<256) && (code != *mychar)) {
switch (cletter) {
case 1:
code--; cletter++; break;
case 2:
code += 3; cletter++; break;
case 3:
code--; cletter++; break;
case 4:
code -= 5; cletter++; break;
case 5:
code--; cletter++; break;
case 6:
code += 3; cletter++; break;
case 7:
code--; cletter++; break;
case 8:
cletter = 1;
switch (blockl1) {
case 1:
code -= 5; blockl1++; break;
case 2:
code += 27; blockl1++; break;
case 3:
code -= 5; blockl1++; break;
case 4:
blockl1 = 1;
switch (blockl2) {
case 1:
code = 0x0d; blockl2++; break;
case 2:
code = 0x2d; blockl2++; break;
case 3:
code = 0xcd; blockl2++; break;
case 4:
code = 0x6d; blockl2 = 1; break;
}
break;
}
break;
}
i++;
}
if (i == 256) retval = 0;
else *mychar = i + 32;
return retval;
}
int DeCode4(unsigned char *mychar) {
int i = 0;
int cletter = 1;
int blockl1 = 1;
int blockl2 = 1;
int retval = 1;
unsigned char code = 0x86; /* The code for a space */
while((i<256) && (code != *mychar)) {
switch (cletter) {
case 1:
code++; cletter++; break;
case 2:
code -= 3; cletter++; break;
case 3:
code++; cletter++; break;
case 4:
code -= 3; cletter++; break;
case 5:
code++; cletter++; break;
case 6:
code -= 3; cletter++; break;
case 7:
code++; cletter++; break;
case 8:
cletter = 1;
switch (blockl1) {
case 1:
code += 13; blockl1++; break;
case 2:
code += 13; blockl1++; break;
case 3:
code += 13; blockl1++; break;
case 4:
blockl1 = 1;
switch (blockl2) {
case 1:
code = 0xe6; blockl2++; break;
case 2:
code = 0xc6; blockl2++; break;
case 3:
code = 0x26; blockl2++; break;
case 4:
code = 0x86; blockl2 = 1; break;
}
break;
}
break;
}
i++;
}
if (i == 256) retval = 0;
else *mychar = i + 32;
return retval;
}

int DeCode5(unsigned char *mychar) {
int i = 0;
int cletter = 1;
int blockl1 = 1;
int blockl2 = 1;
int retval = 1;
unsigned char code = 0x73; /* The code for a space */
while((i<256) && (code != *mychar)) {
switch (cletter) {
case 1:
code--; cletter++; break;
case 2:
code--; cletter++; break;
case 3:
code--; cletter++; break;
case 4:
code += 7; cletter++; break;
case 5:
code--; cletter++; break;
case 6:
code--; cletter++; break;
case 7:
code--; cletter++; break;
case 8:
cletter = 1;
switch (blockl1) {
case 1:
code += 7; blockl1++; break;
case 2:
code -= 25; blockl1++; break;
case 3:
code += 7; blockl1++; break;
case 4:
blockl1 = 1;
switch (blockl2) {
case 1:
code = 0x13; blockl2++; break;
case 2:
code = 0x33; blockl2++; break;
case 3:
code = 0x23; blockl2++; break;
case 4:
code = 0x73; blockl2 = 1; break;
}
break;
}
break;
}
i++;
}
if (i == 256) retval = 0;
else *mychar = i + 32;
return retval;
}

int DeCode6(unsigned char *mychar) {
int i = 0;
int cletter = 1;
int blockl1 = 1;
int blockl2 = 1;
int retval = 1;
unsigned char code = 0x89; /* The code for a space */
while((i<256) && (code != *mychar)) {
switch (cletter) {
case 1:
code--;
cletter++;
break;
case 2:
code += 3;
cletter++;
break;
case 3:
code--;
cletter++;
break;
case 4:
code += 3;
cletter++;
break;
case 5:
code--;
cletter++;
break;
case 6:
code += 3;
cletter++;
break;
case 7:
code--;
cletter++;
break;
case 8:
cletter = 1;
switch (blockl1) {
case 1:
code -= 13;
blockl1++;
break;
case 2:
code += 19;
blockl1++;
break;
case 3:
code -= 13;
blockl1++;
break;
case 4:
blockl1 = 1;
switch (blockl2) {
case 1:
code = 0xe9;
blockl2++;
break;
case 2:
code = 0xc9;
blockl2++;
break;
case 3:
code = 0x29;
blockl2++;
break;
case 4:
code = 0x89;
blockl2 = 1;
break;
}
break;
}
break;
}
i++;
}
if (i == 256) retval = 0;
else *mychar = i + 32;
return retval;
} /* End of DecodeCharSix() */

int DeCode7(unsigned char *mychar) {
int i = 0;
int cletter = 1;
int blockl1 = 1;
int blockl2 = 1;
int retval = 1;
unsigned char code = 0xf4; /* The code for a space */
while((i<256) && (code != *mychar)) {
switch (cletter) {
case 1:
code++; cletter++; break;
case 2:
code++; cletter++; break;
case 3:
code++; cletter++; break;
case 4:
code -= 7; cletter++; break;
case 5:
code++; cletter++; break;
case 6:
code++; cletter++; break;
case 7:
code++; cletter++; break;
case 8:
cletter = 1;
switch (blockl1) {
case 1:
code += 9; blockl1++; break;
case 2:
code -= 23; blockl1++; break;
case 3:
code += 9; blockl1++; break;
case 4:
blockl1 = 1;
switch (blockl2) {
case 1:
code = 0x94; blockl2++; break;
case 2:
code = 0xb4; blockl2++; break;
case 3:
code = 0x54; blockl2++; break;
case 4:
code = 0xf4; blockl2 = 1; break;
}
break;
}
break;
}
i++;
}
if (i == 256) retval = 0;
else *mychar = i + 32;
return retval;
}

int DeCode8(unsigned char *mychar) {
int i = 0;
int cletter = 1;
int blockl1 = 1;
int blockl2 = 1;
int retval = 1;
unsigned char code = 0x4a; /* The code for a space */
while((i<256) && (code != *mychar)) {
switch (cletter) {
case 1:
code++; cletter++; break;
case 2:
code -= 3; cletter++; break;
case 3:
code++; cletter++; break;
case 4:
code += 5; cletter++; break;
case 5:
code++; cletter++; break;
case 6:
code -= 3; cletter++; break;
case 7:
code++; cletter++; break;
case 8:
cletter = 1;
switch (blockl1) {
case 1:
code -= 11;
blockl1++;
break;
case 2:
code += 21; blockl1++; break;
case 3:
code -= 11; blockl1++; break;
case 4:
blockl1 = 1;
switch (blockl2) {
case 1:
code = 0x2a; blockl2++; break;
case 2:
code = 0x0a; blockl2++; break;
case 3:
code = 0xea; blockl2++; break;
case 4:
code = 0x4a; blockl2 = 1; break;
}
break;
}
break;
}
i++;
}
if (i == 256) retval = 0;
else *mychar = i + 32;
return retval;
}

Follow Ups: