Operation on SMS

Post your questions and help other users.

Moderator: Martin

akhileshg1988
Posts: 109
Joined: 16 Apr 2014 04:57

Re: Operation on SMS

Post by akhileshg1988 » 20 Dec 2017 02:37

Hey brother!

First:- The sqlite app I installed doesn't have a UI. As soon as I launch it, a screen pops up giving an option "Install" and saying "Requires root privileges". After I press "Install", it says "downloading..." and after a few seconds, it says "installation complete :D". Thereafter nothing happens, no UI, no options, nothing.

Second:- I installed a root explorer app. Since I'm on Android 7.1.2, therefore tried navigating to /data/user_de/0/com.android.providers.telephony
but this folder doesn't open. The root explorer instead gives the option "Open with" (other apps).
In the "Open with" (other apps) option, the other apps listed there are html viewer and my browser.

What do I do?

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Operation on SMS

Post by Desmanto » 20 Dec 2017 04:13

@bogdyro : I was expecting a shorter flow. I don't use sms received trigger, but simply use Notification on Statusbar Displayed trigger. Then mirror all of necessary text and dismiss notif from messaging app. For the sqlite3, I copy the binary from Titanium Backup data files, directly to /system/xbin/. Most root users should have installed this app.

To test the database, I simply copy the mmssms.db to /sdcard/download and tried it the first there. Then to delete the corresponding message, I don't query the message anymore, but directly perfom delete/update to the database (thus need to be tested first). I have also made triple backup before, backup from TWRP, titanium backup the messaging app, and xml. I am thinking to use the time of the notification as the WHERE clause, or maybe the body text (retrieved from the notification) to match the deletion row. But I don't know if the time stamp will match the date, I am still logging the sms variable to confirm the finding.

The problem with the flow is what happen when multiple sms received in a very short time. I still haven't found out what will happen.


@akhileshg1988 : What SU management app do you use? SuperSU? Magisk? I use SuperSU, works properly with Automagic and MiXplorer. At my phone, the sms is stored at different place, it is at /data/data/com.android.mms/databases/mmssms.db It maybe in different places depends on the phone. You gotta to find it out by yourself. Check your messaging app package name, it should be in that package name data folder.
=======================

This is a very interesting project. I can make the sms become unread, by changing the read to 0. And we even craft the full message, to make it a perfectly legitimate sms. Most Fake sms out there can't craft a perfect message for dual sim phone or have problem dealing with some non AOSP phone. By editing directly to the database, create a full clone of notification, we can craft any kind of message real time. Put it on schedule/timer, and we can escape many awkward situation. :D
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Re: Operation on SMS

Post by bogdyro » 20 Dec 2017 11:18

@akhileshg1988
The sqlite3 'app' doesn't have any interface. You access it from the command line (shell) with action execute root command.
Now,for finding the DB it's up to you but you could try using Mixplorer which is free,you can pick it up from XDA developers, grant it root access, go to /data folder and do a search for mmssms.db. You can find out it's full path by long pressing it.
@Desmanto
Using the received SMS trigger is a more generic way of checking for the info needed as notification structure could be different.
I like to verify against the database that the received SMS is actually the one I am deleting.
So once I do that and I have the _id of the message I can't be deleting anything else even if there's another sms arriving immediately after.
We can't use the timestamp as the trigger comes a little bit later.
And probably receiving multiple sms in a short time should work ok if we don't use parallel execution of multiple instances.
Do you know of an app that can simulate well receiving fake sms? Because it's a bitch debugging this flow otherwise :)

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Operation on SMS

Post by Desmanto » 20 Dec 2017 15:13

@bogdyro : Yeah, as my sms log today, the trigger time and date time is not the same. So can't use that as the check. But mirroring the notification seems easier than querying and parsing the sms. Since both notification will be exactly the same.

For the verifying part, there is a problem with the checking content and sender method. My carrier sometimes can send exactly same message (promotion or information) from time to time. If I check only for the sender and content, all messages with the same content from the sender will be deleted, leaving me no copy of that message (while probably I want to keep at least one copy). Other problem is with the time execution and cpu cycle. To loop over the whole list will take more time, especially when our sms are a lot (I have over 2000+, those I am lazy to erase).

I think about just skipping directly to the last _id, since new message will always has the last _id. But I still don't use it since message can arrived consecutively. The flow maybe triggered by first message, but second message arrived and get the last _id. We ended deleting the second one. That's why I wanna check against the time, because even there can be 10 messages arrived per second, the timestamp using miliseconds won't be the same. Adding a additional check against the timestamp probably is the solution. So we check the _id, sender, content and timestamp around the date field (probaly in range of 1 second). If there are duplicate messages in 1 second, when we choose to delete 1 of them, most likely we want to delete the other as well.

There are a lot of fake sms creator, but I don't test them anymore for a long time. Most are quite shady, having too many permission beyond their function. And not to mention some of them won't work properly in some phones. That's why i log the notification's variable, so I can check it and use it later. I can log the sms received variable as well.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Re: Operation on SMS

Post by bogdyro » 20 Dec 2017 16:47

Yes, using the notification system is a good option also, but more difficult to parse it's text reliably I think.
I think that deleting a wrong sms is not an issue as the _id is unique. Every time a message arrive you immediately process it, remove it's notification and create another one. That way each arrived message would have it's own notification (associated with another _id of that message). Not very elegant but safer. I'm not thinking about spamming situations here... :)
So that's what I was doing in the flow.
Trigger fired (sms received or notification)
- read the last record in the database (it can only be the last since it takes only a few ms to do the actions)
- get the _id of the message and eventually check it's sender and text
- remove the messaging notif and create your own that contains the message _id and a DELETE button
- clicking a DELETE button on the notification uses the message _id to delete it (doesn't matter if it's not the last anymore)

If 10 messages arrive per second it's not gonna be pretty, assuming the flow execution won't stop you would get 10 different notifications from AM (by unchecking parallel execution). If you want to delete multiple spam messages at once, yes, you would have to check the timestamp. To not loop over the whole list you could limit yourself to the last 10 messages. I think they should be read first in a list variable and do the checking outside sql because doing a WHERE clause on text that has special characters is very error prone.

akhileshg1988
Posts: 109
Joined: 16 Apr 2014 04:57

Re: Operation on SMS

Post by akhileshg1988 » 21 Dec 2017 02:09

Hey everyone, Akhilesh here.
I found out the path to the file mmssms.db
In my phone, the path is
/data/user_de/0/com.android.providers.telephony/databases/mmssms.db
As advised, I copied the .db file from the aforementioned location to my internal storage and after providing this internal storage path in the flow, I executed the flow manually. The error msg that I got is attached as screenshot herewith.
Please help.
Attachments
Screenshot_20171221-073504.png
Screenshot_20171221-073504.png (123.37 KiB) Viewed 23403 times

bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Re: Operation on SMS

Post by bogdyro » 21 Dec 2017 08:51

Hi. I made a simpler version of the flow just to test sqlite.
Download and run it. If there's an error with the database a debug dialog should pop-up and you can tell me what the variable 'error' contains.
http://automagic4android.com/flow.php?i ... 79c048ca0f

akhileshg1988
Posts: 109
Joined: 16 Apr 2014 04:57

Re: Operation on SMS

Post by akhileshg1988 » 21 Dec 2017 09:49

I ran the flow.
Got an error.
Attached herewith is the ss of the debug dialog.
Help further bro.
Attachments
Screenshot_20171221-151747.png
Screenshot_20171221-151747.png (124.93 KiB) Viewed 23389 times

bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Re: Operation on SMS

Post by bogdyro » 21 Dec 2017 10:20

Weird error.
What device do you have and what Android version?

akhileshg1988
Posts: 109
Joined: 16 Apr 2014 04:57

Re: Operation on SMS

Post by akhileshg1988 » 21 Dec 2017 10:42

bogdyro wrote:Weird error.
What device do you have and what Android version?
Bro, I have Xiaomi Redmi 1S and the ROM I'm using is Colt ROM (Android version 7.1.2).

Post Reply