Commit 39118ec8 by Fear1ess

4/8

parent 89da278b
...@@ -57,6 +57,7 @@ import java.security.cert.CertificateException; ...@@ -57,6 +57,7 @@ import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory; import java.security.cert.CertificateFactory;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Properties;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
private TextView mText; private TextView mText;
...@@ -110,13 +111,12 @@ public class MainActivity extends AppCompatActivity { ...@@ -110,13 +111,12 @@ public class MainActivity extends AppCompatActivity {
} catch (CameraAccessException e) { } catch (CameraAccessException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@Override @Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if(requestCode == 100) { if(requestCode == 100) {
String aa = System.getProperty("http.agent");
//初始化sdk环境 //初始化sdk环境
WdMain wm = WdMain.getInstance(); WdMain wm = WdMain.getInstance();
wm.init(getApplicationContext(), "test-a341fsfr3123ddadfs"); wm.init(getApplicationContext(), "test-a341fsfr3123ddadfs");
...@@ -138,7 +138,6 @@ public class MainActivity extends AppCompatActivity { ...@@ -138,7 +138,6 @@ public class MainActivity extends AppCompatActivity {
Log.d(TAG, "onError: " + errorMsg); Log.d(TAG, "onError: " + errorMsg);
}*/ }*/
}); });
} }
} }
} }
......
...@@ -6,11 +6,15 @@ include_directories(${CMAKE_SOURCE_DIR}/include) ...@@ -6,11 +6,15 @@ include_directories(${CMAKE_SOURCE_DIR}/include)
if(${CMAKE_ANDROID_ARCH_ABI} STREQUAL "arm64-v8a") if(${CMAKE_ANDROID_ARCH_ABI} STREQUAL "arm64-v8a")
set(ARCH_DEPENDED_SRC set(ARCH_DEPENDED_SRC
wd_syscall64.s) wd_syscall_aarch64.s)
elseif (${CMAKE_ANDROID_ARCH_ABI} STREQUAL "armeabi-v7a") elseif (${CMAKE_ANDROID_ARCH_ABI} STREQUAL "armeabi-v7a")
set(ARCH_DEPENDED_SRC set(ARCH_DEPENDED_SRC
wd_syscall32.s) wd_syscall_arm.s)
elseif (${CMAKE_ANDROID_ARCH_ABI} STREQUAL "x86")
set(ARCH_DEPENDED_SRC
wd_syscall_x86.s)
endif() endif()
add_library( add_library(
......
...@@ -386,11 +386,10 @@ void collect_env(JNIEnv *env, cJSON *json) { ...@@ -386,11 +386,10 @@ void collect_env(JNIEnv *env, cJSON *json) {
void collect_libs_info(JNIEnv *env, cJSON *json) { void collect_libs_info(JNIEnv *env, cJSON *json) {
cJSON* item = cJSON_CreateObject(); cJSON* item = cJSON_CreateObject();
const char* lib_names[] = {"libwdun.so", "libc.so"}; const char* lib_names[] = {"libwdun.so", "libc.so"};
int pid = WDSYSCALL(SYS_getpid);
for(int j = 0; j < sizeof(lib_names)/sizeof(const char*); ++j) { for(int j = 0; j < sizeof(lib_names)/sizeof(const char*); ++j) {
char cmd[64] = {0}; char cmd[64] = {0};
char line[1024] = {0}; char line[1024] = {0};
snprintf(cmd, 63, "cat /proc/%d/maps | grep %s", pid, lib_names[j]); snprintf(cmd, 63, "cat /proc/self/maps | grep %s", lib_names[j]);
FILE *fp = g_funcs.wd_popen(cmd, "r"); FILE *fp = g_funcs.wd_popen(cmd, "r");
if(fgets(line, 1024, fp)) { if(fgets(line, 1024, fp)) {
int pos = 0; int pos = 0;
...@@ -589,6 +588,15 @@ void collect_user_agent(JNIEnv *env, cJSON *json) { ...@@ -589,6 +588,15 @@ void collect_user_agent(JNIEnv *env, cJSON *json) {
addJniStringToJson(env, json, "user-agent", ua_jstr); addJniStringToJson(env, json, "user-agent", ua_jstr);
(*env)->DeleteLocalRef(env, ua_jstr); (*env)->DeleteLocalRef(env, ua_jstr);
jstring key_jstr = (*env)->NewStringUTF(env, "http.agent");
jobject ua2_jstr = wdCallStaticObjectMethod(env, "java/lang/System", "getProperty",
"(Ljava/lang/String;)Ljava/lang/String;", key_jstr);
addJniStringToJson(env, json, "user-agent2", ua2_jstr);
(*env)->DeleteLocalRef(env, key_jstr);
(*env)->DeleteLocalRef(env, ua2_jstr);
logd(WD_COLLECT, "%s", "collect user agent finished..."); logd(WD_COLLECT, "%s", "collect user agent finished...");
} }
...@@ -701,5 +709,63 @@ void collect_risk_info(JNIEnv *env, cJSON *json) { ...@@ -701,5 +709,63 @@ void collect_risk_info(JNIEnv *env, cJSON *json) {
vpn = ""; vpn = "";
} }
cJSON_AddStringToObject(json, "vpn", vpn); cJSON_AddStringToObject(json, "vpn", vpn);
//emulator
const char* emulator_files[] = {
"/dev/socket/qemud",
"/dev/qemu_pipe",
"/goldfish",
"/system/lib/libc_malloc_debug_qemu.so",
"/sys/qemu_trace",
"/system/bin/microvirt-prop",
"/system/lib/libdroid4x.so",
"/system/bin/windroyed",
"/system/bin/microvirtd",
"/system/bin/nox-prop",
"/system/bin/ttVM-prop",
"/system/bin/droid4x-prop",
"/data/.bluestacks.prop",
"/data/app/com.bluestacks.appmart-1.apk",
"/data/app/com.bluestacks.home-1.apk",
"/data/app/com.bluestacks.searchapp-1.apk",
"/data/data/com.bluestacks.setup",
"/dev/vboxuser",
"/fstab.vbox86",
"/init.vbox86.rc",
"/init.svc.vbox86-setup",
"/sys/bus/pci/drivers/vboxguest/module",
"/sys/bus/pci/drivers/vboxguest/new_id",
"/sys/bus/pci/drivers/vboxguest/remove_id",
"/sys/bus/pci/drivers/vboxguest/uevent",
"/sys/bus/platform/drivers/qemu_pipe",
"/sys/bus/platform/drivers/qemu_trace",
"/init.svc.droid4x",
"/init.svc.noxd",
"/init.svc.microvirtd",
"/ro.kernel.android.qemud",
"/androVM.vbox_dpi",
"/androVM.vbox_graph_mode",
"/system/bin/qemu_props",
"/system/bin/androVM-prop",
"/system/lib/libaligl2.so",
"/system/lib/libalitag.so",
"/system/lib/libcloudletevent.so",
"/system/lib/libcloudletos.so",
"/system/lib/nemuguest.ko",
"/system/lib/nemusf.ko",
"/system/lib/nemuvideo.ko",
"/system/lib/vpipe.ko",
"/system/lib/vpipe_novt.ko",
"/system/lib/vboxguest.ko",
"/system/lib/vboxsf.ko",
};
cJSON* emulator = cJSON_CreateArray();
for(int i = 0; i < sizeof(emulator_files)/sizeof(const char*); ++i) {
if(is_file_exists(emulator_files[i])) {
cJSON_AddItemToArray(emulator, cJSON_CreateString(emulator_files[i]));
}
}
cJSON_AddItemToObject(json, "emulator", emulator);
} }
...@@ -10,18 +10,30 @@ ...@@ -10,18 +10,30 @@
#ifdef __arm__ #ifdef __arm__
#define WDSYSCALL(cmd, args...) wd_syscall32(WDNUM(cmd), ##args) #define WDSYSCALL(cmd, args...) wd_syscall_arm(WDNUM(cmd), ##args)
#define WD_SYS_mmap SYS_mmap2 #define WD_SYS_mmap SYS_mmap2
#endif #endif
#ifdef __aarch64__ #ifdef __aarch64__
#define WDSYSCALL(cmd, args...) wd_syscall64(WDNUM(cmd), ##args) #define WDSYSCALL(cmd, args...) wd_syscall_aarch64(WDNUM(cmd), ##args)
#define WD_SYS_mmap SYS_mmap
#endif
#ifdef x86
#define WDSYSCALL(cmd, args...) wd_syscall_x86(WDNUM(cmd), ##args)
#define WD_SYS_mmap SYS_mmap
#endif
#ifdef x86_64
#define WDSYSCALL(cmd, args...) wd_syscall_x64(WDNUM(cmd), ##args)
#define WD_SYS_mmap SYS_mmap #define WD_SYS_mmap SYS_mmap
#endif #endif
#define IMPORTWDSYSCALL \ #define IMPORTWDSYSCALL \
__attribute__((visibility("hidden"))) extern long wd_syscall32(int cmd, ...);\ __attribute__((visibility("hidden"))) extern long wd_syscall_arm(int cmd, ...);\
__attribute__((visibility("hidden"))) extern long wd_syscall64(int cmd, ...); __attribute__((visibility("hidden"))) extern long wd_syscall_aarch64(int cmd, ...);\
__attribute__((visibility("hidden"))) extern long wd_syscall_x86(int cmd, ...);\
__attribute__((visibility("hidden"))) extern long wd_syscall_x64(int cmd, ...);
long wd_set_errno(int n); long wd_set_errno(int n);
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "syscall.h" #include "syscall.h"
#include "fcntl.h" #include "fcntl.h"
#include "errno.h" #include "errno.h"
#include "unistd.h"
IMPORTWDSYSCALL IMPORTWDSYSCALL
...@@ -150,9 +151,8 @@ int read_file(const char *file_path, const char *mode, char *r_buf, size_t r_len ...@@ -150,9 +151,8 @@ int read_file(const char *file_path, const char *mode, char *r_buf, size_t r_len
} }
int is_file_exists(const char *file_path) { int is_file_exists(const char *file_path) {
int fd = WDSYSCALL(SYS_faccessat, AT_FDCWD, file_path, R_OK, 0); int res = WDSYSCALL(SYS_faccessat, AT_FDCWD, file_path, F_OK, 0);
int err = errno; int err = errno;
if(fd == -1) return 0; if(res == -1) return 0;
WDSYSCALL(SYS_close, fd);
return 1; return 1;
} }
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// Created by Fear1ess on 2021/3/31. // Created by Fear1ess on 2021/3/31.
// //
.global wd_syscall64 .global wd_syscall_aarch64
.extern wd_set_errno .extern wd_set_errno
.type wd_syscall64, %function .type wd_syscall_aarch64, %function
wd_syscall64: wd_syscall_aarch64:
/* Move syscall No. from x0 to x8 */ /* Move syscall No. from x0 to x8 */
sub x0, x0, #0xcd sub x0, x0, #0xcd
mov x8, x0 mov x8, x0
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// Created by Fear1ess on 2021/3/31. // Created by Fear1ess on 2021/3/31.
// //
.global wd_syscall32 .global wd_syscall_arm
.extern wd_set_errno .extern wd_set_errno
.type wd_syscall32, %function .type wd_syscall_arm, %function
wd_syscall32: wd_syscall_arm:
mov ip, sp mov ip, sp
stmfd sp!, {r4, r5, r6, r7} stmfd sp!, {r4, r5, r6, r7}
sub r0, r0, #0xcd sub r0, r0, #0xcd
......
.global wd_syscall_x86
.extern wd_set_errno
.type wd_syscall_x86, %function
wd_syscall_x86:
# Push the callee save registers.
push %ebx
push %esi
push %edi
push %ebp
# Get and save the system call entry address.
int $80
push %eax
# Load all the arguments from the calling frame.
# (Not all will be valid, depending on the syscall.)
mov 24(%esp),%eax
mov 28(%esp),%ebx
mov 32(%esp),%ecx
mov 36(%esp),%edx
mov 40(%esp),%esi
mov 44(%esp),%edi
mov 48(%esp),%ebp
# Make the system call.
call *(%esp)
addl $4, %esp
# Error?
cmpl $-4096, %eax
jb 1f
# Yes, so set errno.
negl %eax
pushl %eax
call wd_set_errno
addl $4, %esp
1:
# Restore the callee save registers.
pop %ebp
pop %edi
pop %esi
pop %ebx
ret
\ No newline at end of file
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