-
Notifications
You must be signed in to change notification settings - Fork 1
/
sixnix.asm
88 lines (73 loc) · 1.32 KB
/
sixnix.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
BITS 64
osabi 0x09 ; FreeBSD
global _start
_start:
mov rax,6 ; BSD: sys_close / Linux: sys_lstat
mov rdi,arky
mov rsi,statz
syscall
cmp rax,0
je linux
;
; SunOS code
;
mov rdi,sunz
mov rax,12
syscall
cmp rax,0
jne bsd
mov rdi,1
mov rsi,suno
mov rdx,sunob
mov rax,4
syscall
jmp bexit
;
; BSD code
;
bsd:
mov rdi,1
mov rsi,obsd
mov rdx,obyte
mov rax,4 ; sys_write
syscall
bexit:
mov rdi,69
mov rax,1 ; sys_exit
syscall
linux:
;
; Linux code
;
mov rdi,1
mov rsi,linz
mov rdx,lbyte
mov rax,1 ; sys_write
syscall
mov rax,60 ; sys_exit
mov rdi,42
syscall
section .data
sunz db '/system',0
arky db '/proc/self/stat',0
abyte equ $-arky
suno db 'SunOS',0x0a
sunob equ $-suno
obsd db 'BSD',0x0a
obyte equ $-obsd
linz db 'Linux',0x0a
lbyte equ $-linz
statz db 144 ; sizeof(struct stat)
section .note.openbsd.ident
align 2
dd 8
dd 4
dd 1
db 'OpenBSD',0
dd 0
align 2
section .note.netbsd.ident
dd 7,4,1
db 'NetBSD',0
db 0
dd 200000000