Brandon
2014-08-11 21:35:43
So.. I was messing around with making payloads and decided to try running some in Simba.. Turns out it works.. I converted all the code to HEX/OP-codes using: https://defuse.ca/online-x86-assembler.htm#disassembly
Get Current Process ID (doesn't seem to work.. Works in C/C++ though):
It just shows 2 msg boxes..
I tried writing my own but it didn't work:
Does it work for anyone else? Or just me :l
Get Current Process ID (doesn't seem to work.. Works in C/C++ though):
type fptr = Function: Integer;
var
get_pid: array of byte;
begin
get_pid := [$31, $DB, $55, $89, $E5, $64, $A1, $24, $00, $00, $00, $89, $EC, $5D, $C3, $E8, $EE, $FF, $FF, $FF];
writeln(fptr(get_pid)());
end.
xor ebx, ebx
func:
push ebp
mov ebp, esp
mov eax, dword [FS:0x20]
mov esp, ebp
pop ebp
ret
call func
It just shows 2 msg boxes..
type fptr = Function: Integer;
var
msg_then_access_violate: array of byte;
msg_then_exit_process: array of byte;
both: array of byte;
I: Integer;
begin
msg_then_access_violate := [$31, $db, $eb, $55, $64, $8b, $7b,
$30, $8b, $7f, $0c, $8b, $7f, $1c, $8b, $47, $08, $8b, $77, $20, $8b, $3f,
$80, $7e, $0c, $33, $75, $f2, $89, $c7, $03, $78, $3c, $8b, $57, $78, $01,
$c2, $8b, $7a, $20, $01, $c7, $89, $dd, $8b, $34, $af, $01, $c6, $45, $8b,
$4c, $24, $04, $39, $0e, $75, $f2, $8b, $4c, $24, $08, $39, $4e, $04, $75,
$e9, $8b, $7a, $24, $01, $c7, $66, $8b, $2c, $6f, $8b, $7a, $1c, $01, $c7,
$8b, $7c, $af, $fc, $01, $f8, $c3, $68, $4c, $69, $62, $72, $68, $4c, $6f,
$61, $64, $e8, $9c, $ff, $ff, $ff, $31, $c9, $66, $b9, $33, $32, $51, $68,
$75, $73, $65, $72, $54, $ff, $d0, $50, $68, $72, $6f, $63, $41, $68, $47,
$65, $74, $50, $e8, $7d, $ff, $ff, $ff, $59, $59, $59, $68, $f0, $86, $17,
$04, $c1, $2c, $24, $04, $68, $61, $67, $65, $42, $68, $4d, $65, $73, $73,
$54, $51, $ff, $d0, $53, $53, $53, $53, $ff, $d0];
msg_then_exit_process := [$31, $d2, $b2, $30, $64, $8b, $12, $8b, $52, $0c, $8b, $52, $1c, $8b, $42,
$08, $8b, $72, $20, $8b, $12, $80, $7e, $0c, $33, $75, $f2, $89, $c7, $03,
$78, $3c, $8b, $57, $78, $01, $c2, $8b, $7a, $20, $01, $c7, $31, $ed, $8b,
$34, $af, $01, $c6, $45, $81, $3e, $46, $61, $74, $61, $75, $f2, $81, $7e,
$08, $45, $78, $69, $74, $75, $e9, $8b, $7a, $24, $01, $c7, $66, $8b, $2c,
$6f, $8b, $7a, $1c, $01, $c7, $8b, $7c, $af, $fc, $01, $c7, $68, $79, $74,
$65, $01, $68, $6b, $65, $6e, $42, $68, $20, $42, $72, $6f, $89, $e1, $fe,
$49, $0b, $31, $c0, $51, $50, $ff, $d7];
both := msg_then_access_violate;
SetLength(both, length(msg_then_access_violate) + length(msg_then_exit_process));
for I := Length(msg_then_access_violate) To High(Both) Do
both[I] := msg_then_exit_process[I - Length(msg_then_access_violate)];
fptr(both)();
writeln(fptr(msg_then_access_violate)());
writeln(fptr(msg_then_exit_process)());
end.
I tried writing my own but it didn't work:
cmp_str_insensitive:
push ebp
mov ebp, esp
mov esi, [ebp + 0x08]
mov edi, [ebp + 0x0C]
mov edx, [ebp + 0x10]
xor ecx, ecx
cmp_str_for:
mov ax, [esi + ecx * 0x02]
mov bx, [edi + ecx * 0x02]
inc ecx
cmp ax, 0x61
jl cmp_ins_cont_1
cmp ax, 0x7A
jg cmp_ins_cont_1
sub ax, 0x20
cmp_ins_cont_1:
cmp bx, 0x61
jl cmp_ins_cont_2
cmp bx, 0x7A
jg cmp_ins_cont_2
sub bx, 0x20
cmp_ins_cont_2:
cmp ax, bx
jne cmp_mem_diff
cmp ax, 0
je cmp_mem_same
jmp cmp_str_for
cmp_mem_diff:
mov eax, 0
jmp cmp_mem_done
cmp_mem_same:
mov eax, 1
cmp_mem_done:
mov esp, ebp
pop ebp
ret 0x0C
isK32:
push ebp
mov ebp, esp
mov eax, [ebp + 0x08]
sub esp, 26
mov edx, esp
mov word ptr[edx + 0x00], 75
mov word ptr[edx + 0x02], 69
mov word ptr[edx + 0x04], 82
mov word ptr[edx + 0x06], 78
mov word ptr[edx + 0x08], 69
mov word ptr[edx + 0xE0], 76
mov word ptr[edx + 0x10], 51
mov word ptr[edx + 0x12], 50
mov word ptr[edx + 0x14], 46
mov word ptr[edx + 0x16], 68
mov word ptr[edx + 0x18], 76
mov word ptr[edx + 0x1A], 76
mov word ptr[edx + 0x00], 0
add esp, 26
mov esp, ebp
pop ebp
ret
Get_Kernel32_Address:
push ebp
mov ebp, esp
xor edx, edx
mov edx, [FS:0x30]
mov edx, [edx + 0x0C]
mov edx, [edx + 0x14]
gka_for:
mov esi, [edx + 0x28]
cmp esi, 0
je fail
push edx
push esi
call isK32
pop esi
pop edx
cmp eax, 1
je success
mov edx, [edx]
jmp gka_for
fail:
mov eax, 0
jmp done
success:
mov eax, [edx + 0x10]
done:
mov esp, ebp
pop ebp
ret
call Get_Kernel32_Address
Does it work for anyone else? Or just me :l