-
Notifications
You must be signed in to change notification settings - Fork 0
/
xor-cipher.asm
85 lines (68 loc) · 1.06 KB
/
xor-cipher.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
global _start
extern strcmp
section .data
code db "-c", 0x0
invalid_args_string db "Invalid argument(s). Refer to 'https://github.com/reimeytal/xor-cipher' for help.", 0xA
len_invalid_args equ $ - invalid_args_string
section .text
_start:
pop eax
cmp eax, 1
je invalid_args
add esp, 4
pop ebx
mov eax, code
call strcmp
cmp eax, 1
je code_func
jmp invalid_args
code_func:
pop ebx
mov eax, 5
mov ecx, 0
int 0x80
push eax
jmp code_loop
code_loop:
mov eax, 3
pop ebx
sub esp, 8
mov ecx, esp
add esp, 8
mov edx, 4
int 0x80
mov ebp, eax
mov ebx, [esp]
mov ecx, [ecx]
xor ecx, [ebx]
sub esp, 8
mov [esp], ecx
mov ecx, esp
add esp, 8
mov edx, ebp
mov eax, 4
mov ebx, 1
int 0x80
sub esp, 4
cmp ebp, 4
jne close_exit
jmp code_loop
jmp exit
invalid_args:
mov eax, 4
mov ebx, 1
mov ecx, invalid_args_string
mov edx, len_invalid_args
int 0x80
mov eax, 1
mov ebx, 2
int 0x80
close_exit:
pop ebx
mov eax, 6
int 0x80
jmp exit
exit:
mov eax, 1
mov ebx, 0
int 0x80