Venix/86 Emulation
A step in the Venix Source Restoration Project
What was Venix?
Wait, Unix on MMU-less 8088/8086
So insecure, unprotected and crazy
But…. The best thing going at the time
Why?
Why?
Why?
Venix Source Restoration Project
Venix Source Restoration Project
Venix/86 Under the Hood
a.out, old school Unix
Creating an a.out file
Idealized a.out memory layout
First Steps
Installation Media
Figure out memory layout
a.out format
Layout discovery program
#include <stdio.h>
int data=12;
int bss;
int main(argc, argv)
int argc;
char *argv[];
{
int i;
printf("stack 0x%x\n", (unsigned)&i);
printf("data 0x%x\n", (unsigned)&data);
printf("bss 0x%x\n", (unsigned)&bss);
printf("main 0x%x\n", (unsigned)&main);
}
Turns out… there’s 4 types
Note: cc -z XXX sets the size of the stack to use in the program and moves where the stack starts.
Tiny binary a.out layout
Small a.out binary layout
Emulators
Reverse Engineering System Calls
Venix/86 System call : example of read(2)
.comm _errno,2
.globl _errno
.globl _read
_read:
push bp
mov bp,sp
mov bx,#3
mov ax,*4(bp)
mov dx,*6(bp)
mov cx,*8(bp)
int 0xf1
jcxz L001
mov _errno,cx
L001:
pop bp
ret
System Call number in bx
Arg1 ax
Arg2 dx
Arg3 cx
Jump to kernel: INT F1
CX != 0 -> error, returned in cx
Fork / Exec
The Manual
The Manual
intro(2) man page
read(2) man page
Venix/86 System call : example of read(2)
.comm _errno,2
.globl _errno
.globl _read
_read:
push bp
mov bp,sp
mov bx,#3
mov ax,*4(bp)
mov dx,*6(bp)
mov cx,*8(bp)
int 0xf1
jcxz L001
mov _errno,cx
L001:
pop bp
ret
System Call number in bx
Arg1 ax
Arg2 dx
Arg3 cx
Jump to kernel: INT F1
CX != 0 -> error, returned in cx
vm86venix read call
Helper routines
Status
Next Steps
Questions