sock5deb.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #!/bin/bash
  2. # Simple Dante Socks5 Script for Debian
  3. # Script by Bonveio
  4. # https://github.com/Bonveio/BonvScripts
  5. #
  6. function YourBanner(){
  7. # Edit nyo to
  8. echo -e " Welcome to my Script"
  9. echo -e " SOCKS5 Server Installer for Debian"
  10. echo -e " Script by Bonveio"
  11. echo -e " This script is open for Remodification and Redistribution"
  12. echo -e ""
  13. }
  14. source /etc/os-release
  15. if [[ "$ID" != 'debian' ]]; then
  16. YourBanner
  17. echo -e "[\e[1;31mError\e[0m] This script is for Debian Machine only, exting..."
  18. exit 1
  19. fi
  20. if [[ $EUID -ne 0 ]];then
  21. YourBanner
  22. echo -e "[\e[1;31mError\e[0m] This script must be run as root, exiting..."
  23. exit 1
  24. fi
  25. function Installation(){
  26. cd /root
  27. export DEBIAN_FRONTEND=noninteractive
  28. apt-get update
  29. apt-get upgrade -y
  30. apt-get install wget nano dante-server netcat -y &> /dev/null | echo '[*] Installing SOCKS5 Server...'
  31. cat <<'EOF'> /etc/danted.conf
  32. logoutput: /var/log/socks.log
  33. internal: 0.0.0.0 port = SOCKSPORT
  34. external: SOCKSINET
  35. socksmethod: SOCKSAUTH
  36. user.privileged: root
  37. user.notprivileged: nobody
  38. client pass {
  39. from: 0.0.0.0/0 to: 0.0.0.0/0
  40. log: error connect disconnect
  41. }
  42. client block {
  43. from: 0.0.0.0/0 to: 0.0.0.0/0
  44. log: connect error
  45. }
  46. socks pass {
  47. from: 0.0.0.0/0 to: 0.0.0.0/0
  48. log: error connect disconnect
  49. }
  50. socks block {
  51. from: 0.0.0.0/0 to: 0.0.0.0/0
  52. log: connect error
  53. }
  54. EOF
  55. sed -i "s/SOCKSINET/$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)' | head -1)/g" /etc/danted.conf
  56. sed -i "s/SOCKSPORT/$SOCKSPORT/g" /etc/danted.conf
  57. sed -i "s/SOCKSAUTH/$SOCKSAUTH/g" /etc/danted.conf
  58. sed -i '/\/bin\/false/d' /etc/shells
  59. echo '/bin/false' >> /etc/shells
  60. systemctl restart danted.service
  61. systemctl enable danted.service
  62. }
  63. function Uninstallation(){
  64. echo -e '[*] Uninstalling SOCKS5 Server'
  65. apt-get remove --purge dante-server &> /dev/null
  66. rm -rf /etc/danted.conf
  67. echo -e '[√] SOCKS5 Server successfully uninstalled and removed.'
  68. }
  69. function SuccessMessage(){
  70. clear
  71. echo -e ""
  72. YourBanner
  73. echo -e ""
  74. echo -e "== Success installed SOCKS5 Server into your VPS =="
  75. echo -e ""
  76. echo -e " Your SOCKS5 Proxy IP Address: $(wget -4qO- http://ipinfo.io/ip)"
  77. echo -e " Your SOCKS5 Proxy Port: $SOCKSPORT"
  78. if [ "$SOCKSAUTH" == 'username' ]; then
  79. echo -e " Your SOCKS5 Authentication:"
  80. echo -e " SOCKS5 Username: $socksUser"
  81. echo -e " SOCKS5 Password: $socksPass"
  82. fi
  83. echo -e " Install.txt can be found at /root/socks5.txt"
  84. cat <<EOF> ~/socks5.txt
  85. ==Your SOCKS5 Proxy Information==
  86. IP Address: $(wget -4qO- http://ipinfo.io/ip)
  87. Port: $SOCKSPORT
  88. EOF
  89. if [ "$SOCKSAUTH" == 'username' ]; then
  90. cat <<EOF>> ~/socks5.txt
  91. Username: $socksUser
  92. Password: $socksPass
  93. EOF
  94. fi
  95. cat ~/socks5.txt | nc termbin.com 9999 > /tmp/walwal.txt
  96. echo -e " Your SOCKS5 Information Online: $(tr -d '\0' </tmp/walwal.txt)"
  97. echo -e ""
  98. }
  99. clear
  100. YourBanner
  101. echo -e " To exit the script, kindly Press \e[1;32mCRTL\e[0m key together with \e[1;32mC\e[0m"
  102. echo -e ""
  103. echo -e " Choose SOCKS5 Proxy Type"
  104. echo -e " [1] Public Proxy (Can be Accessible by Anyone in the Internet)"
  105. echo -e " [2] Private Proxy (Can be Accessable using username and password Authentication"
  106. echo -e " [3] Uninstall SOCKS5 Proxy Server"
  107. until [[ "$opts" =~ ^[1-3]$ ]]; do
  108. read -rp " Choose from [1-3]: " -e opts
  109. done
  110. case $opts in
  111. 1)
  112. until [[ "$SOCKSPORT" =~ ^[0-9]+$ ]] && [ "$SOCKSPORT" -ge 1 ] && [ "$SOCKSPORT" -le 65535 ]; do
  113. read -rp " Choose your SOCKS5 Port [1-65535]: " -i 2408 -e SOCKSPORT
  114. done
  115. SOCKSAUTH='none'
  116. Installation
  117. ;;
  118. 2)
  119. until [[ "$SOCKSPORT" =~ ^[0-9]+$ ]] && [ "$SOCKSPORT" -ge 1 ] && [ "$SOCKSPORT" -le 65535 ]; do
  120. read -rp " Choose your SOCKS5 Port [1-65535]: " -i 2408 -e SOCKSPORT
  121. done
  122. SOCKSAUTH='username'
  123. until [[ "$socksUser" =~ ^[a-zA-Z0-9_]+$ ]]; do
  124. read -rp " Your SOCKS5 Username: " -e socksUser
  125. done
  126. until [[ "$socksPass" =~ ^[a-zA-Z0-9_]+$ ]]; do
  127. read -rp " Your SOCKS5 Password: " -e socksPass
  128. done
  129. userdel -r -f $socksUser &> /dev/null
  130. useradd -m -s /bin/false $socksUser
  131. echo -e "$socksPass\n$socksPass\n" | passwd $socksUser &> /dev/null
  132. Installation
  133. ;;
  134. 3)
  135. Uninstallation
  136. exit 1
  137. ;;
  138. esac
  139. SuccessMessage
  140. exit 1