added ios2html libraries folder
This commit is contained in:
parent
ca5a313fe0
commit
0f7263c03b
152
lib/accounts_plugin.sh
Executable file
152
lib/accounts_plugin.sh
Executable file
@ -0,0 +1,152 @@
|
||||
#!/usr/bin/env bash
|
||||
#===============================================================================
|
||||
#
|
||||
# DIRECTORY:
|
||||
# ---
|
||||
#
|
||||
# FILE:
|
||||
# ./accounts_plugin.sh
|
||||
#
|
||||
# USAGE:
|
||||
# . accounts_plugin.sh
|
||||
# OR
|
||||
# source accounts_plugin.sh
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Accounts plugin (library) to generate content with simple template engine.
|
||||
#
|
||||
# BUGS:
|
||||
# ---
|
||||
#
|
||||
# TESTS:
|
||||
# - shellcheck -s bash -e SC2034 ./accounts_plugin.sh
|
||||
# - shellcheck -s ksh -e SC2034 ./accounts_plugin.sh
|
||||
# - shellcheck -s dash -e SC2034 ./accounts_plugin.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Patrick Neumann, patrick@neumannsland.de
|
||||
#
|
||||
# COAUTHOR(S):
|
||||
# Odin Heitmann, odin.heitmann@gmail.com
|
||||
#
|
||||
# COMPANY:
|
||||
# (privately)
|
||||
#
|
||||
# VERSION:
|
||||
# 1.0
|
||||
#
|
||||
# LINK TO THE MOST CURRENT VERSION:
|
||||
# (Sorry, we bet, I'm not allowed to publish it over GitHub!)
|
||||
#
|
||||
# CREATED:
|
||||
# 2018-06-01
|
||||
#
|
||||
# COPYRIGHT (C):
|
||||
# 2018 - Patrick Neumann & Odin Heitmann
|
||||
#
|
||||
# LICENSE:
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# WARRANTY:
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# NOTES:
|
||||
# ---
|
||||
#
|
||||
# TODO:
|
||||
# ---
|
||||
#
|
||||
# HISTORY:
|
||||
# 1.0 - P. N. & O. H. - Initial (for the trainers eyes only) release
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check if functions library is loaded first.
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ "${FUNCTIONS_LOADED}" != "true" ] ; then
|
||||
printf "\\n\\033[01;31;40mERROR: functions library not loaded... EXIT!!!\\033[00m\\n\\n"
|
||||
exit 200
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check if temblate engine library is loaded first.
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ "${TEMPLATE_ENGINE_LOADED}" != "true" ] ; then
|
||||
error_exit "template_engine.sh not loaded" 200
|
||||
fi
|
||||
|
||||
#=== CONFIGURATION (static) ====================================================
|
||||
#assign_binary "xyz" # (un)common
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: get_accounts_list
|
||||
# DESCRIPTION: "Grep" information and store into vars.
|
||||
# PARAMETERS: none (global vars will be used.)
|
||||
#===============================================================================
|
||||
get_accounts_list () {
|
||||
# "943624fd13e27b800cc6d9ce1100c22356ee365c" in iTunes Backup.
|
||||
readonly ACCOUNTS_SQLITE="$( ${BIN_FIND} "${IOS_BACKUP}" -type f -name "Accounts3.sqlite" )"
|
||||
|
||||
if [ -z "${ACCOUNTS_SQLITE}" ] ; then
|
||||
readonly ACCOUNTS_SOURCE="<code>Accounts3.sqlite not found</code>"
|
||||
error "Accounts3.sqlite not found"
|
||||
readonly ACCOUNTS_LIST="<tr><td class='highlight' colspan='4'>ERROR: database not found!</td></tr>"
|
||||
else
|
||||
readonly ACCOUNTS_SOURCE="<a href='Accounts3.sqlite' target='_blank'><code>${ACCOUNTS_SQLITE/${IOS_BACKUP}/\/private\/var}</code></a>"
|
||||
# * -> don't forget to copy write ahead log!
|
||||
${BIN_CP} "${ACCOUNTS_SQLITE}"* "${FOLDER}/"
|
||||
|
||||
readonly ACCOUNTS_LIST="$( ${BIN_SQLITE3} -html "${FOLDER}/Accounts3.sqlite" \
|
||||
"SELECT a.Z_PK, \
|
||||
DATETIME(a.ZDATE+978307200, 'unixepoch'), \
|
||||
t.ZACCOUNTTYPEDESCRIPTION, \
|
||||
a.ZUSERNAME \
|
||||
FROM ZACCOUNT AS a, \
|
||||
ZACCOUNTTYPE AS t \
|
||||
WHERE a.ZACCOUNTTYPE=t.Z_PK;" )"
|
||||
fi
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "INFO: accounts_plugin processed.\\n" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Partial template for hardware information for the simple template engine.
|
||||
#-------------------------------------------------------------------------------
|
||||
# SC2034: all "unused" vars are verified!
|
||||
ACCOUNTS_INFORMATION=$( ${BIN_CAT} <<'EOF'
|
||||
<h2>Accounts</h2>
|
||||
<h4>Sources</h4>
|
||||
<ul class="file">
|
||||
<li>${ACCOUNTS_SOURCE}</li>
|
||||
</ul>
|
||||
<h3>Information</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Date</th>
|
||||
<th>Description</th>
|
||||
<th>Username</th>
|
||||
</tr>
|
||||
${ACCOUNTS_LIST}
|
||||
</table>
|
||||
EOF
|
||||
)
|
||||
|
||||
readonly ACCOUNTS_PLUGIN_LOADED="true"
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "INFO: accounts_plugin.sh loaded.\\n" 1>&2
|
||||
fi
|
||||
# Do not use "exit" at the end of a sourced library!
|
158
lib/addressbook_plugin.sh
Executable file
158
lib/addressbook_plugin.sh
Executable file
@ -0,0 +1,158 @@
|
||||
#!/usr/bin/env bash
|
||||
#===============================================================================
|
||||
#
|
||||
# DIRECTORY:
|
||||
# ---
|
||||
#
|
||||
# FILE:
|
||||
# ./addressbook_plugin.sh
|
||||
#
|
||||
# USAGE:
|
||||
# . addressbook_plugin.sh
|
||||
# OR
|
||||
# source addressbook_plugin.sh
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# AddressBook plugin (library) to generate content with simple template engine.
|
||||
#
|
||||
# BUGS:
|
||||
# ---
|
||||
#
|
||||
# TESTS:
|
||||
# - shellcheck -s bash -e SC2034 ./AddressBook_plugin.sh
|
||||
# - shellcheck -s ksh -e SC2034 ./AddressBook_plugin.sh
|
||||
# - shellcheck -s dash -e SC2034 ./AddressBook_plugin.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Patrick Neumann, patrick@neumannsland.de
|
||||
#
|
||||
# COAUTHOR(S):
|
||||
# Odin Heitmann, odin.heitmann@gmail.com
|
||||
#
|
||||
# COMPANY:
|
||||
# (privately)
|
||||
#
|
||||
# VERSION:
|
||||
# 1.0
|
||||
#
|
||||
# LINK TO THE MOST CURRENT VERSION:
|
||||
# (Sorry, we bet, I'm not allowed to publish it over GitHub!)
|
||||
#
|
||||
# CREATED:
|
||||
# 2018-06-01
|
||||
#
|
||||
# COPYRIGHT (C):
|
||||
# 2018 - Patrick Neumann & Odin Heitmann
|
||||
#
|
||||
# LICENSE:
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# WARRANTY:
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# NOTES:
|
||||
# ---
|
||||
#
|
||||
# TODO:
|
||||
# ---
|
||||
#
|
||||
# HISTORY:
|
||||
# 1.0 - P. N. & O. H. - Initial (for the trainers eyes only) release
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check if functions library is loaded first.
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ "${FUNCTIONS_LOADED}" != "true" ] ; then
|
||||
printf "\\n\\033[01;31;40mERROR: functions library not loaded... EXIT!!!\\033[00m\\n\\n"
|
||||
exit 200
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check if temblate engine library is loaded first.
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ "${TEMPLATE_ENGINE_LOADED}" != "true" ] ; then
|
||||
error_exit "template_engine.sh not loaded" 200
|
||||
fi
|
||||
|
||||
#=== CONFIGURATION (static) ====================================================
|
||||
#assign_binary "xyz" # (un)common
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: get_addressbook_list
|
||||
# DESCRIPTION: "Grep" information and store into vars.
|
||||
# PARAMETERS: none (global vars will be used.)
|
||||
#===============================================================================
|
||||
get_addressbook_list () {
|
||||
# "8e281be6657d4523710d96341b6f86ba89b56df7" in iTunes Backup.
|
||||
readonly ADDRESSBOOK_SQLITE="$( ${BIN_FIND} "${IOS_BACKUP}" -type f -name "AddressBook.sqlitedb" )"
|
||||
|
||||
if [ -z "${ADDRESSBOOK_SQLITE}" ] ; then
|
||||
readonly ADDRESSBOOK_SOURCE="<code>AddressBook.sqlitedb not found</code>"
|
||||
error "AddressBook.sqlitedb not found"
|
||||
readonly ADDRESSBOOK_PERSON="<tr><td class='highlight' colspan='4'>ERROR: database not found!</td></tr>"
|
||||
else
|
||||
readonly ADDRESSBOOK_SOURCE="<a href='AddressBook.sqlitedb' target='_blank'><code>${ADDRESSBOOK_SQLITE/${IOS_BACKUP}/\/private\/var}</code></a>"
|
||||
# Don't forget to copy write ahead log!
|
||||
${BIN_CP} "${ADDRESSBOOK_SQLITE}"* "${FOLDER}/"
|
||||
|
||||
readonly readonly ADDRESSBOOK_PERSON="$( ${BIN_SQLITE3} -html "${FOLDER}/AddressBook.sqlitedb" \
|
||||
"SELECT
|
||||
person.ROWID,
|
||||
person.First,
|
||||
person.Middle,
|
||||
person.Last,
|
||||
multivalue.value
|
||||
FROM
|
||||
ABPerson AS person,
|
||||
ABMultiValue AS multivalue
|
||||
WHERE
|
||||
multivalue.record_id=person.ROWID;" )"
|
||||
|
||||
fi
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "INFO: addressaook_plugin processed.\\n" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Partial template for hardware information for the simple template engine.
|
||||
#-------------------------------------------------------------------------------
|
||||
# SC2034: all "unused" vars are verified!
|
||||
ADDRESSBOOK_INFORMATION=$( ${BIN_CAT} <<'EOF'
|
||||
<h2>AddressBook / Contacts</h2>
|
||||
<h4>Sources</h4>
|
||||
<ul class="file">
|
||||
<li>${ADDRESSBOOK_SOURCE}</li>
|
||||
</ul>
|
||||
<h3>Contacts</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>First name</th>
|
||||
<th>Middle name</th>
|
||||
<th>Last name</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
${ADDRESSBOOK_PERSON}
|
||||
</table>
|
||||
EOF
|
||||
)
|
||||
|
||||
readonly ADDRESSBOOK_PLUGIN_LOADED="true"
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "INFO: addressaook_plugin.sh loaded.\\n" 1>&2
|
||||
fi
|
||||
# Do not use "exit" at the end of a sourced library!
|
297
lib/applications_plugin.sh
Executable file
297
lib/applications_plugin.sh
Executable file
@ -0,0 +1,297 @@
|
||||
#!/usr/bin/env bash
|
||||
#===============================================================================
|
||||
#
|
||||
# DIRECTORY:
|
||||
# ---
|
||||
#
|
||||
# FILE:
|
||||
# ./applications_plugin.sh
|
||||
#
|
||||
# USAGE:
|
||||
# . applications_plugin.sh
|
||||
# OR
|
||||
# source applications_plugin.sh
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Applications_plugin plugin (library) to generate content with simple template engine.
|
||||
#
|
||||
# BUGS:
|
||||
# ---
|
||||
#
|
||||
# TESTS:
|
||||
# - shellcheck -s bash -e SC2034 ./applications_plugin.sh
|
||||
# - shellcheck -s ksh -e SC2034 ./applications_plugin.sh
|
||||
# - shellcheck -s dash -e SC2034 ./applications_plugin.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Patrick Neumann, patrick@neumannsland.de
|
||||
#
|
||||
# COAUTHOR(S):
|
||||
# Odin Heitmann, odin.heitmann@gmail.com
|
||||
#
|
||||
# COMPANY:
|
||||
# (privately)
|
||||
#
|
||||
# VERSION:
|
||||
# 1.0
|
||||
#
|
||||
# LINK TO THE MOST CURRENT VERSION:
|
||||
# (Sorry, we bet, I'm not allowed to publish it over GitHub!)
|
||||
#
|
||||
# CREATED:
|
||||
# 2018-06-01
|
||||
#
|
||||
# COPYRIGHT (C):
|
||||
# 2018 - Patrick Neumann & Odin Heitmann
|
||||
#
|
||||
# LICENSE:
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# WARRANTY:
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# NOTES:
|
||||
# ---
|
||||
#
|
||||
# TODO:
|
||||
# ---
|
||||
#
|
||||
# HISTORY:
|
||||
# 1.0 - P. N. & O. H. - Initial (for the trainers eyes only) release
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check if functions library is loaded first.
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ "${FUNCTIONS_LOADED}" != "true" ] ; then
|
||||
printf "\\n\\033[01;31;40mERROR: functions library not loaded... EXIT!!!\\033[00m\\n\\n"
|
||||
exit 200
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check if temblate engine library is loaded first.
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ "${TEMPLATE_ENGINE_LOADED}" != "true" ] ; then
|
||||
error_exit "template_engine.sh not loaded" 200
|
||||
fi
|
||||
|
||||
#=== CONFIGURATION (static) ====================================================
|
||||
#assign_binary "xyz" # (un)common
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: process_plists
|
||||
# DESCRIPTION: ...
|
||||
# PARAMETER1 : string (file)
|
||||
#===============================================================================
|
||||
process_plists () {
|
||||
# Apps are not part of the iTunes Backup!
|
||||
plist_bin2xml "${1}" "/tmp/iTunesMetadata.plist"
|
||||
local APP_ID="$( ${BIN_GREP} --fixed-strings --after-context=1 "softwareVersionBundleId" /tmp/iTunesMetadata.plist \
|
||||
| ${BIN_TAIL} -n 1 \
|
||||
| ${BIN_SED} "${SED_EXT_REGEXP}" 's|[[:space:]]*</?string>||g' )"
|
||||
local APP_NAME="$( ${BIN_GREP} --fixed-strings --after-context=1 "bundleDisplayName" /tmp/iTunesMetadata.plist \
|
||||
| ${BIN_TAIL} -n 1 \
|
||||
| ${BIN_SED} "${SED_EXT_REGEXP}" 's|[[:space:]]*</?string>||g' )"
|
||||
local APP_VERSION="$( ${BIN_GREP} --fixed-strings --after-context=1 "bundleVersion" /tmp/iTunesMetadata.plist \
|
||||
| ${BIN_TAIL} -n 1 \
|
||||
| ${BIN_SED} "${SED_EXT_REGEXP}" 's|[[:space:]]*</?string>||g' )"
|
||||
local APP_DEVELOPER="$( ${BIN_GREP} --fixed-strings --after-context=1 "artistName" /tmp/iTunesMetadata.plist \
|
||||
| ${BIN_TAIL} -n 1 \
|
||||
| ${BIN_SED} "${SED_EXT_REGEXP}" 's|[[:space:]]*</?string>||g' )"
|
||||
local APP_PURCHASED="$( ${BIN_GREP} --fixed-strings --after-context=1 "purchaseDate" /tmp/iTunesMetadata.plist \
|
||||
| ${BIN_TAIL} -n 1 \
|
||||
| ${BIN_SED} "${SED_EXT_REGEXP}" 's|[[:space:]]*</?string>||g' )"
|
||||
local APP_APPLEID="$( ${BIN_GREP} --fixed-strings --after-context=1 "AppleID" /tmp/iTunesMetadata.plist \
|
||||
| ${BIN_TAIL} -n 1 \
|
||||
| ${BIN_SED} "${SED_EXT_REGEXP}" 's|[[:space:]]*</?string>||g' )"
|
||||
# In dash, string replacement is not supported
|
||||
# Because in dash, string replacement is not supported we can not use:
|
||||
# echo ${1/${IOS_BACKUP}/\/private\/var}
|
||||
${BIN_PRINTF} "<li><a href='${APP_ID}-iTunesMetadata.plist' target='_blank'><code>$( ${BIN_PRINTF} "${1}" | ${BIN_SED} "s|${IOS_BACKUP}|/private/var|" )</code></a></li>\\n" >> /tmp/apps_sources.html
|
||||
${BIN_PRINTF} "<tr>\\n
|
||||
<td>${APP_ID}</td>\\n
|
||||
<td>${APP_NAME}</td>\\n
|
||||
<td>${APP_VERSION}</td>\\n
|
||||
<td>${APP_DEVELOPER}</td>\\n
|
||||
<td>${APP_PURCHASED}</td>\\n
|
||||
<td>${APP_APPLEID}</td>\\n
|
||||
</tr>\\n" >> /tmp/apps_list.html
|
||||
${BIN_MV} /tmp/iTunesMetadata.plist "${FOLDER}/${APP_ID}-iTunesMetadata.plist"
|
||||
}
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: get_applications_list
|
||||
# DESCRIPTION: "Grep" information and store into vars.
|
||||
# PARAMETERS: none (global vars will be used.)
|
||||
#===============================================================================
|
||||
get_applications_list () {
|
||||
# Default applications visible by a user taken from iOS 10.3.3
|
||||
readonly DEFAULT_APPS_LIST1="<li>Phone</li>
|
||||
<li>Safari</li>
|
||||
<li>Mail</li>
|
||||
<li>Music</li>
|
||||
<li>Messages</li>
|
||||
<li>Calendar</li>
|
||||
<li>Photos</li>
|
||||
<li>Camera</li>"
|
||||
|
||||
readonly DEFAULT_APPS_LIST2="<li>Weather</li>
|
||||
<li>Clock</li>
|
||||
<li>Maps</li>
|
||||
<li>Videos</li>
|
||||
<li>Wallet</li>
|
||||
<li>Notes</li>
|
||||
<li>Reminders</li>
|
||||
<li>Stocks</li>"
|
||||
|
||||
readonly DEFAULT_APPS_LIST3="<li>iTunes</li>
|
||||
<li>App Store</li>
|
||||
<li>iBooks</li>
|
||||
<li>Health</li>
|
||||
<li>Home</li>
|
||||
<li>Settings</li>
|
||||
<li>FaceTime</li>
|
||||
<li>Calculator</li>"
|
||||
|
||||
readonly DEFAULT_APPS_LIST4="<li>Podcasts</li>
|
||||
<li>Watch</li>
|
||||
<li>Compass</li>
|
||||
<li>Tips</li>
|
||||
<li>Voice Memos</li>
|
||||
<li>Contacts</li>
|
||||
<li>Find Friends</li>
|
||||
<li>Find iPhone</li>"
|
||||
|
||||
# Some possible sources for informations:
|
||||
# - Phone: /private/var/mobile/Library/CallHistory/CallHistory.storedata
|
||||
# or: 5a4935c78a5255723f707230a451d79c540d2741
|
||||
#
|
||||
# - Safari: /private/var/mobile/Library/Safari/Bookmarks.db
|
||||
# or: d1f062e2da26192a6625d968274bfda8d07821e4
|
||||
#
|
||||
# - Mail: "/private/var/mobile/Library/Envelope Index"
|
||||
# or: ???
|
||||
#
|
||||
# - Messages: /private/var/mobile/Library/SMS/sms.db
|
||||
# or: 3d0d7e5fb2ce288813306e4d4636395e047a3d28
|
||||
#
|
||||
# - Calendar: /private/var/mobile/Library/Calendar/Calendar.sqlitedb
|
||||
# or: 2041457d5fe04d39d0ab481178355df6781e6858
|
||||
#
|
||||
# - Notes: /private/var/mobile/Library/Notes/notes.sqlite
|
||||
# or: ca3bc056d4da0bbf88b5fb3be254f3b7147e639c
|
||||
#
|
||||
# - iTunes Store: /private/var/mobile/Library/com.apple.itunessotred/iTunesMetadata/itunessored2.sqlitedb
|
||||
# or: ???
|
||||
#
|
||||
# - Contacts: /private/var/mobile/Library/AddressBook/AddressBook.sqlitedb
|
||||
# or: 31bb7ba8914766d4ba40d6dfb6113c8b614be442
|
||||
|
||||
readonly APP_DIR="mobile/Containers/Bundle/Application"
|
||||
|
||||
if ! [ -d "${IOS_BACKUP}/${APP_DIR}" ] ; then
|
||||
error "${IOS_BACKUP}/${APP_DIR} not found"
|
||||
readonly APPS_LIST_HTML="<tr><td class='highlight' colspan='6'>ERROR: app directory not found!</td></tr>"
|
||||
else
|
||||
|
||||
# Not 100% save but easy! Will break if newlines are in the path to the plist!
|
||||
${BIN_FIND} "${IOS_BACKUP}"/mobile/Containers/Bundle/Application -name "iTunesMetadata.plist" \
|
||||
| while read -r file ; do process_plists "${file}" ; done
|
||||
|
||||
APPS_SOURCES_HTML="$( ${BIN_CAT} /tmp/apps_sources.html )"
|
||||
${BIN_RM} /tmp/apps_sources.html
|
||||
|
||||
if [ -z "${APPS_SOURCES_HTML}" ] ; then
|
||||
APPS_SOURCES_HTML="<li>none</li>"
|
||||
fi
|
||||
|
||||
readonly APPS_LIST_HTML="$( ${BIN_CAT} /tmp/apps_list.html )"
|
||||
${BIN_RM} /tmp/apps_list.html
|
||||
|
||||
fi
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "INFO: applications_plugin processed.\\n" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Partial template for applications information for the simple template engine.
|
||||
#-------------------------------------------------------------------------------
|
||||
# SC2034: all "unused" vars are verified!
|
||||
APPLICATIONS_INFORMATION=$( ${BIN_CAT} <<'EOF'
|
||||
<h2>Applications</h2>
|
||||
<h3>Preinstalled</h3>
|
||||
<div class='ym-grid ym-equalize linearize-level-1'>
|
||||
<div class='ym-g50 ym-gl'>
|
||||
<div class='ym-grid'>
|
||||
<div class='ym-g50 ym-gl'>
|
||||
<div class='ym-gbox'>
|
||||
<ul>
|
||||
${DEFAULT_APPS_LIST1}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class='ym-g50 ym-gr'>
|
||||
<div class='ym-gbox'>
|
||||
<ul>
|
||||
${DEFAULT_APPS_LIST2}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='ym-g50 ym-gr'>
|
||||
<div class='ym-grid'>
|
||||
<div class='ym-g50 ym-gl'>
|
||||
<div class='ym-gbox'>
|
||||
<ul>
|
||||
${DEFAULT_APPS_LIST3}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class='ym-g50 ym-gr'>
|
||||
<div class='ym-gbox'>
|
||||
<ul>
|
||||
${DEFAULT_APPS_LIST4}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h4>Sources</h4>
|
||||
<ul class="file">
|
||||
${APPS_SOURCES_HTML}
|
||||
</ul>
|
||||
<h3>Installed by user</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th>AppID</th>
|
||||
<th>Name</th>
|
||||
<th>Version</th>
|
||||
<th>Developer</th>
|
||||
<th>Purchased</th>
|
||||
<th>AppleID</th>
|
||||
</tr>
|
||||
${APPS_LIST_HTML}
|
||||
</table>
|
||||
EOF
|
||||
)
|
||||
|
||||
readonly APPLICATIONS_PLUGIN_LOADED="true"
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "INFO: applications_plugin.sh loaded.\\n" 1>&2
|
||||
fi
|
||||
# Do not use "exit" at the end of a sourced library!
|
198
lib/configuration_plugin.sh
Executable file
198
lib/configuration_plugin.sh
Executable file
@ -0,0 +1,198 @@
|
||||
#!/usr/bin/env bash
|
||||
#===============================================================================
|
||||
#
|
||||
# DIRECTORY:
|
||||
# ---
|
||||
#
|
||||
# FILE:
|
||||
# ./configuration_plugin.sh
|
||||
#
|
||||
# USAGE:
|
||||
# . configuration_plugin.sh
|
||||
# OR
|
||||
# source configuration_plugin.sh
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Configuration plugin (library) to generate content with simple template engine.
|
||||
#
|
||||
# BUGS:
|
||||
# ---
|
||||
#
|
||||
# TESTS:
|
||||
# - shellcheck -s bash -e 2034 ./configuration_plugin.sh
|
||||
# - shellcheck -s ksh -e 2034 ./configuration_plugin.sh
|
||||
# - shellcheck -s dash -e 2034 ./configuration_plugin.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Patrick Neumann, patrick@neumannsland.de
|
||||
#
|
||||
# COAUTHOR(S):
|
||||
# Odin Heitmann, odin.heitmann@gmail.com
|
||||
#
|
||||
# COMPANY:
|
||||
# (privately)
|
||||
#
|
||||
# VERSION:
|
||||
# 1.0
|
||||
#
|
||||
# LINK TO THE MOST CURRENT VERSION:
|
||||
# (Sorry, we bet, I'm not allowed to publish it over GitHub!)
|
||||
#
|
||||
# CREATED:
|
||||
# 2018-06-01
|
||||
#
|
||||
# COPYRIGHT (C):
|
||||
# 2018 - Patrick Neumann & Odin Heitmann
|
||||
#
|
||||
# LICENSE:
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# WARRANTY:
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# NOTES:
|
||||
# ---
|
||||
#
|
||||
# TODO:
|
||||
# ---
|
||||
#
|
||||
# HISTORY:
|
||||
# 1.0 - P. N. & O. H. - Initial (for the trainers eyes only) release
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check if functions library is loaded first.
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ "${FUNCTIONS_LOADED}" != "true" ] ; then
|
||||
printf "\\n\\033[01;31;40mERROR: functions library not loaded... EXIT!!!\\033[00m\\n\\n"
|
||||
exit 200
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check if temblate engine library is loaded first.
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ "${TEMPLATE_ENGINE_LOADED}" != "true" ] ; then
|
||||
error_exit "template_engine.sh not loaded" 200
|
||||
fi
|
||||
|
||||
#=== CONFIGURATION (static) ====================================================
|
||||
#assign_binary "xyz" # (un)common
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: get_configuration_info
|
||||
# DESCRIPTION: "Grep" information and store into vars.
|
||||
# PARAMETERS: none (global vars will be used.)
|
||||
#===============================================================================
|
||||
get_configuration_info () {
|
||||
# NOT in iTunes Backup!
|
||||
# There are two data_ark.plist:
|
||||
# - mobile/Library/mad/data_ark.plist
|
||||
# - root/Library/Lockdown/data_ark.plist
|
||||
readonly DATA_ARK_PLIST="$( ${BIN_FIND} "${IOS_BACKUP}" -type f -path "*Lockdown/data_ark.plist" )"
|
||||
|
||||
if [ -z "${DATA_ARK_PLIST}" ] ; then
|
||||
readonly DATA_ARK_SOURCE="<code>data_ark.plist not found</code>"
|
||||
error "data_ark.plist not found"
|
||||
readonly DEVICE_NAME="unknown"
|
||||
readonly TIME_ZONE="unknown"
|
||||
readonly LOCALE="unknown"
|
||||
else
|
||||
readonly DATA_ARK_SOURCE="<a href='data_ark.plist' target='_blank'><code>${DATA_ARK_PLIST/${IOS_BACKUP}/\/private\/var}</code></a>"
|
||||
plist_bin2xml "${DATA_ARK_PLIST}" "${FOLDER}/data_ark.plist"
|
||||
|
||||
readonly DEVICE_NAME="$( ${BIN_GREP} --fixed-strings --after-context=1 "DeviceName" "${FOLDER}/data_ark.plist" \
|
||||
| ${BIN_TAIL} -n 1 \
|
||||
| ${BIN_SED} "${SED_EXT_REGEXP}" 's|[[:space:]]*</?string>||g' )"
|
||||
|
||||
readonly TIME_ZONE="$( ${BIN_GREP} --fixed-strings --after-context=1 "TimeZone" "${FOLDER}/data_ark.plist" \
|
||||
| ${BIN_TAIL} -n 1 \
|
||||
| ${BIN_SED} "${SED_EXT_REGEXP}" 's|[[:space:]]*</?string>||g' )"
|
||||
|
||||
|
||||
readonly LOCALE="$( ${BIN_GREP} --fixed-strings --after-context=1 "com.apple.international-Locale" "${FOLDER}/data_ark.plist" \
|
||||
| ${BIN_TAIL} -n 1 \
|
||||
| ${BIN_SED} "${SED_EXT_REGEXP}" 's|[[:space:]]*</?string>||g' )"
|
||||
fi
|
||||
|
||||
#--- next source ---
|
||||
|
||||
# "7ddb1ea8c09e5baae5e2d2ecac604a4e4e3087de" in iTunes Backup.
|
||||
LOCK_BACKGROUND="$( ${BIN_FIND} "${IOS_BACKUP}" -type f -name "LockBackgroundThumbnail.jpg" )" # <- could be modified later!
|
||||
|
||||
if [ -z "${LOCK_BACKGROUND}" ] ; then
|
||||
readonly LOCK_BACKGROUND="LockBackgroundThumbnail.jpg not found"
|
||||
readonly LOCK_BACKGROUND_SOURCE="<code>${LOCK_BACKGROUND}</code>"
|
||||
error "LockBackgroundThumbnail.jpg not found"
|
||||
else
|
||||
readonly LOCK_BACKGROUND_SOURCE="<a href='LockBackgroundThumbnail.jpg' target='_blank'><code>${LOCK_BACKGROUND/${IOS_BACKUP}/\/private\/var}</code></a>"
|
||||
${BIN_CP} "${LOCK_BACKGROUND}" "${FOLDER}/"
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "INFO: LockBackgroundThumbnail.jpg copied\\n" 1>&2
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "DEVICE_NAME: %s\\n" "${DEVICE_NAME}" 1>&2
|
||||
${BIN_PRINTF} "TIME_ZONE: %s\\n" "${TIME_ZONE}" 1>&2
|
||||
${BIN_PRINTF} "LOCALE: %s\\n" "${LOCALE}" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Partial template for hardware information for the simple template engine.
|
||||
#-------------------------------------------------------------------------------
|
||||
# SC2034: all "unused" vars are verified!
|
||||
CONFIGURATION_INFORMATION=$( ${BIN_CAT} <<'EOF'
|
||||
<h2>Configuration</h2>
|
||||
<div class='ym-grid'>
|
||||
<div class='ym-g75 ym-gl'>
|
||||
<div class='ym-gbox'>
|
||||
<h4>Sources</h4>
|
||||
<ul class="file">
|
||||
<li>${DATA_ARK_SOURCE}</li>
|
||||
<li>${LOCK_BACKGROUND_SOURCE}</li>
|
||||
</ul>
|
||||
<h3>Information</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Device Name:</td>
|
||||
<td>${DEVICE_NAME}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Time Zone:</td>
|
||||
<td>${TIME_ZONE}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Locale:</td>
|
||||
<td>${LOCALE}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class='ym-g25 ym-gr'>
|
||||
<div class='ym-gbox'>
|
||||
<h3>Background</h3>
|
||||
<img alt='${LOCK_BACKGROUND}' class='center' src='LockBackgroundThumbnail.jpg' title='Lock Background Image' height='240'>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
EOF
|
||||
)
|
||||
|
||||
readonly CONFIGURATION_PLUGIN_LOADED="true"
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "INFO: configuration_plugin.sh loaded.\\n" 1>&2
|
||||
fi
|
||||
# Do not use "exit" at the end of a sourced library!
|
541
lib/functions.sh
Executable file
541
lib/functions.sh
Executable file
@ -0,0 +1,541 @@
|
||||
#!/bin/bash
|
||||
#===============================================================================
|
||||
#
|
||||
# DIRECTORY:
|
||||
# ---
|
||||
#
|
||||
# FILE:
|
||||
# ./functions.sh
|
||||
#
|
||||
# USAGE:
|
||||
# . functions.sh
|
||||
# OR
|
||||
# source functions.sh
|
||||
#
|
||||
# OPTIONS:
|
||||
# none
|
||||
#
|
||||
# EXIT STATES:
|
||||
# 101 = uncommon binary not installed
|
||||
# 102 = logfile not defined/supplied
|
||||
# 103 = dir for logfile not writable
|
||||
# 104 = logfile already exists but is not writable
|
||||
# 105 = common binary not installed
|
||||
# 106 = your os is not supported (yet)
|
||||
# 107 = illegal browser command supplied
|
||||
# 108 = no case number supplied
|
||||
# 109 = folder not defined/supplied
|
||||
# 110 = folder already exists
|
||||
# 111 = unable to create folder
|
||||
# 112 = ios_backup not supplied
|
||||
# 113 = ios_backup does not exist
|
||||
# 114 = ios_backup is not a directory
|
||||
# 115 = ios_backup is empty
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Global functions (and configuration library) for scripts.
|
||||
#
|
||||
# REQUIREMENTS:
|
||||
# which, uname, basename, ps, grep, awk, sed, dirname, tee, ...
|
||||
#
|
||||
# BUGS:
|
||||
# ---
|
||||
#
|
||||
# TESTS:
|
||||
# - shellcheck -s bash -e SC2034,SC2016,SC2027,SC2086 ./functions.sh
|
||||
# - shellcheck -s bksh -e SC2034,SC2016,SC2027,SC2086 ./functions.sh
|
||||
# - shellcheck -s dash -e SC2034,SC2016,SC2027,SC2086 ./functions.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Patrick Neumann, patrick@neumannsland.de
|
||||
#
|
||||
# COAUTHOR(S):
|
||||
# Odin Heitmann, odin.heitmann@gmail.com
|
||||
#
|
||||
# COMPANY:
|
||||
# (privately)
|
||||
#
|
||||
# VERSION:
|
||||
# 1.0
|
||||
#
|
||||
# LINK TO THE MOST CURRENT VERSION:
|
||||
# (Sorry, I bet, I'm not allowed to publish it over GitHub!)
|
||||
#
|
||||
# CREATED:
|
||||
# 2018-06-01
|
||||
#
|
||||
# COPYRIGHT (C):
|
||||
# 2018 - Patrick Neumann & Odin Heitmann
|
||||
#
|
||||
# LICENSE:
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# WARRANTY:
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# NOTES:
|
||||
# ---
|
||||
#
|
||||
# TODO:
|
||||
# - check if HOLE directory (ios_backup) is read-only
|
||||
# - find a more portable solution for [[ in abspath
|
||||
#
|
||||
# HISTORY:
|
||||
# 1.0 - P. N. & O. H. - Initial (for the trainers eyes only) release
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
# Relative paths are more portable but less secure.
|
||||
# Absolute paths are more secure but less portable.
|
||||
readonly BIN_WHICH="/usr/bin/which" # common
|
||||
|
||||
readonly BIN_AWK="$( ${BIN_WHICH} "awk" )" # common
|
||||
readonly BIN_BASENAME="$( ${BIN_WHICH} "basename" )" # common
|
||||
readonly BIN_DIRNAME="$( ${BIN_WHICH} "dirname" )" # common
|
||||
readonly BIN_GREP="$( ${BIN_WHICH} "grep" )" # common
|
||||
readonly BIN_PS="$( ${BIN_WHICH} "ps" )" # common
|
||||
readonly BIN_TEE="$( ${BIN_WHICH} "tee" )" # common
|
||||
readonly BIN_UNAME="$( ${BIN_WHICH} "uname" )" # common
|
||||
readonly BIN_TR="$( ${BIN_WHICH} "tr" )" # common
|
||||
readonly BIN_LS="$( ${BIN_WHICH} "ls" )" # common
|
||||
readonly BIN_MKDIR="$( ${BIN_WHICH} "mkdir" )" # common
|
||||
readonly BIN_CUT="$( ${BIN_WHICH} "cut" )" # common
|
||||
readonly BIN_RM="$( ${BIN_WHICH} "rm" )" # common
|
||||
readonly BIN_RMDIR="$( ${BIN_WHICH} "rmdir" )" # common
|
||||
readonly BIN_PWD="$( ${BIN_WHICH} "pwd" )" # common
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check existence of uncommon binaries.
|
||||
#-------------------------------------------------------------------------------
|
||||
#[ -z "${BIN_BC}" ] && error_exit "please install bc and retry" 2
|
||||
|
||||
# Changeable defaults:
|
||||
DEFAULT_SHELL="bash"
|
||||
ECHO_FUNC="display_and_log"
|
||||
GET_HELP="no"
|
||||
DISABLE_LOGGING="no"
|
||||
DISABLE_STDOUT="no"
|
||||
GET_VERSION_ONLY="no"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Detect the shell in which we are running and set shell depended vars.
|
||||
#-------------------------------------------------------------------------------
|
||||
# SC2016: shellcheck fails if awk/sed is used!
|
||||
readonly PROCESS="$( ${BIN_BASENAME} "$( ${BIN_PS} -axco pid,command \
|
||||
| ${BIN_GREP} "$$" \
|
||||
| ${BIN_GREP} -v "grep" \
|
||||
| ${BIN_AWK} '{ print $2; }' )" )"
|
||||
|
||||
# Why conditinal command should be prefered over test:
|
||||
# https://google-styleguide.googlecode.com/svn/trunk/shell.xml#Test,_[_and_[[
|
||||
# and why you don't, if you would support "dash":
|
||||
# http://mywiki.wooledge.org/Bashism
|
||||
if [ "${PROCESS}" = "$( ${BIN_BASENAME} "${0}" )" ] ; then
|
||||
readonly CURRENT_SHELL="${DEFAULT_SHELL}"
|
||||
else
|
||||
readonly CURRENT_SHELL="${PROCESS}"
|
||||
fi
|
||||
|
||||
# Linux can have alle shells and "/bin/echo" has no limitations.
|
||||
# Darwin (14.5.0) has bash 3.2.57, zsh 5.0.5, ksh 93 and tcsh 6.17.00
|
||||
# - kshs and tcshs builtin echo does not support "-e" and/or "-n"!
|
||||
# - "/bin/echo" does not support "-e"!
|
||||
# FreeBSD can have all shells, but "/bin/echo" has the same limitations!
|
||||
# Solution: use printf instead!
|
||||
# Worth readable Link: http://hyperpolyglot.org/unix-shells#echo-note
|
||||
if [ "${CURRENT_SHELL}" = "zsh" ] ; then
|
||||
# zsh does not split a string into words separated by spaces by default!
|
||||
setopt shwordsplit
|
||||
# zshs "which" find the builtin without "-p"!
|
||||
readonly BIN_PRINTF="$( which -p printf )"
|
||||
else
|
||||
readonly BIN_PRINTF="$( which printf )"
|
||||
fi
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "CURRENT_SHELL: %s\\n" "${CURRENT_SHELL}" 1>&2
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Detect operating system name and set os depended vars.
|
||||
# (eg. "sed -E" on macOS is the same as "sed -r" on Linux)
|
||||
#-------------------------------------------------------------------------------
|
||||
readonly OS_NAME="$( ${BIN_UNAME} -s )"
|
||||
|
||||
case "${OS_NAME}" in
|
||||
Darwin) readonly BIN_ID="$( ${BIN_WHICH} "id" )" # common
|
||||
readonly BIN_OPEN="$( ${BIN_WHICH} "open" )" # common
|
||||
readonly SED_EXT_REGEXP="-E"
|
||||
readonly DARWIN_FIND_REGEXP_TYPE="-E "
|
||||
readonly DATE_DISPLAY="-j -f %s "
|
||||
;;
|
||||
Linux) readonly BIN_GETENT="$( ${BIN_WHICH} "getent" )" # common
|
||||
readonly SED_EXT_REGEXP="--regexp-extended"
|
||||
readonly DATE_DISPLAY="-d @"
|
||||
;;
|
||||
FreeBSD) readonly BIN_GETENT="$( ${BIN_WHICH} "getent" )" # common
|
||||
readonly SED_EXT_REGEXP="-E"
|
||||
readonly DATE_DISPLAY="-j -f %s "
|
||||
readonly LINUX_FIND_REGEXP_TYPE="-regextype posix-extended "
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
# printf has to be assinged before!
|
||||
${BIN_PRINTF} "OS_NAME: %s\\n" "${OS_NAME}" 1>&2
|
||||
fi
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: check_logfile
|
||||
# DESCRIPTION: Checks if a logfile is set and can be created.
|
||||
# (needed in "log" and "display_and_log"!)
|
||||
# PARAMETERS: none (a global var will be used.)
|
||||
#===============================================================================
|
||||
# Do not use "function" if you want to support dash:
|
||||
# http://mywiki.wooledge.org/Bashism
|
||||
check_logfile () {
|
||||
if [ -z "${LOG_FILE}" ] ; then
|
||||
# "error_exit" will be defined later!
|
||||
${BIN_PRINTF} "\\033[01;31;40mERROR: logfile not defined/supplied... EXIT!!!\\033[00m\\n"
|
||||
exit 102
|
||||
fi
|
||||
if ! [ -w "$( ${BIN_DIRNAME} "${LOG_FILE}" )" ] ; then
|
||||
${BIN_PRINTF} "\\033[01;31;40mERROR: dir for logfile not writable... EXIT!!!\\033[00m\\n"
|
||||
exit 103
|
||||
fi
|
||||
|
||||
if [ -e "${LOG_FILE}" ] ; then
|
||||
if ! [ -w "${LOG_FILE}" ] ; then
|
||||
${BIN_PRINTF} "\\033[01;31;40mERROR: logfile already exists but is not writable... EXIT!!!\\033[00m\\n"
|
||||
exit 104
|
||||
else
|
||||
${BIN_PRINTF} "\\nlogfile does already exist, overwrite? \
|
||||
(type YES in UPPER letters and hit return!) : "
|
||||
read -r answer
|
||||
if [ "${answer}" != "YES" ] ; then
|
||||
${BIN_PRINTF} "\\033[01;34;40mHINT: move the old logfile to a save place and try again... EXIT!!!\\033[00m\\n"
|
||||
exit 0
|
||||
fi
|
||||
# clear logfile
|
||||
${BIN_PRINTF} "" > "${LOG_FILE}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: display
|
||||
# DESCRIPTION: Wrapper for "echo -n -e".
|
||||
# PARAMETER 1: message (string)
|
||||
#===============================================================================
|
||||
display () {
|
||||
${BIN_PRINTF} "${1}"
|
||||
}
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: log
|
||||
# DESCRIPTION: Wrapper for "echo -n -e" incl. redirection into logfile.
|
||||
# PARAMETER 1: message (string)
|
||||
#===============================================================================
|
||||
log () {
|
||||
${BIN_PRINTF} "${1}" >> "${LOG_FILE}"
|
||||
}
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: display_and_log
|
||||
# DESCRIPTION: Wrapper for "echo -n -e" incl. output to stdout AND redirection
|
||||
# into logfile.
|
||||
# PARAMETER 1: message (string)
|
||||
#===============================================================================
|
||||
display_and_log () {
|
||||
${BIN_PRINTF} "${1}" | ${BIN_TEE} -a "${LOG_FILE}"
|
||||
}
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: quiet
|
||||
# DESCRIPTION: Wrapper for "echo -n -e" incl. redirection into "nirvana".
|
||||
# PARAMETER 1: message (string)
|
||||
#===============================================================================
|
||||
quiet () {
|
||||
${BIN_PRINTF} "${1}" > /dev/null
|
||||
}
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: error
|
||||
# DESCRIPTION: Display red error messages starting with "ERROR:".
|
||||
# PARAMETER 1: message (string)
|
||||
#===============================================================================
|
||||
error () {
|
||||
# TODO: stderr too!?
|
||||
"${ECHO_FUNC}" "\\033[01;31;40mERROR: ${1}!!!\\033[00m\\n"
|
||||
}
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: error_exit
|
||||
# DESCRIPTION: Display red error messages surrounded by "ERROR:" and "EXIT!!!".
|
||||
# PARAMETER 1: message (string)
|
||||
# PARAMETER 2: exit state (integer)
|
||||
# PARAMETER 3: command (optional)
|
||||
#===============================================================================
|
||||
error_exit () {
|
||||
"${BIN_PRINTF}" "\\n\\033[01;31;40mERROR: ${1}... EXIT!!!\\033[00m\\n\\n"
|
||||
|
||||
# Execute command/function before exit
|
||||
if [ -n "${3}" ] ; then
|
||||
${3}
|
||||
fi
|
||||
|
||||
# Clean up before exit
|
||||
${BIN_RM} "${LOG_FILE}"
|
||||
${BIN_RMDIR} "${FOLDER}"
|
||||
|
||||
if ! [ "${2}" -eq "${2}" ] 2> /dev/null ; then
|
||||
exit "${2}"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: hint
|
||||
# DESCRIPTION: Display blue hint messages starting with "HINT:".
|
||||
# PARAMETER 1: message (string)
|
||||
#===============================================================================
|
||||
hint () {
|
||||
"${ECHO_FUNC}" "\\033[01;34;40m${1}\\033[00m\\n"
|
||||
}
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: success
|
||||
# DESCRIPTION: Display green success messages starting with "SUCCESS:".
|
||||
# PARAMETER 1: message (string)
|
||||
#===============================================================================
|
||||
success () {
|
||||
"${ECHO_FUNC}" "\\033[01;32;40mSUCCESS: ${1}!\\033[00m\\n"
|
||||
}
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: assign_binary
|
||||
# DESCRIPTION: check if binary exists and store the absolute path in a var.
|
||||
# PARAMETER 1: command (string)
|
||||
#===============================================================================
|
||||
assign_binary () {
|
||||
# Because in dash, string indexing is not supported we can not use:
|
||||
# "${1:0:1}" = "/"
|
||||
if [ "$( ${BIN_PRINTF} "${1}" | ${BIN_CUT} -c 1 )" = "/" ] ; then
|
||||
# Absolute paths are more secure but less portable.
|
||||
if ! [ -e "${1}" ] ; then
|
||||
error_exit "${1} not installed" 105
|
||||
fi
|
||||
local var="BIN_$( ${BIN_PRINTF} "$( ${BIN_BASENAME} "${1}" )" \
|
||||
| ${BIN_TR} "[[:lower:]]" "[[:upper:]]" \
|
||||
| ${BIN_TR} -d '.' )"
|
||||
eval "readonly $var=\${1}"
|
||||
else
|
||||
# Relative paths are more portable but less secure.
|
||||
local var="BIN_$( ${BIN_PRINTF} "${1}" \
|
||||
| ${BIN_TR} "[[:lower:]]" "[[:upper:]]" \
|
||||
| ${BIN_TR} -d '.' )"
|
||||
# SC2027 & SC2086: It's not a bug... it's a feature!
|
||||
eval "readonly $var=\$( ${BIN_WHICH} "${1}" )"
|
||||
if [ -z "$( eval "${BIN_PRINTF} \$$var" )" ] ; then
|
||||
error_exit "${1} not installed" 105
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: check_browser
|
||||
# DESCRIPTION: Check for browser (default: firefox) and store in var.
|
||||
# (If no Desktop Environment is installed, try "true" as "a browser".)
|
||||
# PARAMETERS: none (a global var will be used.)
|
||||
#===============================================================================
|
||||
check_browser () {
|
||||
if [ -z "${BROWSER}" ] ; then
|
||||
case "${OS_NAME}" in
|
||||
Darwin) readonly BROWSER="Firefox"
|
||||
;;
|
||||
Linux|FreeBSD) BROWSER="firefox"
|
||||
;;
|
||||
*) error_exit "your os is not supported (yet)" 106
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case "${OS_NAME}" in
|
||||
Darwin) if ! [ -d "/Applications/${BROWSER}.app" ] ; then
|
||||
error_exit "illegal browser command (${BROWSER}) supplied" 107
|
||||
fi
|
||||
;;
|
||||
Linux|FreeBSD) readonly BROWSER="$( ${BIN_WHICH} "${BROWSER}" )"
|
||||
if ! [ -x "${BROWSER}" ] ; then
|
||||
error_exit "illegal browser command (${BROWSER}) supplied" 107
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
hint "Defined/supplied browser:\\n ${BROWSER}\\n"
|
||||
}
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: check_case_number
|
||||
# DESCRIPTION: Check if case number is given and store in var.
|
||||
# PARAMETERS: none (a global var will be used.)
|
||||
#===============================================================================
|
||||
check_case_number () {
|
||||
if [ -z "${CASE_NUMBER}" ] ; then
|
||||
${BIN_PRINTF} "\\nNo case number supplied but mandatory - type case numer in and hit return: "
|
||||
read -r case_number
|
||||
if [ -n "${case_number}" ] ; then
|
||||
readonly CASE_NUMBER="${case_number}"
|
||||
${BIN_PRINTF} "\\n"
|
||||
else
|
||||
error_exit "no case number supplied" 108 usage
|
||||
fi
|
||||
fi
|
||||
|
||||
hint "Supplied case number:\\n ${CASE_NUMBER}\\n"
|
||||
}
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: abspath
|
||||
# DESCRIPTION: generate absolute path from relative path
|
||||
# PARAMETERS 1: string (relative or absolute path to directory or file)
|
||||
# SOURCE:
|
||||
# https://stackoverflow.com/questions/3915040/bash-fish-command-to-print-absolute-path-to-a-file#23002317
|
||||
#===============================================================================
|
||||
abspath () {
|
||||
if [ -d "${1}" ]; then
|
||||
# dir
|
||||
( cd "${1}"; ${BIN_PWD} )
|
||||
elif [ -f "${1}" ]; then
|
||||
# file
|
||||
if [[ ${1} = /* ]]; then
|
||||
echo "${1}"
|
||||
elif [[ ${1} == */* ]]; then
|
||||
echo "$( cd "${1%/*}"; ${BIN_PWD} )/${1##*/}"
|
||||
else
|
||||
echo "$( ${BIN_PWD} )/${1}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: check_folder
|
||||
# DESCRIPTION: Check if folder does not exist, could be created in the given
|
||||
# location and store in var.
|
||||
# PARAMETERS: none (a global var will be used.)
|
||||
#===============================================================================
|
||||
check_folder () {
|
||||
if [ -z "${FOLDER}" ] ; then
|
||||
error_exit "folder not defined/supplied" 109 usage
|
||||
fi
|
||||
|
||||
if [ -d "${FOLDER}" ] ; then
|
||||
# I prefer to check for an existing report folder from a previous call
|
||||
# over "just" check if the folder is empty.
|
||||
error_exit "directory (${FOLDER}) already exists" 110
|
||||
fi
|
||||
|
||||
if ! [ -w "$( ${BIN_DIRNAME} "${FOLDER}" )" ] ; then
|
||||
error_exit "unable to create directory (${FOLDER})" 111
|
||||
fi
|
||||
|
||||
# Create folder before abspath
|
||||
${BIN_MKDIR} "${FOLDER}"
|
||||
# because abspath checks for existence!
|
||||
readonly FOLDER="$( abspath "${FOLDER}" )"
|
||||
}
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: check_officer
|
||||
# DESCRIPTION: Check if name of officer is given otherwise use
|
||||
# /etc/passwd or OpenDirectory.
|
||||
# PARAMETERS: none (a global var will be used.)
|
||||
#===============================================================================
|
||||
check_officer () {
|
||||
if [ -z "${OFFICER}" ] ; then
|
||||
case "${OS_NAME}" in
|
||||
Darwin) OFFICER="$( ${BIN_ID} -F )"
|
||||
;;
|
||||
Linux|FreeBSD) OFFICER="$( ${BIN_GETENT} passwd "${LOGNAME}" \
|
||||
| cut -d ":" -f 5 | cut -d "," -f 1 )"
|
||||
;;
|
||||
esac
|
||||
# Sometimes the system don't know the fullname of the user.
|
||||
# The default in Bash on Ubuntu on Windows 10 is "".
|
||||
if [ -z "${OFFICER}" ] || [ "${OFFICER}" = "\"\"" ] ; then
|
||||
readonly OFFICER="unknown"
|
||||
fi
|
||||
fi
|
||||
|
||||
hint "Guessed/supplied officers name:\\n ${OFFICER}\\n"
|
||||
}
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: remove_final_dashes
|
||||
# DESCRIPTION: Check if ios_backup has one or more final dash(es) and
|
||||
# remove them.
|
||||
# PARAMETER 1: string (eg. path to source)
|
||||
#===============================================================================
|
||||
remove_final_dashes () {
|
||||
# Because in dash, string indexing is not supported we can not use:
|
||||
# "${STRING:(-1)}" = "/" and STRING="${STRING:0:(-1)}"
|
||||
local STRING="${1}"
|
||||
local LENGTH="${#STRING}"
|
||||
while [ "$( ${BIN_PRINTF} "${STRING}" | ${BIN_CUT} -c "${LENGTH}" )" = "/" ] ; do
|
||||
STRING="$( ${BIN_PRINTF} "${STRING}" | ${BIN_CUT} -c 1-$(( LENGTH - 1 )) )"
|
||||
LENGTH="$(( LENGTH - 1 ))"
|
||||
done
|
||||
${BIN_PRINTF} "%s\\n" "${STRING}"
|
||||
}
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: check_source
|
||||
# DESCRIPTION: Check if ios_backup is given and store in var.
|
||||
# Otherwise EXIT!
|
||||
# PARAMETERS: none (a global var will be used.)
|
||||
#===============================================================================
|
||||
check_source () {
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "SOURCE: ${1}\\n" 1>&2
|
||||
fi
|
||||
|
||||
if [ -z "${1}" ] ; then
|
||||
error_exit "ios_backup not supplied" 112 usage
|
||||
fi
|
||||
|
||||
if ! [ -e "${1}" ] ; then
|
||||
error_exit "ios_backup (${1}) does not exist" 113
|
||||
fi
|
||||
|
||||
if ! [ -d "${1}" ] ; then
|
||||
error_exit "ios_backup (${1}) is not a directory" 114
|
||||
fi
|
||||
|
||||
if [ -z "$( ${BIN_LS} "${1}" )" ] ; then
|
||||
error_exit "ios_backup (${1}) is empty" 115
|
||||
fi
|
||||
|
||||
# TODO: check if hole directory is read-only
|
||||
|
||||
IOS_BACKUP="$( remove_final_dashes "${1}" )"
|
||||
readonly IOS_BACKUP="$( abspath "${IOS_BACKUP}" )"
|
||||
|
||||
hint "Supplied iOS backup folder:\\n ${IOS_BACKUP}\\n"
|
||||
}
|
||||
|
||||
readonly FUNCTIONS_LOADED="true"
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "INFO: functions.sh loaded.\\n" 1>&2
|
||||
fi
|
||||
# Do not use "exit" at the end of a sourced library!
|
269
lib/hardware_plugin.sh
Executable file
269
lib/hardware_plugin.sh
Executable file
File diff suppressed because one or more lines are too long
29
lib/iphone_hardware_map.tsv
Normal file
29
lib/iphone_hardware_map.tsv
Normal file
@ -0,0 +1,29 @@
|
||||
# "Model Identifier" "Model Number" "Board Config" "Common Name"
|
||||
iPhone1,1 A1203 M68AP iPhone
|
||||
iPhone1,2 A1241_or_A1324 N82AP iPhone_3G
|
||||
iPhone2,1 A1303_or_A1325 N88AP iPhone_3GS
|
||||
iPhone3,1 A1332 N90AP iPhone_4
|
||||
iPhone3,2 A1349 N90BAP iPhone_4
|
||||
iPhone3,3 A1332 N92AP iPhone_4
|
||||
iPhone4,1 A1387_or_vA1431 N94AP iPhone_4s
|
||||
iPhone5,1 A1428_or_A1429 N41AP iPhone_5
|
||||
iPhone5,2 A1429_or_A1442 N42AP iPhone_5
|
||||
iPhone5,3 A1456_or_A1532 N48AP iPhone_5c
|
||||
iPhone5,4 A1507,_A1516,_A1526_or_A1529 N49AP iPhone_5c
|
||||
iPhone6,1 A1453_or_A1533 N51AP iPhone_5s
|
||||
iPhone6,2 A1457,_A1518,_A1528_or_A1530 N53AP iPhone_5s
|
||||
iPhone7,1 A1633,_A1688,_A1691_or_A1700 N61AP iPhone_6
|
||||
iPhone7,2 A1522,_A1522,_A1524_or_A1593 N56AP iPhone_6_Plus
|
||||
iPhone8,1 A1633,_A1688,_A1691_or_A1700 N71AP_or_N71mAP iPhone_6s
|
||||
iPhone8,2 A1634,_A1687,_A1690_or_A1699 N66AP_or_N66mAP iPhone_6s_Plus
|
||||
iPhone8,4 A1662,_A1723_or_A1724 N69AP_or_N69uAP iPhone_SE
|
||||
iPhone9,1 A1660,_A1778,_A1779_or_A1780 D10AP iPhone_7
|
||||
iPhone9,3 A1660,_A1778,_A1779_or_A1780 D101AP iPhone_7
|
||||
iPhone9,2 A1661,_A1784,_A1785_or_A1786 D11AP iPhone_7_Plus
|
||||
iPhone9,4 A1661,_A1784,_A1785_or_A178 D111AP iPhone_7_Plus
|
||||
iPhone10,1 A1863,_A1905,_A1906_or_A1907 D20AP iPhone_8
|
||||
iPhone10,4 A1863,_A1905,_A1906_or_A1907 D201AP iPhone_8
|
||||
iPhone10,2 A1864,_A1897,_A1898_or_A1899 D21AP iPhone_8_Plus
|
||||
iPhone10,5 A1864,_A1897,_A1898_or_A1899 D211AP iPhone_8_Plus
|
||||
iPhone10,3 A1865,_A1901_or_A1902 D22AP iPhone_X
|
||||
iPhone10,6 A1901,_A1901_or_A1902 D221AP iPhone_X
|
Can't render this file because it contains an unexpected character in line 1 and column 3.
|
133
lib/iphone_os_map.tsv
Normal file
133
lib/iphone_os_map.tsv
Normal file
@ -0,0 +1,133 @@
|
||||
# iPhone iOS version -> Build number
|
||||
1.0 1A543a
|
||||
1.0.1 1C25
|
||||
1.0.2 1C28
|
||||
1.1.1 3A109
|
||||
1.1.2 3B48b
|
||||
1.1.3 4A93
|
||||
1.1.4 4A102
|
||||
2.0 5A345
|
||||
2.0 5A347
|
||||
2.0.1 5B108
|
||||
2.0.2 5C1
|
||||
2.1 5F136
|
||||
2.2 5G77
|
||||
2.2.1 5H11
|
||||
3.0 7A341
|
||||
3.0.1 7A400
|
||||
3.1 7C144
|
||||
3.1.2 7D11
|
||||
3.1.3 7E18
|
||||
4.0 8A293
|
||||
4.0.1 8A306
|
||||
4.0.2 8A400
|
||||
4.1 8B117
|
||||
4.2.1 8C148a
|
||||
4.2.5 8E128
|
||||
4.2.6 8E200
|
||||
4.2.7 8E303
|
||||
4.2.8 8E40
|
||||
4.2.9 8E501
|
||||
4.2.10 8E600
|
||||
4.3 8F190
|
||||
4.3.1 8G4
|
||||
4.3.2 8H7
|
||||
4.3.3 8J2
|
||||
4.3.4 8K2
|
||||
4.3.5 8L1
|
||||
5.0 9A334
|
||||
5.0.1 9A405
|
||||
5.0.1 9A406
|
||||
5.1 9B176
|
||||
5.1 9B179
|
||||
5.1.1 9B206
|
||||
5.1.1 9B208
|
||||
6.0 10A403
|
||||
6.0 10A405
|
||||
6.0.1 10A523
|
||||
6.0.1 10A525
|
||||
6.0.2 10A551
|
||||
6.1 10B141
|
||||
6.1 10B142
|
||||
6.1 10B143
|
||||
6.1 10B144
|
||||
6.1.1 10B145
|
||||
6.1.2 10B146
|
||||
6.1.3 10B329
|
||||
6.1.4 10B350
|
||||
6.1.6 10B500
|
||||
7.0 11A465
|
||||
7.0 11A466
|
||||
7.0.1 11A470a
|
||||
7.0.2 11A501
|
||||
7.0.3 11B511
|
||||
7.0.4 11B553
|
||||
7.0.4 11B554a
|
||||
7.0.5 11B601
|
||||
7.0.6 11B651
|
||||
7.1 11D167
|
||||
7.1 11D169
|
||||
7.1.1 11D201
|
||||
7.1.2 11D257
|
||||
8.0 12A365
|
||||
8.0 12A366
|
||||
8.0.1 12A402
|
||||
8.0.2 12A405
|
||||
8.1 12B410
|
||||
8.1 12B411
|
||||
8.1.1 12B435
|
||||
8.1.1 12B436
|
||||
8.1.2 12B440
|
||||
8.1.3 12B466
|
||||
8.2 12D508
|
||||
8.3 12F69
|
||||
8.3 12F70
|
||||
8.4 12H143
|
||||
8.4.1 12H321
|
||||
9.0 13A342
|
||||
9.0 13A343
|
||||
9.0 13A344
|
||||
9.0.1 13A404
|
||||
9.0.1 13A405
|
||||
9.0.2 13A452
|
||||
9.1 13B139
|
||||
9.1 13B143
|
||||
9.2 13C75
|
||||
9.2.1 13D15
|
||||
9.2.1 13D20
|
||||
9.3 13E233
|
||||
9.3 13E234
|
||||
9.3 13E237
|
||||
9.3.1 13E238
|
||||
9.3.2 13F69
|
||||
9.3.3 13G34
|
||||
9.3.4 13G35
|
||||
9.3.5 13G36
|
||||
10.0.1 14A403
|
||||
10.0.2 14A456
|
||||
10.0.3 14A551
|
||||
10.1 14B72
|
||||
10.1 14B72c
|
||||
10.1.1 14B100
|
||||
10.1.1 14B150
|
||||
10.2 14C92
|
||||
10.2.1 14D27
|
||||
10.3 14E277
|
||||
10.3.1 14E304
|
||||
10.3.2 14F89
|
||||
10.3.3 14G60
|
||||
11.0 15A372
|
||||
11.0.1 15A402
|
||||
11.0.2 15A421
|
||||
11.0.3 15A432
|
||||
11.1 15B93
|
||||
11.1.1 15B150
|
||||
11.1.2 15B202
|
||||
11.2 15C113
|
||||
11.2 15C114
|
||||
11.2.1 15C153
|
||||
11.2.2 15C202
|
||||
11.2.5 15D60
|
||||
11.2.6 15D100
|
||||
11.3 15E216
|
||||
11.3.1 15E302
|
Can't render this file because it has a wrong number of fields in line 2.
|
179
lib/kik_plugin.sh
Executable file
179
lib/kik_plugin.sh
Executable file
@ -0,0 +1,179 @@
|
||||
#!/usr/bin/env bash
|
||||
#===============================================================================
|
||||
#
|
||||
# DIRECTORY:
|
||||
# ---
|
||||
#
|
||||
# FILE:
|
||||
# ./kik_plugin.sh
|
||||
#
|
||||
# USAGE:
|
||||
# . kik_plugin.sh
|
||||
# OR
|
||||
# source kik_plugin.sh
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Kik messenger plugin (library) to generate content with simple template engine.
|
||||
#
|
||||
# BUGS:
|
||||
# ---
|
||||
#
|
||||
# TESTS:
|
||||
# - shellcheck -s bash -e SC2034 ./kik_plugin.sh
|
||||
# - shellcheck -s ksh -e SC2034 ./kik_plugin.sh
|
||||
# - shellcheck -s dash -e SC2034 ./kik_plugin.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Patrick Neumann, patrick@neumannsland.de
|
||||
#
|
||||
# COAUTHOR(S):
|
||||
# Odin Heitmann, odin.heitmann@gmail.com
|
||||
#
|
||||
# COMPANY:
|
||||
# (privately)
|
||||
#
|
||||
# VERSION:
|
||||
# 1.0
|
||||
#
|
||||
# LINK TO THE MOST CURRENT VERSION:
|
||||
# (Sorry, we bet, I'm not allowed to publish it over GitHub!)
|
||||
#
|
||||
# CREATED:
|
||||
# 2018-06-01
|
||||
#
|
||||
# COPYRIGHT (C):
|
||||
# 2018 - Patrick Neumann & Odin Heitmann
|
||||
#
|
||||
# LICENSE:
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# WARRANTY:
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# NOTES:
|
||||
# ---
|
||||
#
|
||||
# TODO:
|
||||
# ---
|
||||
#
|
||||
# HISTORY:
|
||||
# 1.0 - P. N. & O. H. - Initial (for the trainers eyes only) release
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check if functions library is loaded first.
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ "${FUNCTIONS_LOADED}" != "true" ] ; then
|
||||
printf "\\n\\033[01;31;40mERROR: functions library not loaded... EXIT!!!\\033[00m\\n\\n"
|
||||
exit 200
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check if temblate engine library is loaded first.
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ "${TEMPLATE_ENGINE_LOADED}" != "true" ] ; then
|
||||
error_exit "template_engine.sh not loaded" 200
|
||||
fi
|
||||
|
||||
#=== CONFIGURATION (static) ====================================================
|
||||
#assign_binary "xyz" # (un)common
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: get_kik_list
|
||||
# DESCRIPTION: "Grep" information and store into vars.
|
||||
# PARAMETERS: none (global vars will be used.)
|
||||
#===============================================================================
|
||||
get_kik_list () {
|
||||
# "8e281be6657d4523710d96341b6f86ba89b56df7" in iTunes Backup.
|
||||
readonly KIK_SQLITE="$( ${BIN_FIND} "${IOS_BACKUP}" -type f -name "kik.sqlite" )"
|
||||
|
||||
if ! [ -f "${KIK_SQLITE}" ] ; then
|
||||
readonly KIK_SOURCE="<code>kik.sqlite not found</code>"
|
||||
error "kik.sqlite not found"
|
||||
readonly KIK_CONTACTS="<tr><td class='highlight' colspan='4'>ERROR: database not found!</td></tr>"
|
||||
readonly KIK_MESSAGES="<tr><td class='highlight' colspan='5'>ERROR: database not found!</td></tr>"
|
||||
else
|
||||
KIK_SOURCE="<a href='kik.sqlite' target='_blank'><code>${KIK_SQLITE/${IOS_BACKUP}/\/private\/var}</code></a>"
|
||||
# Don't forget to copy write ahead log!
|
||||
${BIN_CP} "${KIK_SQLITE}"* "${FOLDER}/"
|
||||
|
||||
readonly KIK_CONTACTS="$( ${BIN_SQLITE3} -html "${FOLDER}/kik.sqlite" \
|
||||
"SELECT
|
||||
Z_PK,
|
||||
ZDISPLAYNAME,
|
||||
ZFIRSTNAME,
|
||||
ZLASTNAME,
|
||||
ZUSERNAME
|
||||
FROM
|
||||
ZKIKUSER;" )"
|
||||
|
||||
readonly KIK_MESSAGES="$( ${BIN_SQLITE3} -html "${FOLDER}/kik.sqlite" \
|
||||
"SELECT
|
||||
m.Z_PK,
|
||||
CASE WHEN m.ZTYPE=1 THEN 'received' WHEN m.ZTYPE=2 THEN 'sent' ELSE '(system)' END,
|
||||
u.ZUSERNAME,
|
||||
DATETIME(m.ZTIMESTAMP+978307200, 'unixepoch'),
|
||||
m.ZBODY
|
||||
FROM
|
||||
ZKIKMESSAGE AS m,
|
||||
ZKIKUSER AS u
|
||||
WHERE
|
||||
m.ZUSER=u.Z_PK;" )"
|
||||
fi
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "INFO: kik_plugin processed.\\n" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Partial template for hardware information for the simple template engine.
|
||||
#-------------------------------------------------------------------------------
|
||||
# SC2034: all "unused" vars are verified!
|
||||
KIK_INFORMATION=$( ${BIN_CAT} <<'EOF'
|
||||
<h2>Kik Messenger</h2>
|
||||
<h4>Sources</h4>
|
||||
<ul class="file">
|
||||
<li>${KIK_SOURCE}</li>
|
||||
</ul>
|
||||
<h3>Contacts</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Displayname</th>
|
||||
<th>Firstname</th>
|
||||
<th>Lastname</th>
|
||||
<th>Username</th>
|
||||
</tr>
|
||||
${KIK_CONTACTS}
|
||||
</table>
|
||||
<h3>Messages</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Direction</th>
|
||||
<th>Username</th>
|
||||
<th>Date</th>
|
||||
<th>Message</th>
|
||||
</tr>
|
||||
${KIK_MESSAGES}
|
||||
</table>
|
||||
EOF
|
||||
)
|
||||
|
||||
readonly KIK_PLUGIN_LOADED="true"
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "INFO: kik_plugin.sh loaded.\\n" 1>&2
|
||||
fi
|
||||
# Do not use "exit" at the end of a sourced library!
|
211
lib/network_plugin.sh
Executable file
211
lib/network_plugin.sh
Executable file
@ -0,0 +1,211 @@
|
||||
#!/usr/bin/env bash
|
||||
#===============================================================================
|
||||
#
|
||||
# DIRECTORY:
|
||||
# ---
|
||||
#
|
||||
# FILE:
|
||||
# ./network_plugin.sh
|
||||
#
|
||||
# USAGE:
|
||||
# . network_plugin.sh
|
||||
# OR
|
||||
# source network_plugin.sh
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Network plugin (library) to generate content with simple template engine.
|
||||
#
|
||||
# BUGS:
|
||||
# ---
|
||||
#
|
||||
# TESTS:
|
||||
# - shellcheck -s bash -e SC2034,SC2016 ./hardware_plugin.sh
|
||||
# - shellcheck -s ksh -e SC2034,SC2016 ./hardware_plugin.sh
|
||||
# - shellcheck -s dash -e SC2034,SC2016 ./hardware_plugin.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Patrick Neumann, patrick@neumannsland.de
|
||||
#
|
||||
# COAUTHOR(S):
|
||||
# Odin Heitmann, odin.heitmann@gmail.com
|
||||
#
|
||||
# COMPANY:
|
||||
# (privately)
|
||||
#
|
||||
# VERSION:
|
||||
# 1.1
|
||||
#
|
||||
# LINK TO THE MOST CURRENT VERSION:
|
||||
# (Sorry, we bet, I'm not allowed to publish it over GitHub!)
|
||||
#
|
||||
# CREATED:
|
||||
# 2018-06-05
|
||||
#
|
||||
# COPYRIGHT (C):
|
||||
# 2018 - Patrick Neumann & Odin Heitmann
|
||||
#
|
||||
# LICENSE:
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# WARRANTY:
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# NOTES:
|
||||
# ---
|
||||
#
|
||||
# TODO:
|
||||
# ---
|
||||
#
|
||||
# HISTORY:
|
||||
# 1.0 - P. N. & O. H. - Initial (for the trainers eyes only) release
|
||||
# 1.1 - P. N. - added network plugin
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check if functions library is loaded first.
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ "${FUNCTIONS_LOADED}" != "true" ] ; then
|
||||
printf "\\n\\033[01;31;40mERROR: functions library not loaded... EXIT!!!\\033[00m\\n\\n"
|
||||
exit 200
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check if temblate engine library is loaded first.
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ "${TEMPLATE_ENGINE_LOADED}" != "true" ] ; then
|
||||
error_exit "template_engine.sh not loaded" 200
|
||||
fi
|
||||
|
||||
#=== CONFIGURATION (static) ====================================================
|
||||
#assign_binary "xyz" # (un)common
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: get_hardware_info
|
||||
# DESCRIPTION: "Grep" information and store into vars.
|
||||
# PARAMETERS: none (global vars will be used.)
|
||||
#===============================================================================
|
||||
get_network_info () {
|
||||
# NOT in iTunes Backup!
|
||||
readonly NETWORK_INTERFACES_PLIST="$( ${BIN_FIND} "${IOS_BACKUP}" -type f -name "NetworkInterfaces.plist" )"
|
||||
|
||||
if [ -z "${NETWORK_INTERFACES_PLIST}" ] ; then
|
||||
readonly NETWORK_INTERFACES_SOURCE="<code>NetworkInterfaces.plist not found</code>"
|
||||
error "NetworkInterfaces.plist not found"
|
||||
readonly MAC_ADDRESS="unknown"
|
||||
else
|
||||
readonly NETWORK_INTERFACES_SOURCE="<a href='NetworkInterfaces.plist' target='_blank'><code>${NETWORK_INTERFACES_PLIST/${IOS_BACKUP}/\/private\/var}</code></a>"
|
||||
plist_bin2xml "${NETWORK_INTERFACES_PLIST}" "${FOLDER}/NetworkInterfaces.plist"
|
||||
|
||||
readonly MAC_ADDRESS="$( ${BIN_GREP} --fixed-strings --after-context=3 "IOMACAddress" "${FOLDER}/NetworkInterfaces.plist" \
|
||||
| ${BIN_GREP} --invert-match "<" \
|
||||
| ${BIN_HEAD} -n 1 \
|
||||
| ${BIN_TR} -d [[:space:]] \
|
||||
| ${BIN_BASE64} --decode \
|
||||
| ${BIN_XXD} -plain \
|
||||
| ${BIN_SED} 's/\(..\)/\1:/g;s/:$//' )"
|
||||
fi
|
||||
|
||||
#--- next source ---
|
||||
|
||||
# NOT in iTunes Backup!
|
||||
# db/dhcpclient/leases/en0-1,c0:f2:fb:b8:8a:63
|
||||
readonly DHCPC_LEASES_PLIST="$( ${BIN_FIND} "${IOS_BACKUP}" -type f -name "en0-1,${MAC_ADDRESS}" )"
|
||||
|
||||
if [ -z "${DHCPC_LEASES_PLIST}" ] ; then
|
||||
readonly DHCPC_LEASES_SOURCE="<code>en0-1,${MAC_ADDRESS} not found</code>"
|
||||
error "en0-1,${MAC_ADDRESS} not found"
|
||||
else
|
||||
readonly DHCPC_LEASES_SOURCE="<a href='en0-1,${MAC_ADDRESS}' target='_blank'><code>${DHCPC_LEASES_PLIST/${IOS_BACKUP}/\/private\/var}</code></a>"
|
||||
plist_bin2xml "${DHCPC_LEASES_PLIST}" "${FOLDER}/en0-1,${MAC_ADDRESS}"
|
||||
|
||||
readonly CLIENT_IP="$( ${BIN_GREP} --fixed-strings --after-context=1 "<key>IPAddress</key>" "${FOLDER}/en0-1,${MAC_ADDRESS}" \
|
||||
| ${BIN_TAIL} -n 1 \
|
||||
| ${BIN_SED} "${SED_EXT_REGEXP}" 's|[[:space:]]*</?string>||g' )"
|
||||
|
||||
readonly LEASE_START_DATE="$( ${BIN_GREP} --fixed-strings --after-context=1 "LeaseStartDate" "${FOLDER}/en0-1,${MAC_ADDRESS}" \
|
||||
| ${BIN_TAIL} -n 1 \
|
||||
| ${BIN_SED} "${SED_EXT_REGEXP}" 's|[[:space:]]*</?string>||g' )"
|
||||
|
||||
readonly BSSID="$( ${BIN_GREP} --fixed-strings --after-context=3 "RouterHardwareAddress" "${FOLDER}/en0-1,${MAC_ADDRESS}" \
|
||||
| ${BIN_GREP} --invert-match "<" \
|
||||
| ${BIN_HEAD} -n 1 \
|
||||
| ${BIN_TR} -d [[:space:]] \
|
||||
| ${BIN_BASE64} --decode \
|
||||
| ${BIN_XXD} -plain \
|
||||
| ${BIN_SED} 's/\(..\)/\1:/g;s/:$//' )"
|
||||
|
||||
readonly ROUTER_IP="$( ${BIN_GREP} --fixed-strings --after-context=1 "<key>RouterIPAddress</key>" "${FOLDER}/en0-1,${MAC_ADDRESS}" \
|
||||
| ${BIN_TAIL} -n 1 \
|
||||
| ${BIN_SED} "${SED_EXT_REGEXP}" 's|[[:space:]]*</?string>||g' )"
|
||||
|
||||
readonly ESSID="$( ${BIN_GREP} --fixed-strings --after-context=1 "SSID" "${FOLDER}/en0-1,${MAC_ADDRESS}" \
|
||||
| ${BIN_TAIL} -n 1 \
|
||||
| ${BIN_SED} "${SED_EXT_REGEXP}" 's|[[:space:]]*</?string>||g' )"
|
||||
fi
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "MAC_ADDRESS: %s\\n" "${MAC_ADDRESS}" 1>&2
|
||||
${BIN_PRINTF} "CLIENT_IP: %s\\n" "${CLIENT_IP}" 1>&2
|
||||
${BIN_PRINTF} "LEASE_START_DATE: %s\\n" "${LEASE_START_DATE}" 1>&2
|
||||
${BIN_PRINTF} "BSSID: %s\\n" "${BSSID}" 1>&2
|
||||
${BIN_PRINTF} "ROUTER_IP: %s\\n" "${ROUTER_IP}" 1>&2
|
||||
${BIN_PRINTF} "ESSID: %s\\n" "${ESSID}" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Partial template for network information for the simple template engine.
|
||||
#-------------------------------------------------------------------------------
|
||||
NETWORK_INFORMATION=$( ${BIN_CAT} <<'EOF'
|
||||
<h2>Network</h2>
|
||||
<h4>Sources</h4>
|
||||
<ul class="file">
|
||||
<li>${NETWORK_INTERFACES_SOURCE}</li>
|
||||
<li>${DHCPC_LEASES_SOURCE}</li>
|
||||
</ul>
|
||||
<h3>Information</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<td>MAC Address (Wi-Fi):</td>
|
||||
<td>${MAC_ADDRESS}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Client IP Address:</td>
|
||||
<td>${CLIENT_IP}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Lease start date:</td>
|
||||
<td>${LEASE_START_DATE}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>BSSID:</td>
|
||||
<td>${BSSID}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Router IP Address:</td>
|
||||
<td>${ROUTER_IP}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>(E)SSID:</td>
|
||||
<td>${ESSID}</td>
|
||||
</tr>
|
||||
</table>
|
||||
EOF
|
||||
)
|
||||
|
||||
readonly NETWORK_PLUGIN_LOADED="true"
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "INFO: network_plugin.sh loaded.\\n" 1>&2
|
||||
fi
|
||||
# Do not use "exit" at the end of a sourced library!
|
177
lib/os_plugin.sh
Executable file
177
lib/os_plugin.sh
Executable file
@ -0,0 +1,177 @@
|
||||
#!/usr/bin/env bash
|
||||
#===============================================================================
|
||||
#
|
||||
# DIRECTORY:
|
||||
# ---
|
||||
#
|
||||
# FILE:
|
||||
# ./os_plugin.sh
|
||||
#
|
||||
# USAGE:
|
||||
# . os_plugin.sh
|
||||
# OR
|
||||
# source os_plugin.sh
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Operating system plugin (library) to generate content with simple template engine.
|
||||
#
|
||||
# BUGS:
|
||||
# ---
|
||||
#
|
||||
# TESTS:
|
||||
# - shellcheck -s bash -e SC2034,SC2016 ./os_plugin.sh
|
||||
# - shellcheck -s ksh -e SC2034,SC2016 ./os_plugin.sh
|
||||
# - shellcheck -s dash -e SC2034,SC2016 ./os_plugin.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Patrick Neumann, patrick@neumannsland.de
|
||||
#
|
||||
# COAUTHOR(S):
|
||||
# Odin Heitmann, odin.heitmann@gmail.com
|
||||
#
|
||||
# COMPANY:
|
||||
# (privately)
|
||||
#
|
||||
# VERSION:
|
||||
# 1.0
|
||||
#
|
||||
# LINK TO THE MOST CURRENT VERSION:
|
||||
# (Sorry, we bet, I'm not allowed to publish it over GitHub!)
|
||||
#
|
||||
# CREATED:
|
||||
# 2018-06-01
|
||||
#
|
||||
# COPYRIGHT (C):
|
||||
# 2018 - Patrick Neumann & Odin Heitmann
|
||||
#
|
||||
# LICENSE:
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# WARRANTY:
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# NOTES:
|
||||
# ---
|
||||
#
|
||||
# TODO:
|
||||
# ---
|
||||
#
|
||||
# HISTORY:
|
||||
# 1.0 - P. N. & O. H. - Initial (for the trainers eyes only) release
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check if functions library is loaded first.
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ "${FUNCTIONS_LOADED}" != "true" ] ; then
|
||||
printf "\\n\\033[01;31;40mERROR: functions library not loaded... EXIT!!!\\033[00m\\n\\n"
|
||||
exit 200
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check if temblate engine library is loaded first.
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ "${TEMPLATE_ENGINE_LOADED}" != "true" ] ; then
|
||||
error_exit "template_engine.sh not loaded" 200
|
||||
fi
|
||||
|
||||
#=== CONFIGURATION (static) ====================================================
|
||||
# See template engine library!
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: get_os_info
|
||||
# DESCRIPTION: "Grep" information and store into vars.
|
||||
# PARAMETERS: none (global vars will be used.)
|
||||
#===============================================================================
|
||||
get_os_info () {
|
||||
# NOT in iTunes Backup!
|
||||
readonly LOCKDOWND_LOG="$( ${BIN_FIND} "${IOS_BACKUP}" -type f -name "lockdownd.log" )"
|
||||
|
||||
if [ -z "${LOCKDOWND_LOG}" ] ; then
|
||||
readonly LOCKDOWND_SOURCE="<code>lockdownd.log not found</code>"
|
||||
error "lockdownd.log not found"
|
||||
readonly BUILD_NUMBER="unknown"
|
||||
readonly OS_VERSION="unknown"
|
||||
else
|
||||
readonly LOCKDOWND_SOURCE="<a href='lockdownd.log' target='_blank'><code>${LOCKDOWND_LOG/${IOS_BACKUP}/\/private\/var}</code></a>"
|
||||
${BIN_CP} "${LOCKDOWND_LOG}" "${FOLDER}/"
|
||||
|
||||
# SC2016: shellcheck fails if awk/sed is used!
|
||||
readonly BUILD_NUMBER="$( ${BIN_AWK} '/Build=/ { print $NF; }' "${FOLDER}/lockdownd.log" | ${BIN_HEAD} -n 1 )"
|
||||
|
||||
[ -f "$( ${BIN_DIRNAME} "${0}" )/lib/iphone_os_map.tsv" ] || error_exit "iphone_os_map.tsv not found" 201
|
||||
|
||||
OS_VERSION="$( ${BIN_GREP} --fixed-strings --word-regexp "${BUILD_NUMBER}" $( ${BIN_DIRNAME} "${0}" )/lib/iphone_os_map.tsv \
|
||||
| ${BIN_CUT} -f 1 )"
|
||||
[ -z "${OS_VERSION}" ] && readonly OS_VERSION="<span title='Not found in our map - please ask for an update!'>unknown</span>"
|
||||
fi
|
||||
|
||||
#--- next source ---
|
||||
|
||||
# EVENTUALLY in iTunes Backup!?
|
||||
# There are three com.saurik.Cydia named folders:
|
||||
# - mobile/Library/Caches/Snapshots/com.saurik.Cydia
|
||||
# - mobile/Library/Caches/Snapshots/com.saurik.Cydia/com.saurik.Cydia
|
||||
# - mobile/Library/Caches/com.saurik.Cydia
|
||||
CACHE_CYDIA="$( ${BIN_FIND} "${IOS_BACKUP}" -type d -path "*Caches/com.saurik.Cydia" )"
|
||||
|
||||
JAILBREAK="no"
|
||||
if [ -n "${CACHE_CYDIA}" ] ; then
|
||||
if [ -n "$( ${BIN_LS} "${CACHE_CYDIA}" )" ] ; then
|
||||
readonly JAILBREAK="yes"
|
||||
fi
|
||||
fi
|
||||
[ "${JAILBREAK}" = "no" ] && readonly CACHE_CYDIA="com.saurik.Cydia not found"
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "OS_VERSION: %s\\n" "${OS_VERSION}" 1>&2
|
||||
${BIN_PRINTF} "BUILD_NUMBER: %s\\n" "${BUILD_NUMBER}" 1>&2
|
||||
${BIN_PRINTF} "JAILBREAK: %s\\n" "${JAILBREAK}" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Partial template for hardware information for the simple template engine.
|
||||
#-------------------------------------------------------------------------------
|
||||
# SC2034: all "unused" vars are verified!
|
||||
OS_INFORMATION=$( ${BIN_CAT} <<'EOF'
|
||||
<h2>Operating System</h2>
|
||||
<h4>Sources</h4>
|
||||
<ul class="file">
|
||||
<li>${LOCKDOWND_SOURCE}</li>
|
||||
<li><code>${CACHE_CYDIA/${IOS_BACKUP}/\/private\/var}</code></li>
|
||||
</ul>
|
||||
<h3>Information</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<td>iOS Version:</td>
|
||||
<td>${OS_VERSION}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Build Number:</td>
|
||||
<td>${BUILD_NUMBER}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Jailbreak detected:</td>
|
||||
<td>${JAILBREAK}</td>
|
||||
</tr>
|
||||
</table>
|
||||
EOF
|
||||
)
|
||||
|
||||
readonly OS_PLUGIN_LOADED="true"
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "INFO: os_plugin.sh loaded.\\n" 1>&2
|
||||
fi
|
||||
# Do not use "exit" at the end of a sourced library!
|
161
lib/sms_plugin.sh
Executable file
161
lib/sms_plugin.sh
Executable file
@ -0,0 +1,161 @@
|
||||
#!/usr/bin/env bash
|
||||
#===============================================================================
|
||||
#
|
||||
# DIRECTORY:
|
||||
# ---
|
||||
#
|
||||
# FILE:
|
||||
# ./sms_plugin.sh
|
||||
#
|
||||
# USAGE:
|
||||
# . sms_plugin.sh
|
||||
# OR
|
||||
# source sms_plugin.sh
|
||||
#
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# SMS/iMessage plugin (library) to generate content with simple template engine.
|
||||
#
|
||||
# BUGS:
|
||||
# ---
|
||||
#
|
||||
# TESTS:
|
||||
# - shellcheck -s bash -e SC2034 ./sms_plugin.sh
|
||||
# - shellcheck -s ksh -e SC2034 ./sms_plugin.sh
|
||||
# - shellcheck -s dash -e SC2034 ./sms_plugin.sh
|
||||
#
|
||||
# AUTHOR:
|
||||
# Patrick Neumann, patrick@neumannsland.de
|
||||
#
|
||||
# COAUTHOR(S):
|
||||
# Odin Heitmann, odin.heitmann@gmail.com
|
||||
#
|
||||
# COMPANY:
|
||||
# (privately)
|
||||
#
|
||||
# VERSION:
|
||||
# 1.0
|
||||
#
|
||||
# LINK TO THE MOST CURRENT VERSION:
|
||||
# (Sorry, we bet, I'm not allowed to publish it over GitHub!)
|
||||
#
|
||||
# CREATED:
|
||||
# 2018-06-01
|
||||
#
|
||||
# COPYRIGHT (C):
|
||||
# 2018 - Patrick Neumann & Odin Heitmann
|
||||
#
|
||||
# LICENSE:
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# WARRANTY:
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# NOTES:
|
||||
# ---
|
||||
#
|
||||
# TODO:
|
||||
# ---
|
||||
#
|
||||
# HISTORY:
|
||||
# 1.0 - P. N. & O. H. - Initial (for the trainers eyes only) release
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check if functions library is loaded first.
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ "${FUNCTIONS_LOADED}" != "true" ] ; then
|
||||
printf "\\n\\033[01;31;40mERROR: functions library not loaded... EXIT!!!\\033[00m\\n\\n"
|
||||
exit 200
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check if temblate engine library is loaded first.
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ "${TEMPLATE_ENGINE_LOADED}" != "true" ] ; then
|
||||
error_exit "template_engine.sh not loaded" 200
|
||||
fi
|
||||
|
||||
#=== CONFIGURATION (static) ====================================================
|
||||
#assign_binary "xyz" # (un)common
|
||||
|
||||
#=== FUNCTION ==================================================================
|
||||
# NAME: get_sms_list
|
||||
# DESCRIPTION: "Grep" information and store into vars.
|
||||
# PARAMETERS: none (global vars will be used.)
|
||||
#===============================================================================
|
||||
get_sms_list () {
|
||||
# "3d0d7e5fb2ce288813306e4d4636395e047a3d28" in iTunes Backup.
|
||||
readonly SMS_SQLITE="$( ${BIN_FIND} "${IOS_BACKUP}" -type f -name "sms.db" )"
|
||||
|
||||
if [ -z "${SMS_SQLITE}" ] ; then
|
||||
readonly SMS_SOURCE="<code>sms.db not found</code>"
|
||||
error "sms.db not found"
|
||||
readonly SMS_LIST="<tr><td class='highlight' colspan='7'>ERROR: database not found!</td></tr>"
|
||||
else
|
||||
readonly SMS_SOURCE="<a href='sms.db' target='_blank'><code>${SMS_SQLITE/${IOS_BACKUP}/\/private\/var}</code></a>"
|
||||
# * -> Don't forget to copy write ahead log!
|
||||
${BIN_CP} "${SMS_SQLITE}"* "${FOLDER}/"
|
||||
|
||||
readonly SMS_LIST="$( ${BIN_SQLITE3} -html "${FOLDER}/sms.db" \
|
||||
"SELECT
|
||||
m.ROWID,
|
||||
m.text,
|
||||
m.service,
|
||||
DATETIME(m.date+978307200, 'unixepoch'),
|
||||
REPLACE (m.account, 'p:', ''),
|
||||
CASE WHEN m.is_from_me=0 THEN '<-' ELSE '->' END,
|
||||
h.id
|
||||
FROM
|
||||
message AS m, handle AS h
|
||||
WHERE
|
||||
m.handle_id=h.ROWID;" )"
|
||||
fi
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "INFO: sms_plugin processed.\\n" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Partial template for hardware information for the simple template engine.
|
||||
#-------------------------------------------------------------------------------
|
||||
# SC2034: all "unused" vars are verified!
|
||||
SMS_INFORMATION=$( ${BIN_CAT} <<'EOF'
|
||||
<h2>SMS/iMessage</h2>
|
||||
<h4>Sources</h4>
|
||||
<ul class="file">
|
||||
<li>${SMS_SOURCE}</li>
|
||||
</ul>
|
||||
<h3>Information</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Text</th>
|
||||
<th>Service</th>
|
||||
<th>Date</th>
|
||||
<th>Me</th>
|
||||
<th>Direction</th>
|
||||
<th>Other</th>
|
||||
</tr>
|
||||
${SMS_LIST}
|
||||
</table>
|
||||
EOF
|
||||
)
|
||||
|
||||
readonly SMS_PLUGIN_LOADED="true"
|
||||
|
||||
if [ "${DEBUG}" = "on" ] ; then
|
||||
${BIN_PRINTF} "INFO: sms_plugin.sh loaded.\\n" 1>&2
|
||||
fi
|
||||
# Do not use "exit" at the end of a sourced library!
|
406
lib/template_engine.sh
Executable file
406
lib/template_engine.sh
Executable file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user