diff --git a/print.s b/print.s index 5fcfbd4..74f57cf 100644 --- a/print.s +++ b/print.s @@ -10,6 +10,16 @@ _start: push r14 push r15 + push rax + push rcx + push rdx + push rsi + push rdi + push r8 + push r9 + push r10 + push r11 + mov rdi, 1 lea rsi, [rel msg] mov rbx, rsi @@ -17,9 +27,6 @@ _start: mov r8, qword [rel section_size] ;text_section size shr r8, 2 inc r8 - inc r8 - inc r8 - inc r8 mov r9, 0 ;increment register mov r10, 0 ;increment register xor r10, r10 @@ -47,16 +54,18 @@ _start: and r12, qword [rsp + 16] jz sq_mul_bit_index sq_mul_loop: + ; check if pow is zero shr r11, 1 cmp r11, 0 je decrypt_loop2 + ; square ... mul rax, ; modulo n ... mov r13, qword [rsp + 8] xor rdx, rdx div r13 mov rax, rdx - ; modulo n ... + ; ... and multiply mov r12, r11 and r12, qword [rsp + 16] cmp r12, 0 @@ -68,7 +77,7 @@ _start: xor rdx, rdx div r13 mov rax, rdx - ; modulo n ... + ; end of loop jmp sq_mul_loop decrypt_loop: @@ -84,22 +93,21 @@ _start: sub rax, r10 ; remove index of result (caesar like cypher so 0/42 values are differents) ; unpadding and write back here mov dword [rbx + r9], 0 - mov rcx, r10 mov r15, r10 shr r15, 5 shl r15, 2 - inc rcx + mov rcx, r10 shl rcx, 59 shr rcx, 59 + inc rcx shl rax, cl mov r14, r9 sub r14, r15 add [rbx + r14], eax - mov rcx, rax - shr rcx, 32 + shr rax, 32 cmp r9, 0 je first_block_skip - add [rbx + r14 - 4], ecx + add [rbx + r14 - 4], eax first_block_skip: ; unpadding and write back here @@ -116,6 +124,16 @@ _start: pop r12 ; pop rsa.n 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 r14 pop r13 diff --git a/srcs/rsa.c b/srcs/rsa.c index b1db1e3..ada2d73 100644 --- a/srcs/rsa.c +++ b/srcs/rsa.c @@ -48,6 +48,8 @@ rsa_t rsa_generate_keys(void) { rsa_t rsa; rsa.d = d; rsa.n = n; + //rsa.d = 104320933; + //rsa.n = 2959006679; return rsa; } diff --git a/zreset_woody.sh b/zreset_woody.sh index 8837fa8..96b5522 100755 --- a/zreset_woody.sh +++ b/zreset_woody.sh @@ -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