text stringlengths 0 1.99k |
|---|
unsigned int argc; |
char *arg; |
void **argv; |
char *group; |
int cmd_class; |
int stash_index; |
unsigned int stash_hash; |
pr_table_t *notes; |
int cmd_id; |
int is_ftp; |
const char *protocol; |
} * |
This structure holds all the attributes related to the command that is |
going to be run on the server. Let's check the values of its members: |
gef➤ p *cmd |
$82 = { |
pool = 0x5555556e0440, |
server = 0x55555568ad28, |
config = 0x5555556e0440, |
tmp_pool = 0x0, |
argc = 0x2, |
arg = 0x5555556b9a98 "CCCwwwwww", |
argv = 0x5555556b9ab8, |
group = 0x0, |
cmd_class = 0x67f, |
stash_index = 0x14, |
stash_hash = 0x3b7b88c, |
notes = 0x5555556b9c28, |
cmd_id = 0xffffffff, |
is_ftp = 0x1, |
protocol = 0x55555563c35f "FTP" |
} |
gef➤ p cmd |
$82 = (cmd_rec *) 0x5555556b99f8 |
The array cmd->argv[] holds a pointer to our command. cmd->argv[0] holds |
the command and cmd->argv[1] the arguments/parameters: |
gef➤ x/s cmd->argv[0] |
0x5555556b9a90: "3333" |
gef➤ x/s cmd->argv[1] |
0x5555556b9aa8: "CCCwwwwww" |
This is defined in src/cmd.c at pr_cmd_alloc() function. |
ProFTPd keeps a global variable called "session", which is responsible for |
storing every attribute related to the current FTP session. The member |
session.curr_cmd_rec holds a pointer to the current command being executed |
in that FTP session. This is exactly the same value of cmd pointer in |
_dispatch(): |
gef➤ p cmd |
$82 = (cmd_rec *) 0x5555556b99f8 |
gef➤ p session.curr_cmd_rec |
$83 = (struct cmd_struc *) 0x5555556b99f8 |
In addition, cmd has cmd->notes member that holds a pointer to a variable |
of type struct table_rec (see src/table.c for more information). |
Giving a couple of steps back, you may have noticed that when a breakpoint |
is hit in pool.c:569, we are always pointing p->sub_next to some valid |
address. This is because otherwise we would have a crash on sstrncpy() |
like the one below: |
$rax : 0x34 |
$rbx : 0x4343434343434344 ("DCCCCCCC"?) |
$rcx : 0x0000555555688768 → 0x0000555500363234 ("426"?) |
$rdx : 0x4343434343434343 ("CCCCCCCC"?) |
$rsp : 0x00007fffffffd930 → 0x0000000000000008 |
$rbp : 0x00007fffffffd970 → 0x00007fffffffd9a0 → [...] |
$rsi : 0x0000555555688768 → 0x0000555500363234 ("426"?) |
$rdi : 0x4343434343434343 ("CCCCCCCC"?) |
$rip : 0x0000555555634d28 → <sstrncpy+161> mov BYTE PTR [rdx], al |
$r8 : 0x0000555555688738 → "Transfer aborted. Data connection closed" |
[...] |
─────────────────────────────────────────────────────────────── stack ──── |
0x00007fffffffd930│+0x0000: 0x0000000000000008 ← $rsp |
0x00007fffffffd938│+0x0008: 0x0000000000000004 |
0x00007fffffffd940│+0x0010: 0x0000555555688769 → 0x5400005555003632 "26" |
0x00007fffffffd948│+0x0018: 0x4343434343434343 |
0x00007fffffffd950│+0x0020: 0x00007fffffffd970 → [...] |
0x00007fffffffd958│+0x0028: 0x0000000055575a8e |
0x00007fffffffd960│+0x0030: 0x0000000000000004 |
0x00007fffffffd968│+0x0038: 0x0000555555678b00 → 0x0000000000000002 |
───────────────────────────────────────────────────────── code:x86:64 ──── |
0x555555634d1e <sstrncpy+151> mov rdx, rbx |
0x555555634d21 <sstrncpy+154> lea rbx, [rdx+0x1] |
0x555555634d25 <sstrncpy+158> movzx eax, BYTE PTR [rax] |
→ 0x555555634d28 <sstrncpy+161> mov BYTE PTR [rdx], al |
0x555555634d2a <sstrncpy+163> add DWORD PTR [rbp-0x14], 0x1 |
0x555555634d2e <sstrncpy+167> sub QWORD PTR [rbp-0x38], 0x1 |
0x555555634d33 <sstrncpy+172> mov rax, QWORD PTR [rbp-0x30] |
0x555555634d37 <sstrncpy+176> movzx eax, BYTE PTR [rax] |
0x555555634d3a <sstrncpy+179> test al, al |
──────────────────────────────────────────────── source:sstrncpy.c+72 ──── |
67 } |
68 |
69 d = dst; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.