Reading sms from android device using ADB shell commands - android

i am working on a project to read the sms of my android mobile,but on internet didn't find much about it. in my search i found following points
You can access android mobile phone through ADB shell commands ,but
only certain limited features.
ADB is a best method to communicate, as it do not require user to add any extension on android device
I use the shell command (found on internet) to send
message ,but it also didn't work
adb shell service call isms 5 s16 "com.android.mms" s16 "+01234567890" s16 "+01000000000" s16 "Hello world !" i32 0 i32 0
Moreover i found that if i want to
use AT commands to do so i have to root the mobile phone
even i tried accessing
com.android.internal.telephony
it shows result permission denied
above are my search results related to reading sms from my android device,
so i just want know,how can i read the sms from my android device
using adb shell commands?
if there is any other way to do so please suggest.

You can Read sms from android mobile using sqlite3, i m also working on the same project. but for this you have to do few things:
1) You must root your mobile (using any root app e.g Kingoroot app)
2) You should know the exact path for sms database of your mobile and you must install sqlite3 (simply google it and you will find it)
3) Only Super User can access that database
4) You must put sqlite.exe file into device/system/xbin (root directory)
5) how to accomplish step 4 ,you need (Titanium backup, root browser )
if done every thing written above all u need is
C:\Users\Ray>cd appdata/local/android/sdk/platform-tools
adb
adb shell
shell#htc_v02_dug:/ $ su
root#htc_v02_dug:/ # cd /data/data/com.android.providers.telephony/databases
root#htc_v02_dug:/data/data/com.android.providers.telephony/databases # sqlite3 mmssms.db
SQLite version 3.7.6.3-Titanium
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select body from sms where read=0;
hi
i m using htc mobile. And the sms i just read hi.

Related

How to obtain IMEI via adb?

I'm trying to track devices, SIMs and airtime cards for test purposes. I have multiple devices plugged into a computer and since the recent update to Android 12, I am not able to get the device IMEI. The IMEI is basically the device's FCC-required serial number and can be obtained from the UI with relative ease, but how can I obtain it via ADB or in some automated method on multiple devices from multiple carriers and OEMs?
Prior to Android 12 FEB patch, I would use service call iphonesubinfo 1 or service call iphonesubinfo 4. But unfortunately after the update I receive back Result: Parcel(ffffffffc ffffffff 00000000 '................') whereas before I would receive a parcel containing the IMEI for processing via script.
Is there a way to get IMEI on Android 12+? I am trying to stay away from using an app. This is a simple thing, from a privileged user (adb shell). It seems like a basic necessity for tracking and logistics purposes.
This command works to obtain IMEI. It works by pressing the dialer key, then typing *#06#, then parsing the text on screen to find the IMEI Label and the next element which contains the actual IMEI. Finally it parses that element by removing all before text=" and all after ".
adb shell "imei=$(input keyevent KEYCODE_CALL;sleep 1;input text '*#06#'; uiautomator dump --compressed /dev/stdout|sed s/\>\<\/\\n/g|grep -A1 IMEI|tail -n1|sed -e 's/.*text=\"//' -e 's/\".*//'); echo ${imei}"
to get just the 16-digit IMEI without checksum, replace the final echo statement with echo ${imei:0:16}
I found a good solution for Samsung One UI
First, run the About menu
adb shell am start -a com.android.settings.ACTION_DEVICE_INFO_SETTINGS
Then dump the UI
adb shell uiautomator dump
View the dump file
adb shell cat /sdcard/window_dump.xml
The IMEI1 in the <node index="12" and IMEI 2 in <node index="13"

is it possible to telnet and do conversation using expect via android app

I want to know if the idea below can be implemented via android app .
My system creates a wifi network (say 'w') and when we connect our android phone to 'w' then our phone will get ip 192.168.1.x and gateway will be 192.168.1.1
Now we will open our android app and press 'run' button in it then it will do following things in background .
telnet 192.168.1.1
Login:root
Password:something
>ifconfig eth0 | grep HWaddr
eth0 Link encap:Ethernet HWaddr 00:04:95:99:8F:1A
>sh
BusyBox v1.17.2 (2021-05-31 16:16:26 IST) built-in shell (ash)<br>
Enter 'help' for a list of built-in commands.
#bs /b/e gpon | grep link_operational_state
pon_link_state : {admin_state=active,sub_
overhead_cfg->overhead_repetition 170
state=operational,link_operational_state=operational o5}
I have written an example above to show that i want to run such commands and extract relevant words from output like "00:04:95:99:8F:1A" and "o5" which i will show on GUI of android app.
I am able to simulate such conversation using spawn , expect script in linux .
Can you suggest if it is possible in android and can you point me to useful links for this purpose .
Thanks .

Android SMS limit on Android 4.0.4

I am working with phone with Android 4.0.4 (I know, the old one)
Now I need to override limit of 100 sms send per hour (Below android 4.1 there should be limit 100 sms per hour. Since android 4.1 there is limit 30 sms per 30 minutes).
Since Android 4.2 it is possible via adb shell settings put global sms_outgoing_check_max_count.
But I have no idea how to do it on Android 4.0.4 without rooting because there is no "adb shell settings" command. Any idea?
P.S. I am not creating app. I need to override this limit ideally in android settings via adb or by using another app for this (if it exists)
You could do it by creating the application and overriding the SmsUsageMonitor:
com.android.internal.telephony.SmsUsageMonitor
It should basically work on any phone, without rooting it first.
Could you try to follow theses steps via ADB :
1.Open Command Terminal
2.Type in adb shell hit enter
3.Type in su hit enter
4.Type in sqlite3 /data/data/com.android.providers.settings/databases/settings.db hit enter
5.Type in INSERT INTO secure (name, value) VALUES('sms_outgoing_check_max_count’, 9999); hit enter
6.Type in INSERT INTO system (name, value) VALUES('sms_outgoing_check_max_count’, 9999); hit enter
7.Type in .exit hit enter (you should now see a hash tag again instead of sqlite>. If not conitune typing in .exit and hitting enter until you are)
8.Type in sqlite3 /data/data/com.google.android.gsf/databases/gservices.db
9.Type in INSERT INTO main (name, value) VALUES('sms_outgoing_check_max_count’, 9999); hit enter
10.Again exit back to where the command line has a hashtag
11.Type in reboot and hit enter.
I don't have a phone with Android 4.0.4, so i can't confirm that it will work
Happy testing !
you have to use abd command to open that restrictions here is the link for tutorial change sms limit
1.Go to the android platform tool directory
`(C:\Users\username\AppData\Local\Android\Sdk\platform-tools)``enter code here`
open command shell by using Shift+mouserightclick and enter this command
adb shell settings put global sms_outgoing_check_max_count 5
settings put global sms_outgoing_check_interval_ms 9000000
I am actually reducing the number so Android warns me if I have sent more than 5 SMS messages within 30(9000000) minutes. Change “5” to whatever number you want
What exactly do you want to acheive with over 100 SMS per hour?
I am sure there is a way more efficient way of sending your data for example through
a wireless network or mobile data. You would hardly manage to reach the data limits of
those networks.
Just saying ... try only to do it over SMS if there really is NO other way of sending it.
Good luck!

Getting android cell phone number using command line

I would like to get the cell phone number of any android device using the command line.
I have tried using:
adb shell service call iphonesubinfo 4
and
adb shell service call iphonesubinfo 5/6/7/8
and it returns Permission denied.
I was wondering if anyone has another solution?
Ps: phones are android 4.1 and above
Thanks you in advance.
You have to obtain root access by using :
adb root
Then you'll find those command work. Usually the phone number will be returned by :
adb shell service call iphonesubinfo 5
or by :
adb shell service call iphonesubinfo 6
It depends on the device is single or dual sim. You'll need to do some string parsing work if you need this result to be recognized by machine.

How do I send an SMS from a shell?

I would like to be able to send an actual SMS message from a shell using just the command line and not relying on any apk to do so. I am interested in sending this message between phones, not from the emulator to the phone. For example, by running the command:
service call phone 2 s16 "1234567890"
I can place a call from phone to phone using the command line. The 'service list' command shows an isms service, which I can't seem to provide the correct arguments for. I would assume that one of the args should be a PDU string but haven't had any luck so far.
In fact, this can be done but requires adb to be installed (Part of the android SDK)
adb shell am start -a android.intent.action.SENDTO -d sms:CCXXXXXXXXXX --es sms_body "SMS BODY GOES HERE" --ez exit_on_sent true
adb shell input keyevent 22
adb shell input keyevent 66
Where CCXXXXXXXXXX is country-code followed by phone number. This may not work correctly on non-standard android installations, you will need to find the correct keyevent values to pass.
How about this?
service call isms 5 s16 "+??????????" i32 0 i32 0 s16 "SMS TEXT HERE"
You can telnet to the emulator doing something similar to "telnet localhost 5554", where 5554 is the port the emulator is listening on. After that, you can send an sms message by doing the following:
sms send 1234 "Hello"
The 1234 can be any string of digits. Enclose the message in quotes if you are including spaces.
edit:
an sms command doesn't exist in Android on real devices, it's an emulator-only feature to fake an SMS receiving not sending.
It's just a convenience for emulated devices that don't have access to any actual cellular network.
cf. http://developer.android.com/guide/developing/devices/emulator.html#sms
I don't have enough reputation points up upvote the answer given by Dmitry, but that IS the answer that works with one minor modification: At least for a US number, instead of putting a plus-sign (+) it worked for me with a "1" e.g. 17079876543 ...
service call isms 5 s16 "17079876543" i32 0 i32 0 s16 "SMS TEXT HERE"
Oh boy oh boy oh boy ... now if I can figure out how to receive SMS over the command line and combine that with emacs (in an emacs shell say - he begins to rub his hands together and crack a slanted grin ... and think about all the other command line levers we can pull!)
You can send any intent you want from the command line, so it's merely a matter of figuring out what intent can be used to send an sms, or if one doesn't exist, then writing an apk which provides such intent-to-sms capability and sending the intent to trigger that from the command line.
If you end up writing an apk to do that, think a little bit about permissions. Which user will the command line be running as - the adb shell user? any old ordinary app user? Your apk will presumably have sms permissions, but do you want to extent that to everything on the phone, or implement some security mechanism in your intent?

Categories

Resources