Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
Linux Library Inject
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chu
Linux Library Inject
Commits
740352d7
Commit
740352d7
authored
Dec 25, 2019
by
Chu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
evil.so
parent
e1c5e5e7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
18 deletions
+23
-18
CMakeLists.txt
CMakeLists.txt
+1
-0
CMakeLists.txt
evil/CMakeLists.txt
+1
-0
evil.cpp
evil/evil.cpp
+8
-0
evil.h
evil/evil.h
+6
-0
main.cpp
inject/main.cpp
+7
-18
No files found.
CMakeLists.txt
View file @
740352d7
...
...
@@ -5,3 +5,4 @@ set(CMAKE_CXX_STANDARD 17)
add_subdirectory
(
host
)
add_subdirectory
(
inject
)
add_subdirectory
(
evil
)
evil/CMakeLists.txt
0 → 100644
View file @
740352d7
add_library
(
evil SHARED evil.cpp evil.h
)
evil/evil.cpp
0 → 100644
View file @
740352d7
#include "evil.h"
#include <cstdio>
void
__attribute__
((
constructor
))
init
()
{
std
::
puts
(
"hello, world"
);
}
evil/evil.h
0 → 100644
View file @
740352d7
#ifndef LINUX_LIBRARY_INJECT_EVIL_H
#define LINUX_LIBRARY_INJECT_EVIL_H
void
__attribute__
((
constructor
))
init
();
#endif // LINUX_LIBRARY_INJECT_EVIL_H
inject/main.cpp
View file @
740352d7
...
...
@@ -5,7 +5,7 @@
#include "elf.h"
#include "process.h"
void
call
_libc_dlopen_mode
();
void
do
_libc_dlopen_mode
();
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -32,26 +32,15 @@ int main(int argc, char *argv[])
// call __libc_dlopen_mode in target process
std
::
cout
<<
"[*] get shellcode in current process
\n
"
;
auto
call_libc_dlopen_mode_addr
=
reinterpret_cast
<
unsigned
char
*>
(
&
call_libc_dlopen_mode
);
auto
call_libc_dlopen_mode_size
=
Elf
(
argv
[
0
]).
get_func_size
(
reinterpret_cast
<
std
::
size_t
>
(
call_libc_dlopen_mode_addr
));
std
::
cout
<<
"[+] shellcode: 0x"
<<
reinterpret_cast
<
std
::
size_t
>
(
call_libc_dlopen_mode_addr
)
<<
" "
<<
std
::
dec
<<
call_libc_dlopen_mode_size
<<
std
::
endl
;
auto
do_libc_dlopen_mode_addr
=
reinterpret_cast
<
unsigned
char
*>
(
&
do_libc_dlopen_mode
);
auto
do_libc_dlopen_mode_size
=
Elf
(
argv
[
0
]).
get_func_size
(
reinterpret_cast
<
std
::
size_t
>
(
do_libc_dlopen_mode_addr
));
std
::
cout
<<
"[+] shellcode: 0x"
<<
reinterpret_cast
<
std
::
size_t
>
(
do_libc_dlopen_mode_addr
)
<<
" "
<<
std
::
dec
<<
do_libc_dlopen_mode_size
<<
std
::
endl
;
std
::
cout
<<
"[*] execute shellcode in target process
\n
"
;
process
.
call_shellcode
(
std
::
vector
(
call_libc_dlopen_mode_addr
,
call_libc_dlopen_mode_addr
+
call_libc_dlopen_mode_size
));
process
.
call_shellcode
(
std
::
vector
(
do_libc_dlopen_mode_addr
,
do_libc_dlopen_mode_addr
+
do_libc_dlopen_mode_size
));
std
::
cout
<<
"[+] injected
\n
"
;
return
0
;
}
void
call_libc_dlopen_mode
()
{
asm
volatile
(
R"(
mov $1, %rdi
mov $94903506460672, %rsi
mov $4, %rdx
mov $1, %rax
syscall
)"
);
}
void
do_libc_dlopen_mode
()
{}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment