Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/lib/fileshare/webc…
Browse files Browse the repository at this point in the history
…lient/braces-3.0.3
  • Loading branch information
zotil authored Jan 18, 2025
2 parents 812c725 + 2609263 commit 782dea8
Show file tree
Hide file tree
Showing 71 changed files with 1,365 additions and 1,451 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ trim_trailing_whitespace = true
insert_final_newline = true
indent_style = tab
indent_size = 2

# 4 space indentation
[*.py]
indent_style = space
indent_size = 4
6 changes: 3 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ flask-restful = "*"
flask-compress = "*"
flask-cors = "4.0.2"
gunicorn = "*"
opencv-python-headless = "*"
paramiko = "*"
peewee = "*"
pip = "*"
pgpy = "*"
PySocks = "*"
pytesseract = "*"
requests = "*"
stem = "1.8.1"
stem = "1.8.2"
tornado = "*"
urwid = "*"

[dev-packages]
opencv-python-headless = "*"
pytest = "*"

[requires]
Expand Down
558 changes: 273 additions & 285 deletions Pipfile.lock

Large diffs are not rendered by default.

41 changes: 24 additions & 17 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bin/automat
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ elif [ $ARGUMENT = 2 ]; then
fi
fi

# Entry 3: Restart Tor, an reconect wifi, if needed.
# Entry 3: Restart Tor, and reconect wifi, if needed.
# This should work in every configuration
elif [ $ARGUMENT = 3 ]; then
INTERNET_IFACE=$(grep "^INTERNET_IFACE=" $RUNFILE | sed "s/.*=//g")
Expand Down
16 changes: 8 additions & 8 deletions bin/clock.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/python3 -W ignore::SyntaxWarning

# This file is part of TorBox, an easy to use anonymizing router based on Raspberry Pi.
# Copyright (C) 2024 radio24
Expand Down Expand Up @@ -28,13 +28,13 @@
from time import ctime

def asciiClock(hour):
num = [" ___ @ / _ \ @ | | | | @ | | | | @ | |_| | @ \___/ @"," __ @ /_ | @ | | @ | | @ | | @ |_| @",
" ___ @ |__ \ @ ) | @ / / @ / /_ @ |____| @"," ____ @ |___ \ @ __) | @ |__ < @ ___) | @ |____/ @",
" _ _ @ | || | @ | || |_ @ |__ _| @ | | @ |_| @"," _____ @ | ____| @ | |__ @ |___ \ @ ___) | @ |____/ @",
" __ @ / / @ / /_ @ | _ \ @ | (_) | @ \___/ @"," ______ @ |____ | @ / / @ / / @ / / @ /_/ @",
" ___ @ / _ \ @ | (_) | @ > _ < @ | (_) | @ \___/ @"," ___ @ / _ \ @ | (_) | @ \__, | @ / / @ /_/ @",
" @ _ @(_)@ _ @(_)@ @"," @ @ __ _ _ __ @/ _` | ' \@\__,_|_|_|_|@ @",
" @ @ _ __ _ __ @| '_ \ ' \@| .__/_|_|_|@|_|@"]
num = [r" ___ @ / _ \ @ | | | | @ | | | | @ | |_| | @ \___/ @"," __ @ /_ | @ | | @ | | @ | | @ |_| @",
r" ___ @ |__ \ @ ) | @ / / @ / /_ @ |____| @"," ____ @ |___ \ @ __) | @ |__ < @ ___) | @ |____/ @",
r" _ _ @ | || | @ | || |_ @ |__ _| @ | | @ |_| @"," _____ @ | ____| @ | |__ @ |___ \ @ ___) | @ |____/ @",
r" __ @ / / @ / /_ @ | _ \ @ | (_) | @ \___/ @"," ______ @ |____ | @ / / @ / / @ / / @ /_/ @",
r" ___ @ / _ \ @ | (_) | @ > _ < @ | (_) | @ \___/ @"," ___ @ / _ \ @ | (_) | @ \__, | @ / / @ /_/ @",
r" @ _ @(_)@ _ @(_)@ @"," @ @ __ _ _ __ @/ _` | ' \@\__,_|_|_|_|@ @",
r" @ @ _ __ _ __ @| '_ \ ' \@| .__/_|_|_|@|_|@"]
clock = ""
for i in range(6):
# Spacer befor the clock
Expand Down
131 changes: 101 additions & 30 deletions bin/hostapd_fallback_komplex_part_1 → bin/hostapd_fallback_komplex_new
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# network can be found on wlan0.
#
# SYNTAX
# nohup ./hostapd_fallback_komplex_part_1 <interface 1> <interface 2>
# nohup ./hostapd_fallback_komplex_new <interface 1> <interface 2>
#
# <interface 1>: Is the interface with the AP: wlan0 or wlan1.
# <interface 2>: Is the interface with the connected cable client: eth0 or eth1
Expand All @@ -38,10 +38,11 @@
# wlan1 entries in the configuration fails and substitutet them with wlan0.
#
#
# EXCEPTION: don't run on TorBox mini (will replace /etc/network/interfaces)
# EXCEPTION: don't run on TorBox mini because TorBox mini has /etc/network/interfaces.mini and /etc/iptables.ipv-mini
# --> asuming that we don't have clients on the wifi
RUNFILE="/home/torbox/torbox/run/torbox.run"
if grep "^TORBOX_MINI=1" ${RUNFILE} ; then exit; fi
ON_A_CLOUD=$(grep "^ON_A_CLOUD=.*" ${RUNFILE} | sed "s/.*=//g")

##### SET VARIABLES ######

Expand Down Expand Up @@ -79,61 +80,88 @@ if pgrep -f "dhclient.$INTERFACE1" ; then
(sudo dhclient -r) 2>&1
# We can only do that, if the interface is not used as AP
if ! grep "^interface=$INTERFACE1" ${HOSTAPD} ; then
sudo ifdown $INTERFACE1
sudo ifdown $INTERFACE1 &>/dev/null
INTERFACE1_DOWN=1
fi
if ! grep "^interface=$INTERFACE3" ${HOSTAPD} ; then
sudo ifdown $INTERFACE3
sudo ifdown $INTERFACE3 &>/dev/null
INTERFACE3_DOWN=1
fi
fi

if pgrep -f "dhclient.$INTERFACE2" ; then
(sudo dhclient -r) 2>&1
sudo ifdown $INTERFACE2
sudo ifdown $INTERFACE4
sudo ifdown $INTERFACE2 &>/dev/null
# NEW v.0.5.4-post: This will disconnect a cable connection
# sudo ifdown $INTERFACE4
INTERFACE2_DOWN=1
fi

ON_A_CLOUD=$(grep "^ON_A_CLOUD=.*" ${RUNFILE} | sed "s/.*=//g")
if [ "$ON_A_CLOUD" -eq "0" ]; then sudo cp etc/network/interfaces.$INTERFACE1$INTERFACE2 /etc/network/interfaces; fi
sleep 1
if [ "$ON_A_CLOUD" -eq "0" ]; then
sudo cp /etc/network/interfaces /etc/network/interfaces.bak
sudo cp etc/network/interfaces.$INTERFACE1$INTERFACE2 /etc/network/interfaces
# iptables can only be safed if WLAN_FAILSAFE=0 in torbox.run
if grep -q "WLAN_FAILSAFE=0" ${RUNFILE} ; then
sudo cp /etc/iptables.ipv4.nat /etc/iptables.ipv4.nat.bak
sudo cp etc/iptables.ipv4-${INTERFACE1}${INTERFACE2}.nat /etc/iptables.ipv4.nat
fi
fi

if [ $INTERFACE1_DOWN = 1 ] ; then
sudo ifup $INTERFACE1
sudo ifup $INTERFACE1 &>/dev/null
INTERFACE1_DOWN=0
fi

if [ $INTERFACE3_DOWN = 1 ] ; then
sudo ifup $INTERFACE3
INTERFACE3_DOWN=0
fi

if [ $INTERFACE2_DOWN = 1 ] ; then
sudo ifup $INTERFACE2
sudo ifup $INTERFACE4
sudo ifup $INTERFACE2 &>/dev/null
# sudo ifup $INTERFACE4
INTERFACE2_DOWN=0
fi

if [ $INTERFACE3_DOWN = 1 ] ; then
sudo ifup $INTERFACE3 &>/dev/null
INTERFACE3_DOWN=0
fi

# Is INTERFACE1 ready?
STATICIP1=$(ip addr show $INTERFACE1 | grep -w inet)
# If wlan0 or wlan1 doesn't have an IP address then we have to do something about it!
if [ -z "$STATICIP1" ] ; then
sudo ifdown $INTERFACE1
sudo ifdown $INTERFACE1 &>/dev/null
# Cannot be run in the background because then it jumps into the next if-then-else clause (still missing IP)
sudo ifup $INTERFACE1
sudo ifup $INTERFACE1 &>/dev/null
fi
# Avoiding to have no IP
STATICIP1=$(ip addr show $INTERFACE1 | grep 192.168.42.1)
if [ -z "$STATICIP1" ] ; then
sudo ifdown $INTERFACE1 &>/dev/null
# Cannot be run in the background because then it jumps into the next if-then-else clause (still missing IP)
sudo ifup $INTERFACE1 &>/dev/null
fi

# Is INTERFACE2 ready?
# Only executed if the interface is down and not used for a cable client
if ip link | grep $INTERFACE2 | grep "state UP" ; then
STATICIP2=$(ip addr show $INTERFACE2 | grep -w 192.168.43.1)
if [ -z "$STATICIP2" ] ; then
sudo ifdown $INTERFACE2 &>/dev/null
# Cannot be run in the background because then it jumps into the next if-then-else clause (still missing IP)
sudo ifup $INTERFACE2 &>/dev/null
fi
else
sudo ifdown $INTERFACE2 &>/dev/null
# Cannot be run in the background because then it jumps into the next if-then-else clause (still missing IP)
sudo ifup $INTERFACE2 &>/dev/null
fi

# If wlan0 or wlan1 is not acting as AP then we have to do something about it!
if ! grep "^interface=$INTERFACE1" ${HOSTAPD} ; then
sudo sed -i "s/^interface=.*/interface=$INTERFACE1/" ${HOSTAPD}
# New v.0.5.4 avoid to run hostapd if it is masked
AP_STATUS=$(sudo systemctl is-enable hostapd)
if [ "$AP_STATUS" != "masked" ] ; then
sudo systemctl restart hostapd
sleep 5
fi
# New v.0.5.4 avoid to run hostapd if it is masked
AP_STATUS=$(sudo systemctl is-enable hostapd)
if [ "$AP_STATUS" != "masked" ] ; then
AP_STATUS=$(sudo systemctl is-active hostapd)
Expand All @@ -149,15 +177,58 @@ if ! grep "^interface=$INTERFACE1" ${HOSTAPD} ; then
fi
fi

# Is INTERFACE2 ready?
# Only executed if the interface is down and not used for a cable client
if ip link | grep $INTERFACE2 | grep "state UP" ; then
STATICIP2=$(ip addr show $INTERFACE2 | grep -w 192.168.43.1)
if [ -z "$STATICIP2" ] ; then
sudo ifdown $INTERFACE2
sudo ifup $INTERFACE2 &>/dev/null &
# Is INTERFACE3 ready?
# Because it is a possible Internet source, the Interface should be up, but
# the IP adress shouldn't be 192.168.42.1 or 192.168.43.1
if ip link | grep $INTERFACE3 | grep "state UP" ; then
STATICIP3=$(ip addr show $INTERFACE3 | grep -w inet)
if [ -z "$STATICIP3" ] ; then
sudo ifdown $INTERFACE3 &>/dev/null
# Cannot be run in the background because then it jumps into the next if-then-else clause (still missing IP)
sudo ifup $INTERFACE3 &>/dev/null
fi
unset STATICIP3
STATICIP3=$(ip addr show $INTERFACE3 | grep 192.168.42.1)
if [ -n "$STATICIP3" ] ; then
sudo ifdown $INTERFACE3 &>/dev/null
# The next line should help TorBox to forget the old IP
ip addr flush dev $INTERFACE3 &>/dev/null
sudo ifup $INTERFACE3 &>/dev/null &
fi
else
sudo ifdown $INTERFACE2
sudo ifup $INTERFACE2 &>/dev/null &
sudo ifdown $INTERFACE3 &>/dev/null
# The next line should help TorBox to forget the old IP
ip addr flush dev $INTERFACE3
sudo ifup $INTERFACE3 &>/dev/null &
fi

# Is INTERFACE4 ready?
# Because it is a possible Internet source, the Interface should be up, but
# the IP adress shouldn't be 192.168.42.1 or 192.168.43.1
if ip link | grep $INTERFACE4 | grep "state UP" ; then
STATICIP4=$(ip addr show $INTERFACE4 | grep -w inet)
if [ -z "$STATICIP4" ] ; then
sudo ifdown $INTERFACE4 &>/dev/null
# Cannot be run in the background because then it jumps into the next if-then-else clause (still missing IP)
sudo ifup $INTERFACE4 &>/dev/null
fi
unset STATICIP4
STATICIP4=$(ip addr show $INTERFACE4 | grep 192.168.43.1)
if [ -n "$STATICIP4" ] ; then
sudo ifdown $INTERFACE4
# The next line should help TorBox to forget the old IP
ip addr flush dev $INTERFACE4
sudo ifup $INTERFACE4 &>/dev/null &
fi
else
sudo ifdown $INTERFACE4
# The next line should help TorBox to forget the old IP
ip addr flush dev $INTERFACE4
sudo ifup $INTERFACE4 &>/dev/null &
fi

# This last part resets the dhcp server and opens the iptables to access TorBox
# This function has to be used after an ifup command
# Important: the right iptables rules to use Tor have to configured afterward
sudo systemctl restart isc-dhcp-server
sudo /sbin/iptables-restore < /etc/iptables.ipv4.nat
108 changes: 0 additions & 108 deletions bin/hostapd_fallback_komplex_part_2

This file was deleted.

9 changes: 6 additions & 3 deletions bin/set_interfaces_2
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,11 @@ captive_tunneling()
echo -e "${YELLOW} even if it shows already an IP!${NOCOLOR}"
echo ""
fi
(nohup $TORBOX_PATH/bin/hostapd_fallback_komplex_part_1 wlan0 eth1) 2>/dev/null
echo -e "${YELLOW}[+] Step 1 of 2 done${NOCOLOR}"
(nohup $TORBOX_PATH/bin/hostapd_fallback_komplex_part_2 wlan0 eth1) 2>/dev/null
# NEW v.0.5.4-post
echo -e "${YELLOW}[+] Step 1 of 2 ...${NOCOLOR}"
nohup bin/hostapd_fallback_komplex_new $I_DEVICE1 $I_DEVICE2 > /dev/null 2>&1 &
pid=$!
wait $pid
echo -e "${YELLOW}[+] Step 2 of 2 done${NOCOLOR}"
sleep 2
fi
Expand Down Expand Up @@ -292,3 +294,4 @@ if [ $CAPTIVE != 1 ] && [ $CAPTIVE != 2 ] && [ "$O_DEVICE" != "ppp0" ]; then
(sudo ifup $O_DEVICE) 2>/dev/null
sleep 1
fi
exit 0
Loading

0 comments on commit 782dea8

Please sign in to comment.