# Pivoting with SSH port forwarding


# cat traceraser 
#!/bin/bash

localhost="127.0.0.1"

declare -A pivotA
pivotA[ip]="1.1.1.1"
pivotA[user]="userA"

declare -A pivotB
pivotB[ip]="2.2.2.2"
pivotB[user]="userB"

declare -A pivotC
pivotC[ip]="3.3.3.3"
pivotC[user]="userC"

declare -A pivotD
pivotD[ip]="4.4.4.4"
pivotD[user]="userD"

declare -A Destination
Destination[ip]="5.5.5.5"
Destination[user]="UserDest"

#echo "||||||||||||"
#echo "TOR Cloud"
echo " ||||||||||"
echo "Pivot ${pivotA[ip]}"
#usewithtor ssh ...  Only in the first hop
ssh -L $localhost:6661:${pivotB[ip]}:22 -f -N -p 22   ${pivotA[user]}@${pivotA[ip]}
echo "  ||||||||"
echo "Pivot ${pivotB[ip]}"
ssh -L $localhost:6662:${pivotC[ip]}:22 -f -N -p 6661 ${pivotB[user]}@$localhost
echo "   ||||||"
echo "Pivot ${pivotC[ip]}"
ssh -L $localhost:6663:${pivotD[ip]}:22 -f -N -p 6662 ${pivotC[user]}@$localhost
echo "    ||||"
echo "Pivot ${pivotD[ip]}"
ssh -D 1080                             -f -N -p 6663 ${pivotD[user]}@$localhost
echo "     ||"
echo "Destination ${Destination[ip]}"
tsocks ssh -p 22 ${Destination[user]}@${Destination[ip]}
killall ssh
# ./traceraser.sh
 ||||||||||
Pivot 1.1.1.1
  ||||||||
Pivot 2.2.2.2
   ||||||
Pivot 3.3.3.3
    ||||
Pivot 4.4.4.4
     ||
Destination 5.5.5.5
UserDest@5.5.5.5's password:

No comments: