This repository has been archived by the owner on Jul 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathauto-clam-antivirus.py
2776 lines (1991 loc) · 89.4 KB
/
auto-clam-antivirus.py
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
import subprocess
import time
def check_if_install():
### check_if_install
pro = subprocess.run('cat /opt/auto-clamIPS/auto-clamav/logs/install.log | grep -F herodium' ,capture_output=True ,shell=True)
print(pro.stdout)
if int(pro.returncode)==0:
subprocess.run(['sudo', 'python3', '/opt/auto-clamIPS/auto-clamav/reinstall.py'])
subprocess.run(['sudo', 'python3', 'auto-clam-antivirus.py'])
exit()
check_if_install()
###########################################
# Install timeshift and backup the system #
###########################################
def timeshift_commands():
pro = subprocess.run(['sudo', 'apt-get', 'install', 'timeshift', '-y'])
pro2 = subprocess.run(['sudo', 'timeshift', '--create',
'--comments', 'uninstall-auto-clam-antivirus'])
print(pro.returncode)
print(pro2.returncode)
if int(pro.returncode|pro2.returncode)==0:
print("")
print("")
print("############################################################")
print("* Timeshift installation and system backup were successful *")
print("############################################################")
print("")
print("")
print("the program will continue the installation process in a few seconds, please wait ...")
print("")
time.sleep(3)
else:
print("")
print("")
print("#####################################################")
print("* warning:system backup is failed *")
print("#####################################################")
print("")
print("")
time.sleep(3)
print("#################################################################")
print("Please check if the internet connection is available")
print("Without installing this software and performing the backup you" )
print("will not be able to uninstall the program and return to the state")
print("you were in before the installation.")
print("#################################################################")
print("")
print("")
loop = input("Do you want to try to Install timeshift and backup the system again? [y/n]")
if loop == "y":
subprocess.run(['sudo', 'bash', 'scripts/fix.sh'])
timeshift_commands()
else:
print("")
print("")
print("##############################################################################")
print("* warning: backup system failed *")
print("##############################################################################")
time.sleep(3)
print("")
print("")
while input("Do you want to continue without backup system? [y/n]") == "n":
exit ()
timeshift_commands()
####################################################################################################################################################################
####################################################################################################################################################################
###########################
# auto-clam-antivirus #
###########################
def clamav_install_commands():
pro1 = subprocess.run(
"sudo apt-get update && sudo apt-get upgrade -y", shell=True)
pro2 = subprocess.run(
['sudo', 'mkdir', '-p', '/opt/auto-clamIPS/auto-clamav/'])
pro3 = subprocess.run(
['sudo', 'mkdir', '-p', '/opt/auto-clamIPS/auto-clamav/logs/'])
pro4 = subprocess.run(
['sudo', 'mkdir', '-p', '/opt/auto-clamIPS/auto-clamav/logs/logs_history/'])
pro5 = subprocess.run(['sudo', 'apt-get', 'install', 'clamav', 'clamav-daemon', '-y'])
pro7 = subprocess.run(
['sudo', 'cp', 'clamav-scan/clamav-root-scan.sh', '/opt/auto-clamIPS/auto-clamav/'])
pro8 = subprocess.run(
['sudo', 'cp', 'clamav-scan/clamscan-root-month-week-Day-Hour-timer/clamscan-root.service', '/etc/systemd/system/'])
pro9 = subprocess.run(
['sudo', 'cp', 'clamav-scan/clamscan-root-month-week-Day-Hour-timer/clamscan-root-week.timer', '/etc/systemd/system/'])
pro10 = subprocess.run(['sudo', 'systemctl', 'daemon-reload'])
pro11 = subprocess.run(
['sudo', 'systemctl', 'start', 'clamscan-root-week.timer'])
pro12 = subprocess.run(
['sudo', 'systemctl', 'enable', 'clamscan-root-week.timer'])
pro13 = subprocess.run(
['sudo', 'systemctl', 'start', 'clamav-daemon'])
pro14 = subprocess.run(
['sudo', 'systemctl', 'enable', 'clamav-daemon'])
pro15 = subprocess.run(
['sudo', 'cp', 'uninstall.py', '/opt/auto-clamIPS/auto-clamav/'])
pro16 = subprocess.run(
['sudo', 'cp', 'reinstall.py', '/opt/auto-clamIPS/auto-clamav/'])
pro17 = subprocess.run(
['sudo', 'apt-get', 'install', 'python3-schedule'])
print(pro1.returncode)
print(pro2.returncode)
print(pro3.returncode)
print(pro4.returncode)
print(pro5.returncode)
print(pro7.returncode)
print(pro8.returncode)
print(pro9.returncode)
print(pro10.returncode)
print(pro11.returncode)
print(pro12.returncode)
print(pro13.returncode)
print(pro14.returncode)
print(pro15.returncode)
print(pro16.returncode)
print(pro17.returncode)
if int(pro1.returncode|pro2.returncode|pro3.returncode|pro4.returncode|pro5.returncode
|pro7.returncode|pro8.returncode|pro9.returncode|pro10.returncode|pro11.returncode
|pro12.returncode|pro13.returncode|pro14.returncode|pro15.returncode|pro16.returncode|
pro17.returncode)==0:
print("")
print("")
print("* Installing and update clamav was successful*")
print("")
print("")
print("the program will continue the installation process in a few seconds, please wait ...")
time.sleep(3)
else:
print("")
print("")
print("* warning: Installing and update clamav finished with errors *")
print("")
time.sleep(3)
print("")
loop = input("Do you want to try to Installing and update clamav again ? [y/n]")
if loop == "y":
subprocess.run(['sudo', 'bash', 'scripts/fix.sh'])
clamav_install_commands()
else:
print("")
print("")
print("* warning: Installing and update clamav was failed *")
print("")
print("")
time.sleep(3)
print("")
clamav_install_commands()
####################################################################################################################################
def options():
pro = subprocess.run(['sudo', 'cp', '-r', 'options', '/opt/auto-clamIPS/auto-clamav/'])
print(pro.returncode)
if int(pro.returncode)==0:
print("")
print("")
print("* Options file copied successfully *")
print("")
print("")
print("the program will continue the installation process in a few seconds, please wait ...")
time.sleep(3)
else:
print("")
print("")
print("* warning: Failed to copy options file *")
print("")
time.sleep(3)
print("")
loop = input("Do you want to try to repeat the procedure again ? [y/n]")
if loop == "y":
subprocess.run(['sudo', 'bash', 'scripts/fix.sh'])
options()
options()
def root_scan_commands():
print("")
print("")
print("You can set 4 types of auto-full-scan for the")
print("entire system and each device connected to it.")
print("the default is to perform a full scan once a week ")
print("")
print("Enter [1] clamscan all 12-hours")
print("Enter [2] clamscan once a day on 00:00:00")
print("Enter [3] clamscan once a week on Sat 3:00:00 (default)")
print("Enter [4] clamscan once a month on /**/15/ 03:00:00")
print("")
print("")
retls = input("select an option: ")
if retls == "1":
with open('/etc/systemd/system/clamscan-root-week.timer', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[4] = "OnCalendar=*-*-* 00,12:00:00 \n"
with open('/etc/systemd/system/clamscan-root-week.timer', 'w', encoding='utf-8') as file:
file.writelines(data)
###
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[21] = "scheduler full-scan = 1 \n"
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'w', encoding='utf-8') as file:
file.writelines(data)
###
if retls == "2":
with open('/etc/systemd/system/clamscan-root-week.timer', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[4] = "OnCalendar=*-*-* 3:00:00 \n"
with open('/etc/systemd/system/clamscan-root-week.timer', 'w', encoding='utf-8') as file:
file.writelines(data)
###
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[21] = "scheduler full-scan = 2 \n"
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'w', encoding='utf-8') as file:
file.writelines(data)
###
if retls == "3":
with open('/etc/systemd/system/clamscan-root-week.timer', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[4] = "OnCalendar=Sat 3:00:00 \n"
with open('/etc/systemd/system/clamscan-root-week.timer', 'w', encoding='utf-8') as file:
file.writelines(data)
###
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[21] = "scheduler full-scan = 3 \n"
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'w', encoding='utf-8') as file:
file.writelines(data)
###
if retls == "4":
with open('/etc/systemd/system/clamscan-root-week.timer', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[4] = "OnCalendar=*-*-15 03:00:00 \n"
with open('/etc/systemd/system/clamscan-root-week.timer', 'w', encoding='utf-8') as file:
file.writelines(data)
###
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[21] = "scheduler full-scan = 4 \n"
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'w', encoding='utf-8') as file:
file.writelines(data)
###
def update_timer():
pro = subprocess.run(['sudo', 'systemctl', 'daemon-reload'])
print(pro.returncode)
if int(pro.returncode)==0:
print("")
print("")
print("* enable root_scanner_timer was successful *")
print("")
print("")
print("the program will continue the installation process in a few seconds, please wait ...")
print("")
time.sleep(3)
else:
print("")
print("")
print("enable root_scanner_timer was failed ")
print("")
print("")
update_timer()
root_scan_commands()
##############################################################################################################################
def home_scan():
print("")
print("")
print("A full scan of the system can take a very long time,so most users ")
print("will prefer to perform it once a week.")
print("To give you more security the program will allow you to perform a ")
print("scan to a home directory only which is considered more problematic.")
print("")
print("")
home_directory = input("Are you interested to running an automatic scan on your home directory ? [y/n] ")
if home_directory == "y":
def timer2_commands():
###
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[29] = "home-scan = enable \n"
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'w', encoding='utf-8') as file:
file.writelines(data)
###
pro = subprocess.run(
['sudo', 'cp', 'clamav-scan/clamav-scan-home.sh', '/opt/auto-clamIPS/auto-clamav/'])
pro2 = subprocess.run(
['sudo', 'cp', 'clamav-scan/clamscan-home-week-Day-Hour-timer/clamscan-home.service', '/etc/systemd/system/'])
pro3 = subprocess.run(
['sudo', 'cp', 'clamav-scan/clamscan-home-week-Day-Hour-timer/clamscan-home-day.timer', '/etc/systemd/system/'])
pro4 = subprocess.run(['sudo', 'systemctl', 'daemon-reload'])
pro5 = subprocess.run(
['sudo', 'systemctl', 'start', 'clamscan-home-day.timer'])
pro6 = subprocess.run(
['sudo', 'systemctl', 'enable', 'clamscan-home-day.timer'])
print(pro.returncode)
print(pro2.returncode)
print(pro3.returncode)
print(pro4.returncode)
print(pro5.returncode)
print(pro6.returncode)
if int(pro.returncode|pro2.returncode|pro3.returncode|pro4.returncode|pro5.returncode|pro6.returncode)==0:
time.sleep(1)
else:
print("")
print("")
print("enable home directory scanner was filled' ")
print("")
print("")
loop = input("Do you want to try to fix possible problems and try to install again? [y/n]")
if loop == "y":
subprocess.run(['sudo', 'bash', 'scripts/fix.sh'])
timer2_commands()
print("")
print("")
print("By logic you will need to perform the scan")
print("at a lower timing than the full scan .")
print("For example, if you run a full scan once a week, you")
print("will want to run a home scan once a day or 12 hours.")
print("")
print("")
print("Enter [1] clamscan all 6-hours")
print("Enter [2] clamscan all 12-hours")
print("Enter [3] clamscan once a day")
print("Enter [4] clamscan once a week")
print("")
print("")
retls = input("select an option: ")
if retls == "1":
with open('/etc/systemd/system/clamscan-home-day.timer', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[4] = "OnCalendar=*-*-* 00,06,12,18:00:00 \n"
with open('/etc/systemd/system/clamscan-home-day.timer', 'w', encoding='utf-8') as file:
file.writelines(data)
###
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[42] = "scheduler home-scan = 1 \n"
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'w', encoding='utf-8') as file:
file.writelines(data)
###
if retls == "2":
with open('/etc/systemd/system/clamscan-home-day.timer', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[4] = "OnCalendar=*-*-* 00,12:00:00 \n"
with open('/etc/systemd/system/clamscan-home-day.timer', 'w', encoding='utf-8') as file:
file.writelines(data)
###
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[42] = "scheduler home-scan = 2 \n"
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'w', encoding='utf-8') as file:
file.writelines(data)
###
if retls == "3":
with open('/etc/systemd/system/clamscan-home-day.timer', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[4] = "OnCalendar=*-*-* 00:00:00 \n"
with open('/etc/systemd/system/clamscan-home-day.timer', 'w', encoding='utf-8') as file:
file.writelines(data)
###
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[42] = "scheduler home-scan = 3 \n"
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'w', encoding='utf-8') as file:
file.writelines(data)
###
if retls == "4":
with open('/etc/systemd/system/clamscan-home-day.timer', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[4] = "OnCalendar=Sat 3:00:00 \n"
with open('/etc/systemd/system/clamscan-home-day.timer', 'w', encoding='utf-8') as file:
file.writelines(data)
###
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[42] = "scheduler home-scan = 4 \n"
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'w', encoding='utf-8') as file:
file.writelines(data)
###
timer2_commands()
def update2_timer():
pro = subprocess.run(['sudo', 'systemctl', 'daemon-reload'])
print(pro.returncode)
if int(pro.returncode)==0:
print("")
print("")
print("* enable home directory scanner was successful *")
print("")
print("")
print("the program will continue the installation process in a few seconds, please wait ...")
print("")
time.sleep(3)
else:
print("")
print("")
print("enable home directory scanner was failed ")
print("")
print("")
update2_timer()
home_scan()
####################################################################################################################################################################
####################################################################################################################################################################
####################
# install cpulimit #
####################
def install_cpulimit():
pro = subprocess.run(['sudo', 'apt-get', 'install', 'cpulimit'])
print(pro.returncode)
if int(pro.returncode)==0:
print("")
print("")
print("* program installation was successful *")
print("")
print("")
print("the program will continue the installation process in a few seconds, please wait ...")
time.sleep(3)
else:
print("")
print("")
print("* warning: program installation was failed *")
print("")
time.sleep(3)
print("")
loop = input("Do you want to try to install the program again ? [y/n]")
if loop == "y":
subprocess.run(['sudo', 'bash', 'scripts/fix.sh'])
install_cpulimit()
install_cpulimit()
####################################################################################################################################################################
####################################################################################################################################################################
#################
# Real-time #
#################
def real_time():
def if_change():
print("")
print("")
print("To make the program more effective and identify")
print("risks immediately you have the option to enable")
print("automatic scan of changes the system will scan")
print("your target directory and all the directories inside")
print("her on a regular basis and if it detects a change")
print("such as creating,downloading,copying,moving a file")
print("or directories with files it will start scanning")
print("only the specific files added or moved")
print("")
print("")
print("")
print("")
change = input("Are you interested to enable a real-time-scanner ? [y/n] ")
if change == "y":
###
###
def if_change_op():
print("")
print("")
print("You have two options:")
print("")
print("1.scan the entire system")
print("2.scan home directory only")
print("")
print("")
print("Note!")
print("")
print("if you want to choose another directory or a list of")
print("directories,you can do so after installation in the")
print("options file")
print("")
print("")
retls = input("select an option: ")
if retls == "1":
with open('clamav-scan/change_service/data_scan.log', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[0] = "/ \n"
with open('clamav-scan/change_service/data_scan.log', 'w', encoding='utf-8') as file:
file.writelines(data)
###
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[127] = "default-real-time = / \n"
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'w', encoding='utf-8') as file:
file.writelines(data)
###
if retls == "2":
with open('clamav-scan/change_service/data_scan.log', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[0] = "/home/ \n"
with open('clamav-scan/change_service/data_scan.log', 'w', encoding='utf-8') as file:
file.writelines(data)
###
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[127] = "default-real-time = /home/ \n"
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'w', encoding='utf-8') as file:
file.writelines(data)
time.sleep(3)
if_change_op()
###
###
def if_change_do():
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[51] = "clam-real-time = enable \n"
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'w', encoding='utf-8') as file:
file.writelines(data)
###
pro = subprocess.run(['sudo', 'apt-get', 'install', 'inotify-tools', '-y'])
pro2 = subprocess.run(
['sudo', 'cp', 'clamav-scan/change_service/if-change.sh', '/opt/auto-clamIPS/auto-clamav/'])
pro2_if_change1 = subprocess.run(
['sudo', 'cp', 'clamav-scan/change_service/change-li.sh', '/opt/auto-clamIPS/auto-clamav/'])
pro2_if_change2 = subprocess.run(
['sudo', 'cp', 'clamav-scan/change_service/cpulimit-chack.sh', '/opt/auto-clamIPS/auto-clamav/'])
pro3 = subprocess.run(
['sudo', 'cp', 'clamav-scan/change_service/if-change-scan.py', '/opt/auto-clamIPS/auto-clamav/'])
pro4 = subprocess.run(
['sudo', 'cp', 'clamav-scan/change_service/clamav-scan-if.sh', '/opt/auto-clamIPS/auto-clamav/'])
pro5 = subprocess.run(
['sudo', 'cp', 'clamav-scan/change_service/clamav-scan-if2.sh', '/opt/auto-clamIPS/auto-clamav/'])
pro6 = subprocess.run(
['sudo', 'cp', 'clamav-scan/change_service/cpulimit_inotifywait.sh', '/opt/auto-clamIPS/auto-clamav/'])
pro6_2 = subprocess.run(
['sudo', 'cp', 'clamav-scan/change_service/integral_cpulimit.sh', '/opt/auto-clamIPS/auto-clamav/'])
pro6_3 = subprocess.run(
['sudo', 'cp', 'scripts/return_back_if.sh', '/opt/auto-clamIPS/auto-clamav/'])
media_scan_1 = subprocess.run(
['sudo', 'mkdir', '-p', '/opt/auto-clamIPS/auto-clamav/media_scan/'])
media_scan_2 = subprocess.run(
['sudo', 'cp', 'clamav-scan/media_scan/check_media.sh', '/opt/auto-clamIPS/auto-clamav/media_scan/'])
media_scan_3 = subprocess.run(
['sudo', 'cp', 'clamav-scan/media_scan/media_if-change.sh', '/opt/auto-clamIPS/auto-clamav/media_scan/'])
media_scan_4 = subprocess.run(
['sudo', 'cp', 'clamav-scan/media_scan/media-li.sh', '/opt/auto-clamIPS/auto-clamav/media_scan/'])
media_scan_5 = subprocess.run(
['sudo', 'cp', 'clamav-scan/media_scan/media_scan_service/media_scan.service', '/etc/systemd/system/'])
media_scan_6 = subprocess.run(
['sudo', 'cp', 'clamav-scan/media_scan/media_scan_service/media_scan.timer', '/etc/systemd/system/'])
data_log = subprocess.run(
['sudo', 'cp', 'clamav-scan/change_service/data_scan.log', '/opt/auto-clamIPS/auto-clamav/logs/'])
pro7 = subprocess.run(
['sudo', 'cp', 'clamav-scan/change_service/if-change.service', '/etc/systemd/system/'])
pro8 = subprocess.run(
['sudo', 'cp', 'clamav-scan/change_service/if-change.timer', '/etc/systemd/system/'])
pro9 = subprocess.run(
['sudo', 'cp', 'clamav-scan/change_service/if-change-scan.service', '/etc/systemd/system/'])
pro10 = subprocess.run(
['sudo', 'cp', 'clamav-scan/change_service/if-change-scan.timer', '/etc/systemd/system/'])
pro11 = subprocess.run(['sudo', 'systemctl', 'daemon-reload'])
pro12 = subprocess.run(['sudo', 'systemctl', 'start', 'if-change.timer'])
pro13 = subprocess.run(['sudo', 'systemctl', 'enable', 'if-change.timer'])
pro14 = subprocess.run(['sudo', 'systemctl', 'enable', 'if-change-scan.timer'])
pro15 = subprocess.run(['sudo', 'systemctl', 'enable', 'media_scan.timer'])
#### make sure 'engrampa' is installed,it is not critical but it is better to have it installed
pro16 = subprocess.run(['sudo', 'apt-get', 'install', 'engrampa', '-y'])
print(pro.returncode)
print(pro2.returncode)
print(pro2_if_change1.returncode)
print(pro2_if_change2.returncode)
print(pro3.returncode)
print(pro4.returncode)
print(pro5.returncode)
print(pro6.returncode)
print(pro6_2.returncode)
print(pro6_3.returncode)
print(media_scan_1.returncode)
print(media_scan_2.returncode)
print(media_scan_3.returncode)
print(media_scan_4.returncode)
print(media_scan_5.returncode)
print(media_scan_6.returncode)
print(data_log.returncode)
print(pro7.returncode)
print(pro8.returncode)
print(pro9.returncode)
print(pro10.returncode)
print(pro11.returncode)
print(pro12.returncode)
print(pro13.returncode)
print(pro14.returncode)
print(pro15.returncode)
if int(pro.returncode|pro2.returncode|pro2_if_change1.returncode|pro2_if_change2.returncode|pro3.returncode|pro4.returncode
|pro5.returncode|pro6.returncode|pro6_2.returncode|pro6_3.returncode|media_scan_1.returncode|media_scan_2.returncode|media_scan_3.returncode
|media_scan_4.returncode|media_scan_5.returncode|media_scan_6.returncode|data_log.returncode|pro7.returncode|pro8.returncode|pro9.returncode
|pro10.returncode|pro11.returncode|pro12.returncode|pro13.returncode|pro14.returncode)==0:
print("")
print("")
print("enable 'if_change' and timers && scripts was successful")
print("")
print("")
print("the program will continue the installation process in a few seconds, please wait ...")
time.sleep(3)
else:
print("")
print("")
print("*warning: enable if_change and timers && scripts was failed*")
print("")
time.sleep(3)
print("")
loop = input("Do you want to try to fix the problem and try again ? [y/n]")
if loop == "y":
subprocess.run(['sudo', 'bash', 'scripts/fix.sh'])
if_change()
else:
print("")
print("")
print("* warning: enable if_change and timers && scripts was failed *")
print("")
time.sleep(3)
print("")
while input("Do you want to continue ? [y/n]") == "n":
exit ()
if_change_do()
if_change()
####################################################################################################################################################################
####################################################################################################################################################################
##################
# move_malware #
##################
def auto_move_malwares():
####### if-change.timer
pro3 = subprocess.run(['sudo', 'systemctl', 'status', 'if-change.timer'], capture_output=True)
print(pro3.stdout)
if int(pro3.returncode)==0:
print("")
print("")
print("!!! This option is intended for professional or experienced users only !!!")
print("")
print("")
print("To make the detection system more")
print("autonomous you have the option to")
print("automatically remove(delete)threats")
print("with real-time-scanner .")
print("")
print("")
print("")
print("Note !")
print("")
print("This option will not include the regular schedulers(full scan and home)")
print("for the reason that sometimes 'auto-remove' may be too aggressive")
print("The real-time scan includes a backup scan in case it fails or in case")
print("malware is found,the backup scan will include the entire home directory")
print("and the 'auto-remove' settings will also be included in this scan ! ")
print("")
print("")
print("Warning !")
print("")
print("If there are files in your home directory that are compatible with windows")
print("that have undergone reverse engineering with tools like")
print("wine to run on linux distro,the antivirus may identify them as a risk")
print("and in case you choose to automatically remove risks")
print("They might deletet")
print("")
print("")
print("It is also not recommended to use unofficial sources for")
print("clam database under this concept,especially not with")
print("'auto-remove' option !")
print("")
print("Use this option only if you know what you are doing !")
print("")
print("")
auto_move = input("Are you interested to enable automatically-remove-threats together with real-time-scanner ? [y/n] ")
if auto_move == "y":
#######
#######
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[60] = "move-malware = enable \n"
with open('/opt/auto-clamIPS/auto-clamav/options/options.conf', 'w', encoding='utf-8') as file:
file.writelines(data)
#######
with open('/opt/auto-clamIPS/auto-clamav/clamav-scan-if.sh', 'r', encoding='utf-8') as file:
data = file.readlines()
print(data)
data[14] = 'clamdscan --fdpass --infected --remove --file-list=$(cat /opt/auto-clamIPS/auto-clamav/auto_check.log) >> "$LOGFILE" \n'
with open('/opt/auto-clamIPS/auto-clamav/clamav-scan-if.sh', 'w', encoding='utf-8') as file:
file.writelines(data)
time.sleep(1)
#######
#######
auto_move_malwares()
real_time()
####################################################################################################################################################################
####################################################################################################################################################################