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
77e1ac96
Commit
77e1ac96
authored
Jan 03, 2020
by
Chu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
padding
parent
7ac48631
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
.gitignore
.gitignore
+1
-0
process.cpp
inject/process.cpp
+9
-8
No files found.
.gitignore
View file @
77e1ac96
.DS_Store
.idea
cmake-build-*
inject/process.cpp
View file @
77e1ac96
...
...
@@ -132,22 +132,23 @@ void Process::set_registers(const user_regs_struct ®isters)
void
Process
::
call_func
(
const
void
*
address
,
std
::
array
<
const
void
*
,
6
>
args
)
{
check_for_attached
();
// 0: 48 83 e4 f0 and $0xfffffffffffffff0, %rsp
// 4: 48 bb ef be ad de ef be ad de movabs $0xdeadbeefdeadbeef, %rbx
// e: ff d3 callq *%rbx
// 10: cc int3
// 0: 90 90 90 90 nop
// 4: 48 83 e4 f0 and $0xfffffffffffffff0, %rsp
// 8: 48 bb ef be ad de ef be ad de movabs $0xdeadbeefdeadbeef, %rbx
// 12: ff d3 callq *%rbx
// 14: cc int3
// https://stackoverflow.com/questions/44613592/shared-library-injection-dl-relocate-object-segfaults
std
::
vector
<
unsigned
char
>
shellcode
=
{
0x
48
,
0x83
,
0xe4
,
0xf0
,
0x48
,
0xbb
,
0xef
,
0xbe
,
0xad
,
0xde
,
0xef
,
0xbe
,
0xad
,
0xde
,
0xff
,
0xd3
,
0xcc
};
std
::
vector
<
unsigned
char
>
shellcode
=
{
0x
90
,
0x90
,
0x90
,
0x90
,
0x48
,
0x83
,
0xe4
,
0xf0
,
0x48
,
0xbb
,
0xef
,
0x
be
,
0xad
,
0x
de
,
0xef
,
0xbe
,
0xad
,
0xde
,
0xff
,
0xd3
,
0xcc
};
while
(
shellcode
.
size
()
%
sizeof
(
void
*
)
!=
0
)
shellcode
.
emplace_back
(
0x90
);
std
::
memcpy
(
shellcode
.
data
()
+
6
,
&
address
,
sizeof
(
address
));
std
::
memcpy
(
shellcode
.
data
()
+
10
,
&
address
,
sizeof
(
address
));
auto
rx_area
=
find_rx_area
();
auto
original_code
=
read
(
rx_area
,
shellcode
.
size
());
write
(
rx_area
,
shellcode
);
auto
original_registers
=
get_registers
();
auto
registers
=
original_registers
;
registers
.
rip
=
reinterpret_cast
<
decltype
(
registers
.
rip
)
>
(
rx_area
);
registers
.
rip
=
reinterpret_cast
<
decltype
(
registers
.
rip
)
>
(
rx_area
)
+
4
;
registers
.
rdi
=
reinterpret_cast
<
decltype
(
registers
.
rdi
)
>
(
args
[
0
]);
registers
.
rsi
=
reinterpret_cast
<
decltype
(
registers
.
rsi
)
>
(
args
[
1
]);
registers
.
rdx
=
reinterpret_cast
<
decltype
(
registers
.
rdx
)
>
(
args
[
2
]);
...
...
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