Created
October 20, 2023 21:41
-
-
Save smarteist/560b9fea17937248c674dac779f4ad7d to your computer and use it in GitHub Desktop.
This script runs ssh proxy in local socks5 port 1080
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -i | |
user_at_host="root@<host>" | |
sudo_pass="password!"; | |
sudo_pass_file="/tmp/sshpass" | |
interfaces_arr=($(ip route show default | sed -n 's/.* dev \([^\ ]*\) .*src.*/\1/p')) | |
for i in "${interfaces_arr[@]}"; do | |
# Activate debugging from here | |
sudo ip route add <host> dev "$i" | |
done | |
echo "use : socks5://127.0.0.1:1080/" | |
# create a file that echo's out your password .. you may need to get crazy with escape chars or for extra credit put ASCII in your password... | |
cat >$sudo_pass_file <<EOF | |
echo $sudo_pass | |
EOF | |
chmod +rwx $sudo_pass_file | |
export SSH_ASKPASS=$sudo_pass_file | |
# sets some vars for ssh to play nice with something to do with GUI but here we are using it to pass creds. | |
setsid --fork ssh -ND 1080 $user_at_host -p 22 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment