ASM x86 を使用して文字列を難読化する簡単なプログラムを作成しました。ユーザーは目的の文字列を入力し、Ekey
難読化する文字列のキー ( ) を選択する必要があります。(シフト演算子またはテーブルルックアップで左右のビットローテーションをエミュレートできることは知っていますが、ASMに慣れようとしています)
サブルーチンにCdecl
パラメーター ( EKey
& ) を渡すなど、受け入れられている C++ 標準の呼び出し手順を採用するようにプログラムを変更しようとしています。tempChar
obfuscate
何時間にもわたる調査にもかかわらず、私はうまくいかなかったので、もう少し経験のある人が親切にガイダンスを提供してくれることを期待してここに来ました.
関連する関数は次のとおりです。
void obfusc_chars (int length, char EKey)
{ char tempChar; // char temporary store
for (int i = 0; i < length; i++) // encrypt characters one at a time
{
tempChar = OChars [i]; //
__asm { //
push eax // save register values on stack to be safe
push ecx // pushes first string on stack
//
movzx ecx,tempChar // set up registers (Nb this isn't StdCall or Cdecl)
lea eax,EKey //
call obfuscate // obfuscate the character
mov tempChar,al //
//
pop ecx // restore original register values from stack
pop eax //
}
EChars [i] = tempChar; // Store encrypted char in the encrypted chars array
}
return;
そしてobfuscate
サブルーチン:
// Inputs: register EAX = 32-bit address of Ekey,
// ECX = the character to be encrypted (in the low 8-bit field, CL).
// Output: register EAX = the encrypted value of the source character (in the low 8-bit field, AL).
__asm {
obfuscate: push esi
push ecx
mov esi, eax
and dword ptr [esi], 0xFF
ror byte ptr [esi], 1
ror byte ptr [esi], 1
add byte ptr [esi], 0x01
mov ecx, [esi]
pop edx
x17:ror dl, 1
dec ecx
jnz x17
mov eax, edx
add eax, 0x20
xor eax, 0xAA
pop esi
ret
}
お読みいただきありがとうございます。