interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / qualification / security673 / pure-raw.om

153 lines · 2553 bytes Raw Blame History
1note Fixed hostile native fixtures, emitted as data by seeded Omega. Not a general source translator.
2note Input is the identified212-byte minimal seeded ELF. Only its176-byte ELF header is retained.
3note Modes0 absolute execveat to unassigned inode;1 raw openat;2 raw getpid;3 raw mmap.
4global image uchar 512
5global mode uchar 8
6global pos ulong 1
7global target uchar 192
8text path "/usr/bin/true"
9fn set64 off ulong value ulong to void
10for i ulong 8
11put image add off i uchar and shr value mul i 8 255
12end
13end
14fn word value ulong to void
15p = get pos 0
16for i ulong 4
17put image add p i uchar and shr value mul i 8 255
18end
19put pos 0 add p 4
20end
21fn mov reg ulong value ulong to void
22word or or 3531603968 reg shl value 5
23end
24fn pathptr to void
25mov 1 320
26note MOVK x1,#64,LSL16, giving the fixed RX mapping address0x400140.
27word 4070574081
28end
29fn execraw to void
30mov 0 3
31pathptr
32mov 2 0
33mov 3 0
34mov 4 4096
35mov 8 281
36end
37fn openraw to void
38mov 0 0
39note SUB x0,x0,#100, AT_FDCWD.
40word 3506540544
41pathptr
42mov 2 0
43mov 3 0
44mov 8 56
45end
46fn mmapraw to void
47mov 0 0
48note MOVZ x1,#16384,LSL16 gives1GiB; MAP_PRIVATE|MAP_ANONYMOUS with no file.
49word 3534225409
50mov 2 3
51mov 3 34
52note MOVN x4,#0 gives descriptor-1.
53word 2457862148
54mov 5 0
55mov 8 222
56end
57fn main to int
58if and ne argcnt 2 ne argcnt 3
59ret 90
60end
61if ne argread 1 mode 0 len mode 1
62ret 90
63end
64m = get mode 0
65if or lt m 48 gt m 51
66ret 90
67end
68n = ulong 0
69more = true
70while more
71if eq n len image
72ret 92
73end
74r = read 0 image n sub len image n
75if lt r 0
76ret 91
77end
78if eq r 0
79if ne n 212
80ret 92
81end
82more = false
83else
84n = add n ulong r
85end
86end
87if or ne get image 0 127 ne get image 1 69
88ret 92
89end
90if or ne get image 2 76 ne get image 3 70
91ret 92
92end
93if or ne get image 18 183 ne get image 56 2
94ret 92
95end
96for i ulong 336
97put image add 176 i 0
98end
99set64 96 512
100set64 104 512
101put pos 0 176
102if eq m 48
103execraw
104end
105if eq m 49
106openraw
107end
108if eq m 50
109mov 8 172
110end
111if eq m 51
112mmapraw
113end
114word 3556769793
115want = ulong 1
116if eq m 48
117want = ulong 13
118end
119note CMN x0,#wanted errno; branch to exit0 only for the exact expected refusal.
120word or 2969567263 shl want 10
121word 1409286240
122mov 0 71
123word 335544322
124mov 0 0
125mov 8 93
126word 3556769793
127sz = ulong len path
128for i ulong sz
129put target i get path i
130end
131if eq argcnt 3
132t = argread 2 target 0 len target
133if or le t 0 ge t long len target
134ret 94
135end
136if ne get target 0 47
137ret 94
138end
139sz = ulong t
140end
141for i ulong sz
142put image add 320 i get target i
143end
144p = ulong 0
145while lt p len image
146r = write 1 image p sub len image p
147if le r 0
148ret 93
149end
150p = add p ulong r
151end
152ret 0
153end