text stringlengths 0 1.99k |
|---|
the table it self, which we have to take into account as well: |
373 if (pr_table_add(cmd->notes, pstrdup(cmd->pool, "displayable-str"), |
→ 374 pstrdup(cmd->pool, res), 0) < 0) { |
375 if (errno != EEXIST) { |
376 pr_trace_msg(trace_channel, 4, |
377 "error setting 'displayable-str' command note: %s", |
strerror(errno)); |
378 } |
379 } |
A crash will occur on pr_table_add() function. In fact, there are some |
functions that are called inside it. |
dprintf table.c:427, "table1: pr_table_kadd: idx==%d\n", (int)idx |
dprintf table.c:588, "table2: pr_table_kget: idx==%d\n", (int)idx |
The indexes are responsible for creating, intentionally, randomizations, |
which complicates our exploitation even more. See the comments at table.c: |
struct table_rec { |
pool *pool; |
unsigned long flags; |
/* These bytes are randomly generated at table creation time, and |
* are used to seed the hashing function, so as to defend/mitigate |
* against attempts to feed carefully crafted keys which force the |
* table into its worst-case performance scenario. |
* |
* For more information on attacks of this nature, see: |
* |
* http://www.cs.rice.edu/~scrosby/hash/CrosbyWallach_UsenixSec2003/ |
*/ |
unsigned int seed; |
/* Maximum number of entries that can be stored in this table. The |
* default maximum (PR_TABLE_DEFAULT_MAX_ENTS) is set fairly high. |
* This limit is present in order to defend/mitigate against certain abuse |
* scenarios. |
* |
* XXX Note that an additional protective measure can/might be placed on |
* the maximum length of a given chain, to detect other types of attacks |
* that force the table into the worse-case performance scenario (i.e. |
* linear scanning of a long chain). If such is added, then a Table API |
* function should be added for returning the length of the longest chain |
* in the table. Such a function could be used by modules to determine |
* if their tables are being abused (or in need of readjustment). |
*/ |
unsigned int nmaxents; |
pr_table_entry_t **chains; |
unsigned int nchains; |
unsigned int nents; |
/* List of free structures. */ |
pr_table_entry_t *free_ents; |
pr_table_key_t *free_keys; |
/* For iterating over all the keys in the entire table. */ |
pr_table_entry_t *tab_iter_ent; |
/* For iterating through all of the possible multiple values for a single |
* key. Only used if the PR_TABLE_FL_MULTI_VALUE flag is set. |
*/ |
pr_table_entry_t *val_iter_ent; |
/* Cache of last looked-up entry. Usage of this field can be enabled |
* by using the PR_TABLE_FL_USE_CACHE flag. |
*/ |
pr_table_entry_t *cache_ent; |
/* Table callbacks. */ |
int (*keycmp)(const void *, size_t, const void *, size_t); |
unsigned int (*keyhash)(const void *, size_t); |
void (*entinsert)(pr_table_entry_t **, pr_table_entry_t *); |
void (*entremove)(pr_table_entry_t **, pr_table_entry_t *); |
As you noticed, we must have memory layout knowledge and the offsets. |
----[ 5.4 - Leaking memory layout |
At the moment our breakpoint is triggered, we can analyse the memory |
layout: |
gef➤ vmmap heap |
[ Legend: Code | Heap | Stack ] |
Start End Offset Perm Path |
0x000056259ecbe000 0x000056259ed00000 0x0000000000000000 rw- [heap] |
0x000056259ed00000 0x000056259ed3f000 0x0000000000000000 rw- [heap] |
These are our base heap addresses. The second heap was allocated to deal |
with our data transfer (STOR command). |
gef➤ p p |
$20 = (struct pool_rec *) 0x56259ed1e770 |
gef➤ p gid_tab |
$21 = (pr_table_t *) 0x56259ecee198 |
gef➤ p session.curr_cmd_rec->notes |
$22 = (pr_table_t *) 0x56259ecf51a8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.