Created
July 31, 2024 05:15
-
-
Save fdciabdul/4064088453327b7297744776f8390631 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Update system | |
echo "Updating system..." | |
sudo apt update && sudo apt upgrade -y | |
# Install Squid for HTTP/HTTPS proxy | |
echo "Installing Squid..." | |
sudo apt install squid -y | |
# Configure Squid | |
echo "Configuring Squid..." | |
sudo tee /etc/squid/squid.conf > /dev/null <<EOL | |
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network | |
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network | |
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network | |
acl SSL_ports port 443 | |
acl Safe_ports port 80 # http | |
acl Safe_ports port 21 # ftp | |
acl Safe_ports port 443 # https | |
acl Safe_ports port 70 # gopher | |
acl Safe_ports port 210 # wais | |
acl Safe_ports port 1025-65535 # unregistered ports | |
acl Safe_ports port 280 # http-mgmt | |
acl Safe_ports port 488 # gss-http | |
acl Safe_ports port 591 # filemaker | |
acl Safe_ports port 777 # multiling http | |
acl CONNECT method CONNECT | |
http_access allow localnet | |
http_access deny all | |
http_port 3128 | |
EOL | |
# Restart Squid | |
echo "Restarting Squid..." | |
sudo systemctl restart squid | |
# Install Dante for SOCKS5 proxy | |
echo "Installing Dante..." | |
sudo apt install dante-server -y | |
# Configure Dante | |
echo "Configuring Dante..." | |
sudo tee /etc/danted.conf > /dev/null <<EOL | |
logoutput: stderr | |
internal: eth0 port = 1080 | |
external: eth0 | |
method: none | |
client pass { | |
from: 0.0.0.0/0 to: 0.0.0.0/0 | |
} | |
pass { | |
from: 0.0.0.0/0 to: 0.0.0.0/0 | |
protocol: tcp udp | |
} | |
EOL | |
# Restart Dante | |
echo "Restarting Dante..." | |
sudo systemctl restart danted | |
# Test HTTP/HTTPS proxy | |
echo "Testing HTTP/HTTPS proxy..." | |
HTTP_TEST=$(curl -x http://localhost:3128 -s -o /dev/null -w "%{http_code}" http://example.com) | |
# Test SOCKS5 proxy | |
echo "Testing SOCKS5 proxy..." | |
SOCKS_TEST=$(curl -x socks5h://localhost:1080 -s -o /dev/null -w "%{http_code}" http://example.com) | |
# Print test results | |
if [ "$HTTP_TEST" -eq 200 ]; then | |
echo "HTTP/HTTPS proxy is working." | |
else | |
echo "HTTP/HTTPS proxy is not working." | |
fi | |
if [ "$SOCKS_TEST" -eq 200 ]; then | |
echo "SOCKS5 proxy is working." | |
else | |
echo "SOCKS5 proxy is not working." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment