From 018303b9cb275bd7a65957b2752e4617cadcf5cc Mon Sep 17 00:00:00 2001 From: Rahul Chatterjee Date: Sun, 8 Dec 2024 20:40:48 -0600 Subject: [PATCH] More linting fixes --- scripts/android_scan.sh | 18 +++++++++--------- scripts/webusb.sh | 41 ----------------------------------------- 2 files changed, 9 insertions(+), 50 deletions(-) delete mode 100755 scripts/webusb.sh diff --git a/scripts/android_scan.sh b/scripts/android_scan.sh index 12a1d6e..018a7ef 100755 --- a/scripts/android_scan.sh +++ b/scripts/android_scan.sh @@ -5,10 +5,10 @@ if [[ $# -lt 1 ]]; then echo -e "You have to provide a serial number. #Num args: $#" - exit -1 + exit 1 fi platform='unknown' -unamestr=`uname` +unamestr="$(uname)" if [[ "$unamestr" == 'Linux' ]]; then platform='linux' elif [[ "$unamestr" == 'Darwin' ]]; then @@ -21,7 +21,7 @@ if command -v adb &>/dev/null; then adb=$(command -v adb) else - echo "Trying static adb. Unlikely to work on newer MAC or Linux. Please install `adb`" + echo "Trying static adb. Unlikely to work on newer MAC or Linux. Please install 'adb'" if [[ $platform == 'darwin' ]]; then adb='static_data/adb-darwin' elif [[ $platform == 'linux' ]]; then @@ -45,7 +45,7 @@ ofname=$dump_dir/${hmac_serial:3}_android.txt email="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$" function scan { act=$1 - $adb $serial shell dumpsys $act | \ + $adb "$serial" shell dumpsys "$act" | \ sed -e 's/\(\s*\)[a-zA-Z0-9._%+-]\+@[a-zA-Z0-9.-]\+\.[a-zA-Z]\{2,4\}\b/\1/g;s/\(\s*\)[a-zA-Z0-9._%+-]\+_gmail.com/\1/g' } @@ -57,7 +57,7 @@ function scan_spy { echo "Run scan first" return 1 fi - grep -Eio '[a-zA-Z0-9\.]*spy[a-zA-Z0-9\.]*' $ofname | sort -u + grep -Eio '[a-zA-Z0-9\.]*spy[a-zA-Z0-9\.]*' "$ofname" | sort -u } @@ -71,7 +71,7 @@ function retrieve { process_uid=$(grep -A1 "Package \[$app\]" $ofname | sed '1d;s/.*userId=\([0-9]\+\).*/\1/g') process_uidu=$(grep -Eo "app=ProcessRecord{[a-f0-9]+ [0-9]+:$app/([a-z0-9]*)" $ofname | cut -d '/' -f 2 | sort -u) - echo $process_uid $process_uidu + echo "$process_uid $process_uidu" # Install date printf 'Install: %s\n' "$(awk "/Package \[$app\]/{flag=1;next}/install permissions:/{flag=0}flag" $ofname | grep Time | tr -d ' ')" @@ -96,13 +96,13 @@ services=(package location media.camera netpolicy mount function dump { for a in ${services[*]}; do echo "DUMP OF SERVICE $a" - scan $a + scan "$a" done echo "DUMP OF SERVICE net_stats" $adb shell cat /proc/net/xt_qtaguid/stats | sed 's/ /,/g' for namespace in secure system global; do echo "DUMP OF SETTINGS $namespace" - $adb shell settings list $namespace + $adb shell settings list "$namespace" done } @@ -130,7 +130,7 @@ elif [[ "$1" == "info" ]]; then retrieve $3 else echo "$ bash $0 [appId]" - exit -1; + exit 1; fi diff --git a/scripts/webusb.sh b/scripts/webusb.sh deleted file mode 100755 index 1e42df4..0000000 --- a/scripts/webusb.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash -function unbind { - if [[ `uname` == 'Linux' ]]; then - echo 'Linux detected.' - echo 'Need custom udev rule for Linux...' - - # FIXME: grab idVendor and idProduct from `lsusb -v | grep ...` - # won't work without this on a per-device basis. - pkexec bash -c "echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="22b8",'\ - ' ATTR{idProduct}=="2e76", MODE="0660", GROUP="plugdev"'\ - > /etc/udev/rules.d/50-webusb.test.rules \ - && echo 'custom udev rule set. Restarting udev...'\ - && service udev restart && echo 'udev restarted.'" - - echo 'Checking if USB device is currently bound.' - tree /sys/bus/usb/devices/1-1:1.0 | grep driver - echo "Testing....don't unbind quite yet." - #echo -n "1-1:1.0" > /sys/bus/usb/drivers/ub/unbind - else - echo 'Not Linux. WebUSB should work without any issues.' - fi -} - -function bind { - echo "Doesn't do anything yet..(see https://lwn.net/Articles/143397/)" - #echo -n "1-1:1.0" > /sys/bus/usb/drivers/ub/unbind -} - -if [[ "$1" == 'unbind' ]]; then - unbind -elif [[ "$1" == 'bind' ]]; then - bind -else - echo "Usage: $ bash $0 " - echo "'unbind' will take away `uname -n`'s driver connection to the mobile device"\ - "so that webUSB can claim it." - echo "'bind' will restore `uname -n`'s driver connection to the mobile device." - echo "HELPFUL HINT: to debug your chrome webUSB connection, check chrome://device-log"\ - "and check the Debug checkbox." - exit -1; -fi