26.07.2018 Views

hacking-the-art-of-exploitation

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

16 .dtors 0000000c 080495ac 080495ac 000005ac 2**2<br />

CONTENTS, ALLOC, LOAD, DATA<br />

17 .jcr 00000004 080495b8 080495b8 000005b8 2**2<br />

CONTENTS, ALLOC, LOAD, DATA<br />

18 .dynamic 000000c8 080495bc 080495bc 000005bc 2**2<br />

CONTENTS, ALLOC, LOAD, DATA<br />

19 .got 00000004 08049684 08049684 00000684 2**2<br />

CONTENTS, ALLOC, LOAD, DATA<br />

20 .got.plt 0000001c 08049688 08049688 00000688 2**2<br />

CONTENTS, ALLOC, LOAD, DATA<br />

21 .data 0000000c 080496a4 080496a4 000006a4 2**2<br />

CONTENTS, ALLOC, LOAD, DATA<br />

22 .bss 00000004 080496b0 080496b0 000006b0 2**2<br />

ALLOC<br />

23 .comment 0000012f 00000000 00000000 000006b0 2**0<br />

CONTENTS, READONLY<br />

24 .debug_aranges 00000058 00000000 00000000 000007e0 2**3<br />

CONTENTS, READONLY, DEBUGGING<br />

25 .debug_pubnames 00000025 00000000 00000000 00000838 2**0<br />

CONTENTS, READONLY, DEBUGGING<br />

26 .debug_info 000001ad 00000000 00000000 0000085d 2**0<br />

CONTENTS, READONLY, DEBUGGING<br />

27 .debug_abbrev 00000066 00000000 00000000 00000a0a 2**0<br />

CONTENTS, READONLY, DEBUGGING<br />

28 .debug_line 0000013d 00000000 00000000 00000a70 2**0<br />

CONTENTS, READONLY, DEBUGGING<br />

29 .debug_str 000000bb 00000000 00000000 00000bad 2**0<br />

CONTENTS, READONLY, DEBUGGING<br />

30 .debug_ranges 00000048 00000000 00000000 00000c68 2**3<br />

CONTENTS, READONLY, DEBUGGING<br />

reader@<strong>hacking</strong>:~/booksrc $<br />

Ano<strong>the</strong>r interesting detail about <strong>the</strong> .dtors section is that it is included in<br />

all binaries compiled with <strong>the</strong> GNU C compiler, regardless <strong>of</strong> whe<strong>the</strong>r any<br />

functions were declared with <strong>the</strong> destructor attribute. This means that <strong>the</strong><br />

vulnerable format string program, fmt_vuln.c, must have a .dtors section<br />

containing nothing. This can be inspected using nm and objdump.<br />

reader@<strong>hacking</strong>:~/booksrc $ nm ./fmt_vuln | grep DTOR<br />

08049694 d __DTOR_END__<br />

08049690 d __DTOR_LIST__<br />

reader@<strong>hacking</strong>:~/booksrc $ objdump -s -j .dtors ./fmt_vuln<br />

./fmt_vuln:<br />

file format elf32-i386<br />

Contents <strong>of</strong> section .dtors:<br />

8049690 ffffffff 00000000 ........<br />

reader@<strong>hacking</strong>:~/booksrc $<br />

As this output shows, <strong>the</strong> distance between __DTOR_LIST__ and __DTOR_END__<br />

is only four bytes this time, which means <strong>the</strong>re are no addresses between <strong>the</strong>m.<br />

The object dump verifies this.<br />

Exploitation 187

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!