Skip to content

Resources

Tools

CheatSheet

Commands

  • Squid
    • Setup
      apt install squid 
      systemctl status squid # Squid will automatically set up a background service and start after being installed.
    • Config
      • Transparent
        • Proxy
          cp /etc/squid/squid.conf /etc/squid/squid.conf.stock
          nano /etc/squid/squid.conf
          	http_port 3128 # Proxy Port
          	  acl lab_clients src 192.168.11.0/24 # My Clients Subnet 
          	  acl SSL_ports port 443 # HTTPS
          	  acl Safe_ports port 80 443 21 1025-65535 # Safe ports to connect 
          	  http_access deny !Safe_ports # Deny if not in SafePorts
          	  http_access deny CONNECT !SSL_ports # Deny the Connect if not 443
          	  http_access allow lab_clients # allow all my subnets clients 
          	  http_access deny all # Deny others 
          	  visible_hostname proxy.fady # Proxy Name 
          	  cache deny all # Don't cache 
          	  access_log /var/log/squid/access.log # Log file 
          	  
          squid -k parse && systemctl restart squid && ss -ltnp | grep squid
          • Username & Password
            apt-get install -y apache2-utils
            htpasswd -c -m /etc/squid/passwd fady
            chown proxy:proxy /etc/squid/passwd 
            chmod 640 /etc/squid/passwd
            nano /etc/squid/squid.conf
            	http_port 3128   
            	acl lab_clients src 192.168.11.0/24
            	acl SSL_ports port 443
            	acl Safe_ports port 80 443 21 1025-65535
            	
            	auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwd # use ncsa auth and passwd is ur db file 
            	auth_param basic children 5 # run 5 workers 
            	auth_param basic credentialsttl 2 hours # cache for 2h 
            	auth_param basic realm Proxy requires valid user # blok anonymous requests 
            	
            	acl authenticated proxy_auth REQUIRED # auth required 
            	
            	http_access deny !Safe_ports
            	http_access deny CONNECT !SSL_ports
            	http_access allow authenticated lab_clients # aloow lab_clients with auth only 
            	http_access deny all
            	cache deny all
            	access_log /var/log/squid/access.log
            	
            squid -k parse && systemctl restart squid
        • Client
          curl -x http://192.168.11.11:3128 http://192.168.22.10/
          curl -x http://192.168.11.11:3128 -k https://192.168.22.10/
          • Username & Password
            curl -x http://fady:[email protected]:3128 -k https://192.168.22.10/ # 200 
            curl -x http://192.168.11.11:3128 -k https://192.168.22.10/ # 407
  • 3Proxy
    • Socks
      • Setup
         apt update && apt install -y build-essential git
         git clone https://github.com/3proxy/3proxy.git
         make -f Makefile.Linux
         
         mkdir -p /opt/3proxy
         install -m 755 /root/3proxy/bin/3proxy /root/3proxy/bin/3proxy_crypt /opt/3proxy/ # copy the bin (not only copy it's chmod , copy , chown , strip ... )
         
         groupadd -r proxy3 # System Group 
         useradd -r -g proxy3 -d /var/lib/3proxy -s /usr/sbin/nologin proxy3 # system acc , add group , with home dir , with no login 
         mkdir -p /var/lib/3proxy /var/log/3proxy # one for state other for logs 
         chown proxy3:proxy3 /var/lib/3proxy /var/log/3proxy # change the owner 
         install -o root -g proxy3 -m 640 /dev/null /etc/3proxy.cfg # config file  
         nano /etc/3proxy.cfg
        	setgid proxy3 # Group ID 
        	setuid proxy3 # User ID
        	nserver 192.168.1.1 # My DNS
        	nscache 65536 # Caching 
        	auth iponly # auth with only whitelist IPs
        	allow * 192.168.11.10 # White listed IP
        	deny * # Deny other 
        	maxconn 100 # Max connectiosn per user 
        	proxy -p3129 -a # HTTP proxy -a anonymous mode [-a1 random client infos]
        	socks -p1080 # start socks proxy 
        	
        	
        nano /etc/systemd/system/3proxy.service # Create a servcie thx for deepseek 
        	[Unit]
        	Description=3proxy anonymous HTTP + SOCKS proxy
        	After=network.target
        	
        	
        	[Service]
        	Type=simple # the simplest supervision model. systemd watches that one PID.
        	User=proxy3 # user 
        	Group=proxy3 # group 
        	ExecStart=/opt/3proxy/3proxy /etc/3proxy.cfg # start command 
        	ExecReload=/bin/kill -SIGUSR1 $MAINPID # reload x= restart 
        	KillMode=process # kill me 
        	Restart=on-failure # restart on failure 
        	RestartSec=5 # time 
        	LimitNOFILE=1048576 # limite to 1024 files 
        	LimitNPROC=infinity
        	TasksMax=infinity
        	NoNewPrivileges=yes # don't assign new ones 
        	PrivateTmp=yes # write on tmp 
        	PrivateDevices=yes # run on like sandbox to not see other dirs , operations , ... 
        	ProtectSystem=strict
        	ProtectHome=yes # don't see any home dirs 
        	ProtectKernelTunables=yes
        	ProtectKernelModules=yes
        	ProtectControlGroups=yes  
        	RestrictAddressFamilies=AF_INET AF_INET6 # only use IPs 
        	RestrictNamespaces=yes
        	LockPersonality=yes
        	ReadWritePaths=/var/log/3proxy # only place to read write 
        	CapabilityBoundingSet=
        	AmbientCapabilities=
        	
        	[Install]
        	WantedBy=multi-user.target
         
        systemctl daemon-reload # Force the system to read new configuration file
        systemctl enable --now 3proxy # enable it 
        systemctl status 3proxy --no-pager
        ss -tulnp | grep -E '3129|1080' # worked 
        • Client
          curl -x http://192.168.11.11:3129 http://192.168.22.10/ # Http 
          curl --socks4 192.168.11.11:1080 http://192.168.22.10 # socks4
          curl --socks4a  192.168.11.11:1080 http://192.168.22.10/ # socks4a 
          curl --socks5 192.168.11.11:1080 http://192.168.22.10/ # socks5 
          curl --socks5-hostname 192.168.11.11:1080 http://192.168.22.10/ # socks5h 
          • Dns Leak
            tcpdump -i any -n 'udp port 53' # watch dns on client 
            curl --socks5  192.168.11.11:1080 https://fadymoheb.com/ # ask for domain in client tcpdump should fire up 
             
            curl --socks5-hostname  192.168.11.11:1080 https://fadymoheb.com/ # tcpdump shouldn't show any thing 
  • Ngnix
    • Reverse Proxy
      • Setup
        apt update && apt install -y nginx
        systemctl is-active nginx && ss -tulnp | grep ':80 ' # same as status but it's for scripts 
        curl -s http://192.168.11.11/ | head -4 # check from the client 
         
        rm -f /etc/nginx/sites-enabled/default # kill the deafult page 
         
        nano /etc/nginx/sites-available/lab-reverse.conf
        	server {
        	    listen 192.168.11.11:80;
        	    server_name _;
        	
        	    location / {
        	        proxy_pass http://192.168.22.10:8001;
        	    }
        	}
         
        ln -s /etc/nginx/sites-available/lab-reverse.conf /etc/nginx/sites-enabled/
        nginx -t 
        systemctl reload nginx
        ss -tulnp | grep ':80 '
        • Client
          curl -s http://192.168.11.11/ | head -20

Notes