-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot
2495 lines (2443 loc) · 125 KB
/
bot
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
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
[[ $(awk -F" " '{print $2}' /usr/lib/telegram) != "@smigolvip" ]] && exit 0
source apibot
api_bot=$1
id_admin=$2
[[ -z $api_bot ]] && exit 0
[[ -z $id_admin ]] && exit 0
ShellBot.init --token "$api_bot" --monitor --return map --flush
ShellBot.username
fun_menu() {
[[ "${message_from_id[$id]}" == "$id_admin" ]] && {
local env_msg
env_msg="=×=×=×=×=×=×=×=×=×=×=×=×=×=×=×=×=\n"
env_msg+="<b>SEJA BEM VINDO(a) AO BOT PWEB</b>\n"
env_msg+="=×=×=×=×=×=×=×=×=×=×=×=×=×=×=×=×=\n\n"
env_msg+="⚠️ <i>SELECIONE UMA OPCAO ABAIXO !</i>\n\n"
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} --text "$env_msg" \
--reply_markup "$keyboard1" \
--parse_mode html
return 0
}
[[ -d /etc/bot/suspensos/${message_from_username} ]] && {
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
--text "$(echo -e "🚫 VC ESTA SUSPENSO 🚫\n\nCONTATE O ADMINISTRADOR")"
return 0
}
if [[ "$(grep -w "${message_from_username}" $ativos | grep -wc 'revenda')" != '0' ]]; then
local env_msg
env_msg="=×=×=×=×=×=×=×=×=×=×=×=×=×=×=×=×=\n"
env_msg+="<b>SEJA BEM VINDO(a) AO BOT PWEB</b>\n"
env_msg+="=×=×=×=×=×=×=×=×=×=×=×=×=×=×=×=×=\n\n"
env_msg+="⚠️ <i>SELECIONE UMA OPCAO ABAIXO !</i>\n\n"
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} --text "$env_msg" \
--reply_markup "$keyboard2" \
--parse_mode html
return 0
elif [[ "$(grep -w "${message_from_username}" $ativos | grep -wc 'subrevenda')" != '0' ]]; then
local env_msg
env_msg="=×=×=×=×=×=×=×=×=×=×=×=×=×=×=×=×=\n"
env_msg+="<b>SEJA BEM VINDO(a) AO BOT PWEB</b>\n"
env_msg+="=×=×=×=×=×=×=×=×=×=×=×=×=×=×=×=×=\n\n"
env_msg+="⚠️ <i>SELECIONE UMA OPCAO ABAIXO !</i>\n\n"
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} --text "$env_msg" \
--reply_markup "$keyboard3" \
--parse_mode html
return 0
else
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
--text "$(echo -e 🚫 ACESSO NEGADO 🚫)"
return 0
fi
}
fun_ajuda() {
[[ ${message_chat_id[$id]} == "" ]] && {
id_chatuser="${callback_query_message_chat_id[$id]}"
id_name="${callback_query_from_username}"
} || {
id_chatuser="${message_chat_id[$id]}"
id_name="${message_from_username}"
}
if [[ "$id_chatuser" = "$id_admin" ]]; then
local env_msg
env_msg="=×=×=×=×=×=×=×=×=×=×=×=×=×=\n"
env_msg+="<b>BEM VINDO(a) AO BOT PWEB</b>\n"
env_msg+="=×=×=×=×=×=×=×=×=×=×=×=×=×=\n\n"
env_msg+="⚠️ <i>Comandos Disponiveis</i>\n\n"
env_msg+="[<b>01</b>] /menu = Exibe menu\n"
env_msg+="[<b>02</b>] /info = Exibe informacoes\n"
env_msg+="[<b>03</b>] /ajuda = Informacoes sobre opcoes\n\n"
env_msg+="⚠️ <i>Opções Disponiveis</i>\n\n"
env_msg+="• <u>INFO VPS</u> = Informacoes do servidor\n\n"
env_msg+="• <u>BACKUP</u> = Cria Backup do banco de dados\n\n"
env_msg+="• <u>OTIMIZAR</u> = Limpa o cache - ram\n\n"
env_msg+="• <u>SPEEDTESTE</u> = Teste de conexao\n\n"
env_msg+="• <u>ARQUIVOS</u> = Hospeda Arquivos\n\n"
env_msg+="• <u>AUTOBACKUP</u> = lig/Des Backup automatico\n\n"
env_msg+="• <u>AJUDA</u> = Informacoes sobre opcoes\n\n"
ShellBot.sendMessage --chat_id $id_chatuser \
--text "$(echo -e $env_msg)" \
--parse_mode html
return 0
elif [[ -d /etc/bot/suspensos/$id_name ]]; then
ShellBot.sendMessage --chat_id $id_chatuser \
--text "$(echo -e "🚫 VC ESTA SUSPENSO 🚫\n\nCONTATE O ADMINISTRADOR")"
return 0
elif [[ "$(grep -w "$id_name" $ativos | awk '{print $NF}')" == 'revenda' ]]; then
local env_msg
env_msg="=×=×=×=×=×=×=×=×=×=×=×=×=×=\n"
env_msg+="<b>BEM VINDO(a) AO BOT PWEB</b>\n"
env_msg+="=×=×=×=×=×=×=×=×=×=×=×=×=×=\n\n"
env_msg+="⚠️ <i>Comandos Disponiveis</i>\n\n"
env_msg+="[<b>01</b>] /menu = Exibe menu\n"
env_msg+="[<b>02</b>] /info = Exibe informacoes\n"
env_msg+="[<b>03</b>] /ajuda = Informacoes sobre opcoes\n\n"
env_msg+="⚠️ <i>Opções Disponiveis</i>\n\n"
env_msg+="• <u>CRIAR USUARIO</u> = Cria usuario ssh\n\n"
env_msg+="• <u>CRIAR TESTE</u> = Cria teste ssh\n\n"
env_msg+="• <u>REMOVER</u> = Remove usuario ssh\n\n"
env_msg+="• <u>INFO USUARIOS</u> = Informacoes do usuario\n\n"
env_msg+="• <u>USUARIOS ONLINE</u> = Exibe Usuários onlines\n\n"
env_msg+="• <u>ALTERAR SENHA</u> = Altera senha ssh\n\n"
env_msg+="• <u>ALTERAR LIMITE</u> = Altera limite ssh\n\n"
env_msg+="• <u>ALTERAR DATA</u> = Altera data ssh\n\n"
env_msg+="• <u>EXPIRADOS</u> = Remove ssh expirados\n\n"
env_msg+="• <u>REVENDAS</u> = Gerenciar Revendas\n\n"
env_msg+="• <u>RELATORIO</u> = Informacoes sobre revendas\n\n"
env_msg+="• <u>AJUDA</u> = Informacoes sobre opcoes\n\n"
ShellBot.sendMessage --chat_id $id_chatuser \
--text "$(echo -e $env_msg)" \
--parse_mode html
return 0
elif [[ "$(grep -w "$id_name" $ativos | awk '{print $NF}')" == 'subrevenda' ]]; then
local env_msg
env_msg="=×=×=×=×=×=×=×=×=×=×=×=×=×=\n"
env_msg+="<b>BEM VINDO(a) AO BOT PWEB</b>\n"
env_msg+="=×=×=×=×=×=×=×=×=×=×=×=×=×=\n\n"
env_msg+="⚠️ <i>Comandos Disponiveis</i>\n\n"
env_msg+="[<b>01</b>] /menu = Exibe menu\n"
env_msg+="[<b>02</b>] /info = Exibe informacoes\n"
env_msg+="[<b>03</b>] /ajuda = Informacoes sobre opcoes\n\n"
env_msg+="⚠️ <i>Opções Disponiveis</i>\n\n"
env_msg+="• <u>CRIAR USUARIO</u> = Cria usuario ssh\n\n"
env_msg+="• <u>CRIAR TESTE</u> = Cria teste ssh\n\n"
env_msg+="• <u>REMOVER</u> = Remove usuario ssh\n\n"
env_msg+="• <u>INFO USUARIOS</u> = Informacoes do usuario\n\n"
env_msg+="• <u>USUARIOS ONLINE</u> = Exibe Usuários onlines\n\n"
env_msg+="• <u>ALTERAR SENHA</u> = Altera senha ssh\n\n"
env_msg+="• <u>ALTERAR LIMITE</u> = Altera limite ssh\n\n"
env_msg+="• <u>ALTERAR DATA</u> = Altera data ssh\n\n"
env_msg+="• <u>EXPIRADOS</u> = Remove ssh expirados\n\n"
env_msg+="• <u>AJUDA</u> = Informacoes sobre opcoes\n\n"
ShellBot.sendMessage --chat_id $id_chatuser \
--text "$(echo -e $env_msg)" \
--parse_mode html
return 0
else
ShellBot.sendMessage --chat_id $id_chatuser \
--text "$(echo -e 🚫 ACESSO NEGADO 🚫)"
return 0
fi
}
verifica_acesso() {
[[ "${message_from_id[$id]}" != "$id_admin" ]] && {
[[ "$(grep -wc ${message_from_username} $suspensos)" != '0' ]] || [[ "$(grep -wc ${message_from_username} $ativos)" == '0' ]] && {
_erro="1"
return 0
}
}
}
fun_adduser() {
[[ "$(grep -wc ${callback_query_from_username} $suspensos)" != '0' ]] && {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "⚠️ VC ESTA SUSPENSO! CONTATE O ADMINISTRADOR"
return 0
}
[[ "${callback_query_from_id[$id]}" == "$id_admin" ]] || [[ "$(grep -wc ${callback_query_from_username} $ativos)" != '0' ]] && {
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "👤 CRIAR USUARIO 👤\n\nNome do usuario:" \
--reply_markup "$(ShellBot.ForceReply)"
} || {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "🚫 ACESSO NEGADO 🚫"
return 0
}
}
criar_user() {
IP=$(cat /etc/IP)
newclient() {
cp /etc/openvpn/client-common.txt ~/$1.ovpn
echo "<ca>" >>~/$1.ovpn
cat /etc/openvpn/easy-rsa/pki/ca.crt >>~/$1.ovpn
echo "</ca>" >>~/$1.ovpn
echo "<cert>" >>~/$1.ovpn
cat /etc/openvpn/easy-rsa/pki/issued/$1.crt >>~/$1.ovpn
echo "</cert>" >>~/$1.ovpn
echo "<key>" >>~/$1.ovpn
cat /etc/openvpn/easy-rsa/pki/private/$1.key >>~/$1.ovpn
echo "</key>" >>~/$1.ovpn
echo "<tls-auth>" >>~/$1.ovpn
cat /etc/openvpn/ta.key >>~/$1.ovpn
echo "</tls-auth>" >>~/$1.ovpn
}
file_user=$1
usuario=$(sed -n '1 p' $file_user | cut -d' ' -f2)
senha=$(sed -n '2 p' $file_user | cut -d' ' -f2)
limite=$(sed -n '3 p' $file_user | cut -d' ' -f2)
data=$(sed -n '4 p' $file_user | cut -d' ' -f2)
validade=$(echo "$data" | awk -F'/' '{print $2FS$1FS$3}' | xargs -i date -d'{}' +%Y-%m-%d)
if /usr/sbin/useradd -M -N -s /bin/false $usuario -e $validade; then
(
echo "${senha}"
echo "${senha}"
) | passwd "${usuario}"
else
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
--text "$(echo -e "❌ ERRO AO CRIAR USUARIO ❌")" \
--parse_mode html
return 0
fi
[[ "${message_from_id[$id]}" != "$id_admin" ]] && {
echo "$usuario:$senha:$info_data:$limite" >/etc/bot/revenda/${message_from_username}/usuarios/$usuario
echo "$usuario:$senha:$info_data:$limite" >/etc/bot/info-users/$usuario
}
echo "$usuario $limite" >>/root/usuarios.db
echo "$senha" >/etc/SSHPlus/senha/$usuario
[[ -e "/etc/openvpn/server.conf" ]] && {
cd /etc/openvpn/easy-rsa/
./easyrsa build-client-full $usuario nopass
newclient "$usuario"
}
echo "usuario $usuario $validade $senha criado"
}
fun_deluser() {
[[ "$(grep -wc ${callback_query_from_username} $suspensos)" != '0' ]] && {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "⚠️ VC ESTA SUSPENSO! CONTATE O ADMINISTRADOR"
return 0
}
[[ "${callback_query_from_id[$id]}" == "$id_admin" ]] || [[ "$(grep -wc ${callback_query_from_username} $ativos)" != '0' ]] && {
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "🗑 REMOVER USUARIO 🗑\n\nNome do usuario:" \
--reply_markup "$(ShellBot.ForceReply)"
} || {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "🚫 ACESSO NEGADO 🚫"
return 0
}
}
fun_del_user() {
usuario=$1
[[ "${message_from_id[$id]}" = "$id_admin" ]] && {
piduser=$(ps -u "$usuario" | grep sshd | cut -d? -f1)
kill -9 $piduser >/dev/null 2>&1
userdel --force "$usuario" 2>/dev/null
grep -v ^$usuario[[:space:]] /root/usuarios.db >/tmp/ph
cat /tmp/ph >/root/usuarios.db
rm /etc/SSHPlus/senha/$usuario >/dev/null 2>&1
} || {
[[ ! -e /etc/bot/revenda/${message_from_username}/usuarios/$usuario ]] && {
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
--text "$(echo -e "❌ O USUARIO NAO EXISTE ❌")" \
--parse_mode html
_erro='1'
return 0
}
piduser=$(ps -u "$usuario" | grep sshd | cut -d? -f1)
kill -9 $piduser >/dev/null 2>&1
userdel --force "$usuario" 2>/dev/null
grep -v ^$usuario[[:space:]] /root/usuarios.db >/tmp/ph
cat /tmp/ph >/root/usuarios.db
rm /etc/SSHPlus/senha/$usuario >/dev/null 2>&1
rm /etc/bot/revenda/${message_from_username}/usuarios/$usuario
rm /etc/bot/info-users/$usuario
}
[[ -e /etc/SSHPlus/userteste/$usuario.sh ]] && rm /etc/SSHPlus/userteste/$usuario.sh
[[ -e "/etc/openvpn/easy-rsa/pki/private/$usuario.key" ]] && {
[[ -e /etc/debian_version ]] && GROUPNAME=nogroup
cd /etc/openvpn/easy-rsa/
./easyrsa --batch revoke $usuario
./easyrsa gen-crl
rm -rf pki/reqs/$usuario.req
rm -rf pki/private/$usuario.key
rm -rf pki/issued/$usuario.crt
rm -rf /etc/openvpn/crl.pem
cp /etc/openvpn/easy-rsa/pki/crl.pem /etc/openvpn/crl.pem
chown nobody:$GROUPNAME /etc/openvpn/crl.pem
[[ -e $HOME/$usuario.ovpn ]] && rm $HOME/$usuario.ovpn >/dev/null 2>&1
}
}
alterar_senha() {
[[ "$(grep -wc ${callback_query_from_username} $suspensos)" != '0' ]] && {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "⚠️ VC ESTA SUSPENSO! CONTATE O ADMINISTRADOR"
return 0
}
[[ "${callback_query_from_id[$id]}" == "$id_admin" ]] || [[ "$(grep -wc ${callback_query_from_username} $ativos)" != '0' ]] && {
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "🔐 Alterar Senha 🔐\n\nNome do usuario:" \
--reply_markup "$(ShellBot.ForceReply)"
} || {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "🚫 ACESSO NEGADO 🚫"
return 0
}
}
alterar_senha_user() {
usuario=$1
senha=$2
echo "$usuario:$senha" | chpasswd
echo "$senha" >/etc/SSHPlus/senha/$usuario
[[ -e /etc/bot/revenda/${message_from_username}/usuarios/$usuario ]] && {
senha2=$(cat /etc/bot/revenda/${message_from_username}/usuarios/$usuario | awk -F : {'print $2'})
sed -i "/$usuario/ s/\b$senha2\b/$senha/g" /etc/bot/revenda/${message_from_username}/usuarios/$usuario
sed -i "/$usuario/ s/\b$senha2\b/$senha/g" /etc/bot/info-users/$usuario
}
[[ $(ps -u $usuario | grep sshd | wc -l) != '0' ]] && pkill -u $usuario >/dev/null 2>&1
}
alterar_limite() {
[[ "$(grep -wc ${callback_query_from_username} $suspensos)" != '0' ]] && {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "⚠️ VC ESTA SUSPENSO! CONTATE O ADMINISTRADOR"
return 0
}
[[ "${callback_query_from_id[$id]}" == "$id_admin" ]] || [[ "$(grep -wc ${callback_query_from_username} $ativos)" != '0' ]] && {
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "👥 Alterar Limite 👥\n\nNome do usuario:" \
--reply_markup "$(ShellBot.ForceReply)"
} || {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "🚫 ACESSO NEGADO 🚫"
return 0
}
}
alterar_limite_user() {
usuario=$1
limite=$2
database="/root/usuarios.db"
[[ "${message_from_id[$id]}" == "$id_admin" ]] && {
grep -v ^$usuario[[:space:]] /root/usuarios.db >/tmp/a
mv /tmp/a /root/usuarios.db
echo $usuario $limite >>/root/usuarios.db
return 0
}
[[ -d /etc/bot/revenda/${message_from_username} ]] && {
[[ ! -e /etc/bot/revenda/${message_from_username}/usuarios/$usuario ]] && {
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
--text "$(echo -e "❌ O USUARIO NAO EXISTE ❌")" \
--parse_mode html
_erro='1'
return 0
}
_limTotal=$(grep -w 'LIMITE_REVENDA' /etc/bot/revenda/${message_from_username}/${message_from_username} | awk '{print $NF}')
[[ "$limite" -gt "$_limTotal" ]] && {
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
--text "$(echo -e "❌ VC NAO TEM LIMITE SUFICIENTE ❌\n\nLimite Atual: $_limTotal ")" \
--parse_mode html
_erro='1'
return 0
}
_limTotal=$(grep -w "${message_from_username}" $ativos | awk '{print $4}')
fun_verif_limite_rev ${message_from_username}
_limsomarev2=$(echo "$_result + $limite" | bc)
echo "Total $_limsomarev2"
[[ "$_limsomarev2" -gt "$_limTotal" ]] && {
[[ "$_limTotal" == "$(($_limTotal - $_result))" ]] && _restant1='0' || _restant1=$(($_limTotal - $_result))
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
--text "$(echo -e "❌ Vc nao tem limite suficiente\n\nLimite restante: $_restant1 ")" \
--parse_mode html
_erro='1'
return 0
}
grep -v ^$usuario[[:space:]] /root/usuarios.db >/tmp/a
mv /tmp/a /root/usuarios.db
echo $usuario $limite >>/root/usuarios.db
limite2=$(cat /etc/bot/revenda/${message_from_username}/usuarios/$usuario | awk -F : {'print $4'})
sed -i "/\b$usuario\b/ s/\b$limite2\b/$limite/" /etc/bot/revenda/${message_from_username}/usuarios/$usuario
sed -i "/\b$usuario\b/ s/\b$limite2\b/$limite/" /etc/bot/info-users/$usuario
}
}
alterar_data() {
[[ "$(grep -wc ${callback_query_from_username} $suspensos)" != '0' ]] && {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "⚠️ VC ESTA SUSPENSO! CONTATE O ADMINISTRADOR"
return 0
}
[[ "${callback_query_from_id[$id]}" == "$id_admin" ]] || [[ "$(grep -wc ${callback_query_from_username} $ativos)" != '0' ]] && {
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "⏳ Alterar Data ⏳\n\nNome do usuario:" \
--reply_markup "$(ShellBot.ForceReply)"
} || {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "🚫 ACESSO NEGADO 🚫"
return 0
}
}
alterar_data_user() {
usuario=$1
inputdate=$2
database="/root/usuarios.db"
[[ "$(echo -e "$inputdate" | sed -e 's/[^/]//ig')" != '//' ]] && {
udata=$(date "+%d/%m/%Y" -d "+$inputdate days")
sysdate="$(echo "$udata" | awk -v FS=/ -v OFS=- '{print $3,$2,$1}')"
} || {
udata=$(echo -e "$inputdate")
sysdate="$(echo -e "$inputdate" | awk -v FS=/ -v OFS=- '{print $3,$2,$1}')"
today="$(date -d today +"%Y%m%d")"
timemachine="$(date -d "$sysdate" +"%Y%m%d")"
[ $today -ge $timemachine ] && {
verify='1'
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
--text "$(echo -e "❌ Erro! Data invalida")" \
--parse_mode html
_erro='1'
return 0
}
}
chage -E $sysdate $usuario
[[ -e /etc/bot/revenda/${message_from_username}/usuarios/$usuario ]] && {
data2=$(cat /etc/bot/info-users/$usuario | awk -F : {'print $3'})
sed -i "s;$data2;$udata;" /etc/bot/info-users/$usuario
echo $usuario $udata ${message_from_username}
sed -i "s;$data2;$udata;" /etc/bot/revenda/${message_from_username}/usuarios/$usuario
}
}
ver_users() {
if [[ "${callback_query_from_id[$id]}" == "$id_admin" ]]; then
arq_info=/tmp/$(echo $RANDOM)
local info_users
info_users='=×=×=×=×=×=×=×=×=×=×=×=×=×=\n'
info_users+='<b>INFORMACOES DOS USUARIOS</b>\n'
info_users+='=×=×=×=×=×=×=×=×=×=×=×=×=×=\n\n'
info_users+='⚠️ Exibe no formato abaixo:\n\n'
info_users+='<code>USUÁRIO SENHA LIMITE DATA</code>\n'
ShellBot.sendMessage --chat_id $id_admin \
--text "$(echo -e $info_users)" \
--parse_mode html
fun_infu() {
local info
for user in $(cat /etc/passwd | awk -F : '$3 >= 1000 {print $1}' | grep -v nobody); do
info='===========================\n'
[[ -e /etc/SSHPlus/senha/$user ]] && senha=$(cat /etc/SSHPlus/senha/$user) || senha='Null'
[[ $(grep -wc $user $HOME/usuarios.db) != '0' ]] && limite=$(grep -w $user $HOME/usuarios.db | cut -d' ' -f2) || limite='Null'
datauser=$(chage -l $user | grep -i co | awk -F : '{print $2}')
[[ $datauser = ' never' ]] && {
data="00/00/00"
} || {
databr="$(date -d "$datauser" +"%Y%m%d")"
hoje="$(date -d today +"%Y%m%d")"
[[ $hoje -ge $databr ]] && {
data="Venceu"
} || {
dat="$(date -d"$datauser" '+%Y-%m-%d')"
data=$(echo -e "$((($(date -ud $dat +%s) - $(date -ud $(date +%Y-%m-%d) +%s)) / 86400)) DIAS")
}
}
info+="$user • $senha • $limite • $data"
echo -e "$info"
done
}
fun_infu >$arq_info
while :; do
ShellBot.sendMessage --chat_id $id_admin \
--text "$(while read linha; do echo $linha; done < <(sed '1,30!d' $arq_info))" \
--parse_mode html
sed -i 1,30d $arq_info
[[ $(cat $arq_info | wc -l) = '0' ]] && rm $arq_info && break
done
elif [[ "$(grep -wc "${callback_query_from_username}" $ativos)" != '0' ]]; then
[[ "$(grep -wc ${callback_query_from_username} $suspensos)" != '0' ]] && {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "⚠️ VC ESTA SUSPENSO! CONTATE O ADMINISTRADOR"
return 0
}
[[ $(ls /etc/bot/revenda/${callback_query_from_username}/usuarios | wc -l) == '0' ]] && {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "VC AINDA NAO CRIOU USUARIO!"
return 0
}
arq_info=/tmp/$(echo $RANDOM)
local info_users
info_users='=×=×=×=×=×=×=×=×=×=×=×=×=×=\n'
info_users+='<b>INFORMACOES DOS USUARIOS</b>\n'
info_users+='=×=×=×=×=×=×=×=×=×=×=×=×=×=\n\n'
info_users+='⚠️ Exibe no formato abaixo:\n\n'
info_users+='<code>USUÁRIO SENHA LIMITE DATA</code>\n'
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "$(echo -e $info_users)" \
--parse_mode html
fun_infu() {
local info
for user in $(ls /etc/bot/revenda/${callback_query_from_username}/usuarios); do
info='===========================\n'
[[ -e /etc/SSHPlus/senha/$user ]] && senha=$(cat /etc/SSHPlus/senha/$user) || senha='Null'
[[ $(grep -wc $user $HOME/usuarios.db) != '0' ]] && limite=$(grep -w $user $HOME/usuarios.db | cut -d' ' -f2) || limite='Null'
datauser=$(chage -l $user | grep -i co | awk -F : '{print $2}')
[[ $datauser = ' never' ]] && {
data="00/00/00"
} || {
databr="$(date -d "$datauser" +"%Y%m%d")"
hoje="$(date -d today +"%Y%m%d")"
[[ $hoje -ge $databr ]] && {
data="Venceu"
} || {
dat="$(date -d"$datauser" '+%Y-%m-%d')"
data=$(echo -e "$((($(date -ud $dat +%s) - $(date -ud $(date +%Y-%m-%d) +%s)) / 86400)) DIAS")
}
}
info+="$user • $senha • $limite • $data"
echo -e "$info"
done
}
fun_infu >$arq_info
while :; do
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "$(while read linha; do echo $linha; done < <(sed '1,30!d' $arq_info))" \
--parse_mode html
sed -i 1,30d $arq_info
[[ $(cat $arq_info | wc -l) = '0' ]] && rm $arq_info && break
done
else
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "$(echo -e 🚫 ACESSO NEGADO 🚫)"
return 0
fi
}
fun_drop() {
port_dropbear=$(ps aux | grep dropbear | awk NR==1 | awk '{print $17;}')
log=/var/log/auth.log
loginsukses='Password auth succeeded'
pids=$(ps ax | grep dropbear | grep " $port_dropbear" | awk -F" " '{print $1}')
for pid in $pids; do
pidlogs=$(grep $pid $log | grep "$loginsukses" | awk -F" " '{print $3}')
i=0
for pidend in $pidlogs; do
let i=i+1
done
if [ $pidend ]; then
login=$(grep $pid $log | grep "$pidend" | grep "$loginsukses")
PID=$pid
user=$(echo $login | awk -F" " '{print $10}' | sed -r "s/'/ /g")
waktu=$(echo $login | awk -F" " '{print $2"-"$1,$3}')
while [ ${#waktu} -lt 13 ]; do
waktu=$waktu" "
done
while [ ${#user} -lt 16 ]; do
user=$user" "
done
while [ ${#PID} -lt 8 ]; do
PID=$PID" "
done
echo "$user $PID $waktu"
fi
done
}
monitor_ssh() {
if [[ "${callback_query_from_id[$id]}" == "$id_admin" ]]; then
database="/root/usuarios.db"
cad_onli=/tmp/$(echo $RANDOM)
local info_on
info_on='=×=×=×=×=×=×=×=×=×=×=×=×=×=\n'
info_on+='<b>MONITOR USUARIOS ONLINES</b>\n'
info_on+='=×=×=×=×=×=×=×=×=×=×=×=×=×=\n\n'
info_on+='⚠️ Exibe no formato abaixo:\n\n'
info_on+='<code>USUÁRIO ONLINE/LIMITE TEMPO\n</code>'
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "$(echo -e $info_on)" \
--parse_mode html
fun_online() {
local info2
for user in $(cat /etc/passwd | awk -F : '$3 >= 1000 {print $1}' | grep -v nobody); do
[[ "$(grep -w $user $database)" != "0" ]] && lim="$(grep -w $user $database | cut -d' ' -f2)" || lim=0
[[ $(netstat -nltp | grep 'dropbear' | wc -l) != '0' ]] && drop="$(fun_drop | grep "$user" | wc -l)" || drop=0
[[ -e /etc/openvpn/openvpn-status.log ]] && ovp="$(cat /etc/openvpn/openvpn-status.log | grep -E ,"$user", | wc -l)" || ovp=0
sqd="$(ps -u $user | grep sshd | wc -l)"
_cont=$(($drop + $ovp))
conex=$(($_cont + $sqd))
[[ $conex -gt '0' ]] && {
timerr="$(ps -o etime $(ps -u $user | grep sshd | awk 'NR==1 {print $1}') | awk 'NR==2 {print $1}')"
info2+="===========================\n"
info2+="🟢 $user $conex/$lim ⏳$timerr\n"
}
done
echo -e "$info2"
}
fun_online >$cad_onli
[[ $(cat $cad_onli | wc -w) != '0' ]] && {
while :; do
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "$(while read linha; do echo $linha; done < <(sed '1,30!d' $cad_onli))" \
--parse_mode html
sed -i 1,30d $cad_onli
[[ "$(cat $cad_onli | wc -l)" = '0' ]] && {
rm $cad_onli
break
}
done
} || {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "Nenhum usuario online" \
--parse_mode html
return 0
}
elif [[ "$(grep -wc "${callback_query_from_username}" $ativos)" != '0' ]]; then
[[ "$(grep -wc ${callback_query_from_username} $suspensos)" != '0' ]] && {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "⚠️ VC ESTA SUSPENSO! CONTATE O ADMINISTRADOR"
return 0
}
[[ $(ls /etc/bot/revenda/${callback_query_from_username}/usuarios | wc -l) == '0' ]] && {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "VC AINDA NAO CRIOU USUARIO!"
return 0
}
database="/root/usuarios.db"
cad_onli=/tmp/$(echo $RANDOM)
local info_on
info_on='=×=×=×=×=×=×=×=×=×=×=×=×=×=\n'
info_on+='<b>MONITOR USUARIOS ONLINES</b>\n'
info_on+='=×=×=×=×=×=×=×=×=×=×=×=×=×=\n\n'
info_on+='⚠️ Exibe no formato abaixo:\n\n'
info_on+='<code>USUÁRIO ONLINE/LIMITE TEMPO\n</code>'
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "$(echo -e $info_on)" \
--parse_mode html
fun_online() {
local info2
for user in $(ls /etc/bot/revenda/${callback_query_from_username}/usuarios); do
[[ "$(grep -w $user $database)" != "0" ]] && lim="$(grep -w $user $database | cut -d' ' -f2)" || lim=0
[[ $(netstat -nltp | grep 'dropbear' | wc -l) != '0' ]] && drop="$(fun_drop | grep "$user" | wc -l)" || drop=0
[[ -e /etc/openvpn/openvpn-status.log ]] && ovp="$(cat /etc/openvpn/openvpn-status.log | grep -E ,"$user", | wc -l)" || ovp=0
sqd="$(ps -u $user | grep sshd | wc -l)"
conex=$(($sqd + $ovp + $drop))
[[ $conex -gt '0' ]] && {
timerr="$(ps -o etime $(ps -u $user | grep sshd | awk 'NR==1 {print $1}') | awk 'NR==2 {print $1}')"
info2+="------------------------------\n"
info2+="👤$user $conex/$lim ⏳$timerr\n"
}
done
echo -e "$info2"
}
fun_online >$cad_onli
[[ $(cat $cad_onli | wc -w) != '0' ]] && {
while :; do
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "<code>$(while read linha; do echo $linha; done < <(sed '1,30!d' $cad_onli))</code>" \
--parse_mode html
sed -i 1,30d $cad_onli
[[ "$(cat $cad_onli | wc -l)" = '0' ]] && {
rm $cad_onli
break
}
done
} || {
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "Nenhum usuario online" \
--parse_mode html
return 0
}
else
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "$(echo -e 🚫 ACESSO NEGADO 🚫)"
return 0
fi
}
fun_verif_user() {
user=$1
[[ -z "$user" ]] && {
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
--text "$(echo -e "Erro")" \
--parse_mode html
return 0
}
[[ "${message_from_id[$id]}" == "$id_admin" ]] && {
[[ "$(awk -F : '$3 >= 1000 { print $1 }' /etc/passwd | grep -wc $user)" == '0' ]] && {
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
--text "$(echo -e ❌ Usuario $user não existe !)" \
--parse_mode html
_erro='1'
return 0
}
}
[[ -d /etc/bot/revenda/${message_from_username} ]] && {
[[ ! -e /etc/bot/revenda/${message_from_username}/usuarios/$user ]] && {
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
--text "$(echo -e ❌ Usuario $user nao existe !)" \
--parse_mode html
_erro='1'
return 0
}
}
}
fun_down() {
[[ "${callback_query_from_id[$id]}" != "$id_admin" ]] && {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "🚫 ACESSO NEGADO 🚫"
return 0
}
[[ ! -d /tmp/file ]] && mkdir /tmp/file
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "[1] - ADICIONAR ARQUIVO\n[2] - EXCLUIR ARQUIVO\n\nInforme a opcao [1-2]:" \
--reply_markup "$(ShellBot.ForceReply)"
}
infovps() {
[[ "${callback_query_from_id[$id]}" != "$id_admin" ]] && {
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "$(echo -e 🚫 ACESSO NEGADO 🚫)"
return 0
}
PTs='/tmp/prts'
_ons=$(ps -x | grep sshd | grep -v root | grep priv | wc -l)
[[ -e /etc/openvpn/openvpn-status.log ]] && _onop=$(grep -c "10.8.0" /etc/openvpn/openvpn-status.log) || _onop="0"
[[ -e /etc/default/dropbear ]] && _drp=$(ps aux | grep dropbear | grep -v grep | wc -l) _ondrp=$(($_drp - 1)) || _ondrp="0"
_on=$(($_ons + $_onop + $_ondrp))
total=$(awk -F: '$3>=1000 {print $1}' /etc/passwd | grep -v nobody | wc -l)
system=$(cat /etc/issue.net)
uso=$(top -bn1 | awk '/Cpu/ { cpu = "" 100 - $8 "%" }; END { print cpu }')
cpucores=$(grep -c cpu[0-9] /proc/stat)
ram1=$(free -h | grep -i mem | awk {'print $2'})
usoram=$(free -m | awk 'NR==2{printf "%.2f%%\t\t", $3*100/$2 }')
total=$(cat -n /root/usuarios.db | tail -n 1 | awk '{print $1}')
echo -e "SSH: $(grep 'Port' /etc/ssh/sshd_config | cut -d' ' -f2 | grep -v 'no' | xargs)" >$PTs
[[ -e "/etc/stunnel/stunnel.conf" ]] && echo -e "SSL Tunel: $(netstat -nplt | grep 'stunnel' | awk {'print $4'} | cut -d: -f2 | xargs)" >>$PTs
[[ -e "/etc/openvpn/server.conf" ]] && echo -e "Openvpn: $(netstat -nplt | grep 'openvpn' | awk {'print $4'} | cut -d: -f2 | xargs)" >>$PTs
[[ "$(netstat -nplt | grep 'sslh' | wc -l)" != '0' ]] && echo -e "SSlh: $(netstat -nplt | grep 'sslh' | awk {'print $4'} | cut -d: -f2 | xargs)" >>$PTs
[[ "$(netstat -nplt | grep 'squid' | wc -l)" != '0' ]] && echo -e "Squid: $(netstat -nplt | grep 'squid' | awk -F ":" {'print $4'} | xargs)" >>$PTs
[[ "$(netstat -nltp | grep 'dropbear' | wc -l)" != '0' ]] && echo -e "DropBear: $(netstat -nplt | grep 'dropbear' | awk -F ":" {'print $4'} | xargs)" >>$PTs
[[ "$(netstat -nplt | grep 'python' | wc -l)" != '0' ]] && echo -e "Proxy Socks: $(netstat -nplt | grep 'python' | awk {'print $4'} | cut -d: -f2 | xargs)" >>$PTs
local info
info="=×=×=×=×=×=×=×=×=×=×=×=×=×=\n"
info+="<b>INFORMACOES DO SERVIDOR</b>\n"
info+="=×=×=×=×=×=×=×=×=×=×=×=×=×=\n\n"
info+="<b>SISTEMA OPERACIONAL</b>\n"
info+="$system\n\n"
info+="<b>PROCESSADOR</b>\n"
info+="<b>Nucleos:</b> $cpucores\n"
info+="<b>Ultilizacao:</b> $uso\n\n"
info+="<b>MEMORIA RAM</b>\n"
info+="<b>Total:</b> $ram1\n"
info+="<b>Ultilizacao:</b> $usoram\n\n"
while read linha; do
info+="<b>$(echo -e "$linha")</b>\n"
done < <(cat $PTs)
info+="\n<b>$total</b><i> USUARIOS</i><b> $_on</b> <i>ONLINE</i>"
ShellBot.sendMessage --chat_id $id_admin \
--text "$(echo -e $info)" \
--parse_mode html
return 0
}
fun_download() {
Opc=$1
[[ -z "$Opc" ]] && {
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
--text "$(echo -e "❌Erro tente novamente")"
_erro='1'
return 0
}
_file2=$2
[[ -z "$_file2" ]] && {
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
--text "$(echo -e "❌Erro tente novamente")"
_erro='1'
return 0
}
_DirArq=$(ls /root/backupvps)
i=0
unset _Pass
while read _Arq; do
i=$(expr $i + 1)
_oP=$i
[[ $i == [1-9] ]] && i=0$i && oP+=" 0$i"
echo -e "[$i] - $_Arq"
_Pass+="\n${_oP}:${_Arq}"
done <<<"${_DirArq}"
_file=$(echo -e "${_Pass}" | grep -E "\b$Opc\b" | cut -d: -f2)
echo $_file2
ShellBot.sendDocument --chat_id ${message_from_id[$id]} \
--document "@/root/backupvps/$_file" \
--caption "$(echo -e "✅ CRIADO COM SUCESSO ✅\n\nUSUARIO: <code>$(awk -F " " '/Nome/ {print $2}' $_file2)</code>\nSENHA: <code>$(awk -F " " '/Senha/ {print $2}' $_file2)</code>\nLIMITE: $(awk -F " " '/Limite/ {print $2}' $_file2)\nEXPIRA EM: $(awk -F " " '/Validade/ {print $2}' $_file2)")" \
--parse_mode html
[[ -e "/root/$(awk -F " " '/Nome/ {print $2}' $_file2).ovpn" ]] && {
ShellBot.sendDocument --chat_id ${message_from_id[$id]} \
--document "@/root/$(awk -F " " '/Nome/ {print $2}' $_file2).ovpn"
}
}
otimizer() {
[[ "${callback_query_from_id[$id]}" != "$id_admin" ]] && {
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "$(echo -e 🚫 ACESSO NEGADO 🚫)"
return 0
}
MEM1=$(free | awk '/Mem:/ {print int(100*$3/$2)}')
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "🧹 LIMPANDO CACHE DO SERVIDOR"
apt-get autoclean -y
echo 3 >/proc/sys/vm/drop_caches
sync && sysctl -w vm.drop_caches=3 1>/dev/null 2>/dev/null
sysctl -w vm.drop_caches=0 1>/dev/null 2>/dev/null
swapoff -a
swapon -a
ram1=$(free -h | grep -i mem | awk {'print $2'})
ram2=$(free -h | grep -i mem | awk {'print $3'})
ram3=$(free -h | grep -i mem | awk {'print $4'})
MEM2=$(free | awk '/Mem:/ {print int(100*$3/$2)}')
res=$(expr $MEM1 - $MEM2)
local sucess
sucess="=×=×=×=×=×=×=×=×=×=×=×=×=×=\n"
sucess+="<b>OTIMIZADO COM SUCESSO !</b>\n"
sucess+="=×=×=×=×=×=×=×=×=×=×=×=×=×=\n\n"
sucess+="<i>Ultilizacao anterior</i> $MEM1%\n\n"
sucess+="<b>Memoria Ram Total</b> $ram1\n"
sucess+="<b>livre</b> $ram3\n"
sucess+="<b>Em uso</b> $ram2\n"
sucess+="<i>Ultilizacao atual</i> $MEM2%\n\n"
sucess+="<b>Economia de:</b> $res%"
ShellBot.sendMessage --chat_id $id_admin \
--text "$(echo -e $sucess)" \
--parse_mode html
return 0
}
speed_test() {
[[ "${callback_query_from_id[$id]}" != "$id_admin" ]] && {
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "$(echo -e 🚫 ACESSO NEGADO 🚫)"
return 0
}
rm /bin/ppweb/speed >/dev/null 2>&1
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "🚀 TESTANDO VELOCIDADE DO SERVIDOR 🚀"
testevelocidade --share > speed
png=$(cat speed | sed -n '5 p' |awk -F : {'print $NF'})
down=$(cat speed | sed -n '7 p' |awk -F : {'print $NF'})
upl=$(cat speed | sed -n '9 p' |awk -F : {'print $NF'})
host=$(cat speed | sed -n '2 p' |awk -F : {'print $NF'})
lnk=$(cat speed | sed -n '10 p' |awk -F : {'print $NF'})
local msg
msg="=×=×=×=×=×=×=×=×=×=×=×=×=×=\n"
msg+="<b>🚀 VELOCIDADE DO SERVIDOR 🚀</b>\n"
msg+="=×=×=×=×=×=×=×=×=×=×=×=×=×=\n\n"
msg+="<b>HOST SERVER:</b>$host\n"
msg+="<b>PING/LATENCIA:</b>$png\n"
msg+="<b>DOWNLOAD:</b>$down\n"
msg+="<b>UPLOAD:</b>$upl\n"
ShellBot.sendMessage --chat_id $id_admin \
--text "$(echo -e $msg)" \
--parse_mode html
ShellBot.sendMessage --chat_id $id_admin \
--text "$(echo -e $lnk)" \
--parse_mode html
rm /bin/ppweb/speed >/dev/null 2>&1
return 0
}
backup_users() {
[[ "${callback_query_from_id[$id]}" != "$id_admin" ]] && {
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "$(echo -e 🚫 ACESSO NEGADO 🚫)"
return 0
}
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "♻️ CRIANDO BACKUP DO BANCO DE DADOS"
cd /var/www/html/pages/system/ && bash cron.autobackup.sh && cd /root >/dev/null 2>&1 || exit
ShellBot.sendDocument --chat_id ${id_admin} \
--document "@/root/backupsql/sshplus.sql.bz2" \
--caption "$(echo -e "♻️ BACKUP DO BANCO DE DADOS ♻️")"
return 0
}
sobremim() {
local msg
msg="=×=×=×=×=×=×=×=×=×=×=×=×=×=\n"
msg+="<b>🤖 BOT PWEB 🤖</b>\n"
msg+="=×=×=×=×=×=×=×=×=×=×=×=×=×=\n\n"
msg+="<b>Desenvolvido por:</b> @swittecnologia\n"
msg+="<b>Canal Oficial:</b> @swittecnologia\n\n"
msg+="Fui criado com o propósito de fornecer informações e ferramentas para gestão em servidores 🐧 GNU/Linux 🐧.\n\n"
msg+="<b>Menu:</b> /menu\n"
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
--text "$(echo -e $msg)" \
--parse_mode html
return 0
}
fun_add_teste() {
if [[ "$(grep -wc ${callback_query_from_username} $suspensos)" != '0' ]]; then
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "⚠️ VC ESTA SUSPENSO! CONTATE O ADMINISTRADOR"
return 0
elif [[ "${callback_query_from_id[$id]}" == "$id_admin" ]]; then
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "👤 CRIAR TESTE 👤\n\nQuantas horas deve durar EX: 1:" \
--reply_markup "$(ShellBot.ForceReply)"
elif [[ "$(grep -wc ${callback_query_from_username} $ativos)" != '0' ]]; then
_limTotal=$(grep -w "${callback_query_from_username}" $ativos | awk '{print $4}')
fun_verif_limite_rev ${callback_query_from_username}
_limsomarev2=$(echo "$_result + 1" | bc)
[[ "$_limsomarev2" -gt "$_limTotal" ]] && {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "❌ VC NAO TEM LIMITE DISPONIVEL!"
return 0
} || {
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id[$id]} \
--text "👤 CRIAR TESTE 👤\n\nQuantas horas deve durar EX: 1:" \
--reply_markup "$(ShellBot.ForceReply)"
}
else
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "🚫 ACESSO NEGADO 🚫"
return 0
fi
}
fun_teste() {
usuario=$(echo teste$((RANDOM % +500)))
senha='1234'
limite='1'
t_time=$1
ex_date=$(date '+%d/%m/%C%y' -d " +2 days")
tuserdate=$(date '+%C%y/%m/%d' -d " +2 days")
[[ -z $t_time ]] && {
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
--text "$(echo -e "❌ Erro tente novamente")" \
--parse_mode html
return 0
_erro='1'
}
/usr/sbin/useradd -M -N -s /bin/false $usuario -e $tuserdate >/dev/null 2>&1
(
echo "$senha"
echo "$senha"
) | passwd $usuario >/dev/null 2>&1
echo "$senha" >/etc/SSHPlus/senha/$usuario
echo "$usuario $limite" >>/root/usuarios.db
[[ "${message_from_id[$id]}" != "$id_admin" ]] && {
echo "$usuario:$senha:$ex_date:$limite" >/etc/bot/revenda/${message_from_username}/usuarios/$usuario
}
dir_teste="/etc/bot/revenda/${message_from_username}/usuarios/$usuario"
cat <<-EOF >/etc/SSHPlus/userteste/$usuario.sh
#!/bin/bash
# USUARIO TESTE
[[ \$(ps -u "$usuario" | grep -c sshd) != '0' ]] && pkill -u $usuario
userdel --force $usuario
grep -v ^$usuario[[:space:]] /root/usuarios.db > /tmp/ph ; cat /tmp/ph > /root/usuarios.db
[[ -e $dir_teste ]] && rm $dir_teste
rm /etc/SSHPlus/senha/$usuario > /dev/null 2>&1
rm /etc/SSHPlus/userteste/$usuario.sh
EOF
chmod +x /etc/SSHPlus/userteste/$usuario.sh
echo "/etc/SSHPlus/userteste/$usuario.sh" | at now + $t_time hour >/dev/null 2>&1
[[ "$t_time" == '1' ]] && hrs="hora" || hrs="horas"
[[ "$(ls /root/backupvps | wc -l)" != '0' ]] && {
for arqv in $(ls /root/backupvps); do
ShellBot.sendDocument --chat_id ${message_from_id[$id]} \
--document "@/root/backupvps/$arqv" \
--caption "$(echo -e "✅ Criado com sucesso ✅\n\nUSUARIO: <code>$usuario</code>\nSENHA: <code>1234</code>\n\n⏳ Expira em: $t_time $hrs")" \
--parse_mode html
done
return 0
} || {
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} \
--text "$(echo -e "✅ <b>Criado com sucesso</b> ✅\n\nIP: $(cat /etc/IP)\nUSUARIO: <code>$usuario</code>\nSENHA: <code>1234</code>\n\n⏳ Expira em: $t_time $hrs")" \
--parse_mode html
return 0
}
}
fun_exp_user() {
if [[ "${callback_query_from_id[$id]}" == "$id_admin" ]]; then
[[ $(cat /root/usuarios.db | wc -l) == '0' ]] && {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "VC AINDA NAO CRIOU USUARIO!"
return 0
}
datenow=$(date +%s)
for user in $(cat /etc/passwd | awk -F : '$3 >= 1000 {print $1}' | grep -v nobody); do
expdate=$(chage -l $user | awk -F: '/Account expires/{print $2}')
echo $expdate | grep -q never && continue
datanormal=$(date -d"$expdate" '+%d/%m/%Y')
expsec=$(date +%s --date="$expdate")
diff=$(echo $datenow - $expsec | bc -l)
echo $diff | grep -q ^\- && continue
pkill -u $user
userdel --force $user
grep -v ^$user[[:space:]] /root/usuarios.db >/tmp/ph
cat /tmp/ph >/root/usuarios.db
[[ -e /etc/bot/info-users/$user ]] && rm /etc/bot/info-users/$user
[[ -e /etc/SSHPlus/userteste/$user.sh ]] && rm /etc/SSHPlus/userteste/$user.sh
[[ "$(ls /etc/bot/revenda)" != '0' ]] && {
for ex in $(ls /etc/bot/revenda); do
[[ -e /etc/bot/revenda/$exp/usuarios/$user ]] && rm /etc/bot/revenda/$ex/usuarios/$user
done
}
done
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "⌛️ USUARIOS SSH EXPIRADOS REMOVIDOS"
return 0
elif [[ "$(grep -wc "${callback_query_from_username}" $ativos)" != '0' ]]; then
[[ "$(grep -wc ${callback_query_from_username} $suspensos)" != '0' ]] && {
ShellBot.answerCallbackQuery --callback_query_id ${callback_query_id[$id]} \
--text "⚠️ VC ESTA SUSPENSO! CONTATE O ADMINISTRADOR"