6.1.24 pwn HITCONCTF2016 House_of_Orange
้ข็ฎๅค็ฐ
$ file houseoforange
houseoforange: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=a58bda41b65d38949498561b0f2b976ce5c0c301, stripped
$ checksec -f houseoforange
RELRO STACK CANARY NX PIE RPATH RUNPATH FORTIFY Fortified Fortifiable FILE
Full RELRO Canary found NX enabled PIE enabled No RPATH No RUNPATH Yes 1 3 houseoforange
$ strings libc-2.23.so | grep "GNU C"
GNU C Library (Ubuntu GLIBC 2.23-0ubuntu3) stable release version 2.23, by Roland McGrath et al.
Compiled by GNU CC version 5.3.1 20160413.64 ไฝ็จๅบ๏ผไฟๆคๅ จๅผ๏ผ้ป่ฎคๅผๅฏ ASLRใ
ๅจ Ubuntu16.04 ไธ็ฉไธไธ๏ผ
$ ./houseoforange
+++++++++++++++++++++++++++++++++++++
@ House of Orange @
+++++++++++++++++++++++++++++++++++++
1. Build the house
2. See the house
3. Upgrade the house
4. Give up
+++++++++++++++++++++++++++++++++++++
Your choice : 1 <-- Build a house
Length of name :20
Name :AAAAAAAAAAAAAAAAAAA
Price of Orange:1
+++++++++++++++++++++++++++++++++++++
1. Red
2. Green
3. Yellow
4. Blue
5. Purple
6. Cyan
7. White
+++++++++++++++++++++++++++++++++++++
Color of Orange:1
Finish
+++++++++++++++++++++++++++++++++++++
@ House of Orange @
+++++++++++++++++++++++++++++++++++++
1. Build the house
2. See the house
3. Upgrade the house
4. Give up
+++++++++++++++++++++++++++++++++++++
Your choice : 3 <-- Upgrade the house
Length of name :10
Name:BBBBBBBBBB
Price of Orange: +++++++++++++++++++++++++++++++++++++
1. Red
2. Green
3. Yellow
4. Blue
5. Purple
6. Cyan
7. White
+++++++++++++++++++++++++++++++++++++
Color of Orange: 1
Finish
+++++++++++++++++++++++++++++++++++++
@ House of Orange @
+++++++++++++++++++++++++++++++++++++
1. Build the house
2. See the house
3. Upgrade the house
4. Give up
+++++++++++++++++++++++++++++++++++++
Your choice : 2 <-- See the house
Name of house : BBBBBBBBBBAAAAAAAAA
Price of orange : 0
__
\/.--,
//_.'
.-""-/""----..
/ . . . . . . . \
/ . . . . . . . . \
|. ไน . . . ไน. .|
\ . . . . . . . . |
\. . . . . . . . ./
\ . . . ๏ผ. . . /
'-.__.__.__._-'
+++++++++++++++++++++++++++++++++++++
@ House of Orange @
+++++++++++++++++++++++++++++++++++++
1. Build the house
2. See the house
3. Upgrade the house
4. Give up
+++++++++++++++++++++++++++++++++++++
Your choice : 4
give up็จๅบๅ ่ฎธๆไปฌๅฏน house ่ฟ่ก BuildใSee ๅ Upgrade ็ๆไฝใๅฏไปฅ็ๅฐๅจ See ็ๆถๅไผผไนๆ็น้ฎ้ข๏ผ"A"็ๅญ็ฌฆไธฒๅบ่ฏฅๆฏ Upgrade ไนๅ็๏ผไฝ่ฟ้่ฟๆฏ่ขซๆๅฐไบๅบๆฅ๏ผ็ๆตๅฏ่ฝๅญๅจไฟกๆฏๆณ้ฒ๏ผ้่ฆ้็นๅ ณๆณจใ
้ข็ฎ่งฃๆ
Build the house
้่ฟๅฏน่ฟๆฎตไปฃ็ ็ๅๆๅฏไปฅๅพๅฐไธคไธช็ปๆไฝ๏ผ
Build ๆๅคๅฏไปฅ่ฟ่ก 4 ๆฌก๏ผๆดไธช่ฟ็จๆ 2 ไธช malloc ๅ 1 ไธช calloc๏ผ
malloc(0x10)๏ผ็ป house struct ๅ้ ็ฉบ้ดmalloc(length)๏ผ็ป name ๅ้ ็ฉบ้ด๏ผๅ ถไธญ length ๆฅ่ช็จๆท่พๅ ฅ๏ผๅฆๆๅคงไบ 0x1000๏ผๅๆ็ ง 0x1000 ๅค็ใcalloc(1, 8)๏ผ็ป orange struct ๅ้ ็ฉบ้ด
้ฃไนๆไปฌๅๆฅ็ไธไธ็จไบ่ฏปๅ ฅ name ็ๅฝๆฐ๏ผ
่ฟไธชๅฝๆฐๅจ่ฏปๅ
ฅ length ้ฟๅบฆ็ๅญ็ฌฆไธฒๅ๏ผๆฒกๆๅจๆซๅฐพๅ ไธ \x00 ๆชๆญ๏ผๆญฃๅฆๆไปฌไธ้ข็ๅฐ็๏ผๅฏ่ฝๅฏผ่ดไฟกๆฏๆณ้ฒใ
See the house
See ไผๆๅฐๅบ house->name๏ผorange->price ๅ orange ๅพๆกใ
Upgrade the house
Upgrade ๆๅคๅฏไปฅ่ฟ่ก 3 ๆฌก๏ผๅฝ็กฎ่ฎค house ๅญๅจๅ๏ผๅฐฑ็ดๆฅๅจ orange->name ็ๅฐๆน่ฏปๅ ฅ้ฟๅบฆไธบ length ็ name๏ผ็ถๅ่ฏปๅ ฅๆฐ็ price ๅ colorใๆฐ็ length ๅๆ ทๆฅ่ช็จๆท่พๅ ฅ๏ผๅฆๆๅคงไบ 0x1000๏ผๅๆ็ ง 0x1000 ๅค็ใ
่ฟ้็้ฎ้ขๅจไบ็จๅบๆฒกๆๅฐๆฐ length ไธๆง length ๅไปปไฝๆฏ่พ๏ผๅฆๆๆฐ length ๅคงไบ ๆง length๏ผ้ฃไนๅฐๅฏผ่ดๅ ๆบขๅบใ
ๆผๆดๅฉ็จ
ๅๅธธ่ง็ๅ ๅฉ็จ้ข็ฎไธๅ็ๆฏ๏ผ่ฟ้ขๅชๆ malloc ่ๆฒกๆ free๏ผไบๆฏๅพๅคๅฉ็จๆนๆณ้ฝ็จไธไบใๅฝ็ถ่ฟ้ขๆฏ็ฌๅไบไธ็ง house-of-orange ็ๅฉ็จๆนๆณ๏ผ่ฟ็งๆนๆณๅฉ็จๅ ๆบขๅบไฟฎๆน _IO_list_all ็ปๆไฝ๏ผไป่ๆนๅ็จๅบๆต๏ผๅๆๆฏ่ฝๅคๆณๆผๅ ๅ libc๏ผๆณ้ฒ็ๆนๆณๆฏ่งฆๅไฝไบ sysmalloc() ไธญ็ _int_free() ๅฐ top chunk ้ๆพๅฐ unsorted bin ไธญ๏ผ่ฏฆ็ปๅ
ๅฎนๅ่็ซ ่ 3.1.8 ๅ 4.13๏ผใ
overwrite top chunk
็ฌฌไธๆญฅ๏ผ่ฆ็ top chunk ็ size ๅ๏ผไปฅ่งฆๅ sysmalloc()ใๅๅปบ็ฌฌไธไธช house๏ผ
ๆ นๆฎไธๅฎ็่งๅไฟฎๆน size๏ผ็ฎๅ่ฏดๅฐฑๆฏ่ฟ้ top chunk size ๆฏ 0x20fa1๏ผ้ฃๅฐฑไฟฎๆนไธบ 0xfa1๏ผ
leak libc
ๆฅไธๆฅๅ้
ไธไธชๅคงไบ top chunk๏ผๅฐไบ mp_.mmap_threshold ็ large chunk๏ผๆญคๆถๅฐ่งฆๅ sysmalloc() ไธญ็ _int_free()๏ผtop chunk ๅฐ่ขซ้ๆพๅฐ unsorted bin ไธญ๏ผๅๆถๆฐ็ top chunk ๅฐ็ฑๆฉๅฑๆนๅผๅ้
ๅบๆฅ๏ผ
ๅฏไปฅ็ๅฐ old top chunk ๅทฒ็ป่ขซๆพๅฐ unsorted bin ไธญไบ๏ผๅ ถ fd, bk ๆ้ๆๅ libcใๆฅไธๆฅๅๅ้ ไธไธช large chunk๏ผ่ฟไธช chunk ๅฐไป old top chunk ไธญๅไธๆฅ๏ผๅฉไธ็ๅๆพๅ unsorted bin๏ผ
ๅฏไปฅ็ๅฐ name 3 ไธๆ้็็ old top chunk ็ bk ๆ้ใๅช่ฆๅฐๅ ถๆๅฐๅบๆฅ๏ผ้่ฟ่ฎก็ฎๅณๅฏๅพๅฐ libc ็ๅบๅใ
leak heap
ๅจไธไธๆญฅไธญๆไปฌ่ฟๅฏไปฅ็ๅฐ name 3 ไธ่ฟๆ้็็ fd_nextsize ๅ bk_nextsize๏ผ่ฟๆฏๅ ไธบๅจๅ้ ไธไธช large chunk ๆถ๏ผไผๅ ๅฐ unsorted bin ไธญ็ large chunk ๅๅบๆพๅฐ large bin ไธญใๅ ไธบๅฝๅ large bin ๆฏ็ฉบ็๏ผๆไปฅ chunk ็ fd_nextsize ๅ bk_nextsize ้ฝๆๅ่ช่บซ๏ผ
ๆไปฅ่ฟ้ๆไปฌ้่ฟไฟฎๆน name ๅณๅฏๆณ้ฒๅบ heap ๅฐๅ๏ผ
house of orange
็ฐๅจๆไปฌๆไบ libc ๅ heap ๅฐๅ๏ผๆฅไธๆฅๅฐฑๆฏ็ๆญฃ็ house-of-orange๏ผ็ธไฟกไฝ ๅทฒ็ป็ไบๅ่็ซ ่๏ผ่ฟ้ๅฐฑไธๅ้ๅคไบใ็ปๆๅฆไธ๏ผ
ๅฏไปฅ็ๅฐ old top chunk ็ size ่ขซๆนๅไธบ 0x60๏ผๅจไธๆฌกๅ้
ๆถ๏ผไผๅ
ไป unsorted bin ไธญๅไธ old top chunk๏ผๅฐๅ
ถๆพๅฐ smallbins[5]๏ผๅๆถ๏ผunsorted bin ็ bk ไนๅฐ่ขซๆนๅๆไบ &IO_list_all-0x10ใ
pwn
็ฑไบไธ่ฝๅค้่ฟๆฃๆฅ๏ผๅฐ่งฆๅๅผๅธธๅค็่ฟ็จ๏ผmalloc_printerr -> __libc_message -> __GI_abort -> _IO_flush_all_lockpใ
ๅผๅฏ ASLR๏ผBingo!!!
exploit
ๅฎๆด็ exp ๅฆไธ๏ผ
ๅ่่ตๆ
Last updated
Was this helpful?