create
This commit is contained in:
commit
6c7681fe57
14
README.md
Normal file
14
README.md
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
### Socks5 Dante-server
|
||||
|
||||
Inspired by: https://wiki.dieg.info/socks
|
||||
|
||||
Install: `sudo bash socks5.sh SOCKS5_PASSWORD`
|
||||
|
||||
Will be created socks5 server:
|
||||
**user:** `usrsocks`
|
||||
**password:** `SOCKS5_PASSWORD` (enter your own)
|
||||
**port:** `1080`
|
||||
|
||||
Uninstall: `sudo bash socks5-uninstall.sh`
|
||||
Will be deleted dante-server, configs, user, and something else.
|
||||
52
socks5-uninstall.sh
Normal file
52
socks5-uninstall.sh
Normal file
@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
read -p "Dante will be completely removed. Do you want to continue? (y/n): " answer
|
||||
if [ "$answer" != "${answer#[Yy]}" ]; then
|
||||
echo "Deleting..."
|
||||
else
|
||||
echo "Canceled by user"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure the script runs with superuser rights
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo -e "\033[31mThis script requires superuser rights.\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Trap errors and exit
|
||||
trap 'echo -e "\033[31mAn error has occurred\033[0m"; exit 1' ERR
|
||||
set -e
|
||||
|
||||
DANTE_CONF="/etc/danted.conf"
|
||||
DANTE_USER="usrsocks"
|
||||
|
||||
rm "${DANTE_CONF}"
|
||||
echo -e "\033[32mRemoved the danted.conf configuration file\033[0m"
|
||||
|
||||
# Rollback configuration file
|
||||
if [ -f "${DANTE_CONF}.bak" ]; then
|
||||
# If backup exists, remove it
|
||||
rm "${DANTE_CONF}.bak"
|
||||
echo -e "\033[32mRemoved the danted.conf.bak file\033[0m"
|
||||
fi
|
||||
|
||||
# Remove the dante user
|
||||
if id "$DANTE_USER" &>/dev/null; then
|
||||
userdel -r "$DANTE_USER"
|
||||
echo -e "\033[32mRemoved the dante user and its home directory\033[0m"
|
||||
else
|
||||
echo -e "\033[33mDante user does not exist. Skipping user removal\033[0m"
|
||||
fi
|
||||
|
||||
# Disable and stop the danted service
|
||||
systemctl stop danted
|
||||
systemctl disable danted
|
||||
echo -e "\033[32mStopped and disabled the Dante service\033[0m"
|
||||
|
||||
# Uninstall dante-server package
|
||||
apt -y remove dante-server
|
||||
echo -e "\033[32mRemoved the dante-server package\033[0m"
|
||||
|
||||
trap - ERR
|
||||
echo -e "\033[32mDante completely removed\033[0m"
|
||||
87
socks5.sh
Normal file
87
socks5.sh
Normal file
@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo -e "\033[31mThis script requires superuser rights.\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Please provide socks5 password as argument"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
trap 'echo -e "\033[31mSomething went wrong\033[0m"; exit 1' ERR
|
||||
set -e
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
DANTE_CONF="/etc/danted.conf"
|
||||
DANTE_USER="usrsocks"
|
||||
DANTE_PASSWORD=$1
|
||||
|
||||
INTERFACE=$(ip -o -4 route show to default | awk '{print $5}')
|
||||
|
||||
if [ -z "$INTERFACE" ]; then
|
||||
echo "Failed to find active network interface"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Active network interface found: $INTERFACE"
|
||||
|
||||
apt update
|
||||
apt install -y dante-server
|
||||
|
||||
|
||||
# Backup existing configuration file
|
||||
if [ -f "${DANTE_CONF}" ]; then
|
||||
cp "$DANTE_CONF" "${DANTE_CONF}.bak"
|
||||
echo -e "\033[32mBackup existing configuration file\033[0m"
|
||||
fi
|
||||
|
||||
NEW_CONFIG=$(cat <<-EOM
|
||||
|
||||
logoutput: syslog stdout /data/logs/danted.log
|
||||
|
||||
internal: $INTERFACE port = 1080
|
||||
external: $INTERFACE
|
||||
|
||||
socksmethod: username
|
||||
user.privileged: root
|
||||
user.unprivileged: nobody
|
||||
user.libwrap: nobody
|
||||
|
||||
client pass {
|
||||
from: 0.0.0.0/0 to: 0.0.0.0/0
|
||||
log: error connect disconnect
|
||||
}
|
||||
|
||||
client block {
|
||||
from: 0.0.0.0/0 to: 0.0.0.0/0
|
||||
log: connect error
|
||||
}
|
||||
|
||||
socks pass {
|
||||
from: 0.0.0.0/0 to: 0.0.0.0/0
|
||||
log: error connect disconnect
|
||||
}
|
||||
|
||||
socks block {
|
||||
from: 0.0.0.0/0 to: 0.0.0.0/0
|
||||
log: connect error
|
||||
}
|
||||
|
||||
EOM
|
||||
)
|
||||
|
||||
# Write configuration file
|
||||
echo "$NEW_CONFIG" > "$DANTE_CONF"
|
||||
|
||||
# Create user for auth
|
||||
useradd -s /bin/false $DANTE_USER
|
||||
echo "$DANTE_USER:$DANTE_PASSWORD" | chpasswd
|
||||
|
||||
systemctl restart danted
|
||||
systemctl enable danted
|
||||
|
||||
trap - ERR
|
||||
echo -e "\033[32mDante SOCKS5 proxy has been installed and configured with authentication\033[0m"
|
||||
Loading…
Reference in New Issue
Block a user