You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
132 lines
12 KiB
132 lines
12 KiB
#!/bin/sh |
|
# Bare Metal Alchemist, 2022 |
|
|
|
############################################# |
|
# Copper - ♀ # |
|
############################################# |
|
|
|
# Copper wires form the backbone of electrical systems worldwide |
|
# and much of the internet as a whole. |
|
|
|
# This ingredient is focused around scripts that make it easier to |
|
# interact with and create new networks on your system. |
|
|
|
locate_torrc() { |
|
if [ -n $TORRCPATH ]; then |
|
if [ -e /usr/local/etc/tor/torrc ]; then |
|
TORRCPATH='/usr/local/etc/tor/torrc' |
|
elif [ -e /etc/tor/torrc ]; then |
|
TORRCPATH='/etc/tor/torrc' |
|
elif [ -e $HOME/.tor/torrc ]; then |
|
TORRCPATH="${HOME}/.tor/torrc" |
|
else |
|
echo -e "${RED}Uh oh...${RESET} I couldn't figure out\ |
|
where your torrc file is. That might cause some issues" |
|
exit 1 |
|
fi |
|
fi |
|
|
|
echo -e "Your torrc is located at ${BLUE}${TORRCPATH}${RESET}" |
|
remember "TORRCPATH=${TORRCPATH}" |
|
} |
|
|
|
configure_tor() { |
|
locate_torrc |
|
|
|
echo -e "Your existing torrc file has the following settings: " |
|
echo "" |
|
cat $TORRCPATH | grep '^[^#]' |
|
echo "" |
|
echo -en "Would you like to reset them?: ${BLUE}(y/n)${RESET} " |
|
read torrc_reset |
|
case $torrc_reset in |
|
"Y" | "y") |
|
cp resources/torrc-template . |
|
sudo sed -i "s#USER#${USER}#g" torrc-template |
|
sudo sed -i "s#HOME#${HOME}#g" torrc-template |
|
sudo mv torrc-template $TORRCPATH |
|
echo -e "${GREEN}Torrc file reset!${RESET}" |
|
;; |
|
'*') |
|
echo "Okay, we'll leave it as is." |
|
;; |
|
esac |
|
echo "" |
|
|
|
echo -e "Tor configuration ${GREEN}complete!${RESET}" |
|
} |
|
|
|
get_external_ip() { |
|
case $DISTRO in |
|
"arch") |
|
install_if_needed dnsutils |
|
;; |
|
"*") |
|
#install_if_needed dig |
|
echo "Not yet supported! Feel free to help out here :)" |
|
;; |
|
esac |
|
|
|
EXTERNAL_IP=$(dig @resolver4.opendns.com myip.opendns.com +short) |
|
echo "Your external IP is $EXTERNAL_IP" |
|
remember "EXTERNAL_IP=$EXTERNAL_IP" |
|
} |
|
|
|
get_domain_name() { |
|
read -p "Do you have a domain name pointing to this computer? (y/n): " dns |
|
echo "" |
|
case $dns in |
|
y | Y) |
|
echo "Good to hear! What is it?" |
|
read -p "http://" domain |
|
;; |
|
*) |
|
echo "Okay, let's just leave it open for now." |
|
domain=$(dig @resolver4.opendns.com myip.opendns.com +short) |
|
anywhere=1 |
|
echo "Try accessing this AO from either localhost, 127.0.0.1, or ${domain}" |
|
;; |
|
esac |
|
|
|
if [ "$anywhere" -eq 1 ]; then |
|
ACCESS_POINT=http://localhost |
|
else |
|
ACCESS_POINT=https://$domain |
|
fi |
|
} |
|
|
|
check_ports() { |
|
install_if_needed nmap |
|
nmap -Pn $domain > nmap.txt |
|
OPEN=1 |
|
if grep -qE "^80/.*(open|filtered)" nmap.txt; then |
|
echo -e "I can see port ${GREEN}80${RESET}!" |
|
else |
|
echo -e "Uh oh, port ${RED}80${RESET} isn't showing up..." |
|
OPEN=0 |
|
fi |
|
|
|
if grep -qE "^443/.*(open|filtered)" nmap.txt; then |
|
echo -e "I can see port ${GREEN}443${RESET} as well!" |
|
else |
|
echo -e "Uh oh, port ${RED}443${RESET} isn't showing up..." |
|
OPEN=0 |
|
fi |
|
rm nmap.txt |
|
echo "" |
|
if [[ $OPEN -eq 0 ]]; then |
|
echo -e "${RED}Port configuration needed.${RESET} Something (probably your wireless router) is blocking us from serving this page to the rest of the internet." |
|
echo "Port forwarding is relatively simple, but as it stands it is beyond the scope of this script to be able to automate it." |
|
echo -e "You'll probably need to look up the login information for your specific router and forward the red ports to the local IP of this computer (${BOLD}$(ip route | grep default | grep -oP "(?<=src )[^ ]+")${RESET})." |
|
echo -e "You can log into your router at this IP address: ${BOLD}$(route -n | grep ^0.0.0.0 | awk '{print $2}')${RESET}" |
|
echo "That's all the help I can give you regarding port forwarding. Good luck!" |
|
echo "" |
|
fi |
|
} |
|
|
|
|
|
|
|
# internet connections? copper wires etc. |
|
# using yggdrasil could maybe fit in here |
|
# nginx setup |
|
# port checking
|
|
|