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
f69ba366
Commit
f69ba366
authored
Dec 24, 2019
by
Chu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shellcode addr and size
parent
7aef115e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
5 deletions
+31
-5
CMakeLists.txt
inject/CMakeLists.txt
+1
-1
elf.cpp
inject/elf.cpp
+22
-0
elf.h
inject/elf.h
+1
-0
main.cpp
inject/main.cpp
+7
-4
No files found.
inject/CMakeLists.txt
View file @
f69ba366
add_executable
(
inject main.cpp process.cpp process.h elf.cpp elf.h
)
set_target_properties
(
inject PROPERTIES LINK_FLAGS
_RELEASE
"-static"
)
set_target_properties
(
inject PROPERTIES LINK_FLAGS
"-static"
)
inject/elf.cpp
View file @
f69ba366
...
...
@@ -75,3 +75,25 @@ std::size_t Elf::get_entry()
return
base_
+
ehdr_
->
e_entry
;
}
std
::
size_t
Elf
::
get_func_size
(
std
::
size_t
address
)
{
if
(
!
memory_
)
load_to_memory
();
for
(
auto
i
=
0
;
i
!=
ehdr_
->
e_shnum
;
++
i
)
{
if
(
shdr_
[
i
].
sh_type
==
SHT_SYMTAB
)
{
auto
sym_tab
=
reinterpret_cast
<
Elf64_Sym
*>
(
&
memory_
[
shdr_
[
i
].
sh_offset
]);
for
(
auto
j
=
0
;
j
!=
shdr_
[
i
].
sh_size
/
sizeof
(
Elf64_Sym
);
++
j
)
{
if
(
sym_tab
->
st_value
==
address
)
return
sym_tab
->
st_size
;
++
sym_tab
;
}
}
}
throw
std
::
runtime_error
(
std
::
to_string
(
address
)
+
" not found in "
+
path_
);
}
inject/elf.h
View file @
f69ba366
...
...
@@ -14,6 +14,7 @@ public:
void
set_base
(
std
::
size_t
base
);
std
::
size_t
find_symbol_address_by_name
(
std
::
string_view
name
);
std
::
size_t
get_entry
();
std
::
size_t
get_func_size
(
std
::
size_t
address
);
private
:
std
::
string
path_
;
...
...
inject/main.cpp
View file @
f69ba366
...
...
@@ -7,7 +7,7 @@
#include "elf.h"
#include "process.h"
extern
"C"
void
func
();
void
call_libc_dlopen_mode
();
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -73,7 +73,10 @@ int main(int argc, char *argv[])
std
::
cout
<<
"[+] entry: 0x"
<<
entry
<<
std
::
endl
;
// copy shellcode to process' entry
std
::
cout
<<
reinterpret_cast
<
void
*>
(
&
func
)
<<
std
::
endl
;
auto
call_libc_dlopen_mode_addr
=
reinterpret_cast
<
std
::
size_t
>
(
&
call_libc_dlopen_mode
);
auto
call_libc_dlopen_mode_size
=
Elf
(
argv
[
0
]).
get_func_size
(
call_libc_dlopen_mode_addr
);
std
::
cout
<<
"[+] shellcode: 0x"
<<
call_libc_dlopen_mode_addr
<<
" "
<<
std
::
dec
<<
call_libc_dlopen_mode_size
<<
std
::
endl
;
// call shellcode
...
...
@@ -82,7 +85,7 @@ int main(int argc, char *argv[])
return
0
;
}
void
func
()
void
call_libc_dlopen_mode
()
{
std
::
cout
<<
"
func
\n
"
;
std
::
cout
<<
"
call_libc_dlopen_mode
\n
"
;
}
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