Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
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
Magisk
Commits
b9c93c66
Commit
b9c93c66
authored
Jun 09, 2022
by
vvb2060
Committed by
John Wu
Jun 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Force app version not lower than daemon
parent
a250e2b5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
+18
-4
cert.cpp
native/jni/core/cert.cpp
+15
-1
core.hpp
native/jni/core/core.hpp
+1
-1
package.cpp
native/jni/core/package.cpp
+2
-2
No files found.
native/jni/core/cert.cpp
View file @
b9c93c66
#include <base.hpp>
#include <flags.h>
using
namespace
std
;
...
...
@@ -95,7 +96,7 @@ struct EOCD {
* This method extracts the first certificate of the first signer
* within the APK v2 signature block.
*/
string
read_certificate
(
int
fd
)
{
string
read_certificate
(
int
fd
,
bool
check_version
)
{
uint32_t
size4
;
uint64_t
size8
;
...
...
@@ -129,6 +130,19 @@ string read_certificate(int fd) {
}
read
(
fd
,
&
central_dir_off
,
sizeof
(
central_dir_off
));
// Read comment
if
(
check_version
)
{
uint16_t
comment_sz
=
0
;
read
(
fd
,
&
comment_sz
,
sizeof
(
comment_sz
));
string
comment
;
comment
.
resize
(
comment_sz
);
read
(
fd
,
comment
.
data
(),
comment_sz
);
if
(
MAGISK_VER_CODE
>
parse_int
(
comment
))
{
// Older version of magisk app is not supported
return
{};
}
}
// Next, find the start of the APK signing block
{
constexpr
int
off
=
sizeof
(
signing_block
::
block_sz_
)
+
sizeof
(
signing_block
::
magic
);
...
...
native/jni/core/core.hpp
View file @
b9c93c66
...
...
@@ -21,7 +21,7 @@ void reboot();
void
start_log_daemon
();
void
setup_logfile
(
bool
reset
);
void
magisk_logging
();
std
::
string
read_certificate
(
int
fd
);
std
::
string
read_certificate
(
int
fd
,
bool
check_version
=
false
);
// Module stuffs
void
handle_modules
();
...
...
native/jni/core/package.cpp
View file @
b9c93c66
...
...
@@ -105,7 +105,7 @@ int get_manager(int user_id, string *pkg, bool install) {
int
dyn
=
open
(
app_path
,
O_RDONLY
|
O_CLOEXEC
);
if
(
dyn
<
0
)
return
false
;
bool
mismatch
=
default_cert
&&
read_certificate
(
dyn
)
!=
*
default_cert
;
bool
mismatch
=
default_cert
&&
read_certificate
(
dyn
,
true
)
!=
*
default_cert
;
close
(
dyn
);
if
(
mismatch
)
{
LOGE
(
"pkg: dyn APK signature mismatch: %s
\n
"
,
app_path
);
...
...
@@ -226,7 +226,7 @@ int get_manager(int user_id, string *pkg, bool install) {
#if ENFORCE_SIGNATURE
string
apk
=
find_apk_path
(
JAVA_PACKAGE_NAME
);
int
fd
=
xopen
(
apk
.
data
(),
O_RDONLY
|
O_CLOEXEC
);
string
cert
=
read_certificate
(
fd
);
string
cert
=
read_certificate
(
fd
,
true
);
close
(
fd
);
if
(
default_cert
&&
cert
!=
*
default_cert
)
{
// Found APK with invalid signature, force replace with stub
...
...
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