Skip to content

Instantly share code, notes, and snippets.

@phx
Created September 15, 2013 06:32
Show Gist options
  • Save phx/6568500 to your computer and use it in GitHub Desktop.
Save phx/6568500 to your computer and use it in GitHub Desktop.
This is a quick starter-template that could send SMS or email alerts from a jailbroken iOS device. Think "text-message forwarding" and/or related functionality.
#/bin/bash
TZ='America/Chicagp'
/usr/bin/sqlite3 /var/mobile/Library/SMS/txt.db <<!
.mode list
.separator |
.out txt.dmp
SELECT
m.rowid as RowID,
DATETIME(date + 978307200, 'unixepoch', 'localtime') as Date,
h.id as "Phone Number", m.service as Service,
CASE is_from_me
WHEN 0 THEN "Received"
WHEN 1 THEN "Sent"
ELSE "Unknown"
END as Type,
CASE
WHEN date_read > 0 then DATETIME(date_read + 978307200, 'unixepoch')
WHEN date_delivered > 0 THEN DATETIME(date_delivered + 978307200, 'unixepoch')
ELSE NULL END as "Date Read/Sent",
text as Text
FROM message m, handle h
WHERE h.rowid = m.handle_id
ORDER BY m.rowid DESC LIMIT 1;
!
STAMP=$(awk -F "|" '{print $2}' txt.dmp)
RECEIVED=$(date --date="$STAMP" "+%a %x [%I:%M %p]")
NUMBER=$(awk -F "|" '{print $3}' txt.dmp)
SERVICE=$(awk -F "|" '{print $4}' txt.dmp)
MESSAGE=$(awk -F "|" '{print $7}' txt.dmp)
# this uses a 3rd party app available in Cydia:
/usr/bin/sendsms [email address or phone number] "
==========================================
$SERVICE Received $RECEIVED
==========================================
SENDER: <$NUMBER>
------------------------------------------
MESSAGE:
$MESSAGE
------------------------------------------
==========================================
<a href=\"mailto:[email protected]\" target=\"_blank\">Respond?</a>
==========================================
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment