[APP][PATCH] SnoopSnitch OnePlus Compatibility Patch

h3ph4est7s

New member
Aug 27, 2020
1
0
0
After some trial and error, I have identified the reason why snoopsnitch isn't working.

The issue is related to the DIAG initialization code in the diag-helper binary.
I'm attaching a working patch and a compiled APK (PM me for the link or maybe a mod. can attach it. I have 10 post link restriction) for your convenience.

PS: the code specifically look for OnePlus manufacturer but it may work on other devices too (with the appropriate changes)

Code:
diff --git a/contrib/diag_helper/jni/diag-helper.c b/contrib/diag_helper/jni/diag-helper.c
index ddb7fcb1..c1b00a33 100644
--- a/contrib/diag_helper/jni/diag-helper.c
+++ b/contrib/diag_helper/jni/diag-helper.c
@@ -3,6 +3,7 @@
 #include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/un.h>
+#include <sys/system_properties.h>
 
 #include <android/log.h>
 
@@ -13,6 +14,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <arpa/inet.h>
+#include <string.h>
 
 
 #define BUF_SIZE 1000000
@@ -62,9 +64,15 @@ open_diag_dev(void)
         int diag_fd = -1;
         int rv = -1;
         int olderrno;
+        bool op = false;
+        char man[PROP_VALUE_MAX + 1];
+
+        __system_property_get("ro.product.manufacturer", man);
 
         logmsg(ANDROID_LOG_DEBUG, "opening diag device");
 
+        if (strcasecmp("oneplus", man) == 0) op = true;
+
         diag_fd = open("/dev/diag", O_RDWR|O_CLOEXEC);
         if (diag_fd < 0) {
                 logmsg(ANDROID_LOG_FATAL, "error opening diag device: %m");
@@ -74,6 +82,7 @@ open_diag_dev(void)
         const unsigned long DIAG_IOCTL_SWITCH_LOGGING = 7;
         const int MEMORY_DEVICE_MODE = 2;
 
+        const int mode_param[] = { MEMORY_DEVICE_MODE, -1, 0 };
         struct diag_logging_mode_param_t stMode = {
 			MEMORY_DEVICE_MODE, 0, 1
 		};
@@ -84,7 +93,10 @@ open_diag_dev(void)
         rv = ioctl(diag_fd, DIAG_IOCTL_SWITCH_LOGGING, MEMORY_DEVICE_MODE);
         if (rv < 0) {
             olderrno = errno;
-            rv = ioctl(diag_fd, DIAG_IOCTL_SWITCH_LOGGING, (void *)&stMode);
+            if(op)
+                rv = ioctl(diag_fd, DIAG_IOCTL_SWITCH_LOGGING, (void *)&mode_param, sizeof(mode_param));
+            else
+                rv = ioctl(diag_fd, DIAG_IOCTL_SWITCH_LOGGING, (void *)&stMode);
         }
 
         if (rv < 0) {
Credits: SRLabs, original author repository: https://opensource.srlabs.de/projects/snoopsnitch

{Mod edit: Added apk on request of OP @h3ph4est7s}
 

Attachments

Last edited by a moderator:

Zaphod_B_1

Member
Oct 7, 2015
16
7
23
Hi,

Thanks for the apk! It's great to see it again running (especially initializing) on my device, love it! As I already wrote in another posting in another thread (sorry for the double post, but in this specific case it's OK I think), there are two things that need to be mentioned:

- the patch level checks do not work on my device, maybe this depends in the ROM I'm using (I'm on Havoc 3.8 / Android 10) - I'll have to check if it maybe works with another ROM.

- I currently cannot say if the detection of silent SMS and IMSI Catchers really is working since I've havent't had such events till now. Silent SMSes should appear from time to time IMO. IMSI catcher events are extremely rare in my experience, I used Snoop Snitch for about one year two or three years ago and got two of those events in the whole year: one in Germany, one in Canada.

Cheers

Zap
 

asprakash83

Member
Feb 8, 2016
6
0
1
I am also facing the same DIAG_CHAR initializing issue. I used your snoopsnitch apk to test on my Oneplus 5, LOS16. The app started, but closed immediately. The backend service keep on restarted. My logcat shows as below.

12-11 13:16:12.186 9407 9407 E [email protected]: Could not get passthrough implementation for [email protected]::ICameraProvider/legacy/0.
12-11 13:16:12.198 9417 9417 I diag-helper: starting
12-11 13:16:12.198 9417 9417 I diag-helper: test mode invoked
12-11 13:16:12.198 9417 9417 D diag-helper: opening diag device
12-11 13:16:12.198 9417 9417 F diag-helper: error setting diag device logging mode: Bad address/Invalid argument
12-11 13:16:12.199 9417 9417 E diag-helper: error opening DIAG device
12-11 13:16:12.200 9261 9261 E msd-service: Terminating MsdService after shutting down due to an unexpected error
12-11 13:16:12.202 9261 9261 I opSnitchServic: System.exit called, status: 1
12-11 13:16:12.202 9261 9261 I AndroidRuntime: VM exiting with result code 1, cleanup skipped.
12-11 13:16:12.215 1359 9176 I ActivityManager: Process .SnoopSnitchService (pid 9261) has died: fore SVC
12-11 13:16:12.215 1359 9176 W ActivityManager: Scheduling restart of crashed service de.srlabs.snoopsnitch/.qdmon.MsdService in 1000ms
12-11 13:16:12.215 1359 1405 W libprocessgroup: kill(-9261, 9) failed: No such process
12-11 13:16:12.215 1359 1405 I libprocessgroup: Successfully killed process cgroup uid 10092 pid 9261 in 0ms
Any kind of help is appreciated.