-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement telfhash function in elf module
- Loading branch information
Showing
6 changed files
with
200 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,77 @@ | ||
To build `elf_with_imports`, first create a dyn.c: | ||
|
||
```c | ||
void foo(void) {} | ||
void foo64(void) {} | ||
void FOO64(void) {} | ||
void FOO(int a) { printf("%d\n", a); } | ||
|
||
void strstuff(void) {} | ||
void stuffstr(void) {} | ||
void memstuff(void) {} | ||
void stuffmem(void) {} | ||
|
||
void STRALLCAPS(void) {} | ||
void ALLCAPSSTR(void) {} | ||
void long_function_to_make_the_tlsh_hash_work() {} | ||
|
||
int a_value; | ||
|
||
// Non global dynsym | ||
#pragma weak weak_fun | ||
void weak_fun(void) {} | ||
``` | ||
|
||
then create a elf.c: | ||
|
||
```c | ||
extern void foo(void); | ||
extern void foo64(void); | ||
extern void FOO64(void); | ||
extern void FOO(int); | ||
|
||
extern void strstuff(void); | ||
extern void stuffstr(void); | ||
extern void memstuff(void); | ||
extern void stuffmem(void); | ||
|
||
extern void STRALLCAPS(void); | ||
extern void ALLCAPSSTR(void); | ||
extern void long_function_to_make_the_tlsh_hash_work(); | ||
|
||
// Non global dynsym | ||
#pragma weak weak_fun | ||
extern void weak_fun(void); | ||
|
||
extern int a_value; | ||
|
||
// Protected dynsym | ||
extern void __attribute__((visibility ("protected"))) protected_fun(void) {} | ||
|
||
int main(void) { | ||
foo(); | ||
foo64(); | ||
FOO64(); | ||
FOO(a_value); | ||
|
||
strstuff(); | ||
stuffstr(); | ||
memstuff(); | ||
stuffmem(); | ||
|
||
STRALLCAPS(); | ||
ALLCAPSSTR(); | ||
long_function_to_make_the_tlsh_hash_work(); | ||
weak_fun(); | ||
protected_fun(); | ||
|
||
return 0; | ||
} | ||
``` | ||
|
||
And compile them: | ||
|
||
``` | ||
gcc -shared -o libdyn.so -fPIC dyn.c | ||
gcc -shared -o elf_with_imports -fPIC elf.c -ldyn -L. | ||
``` |
Binary file not shown.
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