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
4729514a
Commit
4729514a
authored
Apr 05, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove snet module from Magisk
parent
93aedcfe
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1 addition
and
203 deletions
+1
-203
build.py
build.py
+0
-20
settings.gradle
settings.gradle
+1
-1
.gitignore
snet/.gitignore
+0
-1
build.gradle
snet/build.gradle
+0
-23
proguard-rules.pro
snet/proguard-rules.pro
+0
-29
AndroidManifest.xml
snet/src/main/AndroidManifest.xml
+0
-7
SafetyNetHelper.java
snet/src/main/java/com/topjohnwu/snet/SafetyNetHelper.java
+0
-122
No files found.
build.py
View file @
4729514a
...
@@ -395,22 +395,6 @@ def build_stub(args):
...
@@ -395,22 +395,6 @@ def build_stub(args):
build_apk
(
args
,
'stub'
)
build_apk
(
args
,
'stub'
)
def
build_snet
(
args
):
header
(
'* Building snet extension'
)
proc
=
execv
([
gradlew
,
'snet:assembleRelease'
])
if
proc
.
returncode
!=
0
:
error
(
'Build snet extention failed!'
)
source
=
op
.
join
(
'snet'
,
'build'
,
'outputs'
,
'apk'
,
'release'
,
'snet-release-unsigned.apk'
)
target
=
op
.
join
(
config
[
'outdir'
],
'snet.jar'
)
# Extract classes.dex
with
zipfile
.
ZipFile
(
target
,
'w'
,
compression
=
zipfile
.
ZIP_DEFLATED
,
allowZip64
=
False
)
as
zout
:
with
zipfile
.
ZipFile
(
source
)
as
zin
:
zout
.
writestr
(
'classes.dex'
,
zin
.
read
(
'classes.dex'
))
rm
(
source
)
header
(
'Output: '
+
target
)
def
zip_main
(
args
):
def
zip_main
(
args
):
header
(
'* Packing Flashable Zip'
)
header
(
'* Packing Flashable Zip'
)
...
@@ -629,10 +613,6 @@ stub_parser = subparsers.add_parser(
...
@@ -629,10 +613,6 @@ stub_parser = subparsers.add_parser(
'stub'
,
help
=
'build stub Magisk Manager'
)
'stub'
,
help
=
'build stub Magisk Manager'
)
stub_parser
.
set_defaults
(
func
=
build_stub
)
stub_parser
.
set_defaults
(
func
=
build_stub
)
snet_parser
=
subparsers
.
add_parser
(
'snet'
,
help
=
'build snet extention for Magisk Manager'
)
snet_parser
.
set_defaults
(
func
=
build_snet
)
zip_parser
=
subparsers
.
add_parser
(
zip_parser
=
subparsers
.
add_parser
(
'zip'
,
help
=
'zip Magisk into a flashable zip'
)
'zip'
,
help
=
'zip Magisk into a flashable zip'
)
zip_parser
.
set_defaults
(
func
=
zip_main
)
zip_parser
.
set_defaults
(
func
=
zip_main
)
...
...
settings.gradle
View file @
4729514a
include
':app'
,
':signing'
,
':native'
,
':s
net'
,
':s
tub'
,
':shared'
include
':app'
,
':signing'
,
':native'
,
':stub'
,
':shared'
snet/.gitignore
deleted
100644 → 0
View file @
93aedcfe
/build
snet/build.gradle
deleted
100644 → 0
View file @
93aedcfe
apply
plugin:
'com.android.application'
android
{
defaultConfig
{
applicationId
'com.topjohnwu.snet'
minSdkVersion
14
versionCode
13
versionName
'snet'
}
buildTypes
{
release
{
minifyEnabled
true
shrinkResources
true
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
}
}
}
dependencies
{
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
'com.google.android.gms:play-services-safetynet:17.0.0'
}
snet/proguard-rules.pro
deleted
100644 → 0
View file @
93aedcfe
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-
keep
,
allowobfuscation
class
com
.
topjohnwu
.
snet
.
SafetyNetHelper
-
keepclassmembers
class
com
.
topjohnwu
.
snet
.
SafetyNetHelper
{
**
get
(...);
}
-
repackageclasses
'x'
-
allowaccessmodification
snet/src/main/AndroidManifest.xml
deleted
100644 → 0
View file @
93aedcfe
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.topjohnwu.snet"
>
<meta-data
android:name=
"com.google.android.gms.version"
android:value=
"@integer/google_play_services_version"
/>
</manifest>
snet/src/main/java/com/topjohnwu/snet/SafetyNetHelper.java
deleted
100644 → 0
View file @
93aedcfe
package
com
.
topjohnwu
.
snet
;
import
android.content.Context
;
import
android.util.Base64
;
import
android.util.Log
;
import
androidx.annotation.NonNull
;
import
com.google.android.gms.common.ConnectionResult
;
import
com.google.android.gms.common.GoogleApiAvailability
;
import
com.google.android.gms.common.api.ApiException
;
import
com.google.android.gms.safetynet.SafetyNet
;
import
com.google.android.gms.safetynet.SafetyNetApi
;
import
com.google.android.gms.safetynet.SafetyNetClient
;
import
com.google.android.gms.tasks.OnFailureListener
;
import
com.google.android.gms.tasks.OnSuccessListener
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.lang.reflect.InvocationHandler
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Proxy
;
import
java.security.SecureRandom
;
public
class
SafetyNetHelper
implements
InvocationHandler
,
OnSuccessListener
<
SafetyNetApi
.
AttestationResponse
>,
OnFailureListener
{
private
static
final
int
RESPONSE_ERR
=
0x01
;
private
static
final
int
CONNECTION_FAIL
=
0x02
;
private
static
final
int
BASIC_PASS
=
0x10
;
private
static
final
int
CTS_PASS
=
0x20
;
private
static
final
GoogleApiAvailability
API_AVAIL
=
GoogleApiAvailability
.
getInstance
();
private
static
final
SecureRandom
RANDOM
=
new
SecureRandom
();
private
static
final
String
TAG
=
"SNET"
;
private
final
Context
context
;
private
final
Object
callback
;
public
static
Object
get
(
Class
<?>
interfaceClass
,
Context
context
,
Object
cb
)
{
return
Proxy
.
newProxyInstance
(
SafetyNetHelper
.
class
.
getClassLoader
(),
new
Class
[]{
interfaceClass
},
new
SafetyNetHelper
(
context
,
cb
));
}
private
SafetyNetHelper
(
Context
c
,
Object
cb
)
{
context
=
c
;
callback
=
cb
;
}
private
void
invokeCallback
(
int
code
)
{
Class
<?>
clazz
=
callback
.
getClass
();
try
{
clazz
.
getMethod
(
"onResponse"
,
int
.
class
).
invoke
(
callback
,
code
);
}
catch
(
Exception
ignored
)
{
}
}
/* Return magic API key here :) */
private
String
getApiKey
()
{
return
""
;
}
private
int
getVersion
()
{
return
BuildConfig
.
VERSION_CODE
;
}
private
void
attest
()
{
int
code
=
API_AVAIL
.
isGooglePlayServicesAvailable
(
context
);
if
(
code
!=
ConnectionResult
.
SUCCESS
)
{
Log
.
e
(
TAG
,
API_AVAIL
.
getErrorString
(
code
));
invokeCallback
(
CONNECTION_FAIL
);
return
;
}
// Create nonce
byte
[]
nonce
=
new
byte
[
24
];
RANDOM
.
nextBytes
(
nonce
);
SafetyNetClient
client
=
SafetyNet
.
getClient
(
context
);
client
.
attest
(
nonce
,
getApiKey
()).
addOnSuccessListener
(
this
).
addOnFailureListener
(
this
);
}
@Override
public
void
onSuccess
(
SafetyNetApi
.
AttestationResponse
result
)
{
int
code
=
0
;
try
{
String
jsonStr
=
new
String
(
Base64
.
decode
(
result
.
getJwsResult
().
split
(
"\\."
)[
1
],
Base64
.
DEFAULT
));
JSONObject
json
=
new
JSONObject
(
jsonStr
);
code
|=
json
.
getBoolean
(
"ctsProfileMatch"
)
?
CTS_PASS
:
0
;
code
|=
json
.
getBoolean
(
"basicIntegrity"
)
?
BASIC_PASS
:
0
;
}
catch
(
JSONException
e
)
{
code
=
RESPONSE_ERR
;
}
// Return results
invokeCallback
(
code
);
}
@Override
public
void
onFailure
(
@NonNull
Exception
e
)
{
if
(
e
instanceof
ApiException
)
{
int
errCode
=
((
ApiException
)
e
).
getStatusCode
();
Log
.
e
(
TAG
,
API_AVAIL
.
getErrorString
(
errCode
));
}
else
{
Log
.
e
(
TAG
,
"Unknown: "
+
e
);
}
invokeCallback
(
CONNECTION_FAIL
);
}
@Override
public
Object
invoke
(
Object
proxy
,
Method
method
,
Object
[]
args
)
{
switch
(
method
.
getName
())
{
case
"attest"
:
attest
();
break
;
case
"getVersion"
:
return
getVersion
();
}
return
null
;
}
}
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