-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathhostile.asm
97 lines (69 loc) · 1.32 KB
/
hostile.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
86
87
88
89
90
91
92
93
94
95
96
97
%define ZERO_ARGS 0x0
%define WRITE_SYSCALL_NUM 0x1
%define STDOUT_FILENO 0x1
%define BUF_LEN 0x1
%define LOOP_COUNTER 0x8000
%define RANDOM_NUM 0x100
%macro do_write_syscall ZERO_ARGS
mov rdi, STDOUT_FILENO
mov rdx, BUF_LEN
mov rax, WRITE_SYSCALL_NUM
syscall
%endmacro
%macro func_ret ZERO_ARGS
xor rax, rax
ret
%endmacro
%macro save_regs ZERO_ARGS
push rbx
push rdx
push rcx
push rdi
push rsi
push r8
push r9
push r10
%endmacro
%macro restore_regs ZERO_ARGS
pop r10
pop r9
pop r8
pop rsi
pop rdi
pop rcx
pop rdx
pop rbx
%endmacro
%macro clear_regs ZERO_ARGS
xor rax,rax
xor rbx,rbx
xor rcx,rcx
xor rdx,rdx
xor rdi,rdi
xor rsi,rsi
xor r8,r8
xor r9,r9
xor r10,r10
%endmacro
section .text
global pi_hostile_fclose, pi_get_hostile_len
pi_hostile_fclose:
save_regs
clear_regs
push RANDOM_NUM
lea rsi, [ rsp ]
mov rcx, LOOP_COUNTER
loop_start:
inc byte [ rsi ]
push rcx
do_write_syscall
pop rcx
loop loop_start
loop_end:
pop rax
restore_regs
func_ret
pi_hostile_fclose_end:
pi_get_hostile_len:
mov rax, pi_hostile_fclose_end - pi_hostile_fclose
ret