Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SandHook
Project
Project
Details
Activity
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
Administrator
SandHook
Commits
82099cb8
Commit
82099cb8
authored
Apr 16, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix disable dex2oat inline
parent
956330a6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
34 deletions
+20
-34
native_hook.cpp
hooklib/src/main/cpp/nativehook/native_hook.cpp
+20
-34
No files found.
hooklib/src/main/cpp/nativehook/native_hook.cpp
View file @
82099cb8
...
...
@@ -24,7 +24,7 @@ bool isSandHooker(char *const args[]) {
int
orig_arg_count
=
getArrayItemCount
(
args
);
for
(
int
i
=
0
;
i
<
orig_arg_count
;
i
++
)
{
if
(
SDK_INT
>=
ANDROID_N
&&
strstr
(
args
[
i
],
"SandHooker"
))
{
if
(
strstr
(
args
[
i
],
"SandHooker"
))
{
LOGE
(
"skip dex2oat hooker!"
);
return
true
;
}
...
...
@@ -33,60 +33,46 @@ bool isSandHooker(char *const args[]) {
return
false
;
}
char
**
build_new_env
(
char
*
const
envp
[])
{
char
*
provided_ld_preload
=
NULL
;
int
provided_ld_preload_index
=
-
1
;
int
orig_envp_count
=
getArrayItemCount
(
envp
);
char
**
build_new_argv
(
char
*
const
argv
[])
{
for
(
int
i
=
0
;
i
<
orig_envp_count
;
i
++
)
{
if
(
strstr
(
envp
[
i
],
"compiler-filter"
))
{
provided_ld_preload
=
envp
[
i
];
provided_ld_preload_index
=
i
;
}
}
char
ld_preload
[
40
];
if
(
provided_ld_preload
)
{
sprintf
(
ld_preload
,
"--compiler-filter=%s"
,
"speed"
);
}
int
orig_argv_count
=
getArrayItemCount
(
argv
);
int
new_envp_count
=
orig_envp_count
;
if
(
SDK_INT
>=
ANDROID_M
)
{
new_envp_count
=
orig_envp_count
+
1
;
}
char
**
new_envp
=
(
char
**
)
malloc
(
new_envp_count
*
sizeof
(
char
*
));
int
new_argv_count
=
orig_argv_count
+
2
;
char
**
new_argv
=
(
char
**
)
malloc
(
new_argv_count
*
sizeof
(
char
*
));
int
cur
=
0
;
for
(
int
i
=
0
;
i
<
orig_envp_count
;
++
i
)
{
if
(
i
!=
provided_ld_preload_index
)
{
new_envp
[
cur
++
]
=
envp
[
i
];
}
else
{
new_envp
[
i
]
=
ld_preload
;
}
for
(
int
i
=
0
;
i
<
orig_argv_count
;
++
i
)
{
new_argv
[
cur
++
]
=
argv
[
i
];
}
if
(
new_envp_count
!=
orig_envp_count
)
{
new_envp
[
new_envp_count
-
1
]
=
(
char
*
)
(
SDK_INT
>
ANDROID_N2
?
"--inline-max-code-units=0"
:
"--inline-depth-limit=0"
);
if
(
SDK_INT
>=
ANDROID_L2
&&
SDK_INT
<
ANDROID_Q
)
{
new_argv
[
cur
++
]
=
(
char
*
)
"--compile-pic"
;
}
if
(
SDK_INT
>=
23
)
{
new_argv
[
cur
++
]
=
(
char
*
)
(
SDK_INT
>
ANDROID_N2
?
"--inline-max-code-units=0"
:
"--inline-depth-limit=0"
);
}
return
new_envp
;
new_argv
[
cur
]
=
NULL
;
return
new_argv
;
}
extern
"C"
int
fake_execve_disable_inline
(
const
char
*
pathname
,
char
*
argv
[],
char
*
const
envp
[])
{
int
fake_execve_disable_inline
(
const
char
*
pathname
,
char
*
argv
[],
char
*
const
envp
[])
{
if
(
strstr
(
pathname
,
"dex2oat"
))
{
if
(
SDK_INT
>=
ANDROID_N
&&
isSandHooker
(
argv
))
{
LOGE
(
"skip dex2oat!"
);
return
-
1
;
}
char
**
new_
envp
=
build_new_env
(
envp
);
char
**
new_
args
=
build_new_argv
(
argv
);
LOGE
(
"dex2oat by disable inline!"
);
int
ret
=
static_cast
<
int
>
(
syscall
(
__NR_execve
,
pathname
,
argv
,
new_
envp
));
free
(
new_
envp
);
int
ret
=
static_cast
<
int
>
(
syscall
(
__NR_execve
,
pathname
,
new_args
,
envp
));
free
(
new_
args
);
return
ret
;
}
int
ret
=
static_cast
<
int
>
(
syscall
(
__NR_execve
,
pathname
,
argv
,
envp
));
return
ret
;
}
extern
"C"
int
fake_execve_disable_oat
(
const
char
*
pathname
,
char
*
argv
[],
char
*
const
envp
[])
{
int
fake_execve_disable_oat
(
const
char
*
pathname
,
char
*
argv
[],
char
*
const
envp
[])
{
if
(
strstr
(
pathname
,
"dex2oat"
))
{
LOGE
(
"skip dex2oat!"
);
return
-
1
;
...
...
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