feat(print.s): payload should be OK

This commit is contained in:
gbrochar 2024-06-20 08:45:15 +02:00
parent 78ff534aee
commit 0f93258a88
3 changed files with 31 additions and 11 deletions

38
print.s
View File

@ -10,6 +10,16 @@ _start:
push r14 push r14
push r15 push r15
push rax
push rcx
push rdx
push rsi
push rdi
push r8
push r9
push r10
push r11
mov rdi, 1 mov rdi, 1
lea rsi, [rel msg] lea rsi, [rel msg]
mov rbx, rsi mov rbx, rsi
@ -17,9 +27,6 @@ _start:
mov r8, qword [rel section_size] ;text_section size mov r8, qword [rel section_size] ;text_section size
shr r8, 2 shr r8, 2
inc r8 inc r8
inc r8
inc r8
inc r8
mov r9, 0 ;increment register mov r9, 0 ;increment register
mov r10, 0 ;increment register mov r10, 0 ;increment register
xor r10, r10 xor r10, r10
@ -47,16 +54,18 @@ _start:
and r12, qword [rsp + 16] and r12, qword [rsp + 16]
jz sq_mul_bit_index jz sq_mul_bit_index
sq_mul_loop: sq_mul_loop:
; check if pow is zero
shr r11, 1 shr r11, 1
cmp r11, 0 cmp r11, 0
je decrypt_loop2 je decrypt_loop2
; square ...
mul rax, mul rax,
; modulo n ... ; modulo n ...
mov r13, qword [rsp + 8] mov r13, qword [rsp + 8]
xor rdx, rdx xor rdx, rdx
div r13 div r13
mov rax, rdx mov rax, rdx
; modulo n ... ; ... and multiply
mov r12, r11 mov r12, r11
and r12, qword [rsp + 16] and r12, qword [rsp + 16]
cmp r12, 0 cmp r12, 0
@ -68,7 +77,7 @@ _start:
xor rdx, rdx xor rdx, rdx
div r13 div r13
mov rax, rdx mov rax, rdx
; modulo n ... ; end of loop
jmp sq_mul_loop jmp sq_mul_loop
decrypt_loop: decrypt_loop:
@ -84,22 +93,21 @@ _start:
sub rax, r10 ; remove index of result (caesar like cypher so 0/42 values are differents) sub rax, r10 ; remove index of result (caesar like cypher so 0/42 values are differents)
; unpadding and write back here ; unpadding and write back here
mov dword [rbx + r9], 0 mov dword [rbx + r9], 0
mov rcx, r10
mov r15, r10 mov r15, r10
shr r15, 5 shr r15, 5
shl r15, 2 shl r15, 2
inc rcx mov rcx, r10
shl rcx, 59 shl rcx, 59
shr rcx, 59 shr rcx, 59
inc rcx
shl rax, cl shl rax, cl
mov r14, r9 mov r14, r9
sub r14, r15 sub r14, r15
add [rbx + r14], eax add [rbx + r14], eax
mov rcx, rax shr rax, 32
shr rcx, 32
cmp r9, 0 cmp r9, 0
je first_block_skip je first_block_skip
add [rbx + r14 - 4], ecx add [rbx + r14 - 4], eax
first_block_skip: first_block_skip:
; unpadding and write back here ; unpadding and write back here
@ -116,6 +124,16 @@ _start:
pop r12 ; pop rsa.n pop r12 ; pop rsa.n
pop r12 ; pop rsa.d pop r12 ; pop rsa.d
pop r11
pop r10
pop r9
pop r8
pop rdi
pop rsi
pop rdx
pop rcx
pop rax
pop r15 pop r15
pop r14 pop r14
pop r13 pop r13

View File

@ -48,6 +48,8 @@ rsa_t rsa_generate_keys(void) {
rsa_t rsa; rsa_t rsa;
rsa.d = d; rsa.d = d;
rsa.n = n; rsa.n = n;
//rsa.d = 104320933;
//rsa.n = 2959006679;
return rsa; return rsa;
} }

View File

@ -1 +1 @@
./gen_payload.sh && rm -f woody && ./woody_woodpacker resources/sample64 | less ./gen_payload.sh && rm -f woody && ./woody_woodpacker resources/sample64 > log && xxd woody > dump