By Cyrus Peikari, Anton Chuvakin
Book Price: $44.95 USD
£31.95 GBP
PDF Price: $35.99
Cover | Table of Contents | Colophon
debug -r command (the -u command provides a disassembly).
UMULLLS R9, R0,
R0, R0 (discussed in Chapter 4). Without first being
familiar with the ARM instruction set, you probably would not guess
that it performs an unsigned multiply long if the LS status is set,
and then updates the status flags accordingly after it
executes.
ioctl( ) interfaces, proprietary network
protocols, or potentially hostile foreign binaries—rather than toward
the theft of algorithms or bypassing copy protections.-C
(demangle), -D (dynamic symbols),
-g (global/external symbols),
-u (only undefined symbols),
--defined-only (only defined
symbols), and -a (all symbols,
including debugger hints).55 push ebp 89 E5 movl %esp, %ebp 83 EC ?? subl ??, %esp ... 89 EC movl %ebp, %esp ; could also be C9 leave C3 ret
#include <sys/ptrace.h>
#include <stdio.h>
int main( int argc, char **argv ) {
if ( ptrace(PTRACE_TRACEME, 0, NULL, NULL) < 0 ) {
/* we are being debugged */
while (1) ;
}
printf("Success: PTRACE_TRACEME works\n");
return(0);
}asm("\t xorl %ebx, %ebx \n" /* PTRACE_TRACEME = 0 */
"\t movl $26, %ea \n" /* from /usr/include/asm.unistd.h */
"\t int 80 \n" /* system call trap */
);typedef struct { /* ELF File Header */
unsigned char e_ident[16]; /* Magic number */
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 addr */
Elf32_Off e_phoff; /* Prog hdr tbl file offset */
Elf32_Off e_shoff; /* Sect hdr tbl file offset */
Elf32_Word e_flags; /* Processor-specific flags */
Elf32_Half e_ehsize; /* ELF header size in bytes */
Elf32_Half e_phentsize; /* Prog hdr tbl entry size */
Elf32_Half e_phnum; /* Prog hdr tbl entry count */
Elf32_Half e_shentsize; /* Sect hdr tbl entry size */
Elf32_Half e_shnum; /* Sect hdr tbl entry count */
Elf32_Half e_shstrndx; /* Sect hdr string tbl idx */
} Elf32_Ehdr;
.text:00011224 MOV R4, R0 .text:00011228 ADD R0, SP, #0xC .text:0001122C BL CString::CString(void) .text:00011230 ADD R0, SP, #8 .text:00011234 BL CString::CString(void) .text:00011238 ADD R0, SP, #4 .text:0001123C BL CString::CString(void) .text:00011240 ADD R0, SP, #0x10 .text:00011244 BL CString::CString(void) .text:00011248 ADD R0, SP, #0 .text:0001124C BL CString::CString(void) .text:00011250 LDR R1, =unk_131A4 .text:00011254 ADD R0, SP, #0xC .text:00011258 BL CString::operator=(ushort) .text:0001125C LDR R1, =unk_131B0 .text:00011260 ADD R0, SP, #8 .text:00011264 BL CString::operator=(ushort) .text:00011268 LDR R1, =unk_131E0 .text:0001126C ADD R0, SP, #4 .text:00011270 BL ; CString::operator=(ushort) .text:00011274 LDR R1, =unk_1321C .text:00011278 ADD R0, SP, #0 .text:0001127C BL CString::operator=(ushort) .text:00011280 MOV R1, #1 .text:00011284 MOV R0, R4 .text:00011288 BL CWnd::UpdateData(int) .text:0001128C LDR R1, [R4,#0x7C] .text:00011290 LDR R0, [R1,#-8] .text:00011294 CMP R0, #8 .text:00011298 BLT loc_112E4 .text:0001129C BGT loc_112E4 .text:000112A0 LDR R0, [SP,#0xC] .text:000112A4 BL wcscmp .text:000112A8 MOV R2, #0 .text:000112AC MOVS R3, R0 .text:000112B0 MOV R0, #1 .text:000112B4 MOVNE R0, #0 .text:000112B8 ANDS R3, R0, #0xFF .text:000112BC LDRNE R1, [SP,#8] .text:000112C0 MOV R0, R4 .text:000112C4 MOV R3, #0 .text:000112C8 BNE loc_112F4 .text:000112CC LDR R1, [SP,#4] .text:000112D0 B loc_112F4 .text:000112E4 .text:000112E4 loc_112E4 ; CODE XREF: .text:00011298 .text:000112E4 ; .text:0001129C .text:000112E4 LDR R1, [SP] .text:000112E8 MOV R3, #0 .text:000112EC MOV R2, #0 .text:000112F0 MOV R0, R4 .text:000112F4 .text:000112F4 loc_112F4 ; CODE XREF: .text:000112C8 .text:000112F4 ; .text:000112D0 .text:000112F4 BL CWnd_ _MessageBoxW
// lunch.cpp : Overflowing the stomach buffer
#include <stdafx.h>
#include <stdio.h>
#include <string.h>
void bigmac(char *p);
int main(int argc, char *argv[])
{
bigmac("Could you supersize that please?"); // size > 9 overflows
return 0;
}
void bigmac(char *p)
{
char stomach[10]; //limit the size to 10
strcpy(stomach, p);
printf(stomach);
}// lunch.cpp : Overflowing the stomach buffer
#include <stdafx.h>
#include <stdio.h>
#include <string.h>
void bigmac(char *p);
int main(int argc, char *argv[])
{
bigmac("Could you supersize that please?"); // size > 9 overflows
return 0;
}
void bigmac(char *p)
{
char stomach[10]; //limit the size to 10
strcpy(stomach, p);
printf(stomach);
}
bigmac and passes it the
long string "Could you supersize that please?" Unfortunately,