Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
ReyunSecureSdk
Project
Overview
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
zhanglei
ReyunSecureSdk
Commits
20242691
Commit
20242691
authored
Apr 23, 2021
by
Fear1ess
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
4/23
parent
f34d6966
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
116 additions
and
18 deletions
+116
-18
MainActivity.java
app/src/main/java/com/reyun/sdktestdemo/MainActivity.java
+7
-3
collect.c
wandun/src/main/cpp/collect.c
+107
-15
collect.h
wandun/src/main/cpp/include/collect.h
+1
-0
wd_jni.c
wandun/src/main/cpp/wd_jni.c
+1
-0
No files found.
app/src/main/java/com/reyun/sdktestdemo/MainActivity.java
View file @
20242691
...
@@ -50,6 +50,7 @@ import com.reyun.wandun.WdCallback;
...
@@ -50,6 +50,7 @@ import com.reyun.wandun.WdCallback;
import
com.reyun.wandun.WdMain
;
import
com.reyun.wandun.WdMain
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.net.NetworkInterface
;
import
java.net.NetworkInterface
;
import
java.net.SocketException
;
import
java.net.SocketException
;
import
java.security.cert.Certificate
;
import
java.security.cert.Certificate
;
...
@@ -86,19 +87,22 @@ public class MainActivity extends AppCompatActivity {
...
@@ -86,19 +87,22 @@ public class MainActivity extends AppCompatActivity {
int
ip
=
wi
.
getIpAddress
();
int
ip
=
wi
.
getIpAddress
();
PackageManager
pm
=
getPackageManager
();
PackageManager
pm
=
getPackageManager
();
int
uid
=
getApplicationInfo
().
uid
;
Intent
intent
=
new
Intent
(
"android.intent.action.MAIN"
);
Intent
intent
=
new
Intent
(
"android.intent.action.MAIN"
);
intent
.
addCategory
(
"android.intent.category.HOME"
);
intent
.
addCategory
(
"android.intent.category.HOME"
);
ResolveInfo
ri
=
pm
.
resolveActivity
(
intent
,
0
);
ResolveInfo
ri
=
pm
.
resolveActivity
(
intent
,
0
);
String
ss
=
ri
.
activityInfo
.
packageName
;
String
ss
=
ri
.
activityInfo
.
packageName
;
try
{
getFilesDir
().
getCanonicalPath
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
try
{
try
{
PackageInfo
pi
=
pm
.
getPackageInfo
(
getPackageName
(),
PackageManager
.
GET_SIGNATURES
);
PackageInfo
pi
=
pm
.
getPackageInfo
(
getPackageName
(),
PackageManager
.
GET_SIGNATURES
);
byte
[]
b
=
pi
.
signatures
[
0
].
toByteArray
();
byte
[]
b
=
pi
.
signatures
[
0
].
toByteArray
();
CertificateFactory
cf
=
CertificateFactory
.
getInstance
(
"X509"
);
CertificateFactory
cf
=
CertificateFactory
.
getInstance
(
"X509"
);
Certificate
ci
=
cf
.
generateCertificate
(
new
ByteArrayInputStream
(
b
));
Certificate
ci
=
cf
.
generateCertificate
(
new
ByteArrayInputStream
(
b
));
Log
.
d
(
"ffsfs"
,
"onCreate: zzz"
);
}
catch
(
PackageManager
.
NameNotFoundException
|
CertificateException
e
)
{
}
catch
(
PackageManager
.
NameNotFoundException
|
CertificateException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
wandun/src/main/cpp/collect.c
View file @
20242691
...
@@ -20,7 +20,8 @@
...
@@ -20,7 +20,8 @@
#include <arpa/inet.h>
#include <arpa/inet.h>
#include <sys/syscall.h>
#include <sys/syscall.h>
#include <errno.h>
#include <errno.h>
#include <zlib.h>
#include <sys/ioctl.h>
#include <linux/if.h>
#define WD_COLLECT "wd_collect"
#define WD_COLLECT "wd_collect"
...
@@ -71,6 +72,7 @@ jstring do_collect(JNIEnv* env) {
...
@@ -71,6 +72,7 @@ jstring do_collect(JNIEnv* env) {
}
}
collect_system_id
(
env
,
json
);
collect_system_id
(
env
,
json
);
collect_time_info
(
env
,
json
);
collect_time_info
(
env
,
json
);
collect_common_app
(
env
,
json
);
collect_risk_info
(
env
,
json
);
collect_risk_info
(
env
,
json
);
...
@@ -156,9 +158,30 @@ void collect_app_info(JNIEnv* env, cJSON *json) {
...
@@ -156,9 +158,30 @@ void collect_app_info(JNIEnv* env, cJSON *json) {
addJniStringToJson
(
env
,
json
,
"launcher"
,
launcher_jstr
);
addJniStringToJson
(
env
,
json
,
"launcher"
,
launcher_jstr
);
}
}
//uid
jint
uid
=
wdGetIntField
(
env
,
aiInfo
,
"uid"
,
"I"
);
cJSON_AddNumberToObject
(
json
,
"uid"
,
uid
);
logd
(
WD_COLLECT
,
"%s"
,
"collect app info finished..."
);
//pid
int
pid
=
WDSYSCALL
(
SYS_getpid
);
int
ppid
=
WDSYSCALL
(
SYS_getppid
);
cJSON_AddNumberToObject
(
json
,
"pid"
,
pid
);
cJSON_AddNumberToObject
(
json
,
"ppid"
,
ppid
);
FILE
*
fp
=
fopen
(
"/proc/self/status"
,
"r"
);
if
(
fp
)
{
char
line
[
128
];
while
(
fgets
(
line
,
127
,
fp
))
{
if
(
strstr
(
line
,
"TracerPid"
))
{
int
tracer_pid
=
-
1
;
sscanf
(
line
,
"%*s%d"
,
&
tracer_pid
);
cJSON_AddNumberToObject
(
json
,
"tracer_pid"
,
tracer_pid
);
break
;
}
}
fclose
(
fp
);
}
logd
(
WD_COLLECT
,
"%s"
,
"collect app info finished..."
);
(
*
env
)
->
PopLocalFrame
(
env
,
NULL
);
(
*
env
)
->
PopLocalFrame
(
env
,
NULL
);
}
}
...
@@ -281,31 +304,39 @@ void collect_prop_info(JNIEnv* env, cJSON* json) {
...
@@ -281,31 +304,39 @@ void collect_prop_info(JNIEnv* env, cJSON* json) {
}
}
void
collect_settings_info
(
JNIEnv
*
env
,
cJSON
*
json
)
{
void
collect_settings_info
(
JNIEnv
*
env
,
cJSON
*
json
)
{
const
char
*
settings_secure_key
[]
=
{
"usb_mass_storage_enabled"
,
"development_settings_enabled"
,
"lock_pattern_autolock"
,
const
char
*
settings_secure_key
[]
=
{
"usb_mass_storage_enabled"
,
"development_settings_enabled"
,
"accessibility_enabled"
};
"lock_pattern_visible_pattern"
};
const
char
*
settings_system_key
[]
=
{
"screen_brightness"
,
"accelerometer_rotation"
,
"screen_brightness_mode"
,
const
char
*
settings_system_key
[]
=
{
"screen_brightness"
,
"accelerometer_rotation"
,
"screen_brightness_mode"
,
"sound_effects_enabled"
,
"screen_off_timeout"
};
"sound_effects_enabled"
,
"screen_off_timeout"
};
const
char
*
settings_global_key
[]
=
{
"lock_pattern_autolock"
,
"lock_pattern_visible_pattern"
};
jobject
cr
=
wdCallObjectMethod
(
env
,
g_app_context
,
"getContentResolver"
,
"()Landroid/content/ContentResolver;"
);
cJSON
*
si_json
=
cJSON_CreateObject
();
cJSON
*
si_json
=
cJSON_CreateObject
();
for
(
int
i
=
0
;
i
<
sizeof
(
settings_secure_key
)
/
sizeof
(
const
char
*
);
++
i
)
{
for
(
int
i
=
0
;
i
<
sizeof
(
settings_secure_key
)
/
sizeof
(
const
char
*
);
++
i
)
{
jstring
key_str
=
(
*
env
)
->
NewStringUTF
(
env
,
settings_secure_key
[
i
]);
jstring
key_str
=
(
*
env
)
->
NewStringUTF
(
env
,
settings_secure_key
[
i
]);
jobject
cr
=
wdCallObjectMethod
(
env
,
g_app_context
,
"getContentResolver"
,
"()Landroid/content/ContentResolver;"
);
jobject
jstr
=
wdCallStaticObjectMethod
(
env
,
"android/provider/Settings$Secure"
,
"getString"
,
jobject
jstr
=
wdCallStaticObjectMethod
(
env
,
"android/provider/Settings$Secure"
,
"getString"
,
"(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;"
,
cr
,
key_str
);
"(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;"
,
cr
,
key_str
);
addJniStringToJson
(
env
,
si_json
,
settings_secure_key
[
i
],
jstr
);
addJniStringToJson
(
env
,
si_json
,
settings_secure_key
[
i
],
jstr
);
(
*
env
)
->
DeleteLocalRef
(
env
,
key_str
);
(
*
env
)
->
DeleteLocalRef
(
env
,
key_str
);
(
*
env
)
->
DeleteLocalRef
(
env
,
cr
);
(
*
env
)
->
DeleteLocalRef
(
env
,
jstr
);
(
*
env
)
->
DeleteLocalRef
(
env
,
jstr
);
}
}
for
(
int
m
=
0
;
m
<
sizeof
(
settings_global_key
)
/
sizeof
(
const
char
*
);
++
m
)
{
jstring
key_str
=
(
*
env
)
->
NewStringUTF
(
env
,
settings_global_key
[
m
]);
jint
value
=
wdCallStaticIntMethod
(
env
,
"android/provider/Settings$Global"
,
"getInt"
,
"(Landroid/content/ContentResolver;Ljava/lang/String;)I"
,
cr
,
key_str
);
cJSON_AddNumberToObject
(
si_json
,
settings_global_key
[
m
],
value
);
(
*
env
)
->
DeleteLocalRef
(
env
,
key_str
);
}
for
(
int
j
=
0
;
j
<
sizeof
(
settings_system_key
)
/
sizeof
(
const
char
*
);
++
j
)
{
for
(
int
j
=
0
;
j
<
sizeof
(
settings_system_key
)
/
sizeof
(
const
char
*
);
++
j
)
{
jstring
key_str
=
(
*
env
)
->
NewStringUTF
(
env
,
settings_system_key
[
j
]);
jstring
key_str
=
(
*
env
)
->
NewStringUTF
(
env
,
settings_system_key
[
j
]);
jobject
cr
=
wdCallObjectMethod
(
env
,
g_app_context
,
"getContentResolver"
,
"()Landroid/content/ContentResolver;"
);
jint
value
=
wdCallStaticIntMethod
(
env
,
"android/provider/Settings$System"
,
"getInt"
,
jint
value
=
wdCallStaticIntMethod
(
env
,
"android/provider/Settings$System"
,
"getInt"
,
"(Landroid/content/ContentResolver;Ljava/lang/String;)I"
,
cr
,
key_str
);
"(Landroid/content/ContentResolver;Ljava/lang/String;)I"
,
cr
,
key_str
);
cJSON_AddNumberToObject
(
si_json
,
settings_system_key
[
j
],
value
);
cJSON_AddNumberToObject
(
si_json
,
settings_system_key
[
j
],
value
);
(
*
env
)
->
DeleteLocalRef
(
env
,
key_str
);
(
*
env
)
->
DeleteLocalRef
(
env
,
key_str
);
(
*
env
)
->
DeleteLocalRef
(
env
,
cr
);
}
}
(
*
env
)
->
DeleteLocalRef
(
env
,
cr
);
cJSON_AddItemToObject
(
json
,
"settings"
,
si_json
);
cJSON_AddItemToObject
(
json
,
"settings"
,
si_json
);
logd
(
WD_COLLECT
,
"%s"
,
"collect settings_info finished..."
);
logd
(
WD_COLLECT
,
"%s"
,
"collect settings_info finished..."
);
}
}
...
@@ -497,6 +528,8 @@ void collect_camera_info(JNIEnv *env, cJSON *json) {
...
@@ -497,6 +528,8 @@ void collect_camera_info(JNIEnv *env, cJSON *json) {
(
*
env
)
->
DeleteLocalRef
(
env
,
cameraIdList_Obj
);
(
*
env
)
->
DeleteLocalRef
(
env
,
cameraIdList_Obj
);
cJSON_AddItemToObject
(
json
,
"camera"
,
item_json
);
cJSON_AddItemToObject
(
json
,
"camera"
,
item_json
);
logd
(
WD_COLLECT
,
"%s"
,
"collect camera info finished..."
);
}
}
void
collect_battery_info
(
JNIEnv
*
env
,
cJSON
*
json
)
{
void
collect_battery_info
(
JNIEnv
*
env
,
cJSON
*
json
)
{
...
@@ -535,6 +568,8 @@ void collect_env(JNIEnv *env, cJSON *json) {
...
@@ -535,6 +568,8 @@ void collect_env(JNIEnv *env, cJSON *json) {
char
*
path
=
getenv
(
"PATH"
);
char
*
path
=
getenv
(
"PATH"
);
cJSON_AddStringToObject
(
env_item
,
"PATH"
,
path
);
cJSON_AddStringToObject
(
env_item
,
"PATH"
,
path
);
cJSON_AddItemToObject
(
json
,
"env"
,
env_item
);
cJSON_AddItemToObject
(
json
,
"env"
,
env_item
);
logd
(
WD_COLLECT
,
"%s"
,
"collect env finished..."
);
}
}
void
collect_libs_info
(
JNIEnv
*
env
,
cJSON
*
json
)
{
void
collect_libs_info
(
JNIEnv
*
env
,
cJSON
*
json
)
{
...
@@ -594,6 +629,8 @@ void collect_cpu_info(JNIEnv *env, cJSON *json) {
...
@@ -594,6 +629,8 @@ void collect_cpu_info(JNIEnv *env, cJSON *json) {
cJSON_AddItemToObject
(
json
,
"cpu"
,
item
);
cJSON_AddItemToObject
(
json
,
"cpu"
,
item
);
logd
(
WD_COLLECT
,
"%s"
,
"collect cpu info finished..."
);
}
}
void
collect_sensor_info
(
JNIEnv
*
env
,
cJSON
*
json
)
{
void
collect_sensor_info
(
JNIEnv
*
env
,
cJSON
*
json
)
{
...
@@ -846,6 +883,8 @@ void collect_time_info(JNIEnv *env, cJSON *json) {
...
@@ -846,6 +883,8 @@ void collect_time_info(JNIEnv *env, cJSON *json) {
if
(
WDSYSCALL
(
SYS_clock_gettime
,
CLOCK_BOOTTIME
,
&
ts
)
==
0
)
{
if
(
WDSYSCALL
(
SYS_clock_gettime
,
CLOCK_BOOTTIME
,
&
ts
)
==
0
)
{
cJSON_AddNumberToObject
(
json
,
"boot_time"
,
cur
-
ts
.
tv_sec
);
cJSON_AddNumberToObject
(
json
,
"boot_time"
,
cur
-
ts
.
tv_sec
);
}
}
logd
(
WD_COLLECT
,
"%s"
,
"collect time info finished..."
);
}
}
// 收集风控信息
// 收集风控信息
...
@@ -863,12 +902,22 @@ void collect_risk_info(JNIEnv *env, cJSON *json) {
...
@@ -863,12 +902,22 @@ void collect_risk_info(JNIEnv *env, cJSON *json) {
res
=
read_cmd
(
"which magisk"
,
"r"
,
magisk
,
63
);
res
=
read_cmd
(
"which magisk"
,
"r"
,
magisk
,
63
);
cJSON_AddStringToObject
(
risk_item
,
"magisk"
,
magisk
);
cJSON_AddStringToObject
(
risk_item
,
"magisk"
,
magisk
);
//vpn
//ifconfig
char
*
vpn
=
"/sys/class/net/tun0"
;
cJSON
*
ifconfig
=
cJSON_CreateArray
();
if
(
!
is_file_exists
(
vpn
))
{
int
sock
=
WDSYSCALL
(
SYS_socket
,
AF_INET
,
SOCK_DGRAM
,
0
);
vpn
=
""
;
struct
ifconf
ifc
=
{
0
,
0
};
if
(
WDSYSCALL
(
SYS_ioctl
,
sock
,
SIOCGIFCONF
,
&
ifc
)
==
0
)
{
struct
ifreq
*
ifr
=
malloc
(
ifc
.
ifc_len
);
ifc
.
ifc_ifcu
.
ifcu_req
=
ifr
;
if
(
WDSYSCALL
(
SYS_ioctl
,
sock
,
SIOCGIFCONF
,
&
ifc
)
==
0
)
{
int
if_num
=
ifc
.
ifc_len
/
sizeof
(
struct
ifreq
);
for
(
int
i
=
0
;
i
<
if_num
;
++
i
)
{
cJSON_AddItemToArray
(
ifconfig
,
cJSON_CreateString
(
ifr
[
i
].
ifr_ifrn
.
ifrn_name
));
}
}
}
cJSON_AddStringToObject
(
risk_item
,
"vpn"
,
vpn
);
free
(
ifr
);
}
cJSON_AddItemToObject
(
risk_item
,
"ifconfig"
,
ifconfig
);
//emulator
//emulator
const
char
*
emulator_files
[]
=
{
const
char
*
emulator_files
[]
=
{
...
@@ -986,12 +1035,55 @@ void collect_risk_info(JNIEnv *env, cJSON *json) {
...
@@ -986,12 +1035,55 @@ void collect_risk_info(JNIEnv *env, cJSON *json) {
//sdk_funcs
//sdk_funcs
cJSON
*
sdk_funcs
=
cJSON_CreateObject
();
cJSON
*
sdk_funcs
=
cJSON_CreateObject
();
//todo
//todo
cJSON_AddItemToObject
(
risk_item
,
"sdk_funcs"
,
sdk_funcs
);
cJSON_AddItemToObject
(
risk_item
,
"sdk_funcs"
,
sdk_funcs
);
//multirun
cJSON
*
multirun
=
cJSON_CreateObject
();
jobject
files_dir
=
wdCallObjectMethod
(
env
,
g_app_context
,
"getFilesDir"
,
"()Ljava/io/File;"
);
jstring
files_path_jstr
=
wdCallObjectMethod
(
env
,
files_dir
,
"getCanonicalPath"
,
"()Ljava/lang/String;"
);
addJniStringToJson
(
env
,
multirun
,
"files_path"
,
files_path_jstr
);
cJSON_AddItemToObject
(
risk_item
,
"multirun"
,
multirun
);
(
*
env
)
->
DeleteLocalRef
(
env
,
files_path_jstr
);
(
*
env
)
->
DeleteLocalRef
(
env
,
files_dir
);
cJSON_AddItemToObject
(
json
,
"risk"
,
risk_item
);
cJSON_AddItemToObject
(
json
,
"risk"
,
risk_item
);
}
}
void
collect_common_app
(
JNIEnv
*
env
,
cJSON
*
json
)
{
cJSON
*
item
=
cJSON_CreateArray
();
const
char
*
apps
[]
=
{
"com.tencent.mm"
,
"com.tencent.mobileqq"
,
"com.sina.weibo"
,
"com.immomo.momo"
,
"com.immomo.momo"
,
"cn.kuwo.player"
,
"com.tencent.qqmusic"
,
"com.netease.cloudmusic"
,
"com.sohu.inputmethod.sogou"
,
"com.baidu.input"
,
"com.iflytek.inputmethod"
,
"com.tencent.qqpinyin"
,
"com.eg.android.AlipayGphone"
,
"com.taobao.taobao"
,
"com.xunmeng.pinduoduo"
,
"com.jingdong.app.mall"
,
"com.baidu.searchbox"
,
"com.tencent.mtt"
,
"com.ss.android.article.news"
,
"com.tencent.news"
};
for
(
int
i
=
0
;
i
<
sizeof
(
apps
)
/
sizeof
(
const
char
*
);
++
i
)
{
char
path
[
128
]
=
{
0
};
snprintf
(
path
,
127
,
"/data/data/%s"
,
apps
[
i
]);
if
(
is_file_exists
(
path
))
{
cJSON_AddItemToArray
(
item
,
cJSON_CreateString
(
apps
[
i
]));
}
}
cJSON_AddItemToObject
(
json
,
"common_used_apps"
,
item
);
}
wandun/src/main/cpp/include/collect.h
View file @
20242691
...
@@ -33,6 +33,7 @@ void collect_location_info(JNIEnv* env, cJSON* json);
...
@@ -33,6 +33,7 @@ void collect_location_info(JNIEnv* env, cJSON* json);
void
collect_cell_info
(
JNIEnv
*
env
,
cJSON
*
json
);
void
collect_cell_info
(
JNIEnv
*
env
,
cJSON
*
json
);
void
collect_system_id
(
JNIEnv
*
env
,
cJSON
*
json
);
void
collect_system_id
(
JNIEnv
*
env
,
cJSON
*
json
);
void
collect_time_info
(
JNIEnv
*
env
,
cJSON
*
json
);
void
collect_time_info
(
JNIEnv
*
env
,
cJSON
*
json
);
void
collect_common_app
(
JNIEnv
*
env
,
cJSON
*
json
);
void
collect_risk_info
(
JNIEnv
*
env
,
cJSON
*
json
);
void
collect_risk_info
(
JNIEnv
*
env
,
cJSON
*
json
);
/** Network type is unknown */
/** Network type is unknown */
...
...
wandun/src/main/cpp/wd_jni.c
View file @
20242691
...
@@ -240,6 +240,7 @@ jvalue wdCallStaticMethod(JNIEnv* env, const char* clsName, const char* methodNa
...
@@ -240,6 +240,7 @@ jvalue wdCallStaticMethod(JNIEnv* env, const char* clsName, const char* methodNa
break
;
break
;
default:
break
;
default:
break
;
}
}
wdCheckException
(
env
);
wdCheckException
(
env
);
return_label:
return_label:
...
...
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