Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.45 KB | None | 0 0
  1. #!/bin/bash
  2. # UsnekxPHC
  3. clear
  4. echo "                                                                 "
  5. echo "                                                                 "
  6. echo " _|    _|    _|_|_|  _|      _|  _|_|_|_|  _|    _|  _|      _|  "
  7. echo " _|    _|  _|        _|_|    _|  _|        _|  _|      _|  _|    "
  8. echo " _|    _|    _|_|    _|  _|  _|  _|_|_|    _|_|          _|      "
  9. echo " _|    _|        _|  _|    _|_|  _|        _|  _|      _|  _|    "
  10. echo "   _|_|    _|_|_|    _|      _|  _|_|_|_|  _|    _|  _|      _|  "
  11. echo "                                                                 "
  12. echo "                        AUTO SCRIPT                              "
  13. echo "                                                                 "
  14. echo " "
  15.  
  16. HOST=""
  17. SERVER_PASSWORD=""
  18. USER=""
  19. HUB=""
  20. SE_PASSWORD=""
  21.  
  22. HOST=${HOST}
  23. HUB=${HUB}
  24. USER_PASSWORD=${SERVER_PASSWORD}
  25. SE_PASSWORD=${SE_PASSWORD}
  26.  
  27. echo -n "Enter Server IP: "
  28. read HOST
  29. echo -n "Set Virtual Hub: "
  30. read HUB
  31. echo -n "Set ${HUB} hub username: "
  32. read USER
  33. read -s -p "Set ${HUB} hub password: " SERVER_PASSWORD
  34. echo ""
  35. read -s -p "Set SE Server password: " SE_PASSWORD
  36. echo ""
  37. echo " "
  38. echo "Now sit back and wait until the installation finished."
  39. echo " "
  40.  
  41. sudo apt-get -y update && sudo apt-get -y upgrade && apt-get install expect -y
  42. sudo apt-get install checkinstall build-essential -y
  43. wget http://www.softether-download.com/files/softether/v4.27-9666-beta-2018.04.21-tree/Linux/SoftEther_VPN_Server/64bit_-_Intel_x64_or_AMD64/softether-vpnserver-v4.27-9666-beta-2018.04.21-linux-x64-64bit.tar.gz
  44. tar -xzf softether-vpnserver-v4.27-9666-beta-2018.04.21-linux-x64-64bit.tar.gz
  45. rm -rf softether-vpnserver-v4.27-9666-beta-2018.04.21-linux-x64-64bit.tar.gz
  46. cd /root/vpnserver && expect -c 'spawn make; expect number:; send 1\r; expect number:; send 1\r; expect number:; send 1\r; interact'
  47. cd && mv vpnserver/ /usr/local && chmod 600 * /usr/local/vpnserver/ && chmod 700 /usr/local/vpnserver/vpncmd && chmod 700 /usr/local/vpnserver/vpnserver
  48. echo '#!/bin/sh
  49. # description: SoftEther VPN Server
  50. ### BEGIN INIT INFO
  51. # Provides:          vpnserver
  52. # Required-Start:    $local_fs $network
  53. # Required-Stop:     $local_fs
  54. # Default-Start:     2 3 4 5
  55. # Default-Stop:      0 1 6
  56. # Short-Description: softether vpnserver
  57. # Description:       softether vpnserver daemon
  58. ### END INIT INFO
  59. DAEMON=/usr/local/vpnserver/vpnserver
  60. LOCK=/var/lock/subsys/vpnserver
  61. test -x $DAEMON || exit 0
  62. case "$1" in
  63. start)
  64. $DAEMON start
  65. touch $LOCK
  66. ;;
  67. stop)
  68. $DAEMON stop
  69. rm $LOCK
  70. ;;
  71. restart)
  72. $DAEMON stop
  73. sleep 3
  74. $DAEMON start
  75. ;;
  76. *)
  77. echo "Usage: $0 {start|stop|restart}"
  78. exit 1
  79. esac
  80. exit 0' > /etc/init.d/vpnserver
  81. ###
  82. chmod 755 /etc/init.d/vpnserver && /etc/init.d/vpnserver start
  83. update-rc.d vpnserver defaults
  84. ###
  85. echo net.ipv4.ip_forward = 1 >> /etc/sysctl.conf
  86. sysctl -w net.ipv4.ip_forward=1
  87. sysctl --system
  88. echo "nameserver 8.8.8.8" > "/etc/resolv.conf"
  89. echo "nameserver 8.8.4.4" >> "/etc/resolv.conf"
  90.  
  91. ### SSH brute-force protection ###
  92. iptables -A INPUT -p tcp --dport ssh -m conntrack --ctstate NEW -m recent --set
  93. iptables -A INPUT -p tcp --dport ssh -m conntrack --ctstate NEW -m recent --update --seconds 60 --hitcount 10 -j DROP  
  94. ### Protection against port scanning ###
  95. iptables -N port-scanning
  96. iptables -A port-scanning -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s --limit-burst 2 -j RETURN
  97. iptables -A port-scanning -j DROP
  98.  
  99. HOST=${HOST}
  100. HUB_PASSWORD=${SE_PASSWORD}
  101. USER_PASSWORD=${SERVER_PASSWORD}
  102.  
  103. TARGET="/usr/local/"
  104.  
  105. sleep 2
  106. ${TARGET}vpnserver/vpncmd localhost /SERVER /CMD ServerPasswordSet ${SE_PASSWORD}
  107. ${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SE_PASSWORD} /CMD HubCreate ${HUB} /PASSWORD:${HUB_PASSWORD}
  108. ${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SE_PASSWORD} /HUB:${HUB} /CMD UserCreate ${USER} /GROUP:none /REALNAME:none /NOTE:none
  109. ${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SE_PASSWORD} /HUB:${HUB} /CMD UserPasswordSet ${USER} /PASSWORD:${USER_PASSWORD}
  110. ${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SE_PASSWORD} /CMD IPsecEnable /L2TP:yes /L2TPRAW:yes /ETHERIP:no /PSK:vpn /DEFAULTHUB:${HUB}
  111. ${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SE_PASSWORD} /CMD HubDelete DEFAULT
  112. ${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SE_PASSWORD} /HUB:${HUB} /CMD SecureNatEnable
  113. ${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SE_PASSWORD} /CMD VpnOverIcmpDnsEnable /ICMP:yes /DNS:yes
  114. ${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SE_PASSWORD} /CMD ListenerCreate 53
  115. ${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SE_PASSWORD} /CMD ListenerCreate 137
  116. ${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SE_PASSWORD} /CMD ListenerCreate 500
  117. ${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SE_PASSWORD} /CMD ListenerCreate 921
  118. ${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SE_PASSWORD} /CMD ListenerCreate 4500
  119. ${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SE_PASSWORD} /CMD ListenerCreate 4000
  120. ${TARGET}vpnserver/vpncmd localhost /SERVER /PASSWORD:${SE_PASSWORD} /CMD ListenerCreate 40000
  121. clear
  122. echo "Softether server configuration has been done!"
  123. echo " "
  124. echo "Host: ${HOST}"
  125. echo "Virtual Hub: ${HUB}"
  126. echo "Port: 443, 53, 137"
  127. echo "Username: ${USER}"
  128. echo "Password: ${SERVER_PASSWORD}"
  129. echo "Server Password: ${SE_PASSWORD}"
  130. echo " "
  131. echo "Join us in TD's Discord Server"
  132. echo "Invitation link: https://discord.gg/2BCNNYg"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement