Skip to content

Commit f088b6d

Browse files
book_secure_c.md: add clarification on RELRO/GOT
1 parent 5da7618 commit f088b6d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

c_programming/book_secure_c.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,12 @@ Unrelated?; "There is one GOT per compilation unit or object module, and it is l
371371
(I might be wrong here, but quite certain that;) PIE is necessary for executing code which addresses are not known at link/compile time. But even without PIE the stack and heap may be randomized [ASLR_Linux_bypass].
372372
( So with ASLR e.g.; stack starts at random address (randomness but stack/exec/heap/libs are still in a certain area, and grows in a certain direction), heap starts at random address, lib (ld.so?) starts at random adr (must have PIE..?), exec starts on random address (if PIE) )
373373

374+
**Update:** \
375+
- .got includes variable addresses, .got.plt includes function addresses: <https://stackoverflow.com/questions/11676472/what-is-the-difference-between-got-and-got-plt-section>, <https://stevens.netmeister.org/631/elf.html>
376+
- Partial RELRO (as opposed to Full RELRO) is default in GCC and ONLY protects .got, thus .got.plt is still writable and exploitable: <https://book.hacktricks.xyz/binary-exploitation/common-binary-protections-and-bypasses/relro#partial-relro>, <https://www.mdpi.com/2076-3417/12/13/6702>.
377+
- With Full RELRO we can try to perform a buffer overflow attack to replace the return address to a viable gadget already in got.plt.
378+
- With Partial RELRO can try to perform a heap overflow attack to replace the .got.plt entry itself: <https://medium.com/@0xwan/binary-exploitation-heap-overflow-to-overwrite-got-d3c7d97716f1>
379+
- Note that ASLR / PIE / PIC can make these attacks more difficult. GOT-related attacks are done to bypass certain protection mechanisms such as NX-bit.
374380

375381
##### Lazy Binding, PLT, GOT
376382

0 commit comments

Comments
 (0)