Advertisement
metalx1000

Android Send SMS to Contact from Shell/ADB

Feb 26th, 2023 (edited)
1,202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.79 KB | None | 0 0
  1. #!/system/bin/sh
  2. ######################################################################
  3. #Copyright (C) 2023  Kris Occhipinti
  4. #https://filmsbykris.com
  5.  
  6. #This program is free software: you can redistribute it and/or modify
  7. #it under the terms of the GNU General Public License as published by
  8. #the Free Software Foundation version 3 of the License.
  9.  
  10. #This program is distributed in the hope that it will be useful,
  11. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. #GNU General Public License for more details.
  14.  
  15. #You should have received a copy of the GNU General Public License
  16. #along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17. ######################################################################
  18.  
  19. #Sends SMS messages to contact
  20. #fzf required to contact filter
  21. log="/data/local/tmp/sms_recent.log"
  22.  
  23. function contacts(){
  24.   [[ -f "$log" ]] && sort -u "$log"
  25.   content query --uri content://com.android.contacts/data --projection display_name:data4:contact_id|grep '=+'|
  26.   sed 's/display_name=/|/g;s/, data4=/|/g;s/,/|/g'|cut -d\| -f2,3
  27. }
  28.  
  29. contact="$(contacts|fzf)"
  30. [[ $contact ]] || exit 1
  31. # log contact to recent log
  32. echo "$contact" >> "$log"
  33.  
  34. name="${contact%\|*}"
  35. number="${contact##*\|}"
  36.  
  37. [[ $number ]] || exit 1
  38.  
  39. echo -e "\n\n\n"
  40. while [ 1 ]
  41. do
  42.   echo -n "Sending to $name at $number: "
  43.   read msg
  44.   [[ $msg ]] || exit
  45.   #older versions of android
  46.   #service call isms 5 i32 0 s16 "com.android.mms.service" s16 "null" s16 "$number" s16 "null" s16 "$msg" s16 "null" s16 "null" s16 "null" s16 "null" > /dev/null
  47.   #Android 10 and newer
  48.   adb shell service call isms 5 i32 1 s16 "com.android.mms" s16 "null" s16 "$number" s16 "null" s16 "$msg" s16 "null" s16 "null" i32 0 i64 0
  49. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement