Advertisement
takasi

Takashivpn pro

Mar 14th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.93 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #Database Details
  4. HOST='31.22.4.46';
  5. USER='takashiv';
  6. PASS='917!dE6Y]wvXUf';
  7. DBNAME='takashiv_devtakashi';
  8.  
  9.  
  10. #Colors
  11. RED='\033[01;31m';
  12. RESET='\033[0m';
  13. GREEN='\033[01;32m';
  14. WHITE='\033[01;37m';
  15. YELLOW='\033[00;33m';
  16. timedatectl set-timezone Asia/Manila
  17.  
  18. install_packages () {
  19. echo -e "$GREEN Installing Update....$RESET"
  20. apt-get update &> /dev/null
  21. sleep 3
  22. echo -e "$GREEN Installing Packages...$RESET"
  23. apt-get install mysql-client openvpn unzip build-essential curl privoxy apache2 stunnel4 -y &> /dev/null
  24. apt-get install php php-mysqli php-mysql php-gd php-mbstring -y &> /dev/null
  25. apt-get install php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap -y &> /dev/null
  26. }
  27.  
  28. create_directory (){
  29. mkdir /etc/openvpn/script
  30. mkdir /var/www/html/stat
  31. touch /var/www/html/stat/status.txt
  32. }
  33.  
  34. create_files () {
  35. cat <<\EOM >/etc/openvpn/server.conf
  36. port 1194
  37. sndbuf 0
  38. rcvbuf 0
  39. push "sndbuf 393216"
  40. push "rcvbuf 393216"
  41. reneg-sec 432000
  42. push "persist-key"
  43. push "persist-tun"
  44. proto tcp
  45. dev tun
  46. ca ca.crt
  47. cert server.crt
  48. key server.key
  49. dh dh2048.pem
  50. server 10.8.0.0 255.255.255.0
  51. user nobody
  52. username-as-common-name
  53. client-cert-not-required
  54. auth-user-pass-verify /etc/openvpn/script/authvpn.sh via-env
  55. push "redirect-gateway def1 bypass-dhcp"
  56. push "dhcp-option DNS 8.8.4.4"
  57. push "dhcp-option DNS 8.8.8.8"
  58. client-to-client
  59. keepalive 10 120
  60. comp-lzo
  61. script-security 3
  62. client-connect /etc/openvpn/script/connect.sh
  63. client-disconnect /etc/openvpn/script/disconnect.sh
  64. status /var/www/html/stat/status.txt
  65. persist-key
  66. persist-tun
  67. verb 3
  68. EOM
  69.  
  70. cat <<\EOM >/etc/openvpn/server2.conf
  71. port 110
  72. sndbuf 0
  73. rcvbuf 0
  74. push "sndbuf 393216"
  75. push "rcvbuf 393216"
  76. reneg-sec 432000
  77. push "persist-key"
  78. push "persist-tun"
  79. proto tcp
  80. dev tun
  81. ca ca.crt
  82. cert server.crt
  83. key server.key
  84. dh dh2048.pem
  85. server 10.9.0.0 255.255.255.0
  86. user nobody
  87. username-as-common-name
  88. client-cert-not-required
  89. auth-user-pass-verify /etc/openvpn/script/authvpn.sh via-env
  90. push "redirect-gateway def1 bypass-dhcp"
  91. push "dhcp-option DNS 8.8.4.4"
  92. push "dhcp-option DNS 8.8.8.8"
  93. client-to-client
  94. keepalive 10 120
  95. comp-lzo
  96. script-security 3
  97. #client-connect /etc/openvpn/script/connect.sh
  98. #client-disconnect /etc/openvpn/script/disconnect.sh
  99. #status /var/www/html/stat/status.txt
  100. persist-key
  101. persist-tun
  102. verb 3
  103. EOM
  104.  
  105. cat <<\EOM >/etc/openvpn/ca.crt
  106. -----BEGIN CERTIFICATE-----
  107. MIIE5TCCA82gAwIBAgIJAP0GLynOqm38MA0GCSqGSIb3DQEBCwUAMIGnMQswCQYD
  108. VQQGEwJQSDERMA8GA1UECBMIQmF0YW5nYXMxETAPBgNVBAcTCEJhdGFuZ2FzMRIw
  109. EAYDVQQKEwlTYXZhZ2VWUE4xEjAQBgNVBAsTCVNhdmFnZVZQTjEWMBQGA1UEAxMN
  110. c2F2YWdlLXZwbi50azEPMA0GA1UEKRMGc2VydmVyMSEwHwYJKoZIhvcNAQkBFhJz
  111. YXZhZ2U5OUBnbWFpbC5jb20wHhcNMTgwNDIwMDQ1MTMyWhcNMjgwNDE3MDQ1MTMy
  112. WjCBpzELMAkGA1UEBhMCUEgxETAPBgNVBAgTCEJhdGFuZ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qd681eTxUYEACFVZpY3eK3vJYyGtblYHIwfCPTWL6yXQxbMud4C1ISIwel
  129. UFv/qnz/GZmAkN0qB5tNSvB48123F1AWfhhXWG+o+xWxUi+eqsXdUVZ1tpP5WQaH
  130. EUtU6SZ1AXO6l6b/RTXymRrEInCPfbGsEnucnG7naOpBaNRXmpiMppOwzR42sd6I
  131. QOvXkj2e8v9tQ05cffjexks+rfb/d80+1nfkv0HCLWxcdU8yOUqVryhdZLB6Rhw/
  132. crldSHwrGWN+qptpFD160iJLIv3p5vWwUAgRoRai9iHuJMOHn4aDX0N8tbCfS+R5
  133. qn8GWiHaXEu8
  134. -----END CERTIFICATE-----
  135. EOM
  136.  
  137. cat <<\EOM >/etc/openvpn/dh2048.pem
  138. -----BEGIN DH PARAMETERS-----
  139. MIIBCAKCAQEA0ICVDq0dT7Px8IEaEU0EBWEmOVW2EWUOi4pma37x+auX5h+27OjT
  140. C3qvt4fNOXuPRf0CMDIpR9yOjraEqRNv2sPK8MGBRrK2a/DaBvETxWJyQS1g3Vs3
  141. sUBsFtRW/XTF+ziEbTZX4V9jyIWh6m05XkjfNv20szMG91QMotOKup3qYTM5xmgI
  142. HOukzE+/oRh6wxOAp5/fo2yAcpNKTt0QVcwJYSGFyAqV9QfyLHTCXPo0RFxMnifg
  143. fsqRRlPApW0XeE2VPdHHETsEGdGPT5w67X6Y/o5RHuyaDgJa4HqHfjKauCI8RFji
  144. x2VycpPPw21XKLXkwnuC0TVprwWcqOMFcwIBAg==
  145. -----END DH PARAMETERS-----
  146. EOM
  147.  
  148. cat <<\EOM >/etc/openvpn/server.crt
  149. Certificate:
  150. Data:
  151. Version: 3 (0x2)
  152. Serial Number: 1 (0x1)
  153. Signature Algorithm: sha256WithRSAEncryption
  154. Issuer: C=PH, ST=Mandaue Cebu, L=Mandaue Cebu, O=SavageVPN, OU=SavageVPN, CN=savage-vpn.tk/name=server/emailAddress=savage99@gmail.com
  155. Validity
  156. Not Before: Apr 20 04:53:44 2018 GMT
  157. Not After : Apr 17 04:53:44 2028 GMT
  158. Subject: C=PH, ST=Mandaue Cebu, L=Mandaue Cebu, O=SavageVPN, OU=SavageVPN, CN=savage-vpn.tk/name=server/emailAddress=savage99@gmail.com
  159. Subject Public Key Info:
  160. Public Key Algorithm: rsaEncryption
  161. Public-Key: (2048 bit)
  162. Modulus:
  163. 00:b6:a9:b9:e6:f9:19:85:24:ba:6b:dc:7e:b2:d4:
  164. 2c:01:46:26:fa:3e:41:ee:0c:b9:18:27:99:34:27:
  165. 61:eb:4f:cb:83:c0:0b:43:27:05:53:a5:b9:3c:5a:
  166. 8a:c5:7e:2e:72:1d:f9:83:97:44:b5:00:21:36:d7:
  167. 51:27:be:b7:d0:0c:2c:09:38:52:a0:e0:89:6f:cb:
  168. 0e:11:37:d9:7c:43:fe:b1:25:c1:2f:78:25:c1:a0:
  169. 15:c9:1d:35:b6:1d:33:e9:e6:75:83:4b:30:54:a4:
  170. 4e:f5:01:ae:fc:0c:37:c0:c7:07:43:4c:04:50:80:
  171. c8:13:9a:27:4c:d1:6d:c6:87:e4:38:38:67:c1:87:
  172. e4:3a:e3:79:11:c1:23:d4:2c:72:b7:0c:60:72:c7:
  173. 29:7e:36:17:09:2d:ca:9d:b3:49:2f:2f:56:85:a9:
  174. 24:34:5a:e7:eb:4b:ee:cf:43:bb:20:ef:dc:26:95:
  175. e6:dd:3a:8a:61:d8:33:b0:28:0f:fb:ce:d9:db:dd:
  176. ca:2f:85:f0:ec:66:58:67:77:8e:e0:a0:21:f8:b5:
  177. fe:e3:02:7e:3c:9c:5c:91:65:1a:bc:3c:6f:ce:3d:
  178. b8:38:8e:b0:d4:5b:ef:a5:e1:b3:0c:f4:bf:49:95:
  179. 7b:1f:9f:41:9f:ce:fa:ae:e1:e7:68:f4:f9:a6:99:
  180. 74:95
  181. Exponent: 65537 (0x10001)
  182. X509v3 extensions:
  183. X509v3 Basic Constraints:
  184. CA:FALSE
  185. Netscape Cert Type:
  186. SSL Server
  187. Netscape Comment:
  188. Easy-RSA Generated Server Certificate
  189. X509v3 Subject Key Identifier:
  190. 0C:4B:B3:78:75:C7:5E:C8:16:D2:A7:BC:8E:15:3F:33:E3:58:19:04
  191. X509v3 Authority Key Identifier:
  192. keyid:30:B7:64:91:7B:B4:F6:D0:F5:25:03:32:6E:8F:D2:1C:57:9A:F3:48
  193. DirName:/C=PH/ST=Batangas/L=Batangas/O=SavageVPN/OU=SavageVPN/CN=savage-vpn.tk/name=server/emailAddress=savage99@gmail.com
  194. serial:FD:06:2F:29:CE:AA:6D:FC
  195.  
  196. X509v3 Extended Key Usage:
  197. TLS Web Server Authentication
  198. X509v3 Key Usage:
  199. Digital Signature, Key Encipherment
  200. X509v3 Subject Alternative Name:
  201. DNS:server
  202. Signature Algorithm: sha256WithRSAEncryption
  203. 95:13:80:8a:95:42:9e:16:b6:58:5f:4a:d2:74:61:fb:25:04:
  204. 3c:77:fa:09:41:05:e3:9b:df:93:4e:65:8e:b8:05:87:35:c0:
  205. 9a:eb:62:fa:16:0d:15:28:79:b7:7f:8c:55:72:7a:31:16:3f:
  206. ff:ba:29:70:0c:96:78:6e:1e:a9:ff:42:d7:f2:53:43:e6:f3:
  207. a4:3a:02:7b:85:18:18:bc:b6:56:47:3b:be:ae:6f:1c:93:8b:
  208. 13:55:0d:b1:51:30:c2:f4:03:c9:a9:cf:bb:ad:60:70:ec:32:
  209. 1e:e5:74:d5:4d:2b:5e:02:73:28:b0:84:28:f4:6c:93:45:a1:
  210. f8:3c:58:91:38:21:7b:b2:8f:fe:26:4c:18:72:a3:13:79:46:
  211. b8:43:8c:cc:5c:03:7c:20:8a:51:25:8b:d0:80:a8:ae:33:5c:
  212. 19:20:f6:a9:02:39:47:42:1d:37:c6:ec:9f:6e:80:5b:61:0b:
  213. 53:bf:26:4b:6d:b5:a6:98:21:e0:ad:42:3a:7d:3f:c9:00:a3:
  214. 61:4c:76:e0:45:36:0b:7e:71:38:37:4f:73:a9:6f:bf:7a:77:
  215. 04:8d:27:cb:e3:d4:11:f4:c3:c5:85:c2:1d:8a:9f:3b:da:43:
  216. 97:8d:f3:3e:30:51:b4:ad:2b:65:04:58:f3:95:7f:23:b2:3a:
  217. f8:bd:7c:f8
  218. -----BEGIN CERTIFICATE-----
  219. MIIFWDCCBECgAwIBAgIBATANBgkqhkiG9w0BAQsFADCBpzELMAkGA1UEBhMCUEgx
  220. ETAPBgNVBAgTCEJhdGFuZ2FzMREwDwYDVQQHEwhCYXRhbmdhczESMBAGA1UEChMJ
  221. U2F2YWdlVlBOMRIwEAYDVQQLEwlTYXZhZ2VWUE4xFjAUBgNVBAMTDXNhdmFnZS12
  222. cG4udGsxDzANBgNVBCkTBnNlcnZlcjEhMB8GCSqGSIb3DQEJARYSc2F2YWdlOTlA
  223. Z21haWwuY29tMB4XDTE4MDQyMDA0NTM0NFoXDTI4MDQxNzA0NTM0NFowgacxCzAJ
  224. BgNVBAYTAlBIMREwDwYDVQQIEwhCYXRhbmdhczERMA8GA1UEBxMIQmF0YW5nYXMx
  225. EjAQBgNVBAoTCVNhdmFnZVZQTjESMBAGA1UECxMJU2F2YWdlVlBOMRYwFAYDVQQD
  226. Ew1zYXZhZ2UtdnBuLnRrMQ8wDQYDVQQpEwZzZXJ2ZXIxITAfBgkqhkiG9w0BCQEW
  227. EnNhdmFnZTk5QGdtYWlsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  228. ggEBALapueb5GYUkumvcfrLULAFGJvo+Qe4MuRgnmTQnYetPy4PAC0MnBVOluTxa
  229. isV+LnId+YOXRLUAITbXUSe+t9AMLAk4UqDgiW/LDhE32XxD/rElwS94JcGgFckd
  230. NbYdM+nmdYNLMFSkTvUBrvwMN8DHB0NMBFCAyBOaJ0zRbcaH5Dg4Z8GH5DrjeRHB
  231. I9QscrcMYHLHKX42Fwktyp2zSS8vVoWpJDRa5+tL7s9DuyDv3CaV5t06imHYM7Ao
  232. D/vO2dvdyi+F8OxmWGd3juCgIfi1/uMCfjycXJFlGrw8b849uDiOsNRb76Xhswz0
  233. v0mVex+fQZ/O+q7h52j0+aaZdJUCAwEAAaOCAYswggGHMAkGA1UdEwQCMAAwEQYJ
  234. YIZIAYb4QgEBBAQDAgZAMDQGCWCGSAGG+EIBDQQnFiVFYXN5LVJTQSBHZW5lcmF0
  235. ZWQgU2VydmVyIENlcnRpZmljYXRlMB0GA1UdDgQWBBQMS7N4dcdeyBbSp7yOFT8z
  236. 41gZBDCB3AYDVR0jBIHUMIHRgBQwt2SRe7T20PUlAzJuj9IcV5rzSKGBraSBqjCB
  237. pzELMAkGA1UEBhMCUEgxETAPBgNVBAgTCEJhdGFuZ2FzMREwDwYDVQQHEwhCYXRh
  238. bmdhczESMBAGA1UEChMJU2F2YWdlVlBOMRIwEAYDVQQLEwlTYXZhZ2VWUE4xFjAU
  239. BgNVBAMTDXNhdmFnZS12cG4udGsxDzANBgNVBCkTBnNlcnZlcjEhMB8GCSqGSIb3
  240. DQEJARYSc2F2YWdlOTlAZ21haWwuY29tggkA/QYvKc6qbfwwEwYDVR0lBAwwCgYI
  241. KwYBBQUHAwEwCwYDVR0PBAQDAgWgMBEGA1UdEQQKMAiCBnNlcnZlcjANBgkqhkiG
  242. 9w0BAQsFAAOCAQEAlROAipVCnha2WF9K0nRh+yUEPHf6CUEF45vfk05ljrgFhzXA
  243. muti+hYNFSh5t3+MVXJ6MRY//7opcAyWeG4eqf9C1/JTQ+bzpDoCe4UYGLy2Vkc7
  244. vq5vHJOLE1UNsVEwwvQDyanPu61gcOwyHuV01U0rXgJzKLCEKPRsk0Wh+DxYkTgh
  245. e7KP/iZMGHKjE3lGuEOMzFwDfCCKUSWL0ICorjNcGSD2qQI5R0IdN8bsn26AW2EL
  246. U78mS221ppgh4K1COn0/yQCjYUx24EU2C35xODdPc6lvv3p3BI0ny+PUEfTDxYXC
  247. HYqfO9pDl43zPjBRtK0rZQRY85V/I7I6+L18+A==
  248. -----END CERTIFICATE-----
  249. EOM
  250.  
  251. cat <<\EOM >/etc/openvpn/server.key
  252. -----BEGIN PRIVATE KEY-----
  253. MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC2qbnm+RmFJLpr
  254. 3H6y1CwBRib6PkHuDLkYJ5k0J2HrT8uDwAtDJwVTpbk8WorFfi5yHfmDl0S1ACE2
  255. 11EnvrfQDCwJOFKg4Ilvyw4RN9l8Q/6xJcEveCXBoBXJHTW2HTPp5nWDSzBUpE71
  256. Aa78DDfAxwdDTARQgMgTmidM0W3Gh+Q4OGfBh+Q643kRwSPULHK3DGByxyl+NhcJ
  257. Lcqds0kvL1aFqSQ0WufrS+7PQ7sg79wmlebdOoph2DOwKA/7ztnb3covhfDsZlhn
  258. d47goCH4tf7jAn48nFyRZRq8PG/OPbg4jrDUW++l4bMM9L9JlXsfn0Gfzvqu4edo
  259. 9PmmmXSVAgMBAAECggEAOwhHKDpA4SKpjMpJuAmR3yeI2T7dl81M1F2XyZ8gqiez
  260. ofSiryUhN5NLdhHc306UPBUr2jc84TIVid+0PqAIT5hfcutc6NkoEZUSCsZ95wci
  261. fKWy9WBi81yFLeXewehWKrVsLO5TxEcFrXDJ2HMqYYbw9fLPQiUchBlBsjXMwGgG
  262. W8R2WlQaIh0siJzg+FjwOPEbZA7jAJfyGt80HDWVOfsHxsSX80m8rq2nMppXsngF
  263. hhosj/f/WOPJLiA+/Odkv1ZXS1rqnr5GuwdzrEnibqXOx9LCuxp9MZ8t6qWDvgUf
  264. dy1AB2DKRi9s4NCJHPpITXek4ELawLmGxp7KEzQ/0QKBgQDoU16ZGTCVCT/kQlRz
  265. DRZ2fFXNEvEohCTxYJ72iT6MGxZw+2fuZG6VL9fAgUVLleKKUCFUzM3GPQWEQ1ry
  266. VKQjIqQZjyR+rzdqbHOcG4qYz93enH0FIB9cW/FiU3m5EAzU+TkagZCFq254Kb7i
  267. IQzrWTn24jFX1fQkgcNoXbNUMwKBgQDJRtEs/4e/enVs/6iGjjTGltjyXPS3QM/k
  268. ylZGL+Wc1gQWAsfTO6tYMMPVupyyl2JQjhUydIu3g7D2R4IRKlpprEd8S0MoJou9
  269. Lp/JudlDDJs9Q6Z2q99JpbXdhJ2aOTmSgOKHnkFQRRP/LOxaNwuE/xuhYWubvtFW
  270. y9u+B8uMFwKBgQCJuZqTweYWA+S3aUbs6W5OkUjACKGj9ip8WV4DIrtMjWZRVgh3
  271. v1v63uDVAw1UUKd6fSQ1RDAce+JAVTmd/OVM2uVTLZNh8nc0hNRIT99q1Zdet4A5
  272. wKA2vV6sfnXjaotg2dmrR/Gn/EfBvmWlYhhpkHyXSeIcgv53geGYhiugFwKBgQC3
  273. pRmtyOh+2KjTbuDBBHc6yt/fItlVaplE0yismX8S/mJ0As13+fV4XeYQ2Feoy180
  274. yK6mfpgMNOf9jXkrWE1uJXaD/dekhqbxUd0RHbUR7CqoV1VG6cKtW7j4CMwTryrM
  275. dTQ7MTW+m4iHRuHP3nFwQ6NeN5kLXat7Wj2AwXQCuQKBgESdvXETE6Oy3GVeO1zd
  276. tDlYxpA620daYaNo9MDpV49m89Lt8Maou080+gEJDrqqhyiaEQStrvz31mXIA+w7
  277. YTX1gKAF4qCXy3IKLqN3umdpEYkV2MVEfXlUE6aZZMogta9F5cne3CNDyHzq/RvS
  278. l9rNm+ntgV3+QioNbRWhG9fb
  279. -----END PRIVATE KEY-----
  280. EOM
  281.  
  282. cat <<\EOM >/etc/openvpn/script/config.sh
  283. #!/bin/bash
  284. HOST='DBHOST'
  285. USER='DBUSER'
  286. PASS='DBPASS'
  287. DB='DBNAME'
  288. EOM
  289.  
  290. cat <<\EOM >/etc/openvpn/script/connect.sh
  291. #!/bin/bash
  292. . /etc/openvpn/script/config.sh
  293. ##tm="$(date +%s)"
  294. ##dt="$(date +'%Y-%m-%d %H:%M:%S')"
  295. ##timestamp="$(date +'%FT%TZ')"
  296. ##set status online to user connected
  297. mysql -u $USER -p$PASS -D $DB -h $HOST -e "UPDATE users SET is_active=1 WHERE user_name='$common_name' "
  298. EOM
  299.  
  300. cat <<\EOM >/etc/openvpn/script/disconnect.sh
  301. #!/bin/bash
  302. . /etc/openvpn/script/config.sh
  303. tm="$(date +%s)"
  304. dt="$(date +'%Y-%m-%d %H:%M:%S')"
  305. timestamp="$(date +'%FT%TZ')"
  306.  
  307. ##mysql -u $USER -p$PASS -D $DB -h $HOST -sN -e "UPDATE bandwidth_logs SET bytes_received='$bytes_received',bytes_sent='$bytes_sent',time_out='$dt', status='offline' WHERE username='$common_name' AND status='online' AND category='vip' "
  308.  
  309. mysql -u $USER -p$PASS -D $DB -h $HOST -sN -e "UPDATE users SET is_active=0 WHERE user_name='$common_name' "
  310.  
  311. EOM
  312.  
  313. cat <<EOF >/etc/privoxy/config
  314. user-manual /usr/share/doc/privoxy/user-manual
  315. confdir /etc/privoxy
  316. logdir /var/log/privoxy
  317. filterfile default.filter
  318. logfile logfile
  319. listen-address 0.0.0.0:8080
  320. toggle 1
  321. enable-remote-toggle 0
  322. enable-remote-http-toggle 0
  323. enable-edit-actions 0
  324. enforce-blocks 0
  325. buffer-limit 4096
  326. enable-proxy-authentication-forwarding 1
  327. forwarded-connect-retries 1
  328. accept-intercepted-requests 1
  329. allow-cgi-request-crunching 1
  330. split-large-forms 0
  331. keep-alive-timeout 5
  332. tolerate-pipelining 1
  333. socket-timeout 300
  334. permit-access 0.0.0.0/0 `curl ipecho.net/plain`
  335. EOF
  336.  
  337. cat <<EOF >/etc/stunnel/stunnel.pem
  338. -----BEGIN RSA PRIVATE KEY-----
  339. MIIEpQIBAAKCAQEAyN+jQb8vvS1jwbQSXAP9H0alRxuXuijhIp3u1gePGBsGLGg8
  340. CWQrdhbB40W7Ov2xzg4KyiRwLgcfnOP2tHvtsN7BzC8DWrqqZsNyENDyIs3sX5oc
  341. +JGLQZJiv2QSAP3N/4/UAAswUnGRW1TzQFXISSVeiScBsB96LoVLiPdA1e4Hhjkb
  342. vggLOHHTcXqc1BBzIt9eg672O+yiILsOFuYPGh3TBwVZ0DvKYZocEsJ/RExOuAID
  343. x0+THlpyO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zuWEus8tIjQxW2
  359. YaU30mGp9952gyoc/1ZwWSOgRp+ofQRpm8XWqu6iWn2xU4mA+Q19QVbcugOteC49
  360. Kxy5QSYrcclK5nNoiVnz5KRkBVyfGUfPbQneMhF1b6NxgDy3pxst+/0DsNVbgUC5
  361. niou9T0CgYEAkTXYooaf7JTAMlu/wLunkT0ZWKL/bU4ZgOFVFnF2gdfWJnHTMSu5
  362. PtxyjisZJNbON6xW0pIjcTuUQCIpL0LoZ7qd5zi5QqISb+eKzK8ENMxgnV7MEx78
  363. lufFKJYrjhC8j9pwY5pAR5uw2HKMS34IqLXct6NypoEYsJ48YDfA0Qw=
  364. -----END RSA PRIVATE KEY-----
  365. -----BEGIN CERTIFICATE-----
  366. MIIEATCCAumgAwIBAgIJAPDuiksIWVs2MA0GCSqGSIb3DQEBCwUAMIGWMQswCQYD
  367. VQQGEwJQSDESMBAGA1UECAwJU1RST05HVlBOMRIwEAYDVQQHDAlTVFJPTkdWUE4x
  368. EjAQBgNVBAoMCVNUUk9OR1ZQTjESMBAGA1UECwwJU1RST05HVlBOMRIwEAYDVQQD
  369. DAlTVFJPTkdWUE4xIzAhBgkqhkiG9w0BCQEWFHN0cm9uZy12cG5AZ21haWwuY29t
  370. MB4XDTE4MDcwMzA1MTM0MVoXDTIxMDcwMjA1MTM0MVowgZYxCzAJBgNVBAYTAlBI
  371. MRIwEAYDVQQIDAlTVFJPTkdWUE4xEjAQBgNVBAcMCVNUUk9OR1ZQTjESMBAGA1UE
  372. CgwJU1RST05HVlBOMRIwEAYDVQQLDAlTVFJPTkdWUE4xEjAQBgNVBAMMCVNUUk9O
  373. R1ZQTjEjMCEGCSqGSIb3DQEJARYUc3Ryb25nLXZwbkBnbWFpbC5jb20wggEiMA0G
  374. CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDI36NBvy+9LWPBtBJcA/0fRqVHG5e6
  375. KOEine7WB48YGwYsaDwJZCt2FsHjRbs6/bHODgrKJHAuBx+c4/a0e+2w3sHMLwNa
  376. uqpmw3IQ0PIizexfmhz4kYtBkmK/ZBIA/c3/j9QACzBScZFbVPNAVchJJV6JJwGw
  377. H3ouhUuI90DV7geGORu+CAs4cdNxepzUEHMi316DrvY77KIguw4W5g8aHdMHBVnQ
  378. O8phmhwSwn9ETE64AgPHT5MeWnI7c9mEijcQ3kFUKYFyxRugHIf38uyH7Xm0mqm8
  379. zy6IH2mPGVZSJE2IeOYnn6k5ZfgWkaWCslRhJKxRR11eY9VYCPUF5DYbAgMBAAGj
  380. UDBOMB0GA1UdDgQWBBTxI2YSnxnuDpwgxKOUgglmgiH/vDAfBgNVHSMEGDAWgBTx
  381. I2YSnxnuDpwgxKOUgglmgiH/vDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA
  382. A4IBAQC30dcIPWlFfBEK/vNzG1Dx+BWkHCfd2GfmVc+VYSpmiTox13jKBOyEdQs4
  383. xxB7HiESKkpAjQ0YC3mjE6F53NjK0VqdfzXhopg9i/pQJiaX0KTTcWIelsJNg2aM
  384. s8GZ0nWSytcAqAV6oCnn+eOT/IqnO4ihgmaVIyhfYvRgXfPU/TuERtL9f8pAII44
  385. jAVcy60MBZ1bCwQZcToZlfWCpO/8nLg4nnv4e3W9UeC6rDgWgpI6IXS3jikN/x3P
  386. 9JIVFcWLtsOLC+D/33jSV8XDM3qTTRv4i/M+mva6znOI89KcBjsEhX5AunSQZ4Zg
  387. QkQTJi/td+5kVi00NXxlHYH5ztS1
  388. -----END CERTIFICATE-----
  389. EOF
  390.  
  391. cat <<EOF >/etc/stunnel/stunnel.conf
  392. cert = /etc/stunnel/stunnel.pem
  393. client = no
  394. socket = a:SO_REUSEADDR=1
  395. socket = l:TCP_NODELAY=1
  396. socket = r:TCP_NODELAY=1
  397.  
  398. [SSH]
  399. accept = 443
  400. connect = 127.0.0.1:22
  401. EOF
  402. }
  403.  
  404. iptable_rules (){
  405. echo "
  406. net.ipv4.ip_forward = 1
  407. " > /etc/sysctl.conf
  408. sysctl -p
  409. chmod -R 755 /etc/openvpn
  410. iptables -t nat -A POSTROUTING -s 10.8.0.0/16 -o eth0 -j MASQUERADE
  411. iptables -t nat -A POSTROUTING -s 10.8.0.0/16 -o eth0 -j SNAT --to-source `curl ipecho.net/plain`
  412. iptables -t nat -A POSTROUTING -s 10.8.0.0/16 -o ens3 -j MASQUERADE
  413. iptables -t nat -A POSTROUTING -s 10.8.0.0/16 -o ens3 -j SNAT --to-source `curl ipecho.net/plain`
  414. iptables -t nat -A POSTROUTING -s 10.9.0.0/16 -o eth0 -j MASQUERADE
  415. iptables -t nat -A POSTROUTING -s 10.9.0.0/16 -o eth0 -j SNAT --to-source `curl ipecho.net/plain`
  416. iptables -t nat -A POSTROUTING -s 10.9.0.0/16 -o ens3 -j MASQUERADE
  417. iptables -t nat -A POSTROUTING -s 10.9.0.0/16 -o ens3 -j SNAT --to-source `curl ipecho.net/plain`
  418. systemctl start openvpn
  419. }
  420.  
  421. change_details (){
  422. sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/stunnel4
  423. sed -i "s|DBHOST|$HOST|g" /etc/openvpn/script/config.sh
  424. sed -i "s|DBUSER|$USER|g" /etc/openvpn/script/config.sh
  425. sed -i "s|DBPASS|$PASS|g" /etc/openvpn/script/config.sh
  426. sed -i "s|DBNAME|$DBNAME|g" /etc/openvpn/script/config.sh
  427. }
  428.  
  429. enable_server () {
  430. systemctl enable privoxy
  431. systemctl enable stunnel4
  432. systemctl enable openvpn
  433. service ssh restart
  434. systemctl restart privoxy
  435. systemctl restart stunnel4
  436. systemctl restart openvpn
  437. }
  438.  
  439. display_memo () {
  440. clear
  441. echo -e "${YELLOW}#############################################"
  442. echo -e "# ${YELLOW}DEBIAN9 Setup Dual POrt OPENVPN/SSH/SSL #"
  443. echo -e "# ${YELLOW} TAKASIVPN PRO #"
  444. echo -e "# ${YELLOW}Setup by: dev_orly of scripsteam #"
  445. echo -e "# ${YELLOW}Dont EDIT CODES: CASE---- SENSITIVE #"
  446. echo -e "# ${YELLOW}owner: Takashi #"
  447. echo -e "#############################################${RESET}"
  448. }
  449.  
  450. install_cron (){
  451. crontab -l > mycron;.
  452. echo "*/5 * * * * php /root/ssh.php >/dev/null 2>&1" >> mycron;
  453. echo "*/5 * * * * bash /root/active.sh >/dev/null 2>&1" >> mycron;
  454. echo "*/5 * * * * bash /root/inactive.sh >/dev/null 2>&1" >> mycron;
  455. crontab mycron;
  456. rm mycron;
  457. service cron restart;
  458. sed -i "s|DBHOST|$HOST|g" /root/ssh.php
  459. sed -i "s|DBUSER|$USER|g" /root/ssh.php
  460. sed -i "s|DBPASS|$PASS|g" /root/ssh.php
  461. sed -i "s|DBNAME|$DBNAME|g" /root/ssh.php
  462. }
  463.  
  464. display_memo
  465. PS3='Please enter your choice:'
  466. options=("Install Prem" "Install VIP" "Install PRIVATE" "Quit")
  467. select opt in "${options[@]}"
  468. do
  469. case $opt in
  470. "Install Prem")
  471. clear
  472. display_memo
  473. install_packages
  474. create_directory
  475. cat <<\EOM >/etc/openvpn/script/authvpn.sh
  476. #!/bin/bash
  477. . /etc/openvpn/script/config.sh
  478. user_name=`mysql -u $USER -p$PASS -h $HOST $DB -sN -e "SELECT user_name FROM users WHERE user_name='$username' AND user_pass='$password' AND is_validated=1 AND frozen=0 AND (duration > 0 OR vip_duration > 0 OR private_duration > 0)"`
  479. [ "$user_name" != '' ] && [ "$user_name" = "$username" ] && echo "user : $username" && echo 'authentication ok.' && exit 0 || echo 'Mali User Or Pass'; exit 1
  480. EOM
  481. create_files
  482. iptable_rules &> /dev/null
  483. change_details
  484. enable_server
  485. ##ssh link pls change this to your link
  486. wget -O ssh.php strongteam.co/lamborghini/premiumssh.sh
  487. install_cron
  488. display_memo
  489. echo -e "$GREEN Installation Done....$RESET"
  490. rm -f install.sh
  491. break;;
  492.  
  493. "Install VIP")
  494. clear
  495. display_memo
  496. install_packages
  497. create_directory
  498. cat <<\EOM >/etc/openvpn/script/authvpn.sh
  499. #!/bin/bash
  500. . /etc/openvpn/script/config.sh
  501. user_name=`mysql -u $USER -p$PASS -h $HOST $DB -sN -e "SELECT user_name FROM users WHERE user_name='$username' AND user_pass='$password' AND is_validated=1 AND frozen=0 AND (vip_duration > 0 OR private_duration > 0)"`
  502. [ "$user_name" != '' ] && [ "$user_name" = "$username" ] && echo "user : $username" && echo 'authentication ok.' && exit 0 || echo 'Mali User Or Pass'; exit 1
  503. EOM
  504. create_files
  505. iptable_rules &> /dev/null
  506. change_details
  507. enable_server
  508. ##ssh link pls change this to your link
  509. wget -O ssh.php strongteam.co/lamborghini/vipssh.sh
  510. install_cron
  511. display_memo
  512. echo -e "$GREEN Installation Done....$RESET"
  513. rm -f install.sh
  514. break;;
  515.  
  516. "Install PRIVATE")
  517. clear
  518. display_memo
  519. install_packages
  520. create_directory
  521. cat <<\EOM >/etc/openvpn/script/authvpn.sh
  522. #!/bin/bash
  523. . /etc/openvpn/script/config.sh
  524. user_name=`mysql -u $USER -p$PASS -h $HOST $DB -sN -e "SELECT user_name FROM users WHERE user_name='$username' AND user_pass='$password' AND is_validated=1 AND frozen=0 AND private_duration > 0"`
  525. [ "$user_name" != '' ] && [ "$user_name" = "$username" ] && echo "user : $username" && echo 'authentication ok.' && exit 0 || echo 'Mali User Or Pass'; exit 1
  526. EOM
  527. create_files
  528. iptable_rules &> /dev/null
  529. change_details
  530. enable_server
  531. ##ssh link pls change this to your link
  532. wget -O ssh.php strongteam.co/lamborghini/privatessh.sh
  533. install_cron
  534. display_memo
  535. echo -e "$GREEN Installation Done....$RESET"
  536. rm -f install.sh
  537. break;;
  538. "Quit")
  539. rm -f install.sh
  540. break
  541. ;;
  542. *) echo invalid option;;
  543. esac
  544. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement