struct Data
{
unsigned
int
value1;
unsigned
int
value2;
unsigned
int
value3;
unsigned char valuetable[
0x100
];
};
Data data;
/
/
value1 输入的值
char Initvaluetabl(Data
*
data, unsigned
int
value1,
int
value2,
int
value3)
{
unsigned
int
local2
=
value2;
data
-
>value2
=
0
;
data
-
>value3
=
0
;
unsigned char
*
ecx
=
data
-
>valuetable;
for
(
int
i
=
0
; i <
0x100
; i
+
+
)
{
data
-
>valuetable[i]
=
i;
}
unsigned
int
local1
=
0
;
unsigned
int
ebx
=
0
;
do
{
int
edx
=
0
;
unsigned char
*
esi
=
data
-
>valuetable;
unsigned
int
eax
=
((unsigned char
*
)(&value1))[ebx
%
local2]
+
local1;
edx
=
eax
+
esi[ebx];
edx
=
edx
%
256
;
unsigned char cl
=
esi[ebx];
unsigned char al
=
esi[edx];
esi[ebx]
=
al;
esi[edx]
=
cl;
local1
=
edx;
ebx
+
+
;
}
while
(ebx <
0x100
);
return
1
;
}
int
sub_401AF0(Data
*
data, unsigned char
*
xorvalue1,
int
value2, BYTE
*
destvalue)
{
unsigned
int
eax;
for
(
int
i
=
0
; i < value2; i
+
+
)
{
int
index
=
(data
-
>value2
+
1
) &
0xff
;
data
-
>value2
=
index;
data
-
>value3
=
(data
-
>valuetable[index]
+
data
-
>value3) &
0xff
;
unsigned char al
=
data
-
>valuetable[data
-
>value3];
unsigned char dl
=
data
-
>valuetable[index];
data
-
>valuetable[index]
=
al;
data
-
>valuetable[data
-
>value3]
=
dl;
unsigned
int
edx
=
data
-
>valuetable[data
-
>value3];
unsigned
int
eax
=
data
-
>valuetable[data
-
>value2];
edx
+
=
eax;
edx
=
edx
%
256
;
edx
=
data
-
>valuetable[edx];
dl
=
edx ^ xorvalue1[i];
destvalue[i]
=
dl;
return
value2;
}
int
main(
int
argc, char
*
argv[])
{
int
inputvalue
=
0
;
printf(
"请输入:"
);
scanf(
"%d"
, &inputvalue);
Initvaluetabl(&data, inputvalue,
0x4
,
0x300
);
DWORD retvalue;
unsigned
int
xorvalue
=
inputvalue ^
0x55AAAA55
;
sub_401AF0(&data, (unsigned char
*
)&xorvalue,
4
, (BYTE
*
)&retvalue);
printf(
"destvale:%u\r\n"
, retvalue);
system(
"pause"
);
return
0
;
}