Итак, я пытаюсь выяснить, как расшифровать строку переменных. Я понимаю, как работает регистр и как работает этот код, но мне не удается выполнить обратный инжиниринг моего кода.
Я не понимаю, что делает команда ror, и я понимаю, что xor - это только 1 + 1= 0, 1 + 0 = 1, 0 + 0 = 0.
Я пытался И операцию, я пытался вычесть другое число. Я пытался понять команду ROR, но я не уверен, насколько это важно.
.386
.model flat, stdcall
.stack 4096
ExitProcess PROTO, dwExitCode: DWORD
.data
; define your variables here
ptxt BYTE "Plain text for testing", 0
ctxt BYTE 5dh,0a5h,66h,0a7h,06h,9ch,39h,0e6h,
0a5h,5dh,0feh,0a5h,66h,0a7h,06h,9ch,
5dh,0c6h,38h,66h,66h,0e5h,0e6h,06h,58h,
9ch,0fbh,0e6h,46h,0d0h,27h,46h,30h,
5dh,0feh,0c6h,38h,66h,66h,0e5h,0e6h,
06h,58h,9ch,0
.code
main PROC
; Modify this to call sub_dec with ctxt
; instead of ptxt
; puts address of pxtext into stack
push OFFSET ctxt
; puts number of variables into stack
push LENGTHOF ctxt
call sub_dec
main ENDP
sub_enc PROC
; puts ebp into stack
push ebp
; makes the sp value go into ebp
mov ebp, esp
; Retrieve the arguments
; sets the loop counter to 17
mov ecx, [ebp+8]
; subtracts by 1 because we don't care about the null
dec ecx
; moves the value of the base pointer into esi, which is the register that holds the next direction
mov esi, [ebp+12]
; Encryption
xor eax, eax
MORE:
; whatever esi is pointing to goes into eax
mov al, [esi]
; adds 27 to eax
add al, 27
; compares the content of eax with 189
xor al, 189
; rotates the set z and s flag
ror al, 3
; updates the memory so eax value gets changed and encrypts the letter.
mov [esi], al
; moves esi to the next byte
inc esi
loop MORE
pop ebp
ret 8
sub_enc endp
sub_dec PROC
push ebp
mov ebp, esp
; Retrieve the arguments
mov ecx, [ebp+8]
dec ecx
mov esi, [ebp+12]
; Put your decryption code here
; Copy the encryption loop and modify it
xor eax, eax
MORE
mov al, [esi]
add al, 27
and al, 189
ror al, 3
mov [esi], al
inc esi
loop MORE
pop ebp
ret 8
sub_dec endp
end main
Invoke ExitProcess, 0
Таким образом, sub_enc является просто примером шифрования. Теперь я хочу расшифровать строку ptxt. Я знаю три строки, которые мне нужно изменить:
add al, 27
and al, 189
ror al, 3
Я украл из цикла шифрования, чтобы понять, как этот процесс работает в моем реестре, но я думаю, что я не понимаю, как выяснить,заключается в том, как обнаружить шаблон, который преобразует символы ASCII в символы ASCII, которые что-то излагают. Если это имеет смысл?