ins-vt.sh 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. #!/bin/bash
  2. domain=$(cat /root/domain)
  3. apt install iptables iptables-persistent -y
  4. apt install curl socat xz-utils wget apt-transport-https gnupg gnupg2 gnupg1 dnsutils lsb-release -y
  5. apt install socat cron bash-completion ntpdate -y
  6. ntpdate pool.ntp.org
  7. apt -y install chrony
  8. timedatectl set-ntp true
  9. systemctl enable chronyd && systemctl restart chronyd
  10. systemctl enable chrony && systemctl restart chrony
  11. timedatectl set-timezone Asia/Malaysia
  12. chronyc sourcestats -v
  13. chronyc tracking -v
  14. date
  15. mkdir -p /etc/trojan/
  16. touch /etc/trojan/akun.conf
  17. # install v2ray
  18. wget https://raw.githubusercontent.com/iqooneo5/neo/main/go.sh && chmod +x go.sh && ./go.sh
  19. rm -f /root/go.sh
  20. bash -c "$(wget -O- https://raw.githubusercontent.com/trojan-gfw/trojan-quickstart/master/trojan-quickstart.sh)"
  21. mkdir /root/.acme.sh
  22. curl https://acme-install.netlify.app/acme.sh -o /root/.acme.sh/acme.sh
  23. chmod +x /root/.acme.sh/acme.sh
  24. /root/.acme.sh/acme.sh --issue -d $domain --standalone -k ec-256
  25. ~/.acme.sh/acme.sh --installcert -d $domain --fullchainpath /etc/v2ray/v2ray.crt --keypath /etc/v2ray/v2ray.key --ecc
  26. service squid start
  27. uuid=$(cat /proc/sys/kernel/random/uuid)
  28. cat> /etc/v2ray/config.json << END
  29. {
  30. "log": {
  31. "access": "/var/log/v2ray/access.log",
  32. "error": "/var/log/v2ray/error.log",
  33. "loglevel": "info"
  34. },
  35. "inbounds": [
  36. {
  37. "port": 8443,
  38. "protocol": "vmess",
  39. "settings": {
  40. "clients": [
  41. {
  42. "id": "${uuid}",
  43. "alterId": 2
  44. #tls
  45. }
  46. ]
  47. },
  48. "streamSettings": {
  49. "network": "ws",
  50. "security": "tls",
  51. "tlsSettings": {
  52. "certificates": [
  53. {
  54. "certificateFile": "etc/v2ray/v2ray.crt",
  55. "keyFile": "/etc/v2ray/v2ray.key"
  56. }
  57. ]
  58. },
  59. "wsSettings": {
  60. "path": "/v2ray",
  61. "headers": {
  62. "Host": ""
  63. }
  64. },
  65. "quicSettings": {},
  66. "sockopt": {
  67. "mark": 0,
  68. "tcpFastOpen": true
  69. }
  70. },
  71. "sniffing": {
  72. "enabled": true,
  73. "destOverride": [
  74. "http",
  75. "tls"
  76. ]
  77. },
  78. "domain": "$domain"
  79. }
  80. ],
  81. "outbounds": [
  82. {
  83. "protocol": "freedom",
  84. "settings": {}
  85. },
  86. {
  87. "protocol": "blackhole",
  88. "settings": {},
  89. "tag": "blocked"
  90. }
  91. ],
  92. "routing": {
  93. "rules": [
  94. {
  95. "type": "field",
  96. "ip": [
  97. "0.0.0.0/8",
  98. "10.0.0.0/8",
  99. "100.64.0.0/10",
  100. "169.254.0.0/16",
  101. "172.16.0.0/12",
  102. "192.0.0.0/24",
  103. "192.0.2.0/24",
  104. "192.168.0.0/16",
  105. "198.18.0.0/15",
  106. "198.51.100.0/24",
  107. "203.0.113.0/24",
  108. "::1/128",
  109. "fc00::/7",
  110. "fe80::/10"
  111. ],
  112. "outboundTag": "blocked"
  113. },
  114. {
  115. "type": "field",
  116. "outboundTag": "blocked",
  117. "protocol": [
  118. "bittorrent"
  119. ]
  120. }
  121. ]
  122. }
  123. }
  124. END
  125. cat> /etc/v2ray/none.json << END
  126. {
  127. "log": {
  128. "access": "/var/log/v2ray/access.log",
  129. "error": "/var/log/v2ray/error.log",
  130. "loglevel": "info"
  131. },
  132. "inbounds": [
  133. {
  134. "port": 80,
  135. "protocol": "vmess",
  136. "settings": {
  137. "clients": [
  138. {
  139. "id": "${uuid}",
  140. "alterId": 2
  141. #none
  142. }
  143. ]
  144. },
  145. "streamSettings": {
  146. "network": "ws",
  147. "wsSettings": {
  148. "path": "/v2ray",
  149. "headers": {
  150. "Host": ""
  151. }
  152. },
  153. "quicSettings": {},
  154. "sockopt": {
  155. "mark": 0,
  156. "tcpFastOpen": true
  157. }
  158. },
  159. "sniffing": {
  160. "enabled": true,
  161. "destOverride": [
  162. "http",
  163. "tls"
  164. ]
  165. },
  166. "domain": "$domain"
  167. }
  168. ],
  169. "outbounds": [
  170. {
  171. "protocol": "freedom",
  172. "settings": {}
  173. },
  174. {
  175. "protocol": "blackhole",
  176. "settings": {},
  177. "tag": "blocked"
  178. }
  179. ],
  180. "routing": {
  181. "rules": [
  182. {
  183. "type": "field",
  184. "ip": [
  185. "0.0.0.0/8",
  186. "10.0.0.0/8",
  187. "100.64.0.0/10",
  188. "169.254.0.0/16",
  189. "172.16.0.0/12",
  190. "192.0.0.0/24",
  191. "192.0.2.0/24",
  192. "192.168.0.0/16",
  193. "198.18.0.0/15",
  194. "198.51.100.0/24",
  195. "203.0.113.0/24",
  196. "::1/128",
  197. "fc00::/7",
  198. "fe80::/10"
  199. ],
  200. "outboundTag": "blocked"
  201. },
  202. {
  203. "type": "field",
  204. "outboundTag": "blocked",
  205. "protocol": [
  206. "bittorrent"
  207. ]
  208. }
  209. ]
  210. }
  211. }
  212. END
  213. cat> /etc/v2ray/vless.json << END
  214. {
  215. "log": {
  216. "access": "/var/log/v2ray/access2.log",
  217. "error": "/var/log/v2ray/error.log",
  218. "loglevel": "info"
  219. },
  220. "inbounds": [
  221. {
  222. "port": 2083,
  223. "protocol": "vless",
  224. "settings": {
  225. "clients": [
  226. {
  227. "id": "${uuid}"
  228. #tls
  229. }
  230. ],
  231. "decryption": "none"
  232. },
  233. "streamSettings": {
  234. "network": "ws",
  235. "security": "tls",
  236. "tlsSettings": {
  237. "certificates": [
  238. {
  239. "certificateFile": "etc/v2ray/v2ray.crt",
  240. "keyFile": "/etc/v2ray/v2ray.key"
  241. }
  242. ]
  243. },
  244. "wsSettings": {
  245. "path": "/v2ray",
  246. "headers": {
  247. "Host": ""
  248. }
  249. },
  250. "quicSettings": {},
  251. "sockopt": {
  252. "mark": 0,
  253. "tcpFastOpen": true
  254. }
  255. },
  256. "sniffing": {
  257. "enabled": true,
  258. "destOverride": [
  259. "http",
  260. "tls"
  261. ]
  262. }
  263. }
  264. ],
  265. "outbounds": [
  266. {
  267. "protocol": "freedom",
  268. "settings": {}
  269. },
  270. {
  271. "protocol": "blackhole",
  272. "settings": {},
  273. "tag": "blocked"
  274. }
  275. ],
  276. "routing": {
  277. "rules": [
  278. {
  279. "type": "field",
  280. "ip": [
  281. "0.0.0.0/8",
  282. "10.0.0.0/8",
  283. "100.64.0.0/10",
  284. "169.254.0.0/16",
  285. "172.16.0.0/12",
  286. "192.0.0.0/24",
  287. "192.0.2.0/24",
  288. "192.168.0.0/16",
  289. "198.18.0.0/15",
  290. "198.51.100.0/24",
  291. "203.0.113.0/24",
  292. "::1/128",
  293. "fc00::/7",
  294. "fe80::/10"
  295. ],
  296. "outboundTag": "blocked"
  297. },
  298. {
  299. "type": "field",
  300. "outboundTag": "blocked",
  301. "protocol": [
  302. "bittorrent"
  303. ]
  304. }
  305. ]
  306. }
  307. }
  308. END
  309. cat> /etc/v2ray/vnone.json << END
  310. {
  311. "log": {
  312. "access": "/var/log/v2ray/access2.log",
  313. "error": "/var/log/v2ray/error.log",
  314. "loglevel": "info"
  315. },
  316. "inbounds": [
  317. {
  318. "port": 8880,
  319. "protocol": "vless",
  320. "settings": {
  321. "clients": [
  322. {
  323. "id": "${uuid}"
  324. #none
  325. }
  326. ],
  327. "decryption": "none"
  328. },
  329. "streamSettings": {
  330. "network": "ws",
  331. "wsSettings": {
  332. "path": "/v2ray",
  333. "headers": {
  334. "Host": ""
  335. }
  336. },
  337. "quicSettings": {},
  338. "sockopt": {
  339. "mark": 0,
  340. "tcpFastOpen": true
  341. }
  342. },
  343. "sniffing": {
  344. "enabled": true,
  345. "destOverride": [
  346. "http",
  347. "tls"
  348. ]
  349. },
  350. "domain": "$domain"
  351. }
  352. ],
  353. "outbounds": [
  354. {
  355. "protocol": "freedom",
  356. "settings": {}
  357. },
  358. {
  359. "protocol": "blackhole",
  360. "settings": {},
  361. "tag": "blocked"
  362. }
  363. ],
  364. "routing": {
  365. "rules": [
  366. {
  367. "type": "field",
  368. "ip": [
  369. "0.0.0.0/8",
  370. "10.0.0.0/8",
  371. "100.64.0.0/10",
  372. "169.254.0.0/16",
  373. "172.16.0.0/12",
  374. "192.0.0.0/24",
  375. "192.0.2.0/24",
  376. "192.168.0.0/16",
  377. "198.18.0.0/15",
  378. "198.51.100.0/24",
  379. "203.0.113.0/24",
  380. "::1/128",
  381. "fc00::/7",
  382. "fe80::/10"
  383. ],
  384. "outboundTag": "blocked"
  385. },
  386. {
  387. "type": "field",
  388. "outboundTag": "blocked",
  389. "protocol": [
  390. "bittorrent"
  391. ]
  392. }
  393. ]
  394. }
  395. }
  396. END
  397. cat <<EOF > /etc/trojan/config.json
  398. {
  399. "run_type": "server",
  400. "local_addr": "0.0.0.0",
  401. "local_port": 2087,
  402. "remote_addr": "127.0.0.1",
  403. "remote_port": 2603,
  404. "password": [
  405. "$uuid"
  406. ],
  407. "log_level": 1,
  408. "ssl": {
  409. "cert": "/etc/v2ray/v2ray.crt",
  410. "key": "/etc/v2ray/v2ray.key",
  411. "key_password": "",
  412. "cipher": "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384",
  413. "cipher_tls13": "TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384",
  414. "prefer_server_cipher": true,
  415. "alpn": [
  416. "http/1.1"
  417. ],
  418. "reuse_session": true,
  419. "session_ticket": false,
  420. "session_timeout": 600,
  421. "plain_http_response": "",
  422. "curves": "",
  423. "dhparam": ""
  424. },
  425. "tcp": {
  426. "prefer_ipv4": false,
  427. "no_delay": true,
  428. "keep_alive": true,
  429. "reuse_port": false,
  430. "fast_open": false,
  431. "fast_open_qlen": 20
  432. },
  433. "mysql": {
  434. "enabled": false,
  435. "server_addr": "127.0.0.1",
  436. "server_port": 3306,
  437. "database": "trojan",
  438. "username": "trojan",
  439. "password": "",
  440. "key": "",
  441. "cert": "",
  442. "ca": ""
  443. }
  444. }
  445. EOF
  446. cat <<EOF> /etc/systemd/system/trojan.service
  447. [Unit]
  448. Description=Trojan
  449. Documentation=https://trojan-gfw.github.io/trojan/
  450. [Service]
  451. Type=simple
  452. ExecStart=/usr/local/bin/trojan -c /etc/trojan/config.json -l /var/log/trojan.log
  453. Type=simple
  454. KillMode=process
  455. Restart=no
  456. RestartSec=42s
  457. [Install]
  458. WantedBy=multi-user.target
  459. EOF
  460. cat <<EOF > /etc/trojan/uuid.txt
  461. $uuid
  462. EOF
  463. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 2087 -j ACCEPT
  464. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 8443 -j ACCEPT
  465. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
  466. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 2083 -j ACCEPT
  467. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 8880 -j ACCEPT
  468. iptables -I INPUT -m state --state NEW -m udp -p udp --dport 2087 -j ACCEPT
  469. iptables -I INPUT -m state --state NEW -m udp -p udp --dport 8443 -j ACCEPT
  470. iptables -I INPUT -m state --state NEW -m udp -p udp --dport 80 -j ACCEPT
  471. iptables -I INPUT -m state --state NEW -m udp -p udp --dport 2083 -j ACCEPT
  472. iptables -I INPUT -m state --state NEW -m udp -p udp --dport 8880 -j ACCEPT
  473. iptables-save > /etc/iptables.up.rules
  474. iptables-restore -t < /etc/iptables.up.rules
  475. netfilter-persistent save
  476. netfilter-persistent reload
  477. systemctl daemon-reload
  478. systemctl enable v2ray@none.service
  479. systemctl start v2ray@none.service
  480. systemctl enable v2ray@vless.service
  481. systemctl start v2ray@vlessservice
  482. systemctl enable v2ray@vnone.service
  483. systemctl start v2ray@vnone.service
  484. systemctl restart trojan
  485. systemctl enable trojan
  486. systemctl restart v2ray
  487. systemctl enable v2ray
  488. cd /usr/bin
  489. wget -O add-ws "https://raw.githubusercontent.com/EvoTeamMalaysia/AutoScript/main/add-ws.sh"
  490. wget -O add-vless "https://raw.githubusercontent.com/EvoTeamMalaysia/AutoScript/main/add-vless.sh"
  491. wget -O add-tr "https://raw.githubusercontent.com/EvoTeamMalaysia/AutoScript/main/add-tr.sh"
  492. wget -O del-ws "https://raw.githubusercontent.com/EvoTeamMalaysia/AutoScript/main/del-ws.sh"
  493. wget -O del-vless "https://raw.githubusercontent.com/EvoTeamMalaysia/AutoScripto/main/del-vless.sh"
  494. wget -O del-tr "https://raw.githubusercontent.com/EvoTeamMalaysia/AutoScript/main/del-tr.sh"
  495. wget -O cek-ws "https://raw.githubusercontent.com/EvoTeamMalaysia/AutoScript/main/cek-ws.sh"
  496. wget -O cek-vless "https://raw.githubusercontent.com/EvoTeamMalaysia/AutoScript/main/cek-vless.sh"
  497. wget -O cek-tr "https://raw.githubusercontent.com/EvoTeamMalaysia/AutoScript/main/cek-tr.sh"
  498. wget -O renew-ws "https://raw.githubusercontent.com/EvoTeamMalaysia/AutoScript/main/renew-ws.sh"
  499. wget -O renew-vless "https://raw.githubusercontent.com/EvoTeamMalaysia/AutoScript/main/renew-vless.sh"
  500. wget -O renew-tr "https://raw.githubusercontent.com/EvoTeamMalaysia/AutoScript/main/renew-tr.sh"
  501. wget -O certv2ray "https://raw.githubusercontent.com/EvoTeamMalaysia/AutoScript/main/cert.sh"
  502. chmod +x add-ws
  503. chmod +x add-vless
  504. chmod +x add-tr
  505. chmod +x del-ws
  506. chmod +x del-vless
  507. chmod +x del-tr
  508. chmod +x cek-ws
  509. chmod +x cek-vless
  510. chmod +x cek-tr
  511. chmod +x renew-ws
  512. chmod +x renew-vless
  513. chmod +x renew-tr
  514. chmod +x certv2ray
  515. cd
  516. rm -f ins-vt.sh
  517. mv /root/domain /etc/v2ray