l sshify: init

This commit is contained in:
lassulus 2021-09-22 11:24:32 +02:00
parent a324b1add1
commit 9472181f28
2 changed files with 39 additions and 0 deletions

View File

@ -117,6 +117,7 @@ with import <stockholm/lib>;
iftop iftop
tcpdump tcpdump
mosh mosh
sshify
#stuff for dl #stuff for dl
aria2 aria2

View File

@ -0,0 +1,38 @@
{ pkgs }:
pkgs.writers.writeBashBin "sshify" ''
set -efu
TMPDIR=$(mktemp -d)
SSH_ARGS=()
while [[ "$#" -gt 0 ]]; do
case $1 in
--)
shift
break
;;
*)
SSH_ARGS+=($1)
;;
esac
shift
done
if [[ "$#" -le 0 ]]; then
echo no command specified
exit 1
fi
RANDOM_HIGH_PORT=$(shuf -i 20000-65000 -n 1)
cat << EOF >$TMPDIR/proxychains.conf
[ProxyList]
socks4 127.0.0.1 $RANDOM_HIGH_PORT
EOF
ssh -fNM -S "$TMPDIR/socket" -D "$RANDOM_HIGH_PORT" "''${SSH_ARGS[@]}"
trap "ssh -S $TMPDIR/socket -O exit bla 2>/dev/null; rm -rf $TMPDIR >&2" EXIT
${pkgs.proxychains-ng}/bin/proxychains4 -q -f "$TMPDIR/proxychains.conf" "$@"
''