Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added function to bring shark online via host; fixed typo #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

shark-upgrade.bin
28 changes: 27 additions & 1 deletion sharkjack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,34 @@ function setup_shark(){
if [[ -z $SSHKEYPATH ]]; then
ssh-copy-id -i [email protected]
else
ssh-copy-id -i $SSHKEYPATH "[email protected].42.1"
ssh-copy-id -i $SSHKEYPATH "[email protected].24.1"
fi
exitscript 0
}

function online_shark() {
locate_shark
echo -e "\nConfiguring host and shark for internet access\n"
IFIP=$(ip ad show $IFACE | grep inet | awk '{print $2}' | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}")

# configuring shark
ssh [email protected] "ip route add default via $IFIP dev eth0 && echo 'nameserver 9.9.9.9' > /etc/resolv.conf"
echo -e "\nAdded Quad9 (9.9.9.9) as DNS-Resolver, modify in sharks' /etc/resolv.conf if needed"

# configuring host
UPLINK=$(ip route show default | awk '{print $5}' | grep -v $IFACE)
echo -e "\nUsing interface $UPLINK for uplink"
iptables -A FORWARD -o $UPLINK -i $IFACE -s 172.16.24.0/24 -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -F POSTROUTING
iptables -t nat -A POSTROUTING -o $UPLINK -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
# making sure the os does not try to route through the shark
ip route del default via 172.16.24.1 &>/dev/null

exitscript 0
}

function main_menu() {
banner
if [[ $OS -eq 1 ]]; then
Expand All @@ -332,6 +355,7 @@ function main_menu() {
[$(tput bold)G$(tput sgr0)]et loot saved on Shark Jack\n\n\
[$(tput bold)R$(tput sgr0)]eset known_hosts keys for the Shark Jack on this system\n\
[$(tput bold)S$(tput sgr0)]etup ssh keys for easy access\n\
[$(tput bold)O$(tput sgr0)]nline mode for downloading packages etc.\n\
[$(tput bold)Q$(tput sgr0)]uit\n\n"

read -r -sn1 key
Expand All @@ -342,11 +366,13 @@ function main_menu() {
[gG]) get_loot;;
[rR]) reset_key;;
[sS]) setup_shark;;
[oO]) online_shark;;
[qQ]) exitscript 0;;
*) main_menu;;
esac
}


# Validate priv / iptables
root_check
os_check
Expand Down