Skip to content

Commit

Permalink
add sshd_get_host_keys_address
Browse files Browse the repository at this point in the history
  • Loading branch information
smx-smx committed Apr 15, 2024
1 parent 9a1947a commit ac9317a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions xzre.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,18 @@ void main_shared(){
item->func_end ? PTRDIFF(item->func_end, elf_addr) : 0,
item->xref ? PTRDIFF(item->xref, elf_addr) : 0);
}


u64 code_size = 0, data_size = 0;
void *data_start = elf_get_data_segment(&einfo, &data_size, 0);
void *data_end = (void *)PTRADD(data_start, data_size);
void *code_start = elf_get_code_segment(&einfo, &code_size);
void *code_end = (void *)PTRADD(code_start, code_size);
void *ssh_host_keys = NULL;
if(sshd_get_host_keys_address(data_start, data_end, code_start, code_end, &strings, &ssh_host_keys)){
printf("sensitive_data.host_keys: %p\n", ssh_host_keys);
}

//xzre_backdoor_setup();
puts("main_shared(): OK");
}
Expand Down
19 changes: 19 additions & 0 deletions xzre.h
Original file line number Diff line number Diff line change
Expand Up @@ -2201,6 +2201,25 @@ extern BOOL find_link_map_l_audit_any_plt_bitmask(
backdoor_data_handle_t *data,
instruction_search_ctx_t *search_ctx);

/**
* @brief finds the address of `sensitive_data.host_keys` in sshd
*
* @param data_start start of the sshd data segment
* @param data_end end of the sshd data segment
* @param code_start start of the sshd code segment
* @param code_end end of the sshd code segment
* @param string_refs info about resolved functions
* @param host_keys_out pointer to receive the address of the host keys (`struct sshkey` in sshd)
* @return BOOL TRUE if the address was found, FALSE otherwise
*/
extern BOOL sshd_get_host_keys_address(
uint8_t *data_start,
uint8_t *data_end,
uint8_t *code_start,
uint8_t *code_end,
string_references_t *string_refs,
void **host_keys_out);

/**
* @brief counts the number of times the IFUNC resolver is called
*
Expand Down
1 change: 1 addition & 0 deletions xzre.lds.in
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ SECTIONS_BEGIN()
DEFSYM(find_dl_naudit, .text.lzma_filter_flags_decoda)
DEFSYM(find_link_map_l_audit_any_plt, .text.lzma_index_hash_inia)
DEFSYM(find_link_map_l_audit_any_plt_bitmask, .text.lzma_index_iter_locata)
DEFSYM(sshd_get_host_keys_address, .text.lzma_bufcpa)
SECTIONS_END(.text)

SECTIONS_BEGIN()
Expand Down

0 comments on commit ac9317a

Please sign in to comment.