[Replicant] [PATCH] screencap: Add naive SSH backend implementation.
Denis 'GNUtoo' Carikli
GNUtoo at no-log.org
Sun May 21 13:04:09 UTC 2017
This implementation is not efficent as each command will spawn a
new ssh command, which has considerable overhead and latency.
Example usage:
./screencap.sh -h root at 192.168.43.1 -f OUTPUT.PNG
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at no-log.org>
---
screencap/screencap.sh | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/screencap/screencap.sh b/screencap/screencap.sh
index 53284b3..7ed7d8c 100755
--- a/screencap/screencap.sh
+++ b/screencap/screencap.sh
@@ -18,13 +18,25 @@
set -e
FFMEG="ffmpeg"
-ADB="adb"
+ADB=""
FB_PATH="/dev/graphics/fb0"
+SSH_HOST=""
TMP_FB="fb_raw"
TMP_FB_RS="fb_raw_rs"
RECOVERY=false
+ssh_wrapper()
+{
+ if [ "$1" = "shell" ] ; then
+ shift 1
+ ssh "${SSH_HOST}" "su -c \"$@\""
+ elif [ "$1" = "pull" ] ; then
+ shift 1
+ scp ${SSH_HOST}:$@
+ fi
+}
+
print_usage () {
echo
echo "Usage: $0 [OPTIONS] -f OUTPUT.PNG"
@@ -33,6 +45,7 @@ print_usage () {
echo "Options:"
echo "-r, --recovery Device is booted in recovery mode"
echo "-s, --screen-size Specify screen size (mandatory in recovery mode)"
+ echo "-h, --ssh-host Connect to the given host through SSH"
echo
}
@@ -66,7 +79,8 @@ take_screenshot () {
PIX_FMT="rgb565"
fi
- $ADB pull $FB_PATH $TMP_FB
+ $ADB shell "cat $FB_PATH > /data/local/tmp/$TMP_FB"
+ $ADB pull /data/local/tmp/$TMP_FB $TMP_FB
dd bs=$BS count=$SCREEN_SIZE_Y if=$TMP_FB of=$TMP_FB_RS
$FFMEG -vcodec rawvideo -f rawvideo -pix_fmt $PIX_FMT -s $SCREEN_SIZE \
@@ -91,6 +105,11 @@ do
SCREEN_SIZE="$2"
shift 2
;;
+ -h|--ssh-host)
+ SSH_HOST="$2"
+ shift 2
+ ;;
+
"")
break
;;
@@ -102,6 +121,12 @@ do
esac
done
+if [ -z "${SSH_HOST}" ] ; then
+ ADB="adb"
+else
+ ADB="ssh_wrapper"
+fi
+
if [ "$OUTFILE" = "" ]; then
echo "No output file specified"
print_usage
--
2.13.0
More information about the Replicant
mailing list