TeCoEd (Teaching Computing Education)
  • Home
    • Freelance
    • Book
    • Downloading
  • Python
    • Learn Python >
      • Python Modules
    • PyGame Zero
    • Python Programs >
      • Higher or Lower
      • Magic Calculator
      • Password Checker
      • Python Pit
    • What's News App
    • Pixels to Cells
    • Python Mosaics
    • Python OCR
    • L-1-AM
    • Web Scraping >
      • Scraping Trains
    • Weather App
    • Snakes and Windows
    • Python Web Server >
      • Flask
    • Python Picks
  • Ras Pi
    • All About the Pi
    • Getting Started
    • Remote Desktop and VNC
    • Static IP Address
    • Sonic Pi >
      • 3.14
    • Twitter Feed >
      • Tweepy
    • Android & Pi >
      • Advanced Apps
      • Odds
    • A.I on the the Pi
    • CRON
    • Pick Your Own
  • Pi Hardware
    • Pi HATS >
      • Sense Hat Hacks
      • AstroPi HAT
      • Unicorn-HAT >
        • Unicorn Alphabet Disco
        • Uni Codes / Programs
      • Skywriter
      • Piano HAT
    • STS Pi
    • Pi Camera >
      • Pi-Cam, Python & Email >
        • Time Lapse
      • Pi Noir
    • Pipsta >
      • Flask, Input & Printers
    • Raspberry Pi Power >
      • Energenie IR power
    • Pibrella
    • Distance Sensor
    • LCD Screen
    • Pi-Tooth
    • Robot Arm
    • PiGlow
    • PiFM
    • Accelerometer
    • PiFace >
      • Installing PiFace >
        • Python Commands
  • Pi-Hacks
    • Drone Hacks
    • Pi Glue Gun Hack
    • Blinkt!
    • Sonic Pixels
    • R2D2
    • Get to the chopper
    • Astro Bird
    • Twitter Translator
    • Hacking a Robot
    • Nature_Box >
      • Best Nature Photos
    • Wearable Tech >
      • Project New York
      • P.N.Y Part 2 Health
      • P.N.Y Part 3 Games
      • P.N.Y Part 4 Translation
    • Dino-Tweet
    • Other Links
  • Pi-Hacks 2
    • The Joker
    • Hologram Machine
    • Google Vision: Camera Tell
    • Yoda Tweets
    • Pi Phone
    • Darth Beats
    • Twitter Keyword Finder
    • Crimbo Lights Hack
    • Xmas Elf
    • Halloween 2016
    • Halloween Hack 2015
    • Socrative Zombie
    • Voice Translation
    • The Blue-Who Finder
    • GPIO, Twitter
    • Pi Chat Bot >
      • Dictionary Definitions
    • PiGlow & Email
    • Pibrella Alarm System
    • SMS with Python >
      • Spooking a Mobile
  • Pi-Hacks 3
    • LED Dance Suit
    • Ferminal
    • Crypto Tracker
    • David Bowie
    • Lamp Prank >
      • TEST
    • Yoda FM
    • Retro Player
    • LED Pixel Art
    • TARDIS
    • Battleships
    • LED Board
    • Night Vision
    • Enviro+ Weather
  • Minecraft
    • Minecraft API
    • Minecraft Sweeper
    • PiGlove: Minecraft Power Up
    • Minecraft Photo-booth
    • Rendering Pixels
    • Speed Cube
    • Lucky Dip
  • Computing
    • Why Computing?
    • Can You Compute
    • micro:bit
    • Coding Resources
    • Learn to Code >
      • Coding with iPads
      • Apps Creation Tools
      • sKratchInn
      • Sound Editing
    • Cheat Sheets
    • Theory
    • HOUR OF CODING
    • BEBRAS Computing Challange
    • Computer Facts
    • Free Software and Links
  • Contact Me
  • Random Hacks
    • Movile

PI PROJECTS:  Hacking a Mobile with Python 


What is it?


Seen those films where they track mobile phone calls and texting logs?  Ever wanted to try it?  Here we combine Twilio and Python to create a simple code that will return call details and text messages sent from your own phone.  This a simulated environment where you can code and practice.

Getting started


First ensure that you are signed up for a Twilio account and number.  This is free but will only allow you to send SMS to and from the registered phone.  You will receive a verification code via SMS to the registered phone.  When promoted enter this onto the Twilio site to authenticate your account and phone.  Instructions and installation guide are found here

Getting a List of the Phone Calls Made


This simple program looks up and returns a complete list of all the phones calls made to and from the Mobile Phone.  It includes the  number that called and the number of the phone that received the call.

Simple code to retrieve call logs:

from twilio.rest import TwilioRestClient

account_sid = "A666666777777767672d"  #use your sid

auth_token = "777777777777777773f0"    #use your token

client = TwilioRestClient(account_sid, auth_token)
 
for call in client.calls.list():
    print "From: " + call.from_formatted + " To: " + call.to_formatted

Save the code with a suitable file name such as phonelogs.py and execute the code in the LX Terminal, sudo python phone_logs.py

Picture

Retrieve a List of Sent Messages


Now for the fun hack where Python will grab a list of sent SMS messages and return them to your console LX terminal.  The simple code to do this is client.sms.messages.list()  This returns a list of all the SMS messages sent to the phone.  Then a for loop is used to iterate through the list and print out each message.
Picture
You can combine this with date_sent and to / from to return the phone numbers of the sender and the receiver and the date the text message was sent from the phone.
 
Combining these features creates the following code:

from twilio.rest import TwilioRestClient
 account_sid = "AC2e4444444444442d"                     
#use your sid
auth_token = "4f343434343434343434343"            
#use your token
client = TwilioRestClient(account_sid, auth_token)

smss = client.sms.messages.list()
  #grabs a list of messages
for i in smss:
    print i.body                  #prints the message
    print i.date_sent         #prints the date the text was sent
    print i.to                        #prints who the text was sent to

Save the code with a suitable file name such as text_logs.py and execute the code in the LX Terminal, sudo python text_logs.py


A log Hack of the Messages Sent to a Mobile Phone


Powered by Create your own unique website with customizable templates.