Commit 20242691 by Fear1ess

4/23

parent f34d6966
......@@ -50,6 +50,7 @@ import com.reyun.wandun.WdCallback;
import com.reyun.wandun.WdMain;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.security.cert.Certificate;
......@@ -86,19 +87,22 @@ public class MainActivity extends AppCompatActivity {
int ip = wi.getIpAddress();
PackageManager pm =getPackageManager();
int uid = getApplicationInfo().uid;
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.HOME");
ResolveInfo ri = pm.resolveActivity(intent, 0);
String ss = ri.activityInfo.packageName;
try {
getFilesDir().getCanonicalPath();
} catch (IOException e) {
e.printStackTrace();
}
try {
PackageInfo pi = pm.getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
byte[] b = pi.signatures[0].toByteArray();
CertificateFactory cf = CertificateFactory.getInstance("X509");
Certificate ci = cf.generateCertificate(new ByteArrayInputStream(b));
Log.d("ffsfs", "onCreate: zzz");
} catch (PackageManager.NameNotFoundException | CertificateException e) {
e.printStackTrace();
}
......
......@@ -20,7 +20,8 @@
#include <arpa/inet.h>
#include <sys/syscall.h>
#include <errno.h>
#include <zlib.h>
#include <sys/ioctl.h>
#include <linux/if.h>
#define WD_COLLECT "wd_collect"
......@@ -71,6 +72,7 @@ jstring do_collect(JNIEnv* env) {
}
collect_system_id(env, json);
collect_time_info(env, json);
collect_common_app(env, json);
collect_risk_info(env, json);
......@@ -156,9 +158,30 @@ void collect_app_info(JNIEnv* env, cJSON *json) {
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);
}
......@@ -281,31 +304,39 @@ void collect_prop_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",
"lock_pattern_visible_pattern"};
const char* settings_secure_key[] = {"usb_mass_storage_enabled", "development_settings_enabled", "accessibility_enabled"};
const char* settings_system_key[] = {"screen_brightness", "accelerometer_rotation", "screen_brightness_mode",
"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();
for(int i = 0; i < sizeof(settings_secure_key)/sizeof(const char*); ++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",
"(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;", cr, key_str);
addJniStringToJson(env, si_json, settings_secure_key[i], jstr);
(*env)->DeleteLocalRef(env, key_str);
(*env)->DeleteLocalRef(env, cr);
(*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) {
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",
"(Landroid/content/ContentResolver;Ljava/lang/String;)I", cr, key_str);
cJSON_AddNumberToObject(si_json, settings_system_key[j], value);
(*env)->DeleteLocalRef(env, key_str);
(*env)->DeleteLocalRef(env, cr);
}
(*env)->DeleteLocalRef(env, cr);
cJSON_AddItemToObject(json, "settings", si_json);
logd(WD_COLLECT, "%s", "collect settings_info finished...");
}
......@@ -497,6 +528,8 @@ void collect_camera_info(JNIEnv *env, cJSON *json) {
(*env)->DeleteLocalRef(env, cameraIdList_Obj);
cJSON_AddItemToObject(json, "camera", item_json);
logd(WD_COLLECT, "%s", "collect camera info finished...");
}
void collect_battery_info(JNIEnv *env, cJSON *json) {
......@@ -535,6 +568,8 @@ void collect_env(JNIEnv *env, cJSON *json) {
char* path = getenv("PATH");
cJSON_AddStringToObject(env_item, "PATH", path);
cJSON_AddItemToObject(json, "env", env_item);
logd(WD_COLLECT, "%s", "collect env finished...");
}
void collect_libs_info(JNIEnv *env, cJSON *json) {
......@@ -594,6 +629,8 @@ void collect_cpu_info(JNIEnv *env, cJSON *json) {
cJSON_AddItemToObject(json, "cpu", item);
logd(WD_COLLECT, "%s", "collect cpu info finished...");
}
void collect_sensor_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) {
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) {
res = read_cmd("which magisk", "r", magisk, 63);
cJSON_AddStringToObject(risk_item, "magisk", magisk);
//vpn
char *vpn = "/sys/class/net/tun0";
if (!is_file_exists(vpn)) {
vpn = "";
//ifconfig
cJSON* ifconfig = cJSON_CreateArray();
int sock = WDSYSCALL(SYS_socket, AF_INET, SOCK_DGRAM, 0);
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
const char *emulator_files[] = {
......@@ -986,12 +1035,55 @@ void collect_risk_info(JNIEnv *env, cJSON *json) {
//sdk_funcs
cJSON* sdk_funcs = cJSON_CreateObject();
//todo
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);
}
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);
}
......@@ -33,6 +33,7 @@ void collect_location_info(JNIEnv* env, cJSON* json);
void collect_cell_info(JNIEnv* env, cJSON* json);
void collect_system_id(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);
/** Network type is unknown */
......
......@@ -240,6 +240,7 @@ jvalue wdCallStaticMethod(JNIEnv* env, const char* clsName, const char* methodNa
break;
default: break;
}
wdCheckException(env);
return_label:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment