I created a small program that will create a boot disk(Intel/AMD) and a very simple text
editor and by simple I mean simple.
The enclosed programs are:
1. The assembly code for the hex array included in the C code...What does it do? Well the code, when
written directly to the floppy device will create a boot disk that has a stack and code space
and the routines that will ennable a very simple text editor...i.e what you type in will be displayed.
.Its very simple program just some 16 bit programming I play with when I'm bored
2. The C code just grabs the hex array(the assembler from above) and writes directly to the floppy device,
hence creating a bootable floppy
A few things to note - This is not a virus or anything like that. If you don't trust me then get an
Intel/AMD manual and check the opcodes, the manuals with bear out that it is what it is.
This will only work on a Linux box because of this line
floppy_desc=open("/dev/fd0",O_RDWR);
But you can port it to Windows if you like
So how do I create a boot disk?
Copy the C code and compile, Insert a floppy into the the drive and execute. Now just boot off the
floppy and start typing when the blue screen appears..
If you don't have a floppy then you could download QEMU and boot it there. Just comment out this line
//floppy_desc=open("/dev/fd0",O_RDWR);
and uncomment this line
floppy_desc=open("dosimage",O_RDWR|O_CREAT, 0666);
Then compile and execute the dosimage file with QEMU like
qemu dosimage
assembly code
The C code
Have fun with it
editor and by simple I mean simple.
The enclosed programs are:
1. The assembly code for the hex array included in the C code...What does it do? Well the code, when
written directly to the floppy device will create a boot disk that has a stack and code space
and the routines that will ennable a very simple text editor...i.e what you type in will be displayed.
.Its very simple program just some 16 bit programming I play with when I'm bored
2. The C code just grabs the hex array(the assembler from above) and writes directly to the floppy device,
hence creating a bootable floppy
A few things to note - This is not a virus or anything like that. If you don't trust me then get an
Intel/AMD manual and check the opcodes, the manuals with bear out that it is what it is.
This will only work on a Linux box because of this line
floppy_desc=open("/dev/fd0",O_RDWR);
But you can port it to Windows if you like
So how do I create a boot disk?
Copy the C code and compile, Insert a floppy into the the drive and execute. Now just boot off the
floppy and start typing when the blue screen appears..
If you don't have a floppy then you could download QEMU and boot it there. Just comment out this line
//floppy_desc=open("/dev/fd0",O_RDWR);
and uncomment this line
floppy_desc=open("dosimage",O_RDWR|O_CREAT, 0666);
Then compile and execute the dosimage file with QEMU like
qemu dosimage
assembly code
Code:
.code16
.section .data
.section .text
.global _start
_start:
movw $0xb800, %ax
movw %ax, %es
movw $0x8000, %ax
movw %ax, %ss
movw $0x0, %sp
movw $0x7000, %ax
movw %ax, %ds
xorw %bx, %bx
call clearit
movb $0, %dh
movb $0, %dl
movb $0, %bh
movb $2, %ah
int $0x10
loop1:
movb $0, %ah
int $0x16
movb $0x0e, %ah
int $0x10
cmpb $0xd, %al
jne bytenotequal
movb $0x3, %ah
movb $0, %bh
int $0x10
incb %dh
movb $0, %bh
movb $2, %ah
int $0x10
bytenotequal:
movb $0x0e, %ah
jmp loop1
clearit:
movb $0x20, %es:(%bx)
incw %bx
movb $0x1f, %es:(%bx)
incw %bx
cmpw $4000, %bx
jle clearit
ret
The C code
Code:
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
char boot_buf[512] = {
0xB8,0x00,0xB8,0x8E,0xC0,0xB8,0x00,0x80,0x8E,0xD0,0xBC,0x00,0x00,0xB8,0x00,0x70,0x8E,0xD8,0x31,0xDB,
0xE8,0x28,0x00,0xB6,0x00,0xB2,0x00,0xB7,0x00,0xB4,0x02,0xCD,0x10,0xB4,0x00,0xCD,0x16,0xB4,0x0E,0xCD,
0x10,0x3C,0x0D,0x75,0x0E,0xB4,0x03,0xB7,0x00,0xCD,0x10,0xFE,0xC6,0xB7,0x00,0xB4,0x02,0xCD,0x10,0xB4,
0x0E,0xEB,0xE2,0x26,0xC6,0x07,0x20,0x43,0x26,0xC6,0x07,0x1F,0x43,0x81,0xFB,0xA0,0x0F,0x7E,0xF0,0xC3
};
int main(int argc, char**argv)
{
int floppy_desc;
boot_buf[510]=0x55;//to make the floppy/image bootable
boot_buf[511]=0xaa;//to make the floppy/image bootable
//floppy_desc=open("/dev/fd0",O_RDWR);
floppy_desc=open("dosimage",O_RDWR|O_CREAT, 0666);
lseek(floppy_desc,0,SEEK_CUR);
write(floppy_desc,boot_buf,512);
close(floppy_desc);
}
Have fun with it