-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsshscript
660 lines (596 loc) · 21.1 KB
/
sshscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
#!/bin/sh
wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg|apt-key add -
sleep 2
echo "deb http://build.openvpn.net/debian/openvpn/release/2.4 stretch main" > /etc/apt/sources.list.d/openvpn-aptrepo.list
#Requirement
apt update
apt upgrade -y
apt install openvpn nginx php7.0-fpm stunnel4 squid3 dropbear easy-rsa vnstat ufw build-essential fail2ban zip -y
# initializing var
export DEBIAN_FRONTEND=noninteractive
OS=`uname -m`;
MYIP=$(wget -qO- ipv4.icanhazip.com);
MYIP2="s/xxxxxxxxx/$MYIP/g";
cd /root
wget "https://raw.githubusercontent.com/Hira20/VPSauto/master/tool/plugin.tgz"
# disable ipv6
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
# set time GMT +8
ln -fs /usr/share/zoneinfo/Asia/Manila /etc/localtime
# # install webmin
# cd
# wget "https://raw.githubusercontent.com/Hira20/VPSauto/master/webmin_1.801_all.deb"
# dpkg --install webmin_1.801_all.deb;
# apt-get -y -f install;
# sed -i 's/ssl=1/ssl=0/g' /etc/webmin/miniserv.conf
# rm /root/webmin_1.801_all.deb
# service webmin restart
# install screenfetch
# cd
# wget -O /usr/bin/screenfetch "https://raw.githubusercontent.com/Hira20/VPSauto/master/tool/screenfetch"
# chmod +x /usr/bin/screenfetch
# echo "clear" >> .profile
# echo "screenfetch" >> .profile
# install dropbear
sed -i 's/NO_START=1/NO_START=0/g' /etc/default/dropbear
sed -i 's/DROPBEAR_PORT=22/DROPBEAR_PORT=442/g' /etc/default/dropbear
echo "/bin/false" >> /etc/shells
# install unzip
apt-get install unzip
# install squid3
cat > /etc/squid/squid.conf <<-END
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
acl SSL_ports port 444
acl Safe_ports port 80
acl Safe_ports port 21
acl Safe_ports port 444
acl Safe_ports port 70
acl Safe_ports port 210
acl Safe_ports port 1025-65535
acl Safe_ports port 280
acl Safe_ports port 488
acl Safe_ports port 591
acl Safe_ports port 777
acl CONNECT method CONNECT
acl SSH dst xxxxxxxxx-xxxxxxxxx/32
http_access allow SSH
http_access allow manager localhost
http_access deny manager
http_access allow localhost
http_access deny all
http_port 3128
http_port 8080
coredump_dir /var/spool/squid3
error_directory /usr/share/squid/errors/English
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
visible_hostname Hiratechi
END
sed -i $MYIP2 /etc/squid/squid.conf;
# Change Squid Page
# cat > /usr/share/squid-langpack/en/ERR_INVALID_URL <<-END
# <!DOCTYPE html>
# <html><head>
# <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
# <meta name="description" content="%h SQUID PROXY" />
# <title>Welcome to %h SQUID PROXY</title>
# <script type="text/javascript">
# function Redirect()
# {
# window.location="https://discord.gg/EHq4XjH";
# }
# setTimeout('Redirect()', 60);
# </script>
# <center>Thanks for visiting!<br><br>Loading please wait...</center><br><br>
# <hr>
# <div id="footer">
# <p>SQUID PROXY Generated by %h on %T Philippines</p>
# <!-- %c -->
# </div>
# </body></html>
# END
# setting banner
rm /etc/issue.net
wget -O /etc/issue.net "https://raw.githubusercontent.com/Hira20/AutoScriptVPS/master/Files/Others/issue.net"
sed -i 's@#Banner@Banner@g' /etc/ssh/sshd_config
sed -i 's@DROPBEAR_BANNER=""@DROPBEAR_BANNER="/etc/issue.net"@g' /etc/default/dropbear
service ssh restart
service dropbear restart
#install OpenVPN
# cp -r /usr/share/easy-rsa/ /etc/openvpn
# mkdir /etc/openvpn/easy-rsa/keys
# # replace bits
# sed -i 's|export KEY_COUNTRY="US"|export KEY_COUNTRY="PH"|' /etc/openvpn/easy-rsa/vars
# sed -i 's|export KEY_PROVINCE="CA"|export KEY_PROVINCE="MANILA"|' /etc/openvpn/easy-rsa/vars
# sed -i 's|export KEY_CITY="SanFrancisco"|export KEY_CITY="METRO MANILA"|' /etc/openvpn/easy-rsa/vars
# sed -i 's|export KEY_ORG="Fort-Funston"|export KEY_ORG="TEAM_EPIPHANY"|' /etc/openvpn/easy-rsa/vars
# sed -i 's|export KEY_EMAIL="[email protected]"|export KEY_EMAIL="[email protected]"|' /etc/openvpn/easy-rsa/vars
# sed -i 's|export KEY_OU="MyOrganizationalUnit"|export KEY_OU="STRICTLY_NO_TORRENT_ALLOWED_IN_THIS_SERVER"|' /etc/openvpn/easy-rsa/vars
# sed -i 's|export KEY_NAME="EasyRSA"|export KEY_NAME="HIRATECHI"|' /etc/openvpn/easy-rsa/vars
# sed -i 's|export KEY_OU=changeme|export KEY_OU=STRICTLY_NO_TORRENT_ALLOWED_IN_THIS_SERVER|' /etc/openvpn/easy-rsa/vars
# #Create Diffie-Helman Pem
# openssl dhparam -out /etc/openvpn/dh2048.pem 2048
# # Create PKI
# cd /etc/openvpn/easy-rsa
# cp openssl-1.0.0.cnf openssl.cnf
# . ./vars
# ./clean-all
# export EASY_RSA="${EASY_RSA:-.}"
# "$EASY_RSA/pkitool" --initca $*
# # create key server
# export EASY_RSA="${EASY_RSA:-.}"
# "$EASY_RSA/pkitool" --server server
# # setting KEY CN
# export EASY_RSA="${EASY_RSA:-.}"
# "$EASY_RSA/pkitool" client
# cd
# #cp /etc/openvpn/easy-rsa/keys/{server.crt,server.key} /etc/openvpn
# cp /etc/openvpn/easy-rsa/keys/server.crt /etc/openvpn/server.crt
# cp /etc/openvpn/easy-rsa/keys/server.key /etc/openvpn/server.key
# cp /etc/openvpn/easy-rsa/keys/ca.crt /etc/openvpn/ca.crt
# chmod +x /etc/openvpn/ca.crt
# Setting Server
# tar -xzvf /root/plugin.tgz -C /usr/lib/openvpn/
# chmod +x /usr/lib/openvpn/*
# cat > /etc/openvpn/server.conf <<-END
# port 1153
# proto tcp
# dev tun
# ca ca.crt
# cert server.crt
# key server.key
# dh dh2048.pem
# verify-client-cert none
# username-as-common-name
# plugin /usr/lib/openvpn/plugins/openvpn-plugin-auth-pam.so login
# server 192.168.10.0 255.255.255.0
# ifconfig-pool-persist ipp.txt
# push "redirect-gateway def1 bypass-dhcp"
# push "dhcp-option DNS 1.1.1.1"
# push "dhcp-option DNS 1.0.0.1"
# push "route-method exe"
# push "route-delay 2"
# socket-flags TCP_NODELAY
# push "socket-flags TCP_NODELAY"
# duplicate-cn
# keepalive 10 120
# comp-lzo
# user nobody
# group nogroup
# persist-key
# persist-tun
# status openvpn-status.log
# log openvpn.log
# verb 3
# ncp-disable
# cipher none
# auth none
# END
# systemctl start openvpn@server
# #Create OpenVPN Config
# mkdir -p /home/vps/public_html
# cat > /home/vps/public_html/client.ovpn <<-END
# # Created by reputation aka Hiratechi
# # TEAM Epiphany | www.pinoythread.com
# # Discord Group : https://discord.gg/EHq4XjH
# # RULES [ NO TORRENT | NO DDOS | NO BULLSHIT PLS ]
# client
# dev tun
# proto tcp
# remote $MYIP 1153
# persist-key
# persist-tun
# pull
# resolv-retry infinite
# nobind
# user nobody
# comp-lzo
# remote-cert-tls server
# verb 3
# mute 2
# connect-retry 3
# connect-retry-max 8080
# keepalive 15 45
# mute-replay-warnings
# redirect-gateway def1
# script-security 2
# route-method exe
# route-delay 2
# auth-user-pass
# cipher none
# auth none
# http-proxy-retry
# # If squid is not working try to install Privoxy in your vps
# http-proxy $MYIP 8080
# http-proxy-option CUSTOM-HEADER ""
# http-proxy-option CUSTOM-HEADER "POST https://viber.com HTTP/1.0"
# http-proxy-option CUSTOM-HEADER "Connection: Keep-Alive"
# http-proxy-option CUSTOM-HEADER "Proxy-Connection: Keep-Alive"
## Uncomment below if you like to do auto-login in mobile
#<auth-user-pass>
#your_username
#your_password
#</auth-user-pass>
# END
# echo '<ca>' >> /home/vps/public_html/client.ovpn
# cat /etc/openvpn/ca.crt >> /home/vps/public_html/client.ovpn
# echo '</ca>' >> /home/vps/public_html/client.ovpn
# cat > /home/vps/public_html/clientssl.ovpn <<-END
# # Created by reputation aka Hiratechi
# # TEAM Epiphany | www.pinoythread.com
# # Discord Group : https://discord.gg/EHq4XjH
# # RULES [ NO TORRENT | NO DDOS | NO BULLSHIT PLS ]
# client
# dev tun
# proto tcp
# remote 127.0.0.1 1153
# route $MYIP 255.255.255.255 net_gateway
# persist-key
# persist-tun
# pull
# resolv-retry infinite
# nobind
# user nobody
# comp-lzo
# remote-cert-tls server
# verb 3
# mute 2
# connect-retry 5
# connect-retry-max 8080
# mute-replay-warnings
# redirect-gateway def1
# script-security 2
# auth-user-pass
# cipher none
# auth none
# ## Uncomment below if you like to do auto-login in mobile
# #<auth-user-pass>
# #your_username
# #your_password
# #</auth-user-pass>
# END
# echo '<ca>' >> /home/vps/public_html/clientssl.ovpn
# cat /etc/openvpn/ca.crt >> /home/vps/public_html/clientssl.ovpn
# echo '</ca>' >> /home/vps/public_html/clientssl.ovpn
# cat > /home/vps/public_html/stunnel.conf <<-END
# client = yes
# debug = 6
# [openvpn]
# accept = 127.0.0.1:1153
# connect = $MYIP:443
# TIMEOUTclose = 0
# verify = 0
# sni = m.facebook.com
# END
# Configure Stunnel
# sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/stunnel4
# openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -sha256 -subj '/CN=127.0.0.1/O=localhost/C=PH' -keyout /etc/stunnel/stunnel.pem -out /etc/stunnel/stunnel.pem
# cat > /etc/stunnel/stunnel.conf <<-END
# sslVersion = all
# pid = /stunnel.pid
# socket = l:TCP_NODELAY=1
# socket = r:TCP_NODELAY=1
# client = no
# [openvpn]
# accept = 443
# connect = 127.0.0.1:1153
# cert = /etc/stunnel/stunnel.pem
[dropbear]
accept = 444
connect = 127.0.0.1:442
cert = /etc/stunnel/stunnel.pem
END
#Setting UFW
ufw allow ssh
ufw allow 1153/tcp
sed -i 's|DEFAULT_INPUT_POLICY="DROP"|DEFAULT_INPUT_POLICY="ACCEPT"|' /etc/default/ufw
sed -i 's|DEFAULT_FORWARD_POLICY="DROP"|DEFAULT_FORWARD_POLICY="ACCEPT"|' /etc/default/ufw
# set ipv4 forward
echo 1 > /proc/sys/net/ipv4/ip_forward
sed -i 's|#net.ipv4.ip_forward=1|net.ipv4.ip_forward=1|' /etc/sysctl.conf
sysctl -w net.ipv4.ip_forward=1
#Setting IPtables
cat > /etc/iptables.up.rules <<-END
*nat
:PREROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -j SNAT --to-source xxxxxxxxx
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -s 192.168.10.0/24 -o eth0 -j MASQUERADE
-A POSTROUTING -j MASQUERADE
COMMIT
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:fail2ban-ssh - [0:0]
-A INPUT -p tcp -m multiport --dports 22 -j fail2ban-ssh
-A INPUT -p ICMP --icmp-type 8 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 53 -j ACCEPT
-A INPUT -p tcp --dport 22 -m state --state NEW -j ACCEPT
-A INPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT
-A INPUT -p tcp --dport 143 -m state --state NEW -j ACCEPT
-A INPUT -p tcp --dport 442 -m state --state NEW -j ACCEPT
-A INPUT -p tcp --dport 443 -m state --state NEW -j ACCEPT
-A INPUT -p tcp --dport 444 -m state --state NEW -j ACCEPT
-A INPUT -p tcp --dport 1153 -m state --state NEW -j ACCEPT
-A INPUT -p udp --dport 1153 -m state --state NEW -j ACCEPT
-A INPUT -p tcp --dport 3128 -m state --state NEW -j ACCEPT
-A INPUT -p udp --dport 3128 -m state --state NEW -j ACCEPT
-A INPUT -p tcp --dport 8000 -m state --state NEW -j ACCEPT
-A INPUT -p udp --dport 8000 -m state --state NEW -j ACCEPT
-A INPUT -p tcp --dport 8080 -m state --state NEW -j ACCEPT
-A INPUT -p udp --dport 8080 -m state --state NEW -j ACCEPT
-A INPUT -p tcp --dport 8888 -m state --state NEW -j ACCEPT
-A INPUT -p udp --dport 8888 -m state --state NEW -j ACCEPT
-A INPUT -p tcp --dport 10000 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,SYN,RST,PSH,ACK,URG -j DROP
-A INPUT -f -j DROP
-A INPUT -p tcp -m tcp ! --tcp-flags FIN,SYN,RST,ACK SYN -m state --state NEW -j DROP
-A INPUT -m string --string "peer_id" --algo kmp --to 65535 -j DROP
-A INPUT -m string --string "BitTorrent" --algo kmp --to 65535 -j DROP
-A INPUT -m string --string "BitTorrent protocol" --algo kmp --to 65535 -j DROP
-A INPUT -m string --string "bittorrent-announce" --algo kmp --to 65535 -j DROP
-A INPUT -m string --string "announce.php?passkey=" --algo kmp --to 65535 -j DROP
-A INPUT -m string --string "find_node" --algo kmp --to 65535 -j DROP
-A INPUT -m string --string "info_hash" --algo kmp --to 65535 -j DROP
-A INPUT -m string --string "get_peers" --algo kmp --to 65535 -j DROP
-A INPUT -m string --string "announce" --algo kmp --to 65535 -j DROP
-A INPUT -m string --string "announce_peers" --algo kmp --to 65535 -j DROP
-A INPUT -p udp -m string --string "BitTorrent" --algo bm --to 65535 -j DROP
-A INPUT -p udp -m string --string ".torrent" --algo bm --to 65535 -j DROP
-A INPUT -p udp -m string --string "announce" --algo bm --to 65535 -j DROP
-A INPUT -p udp -m string --string "info_hash" --algo bm --to 65535 -j DROP
-A INPUT -p udp -m string --string "tracker" --algo bm --to 65535 -j DROP
-A FORWARD -i eth0 -o ppp0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i ppp0 -o eth0 -j ACCEPT
-A FORWARD -p tcp -m tcp --dport 6881:6889 -j DROP
-A FORWARD -m string --string "get_peers" --algo bm --to 65535 -j DROP
-A FORWARD -p udp -m string --string "BitTorrent" --algo bm --to 65535 -j DROP
-A FORWARD -p udp -m string --string "BitTorrent protocol" --algo bm --to 65535 -j DROP
-A FORWARD -p udp -m string --string "peer_id=" --algo bm --to 65535 -j DROP
-A FORWARD -p udp -m string --string ".torrent" --algo bm --to 65535 -j DROP
-A FORWARD -p udp -m string --string "announce.php?passkey=" --algo bm --to 65535 -j DROP
-A FORWARD -p udp -m string --string "torrent" --algo bm --to 65535 -j DROP
-A FORWARD -p udp -m string --string "announce" --algo bm --to 65535 -j DROP
-A FORWARD -p udp -m string --string "info_hash" --algo bm --to 65535 -j DROP
-A FORWARD -p udp -m string --string "tracker" --algo bm --to 65535 -j DROP
-A OUTPUT -p udp -m string --string "tracker" --algo bm --to 65535 -j DROP
-A OUTPUT -p udp -m string --string "info_hash" --algo bm --to 65535 -j DROP
-A OUTPUT -p udp -m string --string "announce" --algo bm --to 65535 -j DROP
-A OUTPUT -p udp -m string --string ".torrent" --algo bm --to 65535 -j DROP
-A OUTPUT -p udp -m string --string "BitTorrent" --algo bm --to 65535 -j DROP
-A OUTPUT -p tcp -m tcp --dport 1723 -j ACCEPT
-A OUTPUT -p icmp -m icmp --icmp-type 8 -j DROP
-A OUTPUT -p tcp -m tcp --dport 6881:6889 -j DROP
-A fail2ban-ssh -j RETURN
COMMIT
*raw
:PREROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
END
sed -i $MYIP2 /etc/iptables.up.rules;
iptables-restore < /etc/iptables.up.rules
# Create and Configure rc.local
cat > /etc/rc.local <<-END
#!/bin/sh -e
exit 0
END
chmod +x /etc/rc.local
sed -i '$ i\echo "nameserver 1.1.1.1" > /etc/resolv.conf' /etc/rc.local
sed -i '$ i\echo "nameserver 1.0.0.1" >> /etc/resolv.conf' /etc/rc.local
sed -i '$ i\iptables-restore < /etc/iptables.up.rules' /etc/rc.local
# Configure menu
cd /usr/local/bin/
wget "https://raw.githubusercontent.com/Hira20/VPSauto/master/tool/premiummenu.zip"
unzip premiummenu.zip
chmod +x /usr/local/bin/*
# add eth0 to vnstat
vnstat -u -i eth0
# compress configs
cd /home/vps/public_html
zip openvpn.zip client.ovpn clientssl.ovpn stunnel.conf
# install libxml-parser
apt-get install -y libxml-parser-perl
# Adding user
#!/bin/bash
# Created by http://www.vps-murah.net
# Modified by 0123456
red='\e[1;31m'
green='\e[0;32m'
NC='\e[0m'
echo "Connecting to Server..."
sleep 0.5
echo "Checking Permision..."
sleep 0.4
CEK=0123456
if [ "$CEK" != "0123456" ]; then
echo -e "${red}Permission Denied!${NC}";
echo $CEK;
exit 0;
else
echo -e "${green}Permission Accepted...${NC}"
sleep 1
clear
fi
echo ""
echo ""
echo ""
username="johnmic33"
egrep "^$username" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo "Username already exists in your VPS"
exit 0
else
password="cubiotej33"
masa_aktif=99
MYIP=$(wget -qO- ipv4.icanhazip.com)
today=`date +%s`
masa_aktif_detik=$(( $masa_aktif * 86400 ))
saat_expired=$(($today + $masa_aktif_detik))
tanggal_expired=$(date -u --date="1970-01-01 $saat_expired sec GMT" +%Y/%m/%d)
tanggal_expired_display=$(date -u --date="1970-01-01 $saat_expired sec GMT" '+%d %B %Y')
clear
echo "Connecting to Server..."
sleep 0.5
echo "Creating Account..."
sleep 0.5
echo "Generating Host..."
sleep 0.5
echo "Generating Your New Username: $username"
sleep 0.5
echo "Generating Password: $password"
sleep 1
useradd $username
usermod -s /bin/false $username
usermod -e $tanggal_expired $username
egrep "^$username" /etc/passwd >/dev/null
echo -e "$password\n$password" | passwd $username
clear
echo ""
echo ""
echo ""
echo "---------------------------------------"
echo " ACCOUNT DETAILS "
echo "---------------------------------------"
echo " Username : $username"
echo " Password : $password"
echo " Active Time : $masa_aktif Days"
echo " Date Expired : $tanggal_expired_display"
echo "---------------------------------------"
echo " "
echo " "
echo " "
fi
# Autokill 0
#!/bin/bash
# Created by http://www.vps-murah.net
# Remodified by reputation
if [[ $USER != "root" ]]; then
echo "Oops! root privileges needed"
exit
fi
# go to root
cd
#Cek Curl
if [ ! -e /usr/bin/curl ]; then
if [[ "$OS" = 'debian' ]]; then
apt-get -y update && apt-get -y install curl
else
yum -y update && yum -y install curl
fi
fi
# check registered ip
red='\e[1;31m'
green='\e[0;32m'
NC='\e[0m'
echo "Connecting to Server..."
sleep 0.4
echo "Checking Permision..."
sleep 0.3
CEK=0123456
if [ "$CEK" != "0123456" ]; then
echo -e "${red}Permission Denied!${NC}";
echo $CEK;
exit 0;
else
echo -e "${green}Permission Accepted...${NC}"
sleep 0.6
clear
fi
if [[ -e /etc/debian_version ]]; then
OS=debian
RCLOCAL='/etc/rc.local'
elif [[ -e /etc/centos-release || -e /etc/redhat-release ]]; then
OS=centos
RCLOCAL='/etc/rc.d/rc.local'
chmod +x /etc/rc.d/rc.local
else
echo "This script only works on Debian and CentOS system."
exit
fi
x=0
#dropbear
rm -f /root/dropbearport
dropbearport="$(netstat -nlpt | grep -i dropbear | grep -i 0.0.0.0 | awk '{print $4}' | cut -d: -f2)"
echo "Dropbear Port:"
cat > /root/dropbearport <<-END
$dropbearport
END
exec</root/dropbearport
while read line
do
sed "s/#iptables -A INPUT -p tcp --syn --dport $line -m connlimit --connlimit-above 2 -j REJECT//g" -i $RCLOCAL
sed "s/#iptables -A INPUT -p tcp --syn --dport $line -m connlimit --connlimit-above 3 -j REJECT//g" -i $RCLOCAL
sed "s/iptables -A INPUT -p tcp --syn --dport $line -m connlimit --connlimit-above 2 -j REJECT//g" -i $RCLOCAL
sed "s/iptables -A INPUT -p tcp --syn --dport $line -m connlimit --connlimit-above 3 -j REJECT//g" -i $RCLOCAL
echo "$line ==> Limit $x login"
#grep "iptables -A INPUT -p tcp --syn --dport $line -m connlimit --connlimit-above $x -j REJECT" $RCLOCAL > /dev/null
#if [[ $? != 0 ]];then
#sed -i "1 a\iptables -A INPUT -p tcp --syn --dport $line -m connlimit --connlimit-above $x -j REJECT" $RCLOCAL
#fi
#sed "s/#iptables -A INPUT -p tcp --syn --dport $line -m connlimit --connlimit-above $x -j REJECT/iptables -A INPUT -p tcp --syn --dport $line -m connlimit --connlimit-above $x -j REJECT/g" -i $RCLOCAL
done
echo ""
rm -f /root/dropbearport
#openssh
rm -f /root/opensshport
opensshport="$(netstat -nlpt | grep -i sshd | grep -i 0.0.0.0 | awk '{print $4}' | cut -d: -f2)"
echo "OpenSSH Port:"
cat > /root/opensshport <<-END
$opensshport
END
exec</root/opensshport
while read line
do
sed "s/#iptables -A INPUT -p tcp --syn --dport $line -m connlimit --connlimit-above 2 -j REJECT//g" -i $RCLOCAL
sed "s/#iptables -A INPUT -p tcp --syn --dport $line -m connlimit --connlimit-above 3 -j REJECT//g" -i $RCLOCAL
sed "s/iptables -A INPUT -p tcp --syn --dport $line -m connlimit --connlimit-above 2 -j REJECT//g" -i $RCLOCAL
sed "s/iptables -A INPUT -p tcp --syn --dport $line -m connlimit --connlimit-above 3 -j REJECT//g" -i $RCLOCAL
echo "$line ==> Limit $x login"
#grep "iptables -A INPUT -p tcp --syn --dport $line -m connlimit --connlimit-above $x -j REJECT" $RCLOCAL > /dev/null
#if [[ $? != 0 ]];then
#sed -i "1 a\iptables -A INPUT -p tcp --syn --dport $line -m connlimit --connlimit-above $x -j REJECT" $RCLOCAL
#fi
#sed "s/#iptables -A INPUT -p tcp --syn --dport $line -m connlimit --connlimit-above $x -j REJECT/iptables -A INPUT -p tcp --syn --dport $line -m connlimit --connlimit-above $x -j REJECT/g" -i $RCLOCAL
done
echo ""
rm -f /root/opensshport
sed '/^$/d' $RCLOCAL > /tmp/rc.local
cat /tmp/rc.local > $RCLOCAL
$RCLOCAL start
# finalizing
vnstat -u -i eth0
apt-get -y autoremove
chown -R www-data:www-data /home/vps/public_html
service nginx start
service php7.0-fpm start
service vnstat restart
service openvpn restart
service dropbear restart
service fail2ban restart
service squid restart
#clearing history
history -c
-rf /root/*
cd /root
# info
clear
echo " "
echo "Installation has been completed!!"
echo "YOUR VPS WILL REBOOT IN 5 SECONDS"
sleep 5
reboot