-4

次の暗号化ルーチンを解読する方法を知っている人はいますか? 基本的に、私は暗号化キーを持っています。それを入力すると、暗号化される 6 文字の単語を入力するよう求められます。これをどのように復号化しますか?ありがとう

暗号化:

      push edx 
      push ecx 
      not eax 
      add eax,0x04 
      mov edx,eax 
      pop eax 
      xor eax,edx 
      pop edx 
      rol al,1 
      rol al,1
      rol al,1 
      sub al,0x02 
      ret 
4

1 に答える 1

2

編集:新しいコードについては、下部を参照してください

このコードは奇妙ですが、次のようなことをしているようです: (未テスト)

char encrypt(char a, int c)
{
    int t = 4 + ~a;        // the NOT and the ADD
    int t2 = (c ^ t) & 0xFF;  // the XOR
    int t3 = ((t2 << 3) | (t2 >> 5)) & 0xFF;  // the three ROL's
    return (char)(t3 - 2);   // the SUB
}

対応する復号化は、次のようになると思います: (未テスト)

char decrypt(char a, int c)
{
    int t = (a + 2) & 0xFF;
    int t2 = ((t >> 3) | (t << 5)) & 0xFF;
    int t3 = t2 ^ c;
    return (char)~(t3 - 4);
}

アセンブリのどれがこれになる可能性がありますか:(テストされておらず、混乱していません)

add al, 2
ror al, 3   ; or three times ror al, 1
xor al, cl
sub al, 4
not al
ret

または、「ほぼ32ビット」で実行できます:(これもテストされていません)

add eax, 2
ror al, 3
xor eax, ecx
sub eax, 4
not eax
movzx eax, al  ; or just ignore everything but the low byte
ret

何もテストされていませんが、私が使用した一般的な戦略は次のとおりです。左に 3 回転する場合は、右に 3 回転します。4 を足すと、4 を引きます。


鍵とデータを混同してしまったので間違えてしまいました。実際には、次のようにする必要があります: (これもテストされていません)

; eax = EKey, cl = char
decryptB:
  add ecx, 2   // undo sub 2
  ror cl, 3    // undo rol
  not eax      // actually do not
  add eax, 4   // actually do add 4
  xor eax, ecx // undo xor
  ret

キーに対して行われる操作は逆であってはならないためです。

于 2012-07-26T21:20:14.897 に答える