-
Notifications
You must be signed in to change notification settings - Fork 4
/
linuxblueprint.sh
executable file
·1577 lines (1486 loc) · 62.6 KB
/
linuxblueprint.sh
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
##################################################################################
# linuxblueprint.sh
# Authors: James McNabb, Eric Wold, Arsam Pathan, Dylan Chamberlain
#
#
# This script "blueprints" a linux system and gathers information for
# system vetting needs and generates a report of in the current working
# directory. An overview of report secitons can be found below.
#
#
# Report Sections:
# 1. Host Name
# 2. System Information
# 3. Hardware Information
# 4. Banners
# 5. Host File
# 6. DNS IInformation
# 7. User Information
# 8. Goups Information
# 9. Home Directories
# 10. Installed Software
# 11. Services and Statuses
# 12. Open Ports
# 13. Cron Jobs
# 14. Firewall Setup
# 15. SSH Setup
# 16. Webserver Information
# 17. SSL Information
# 18. Samba/SMB Informaiton
# 19. App Armor/SeLinux Informaiton
# 20. Syslog Information
# 21. Fail2Ban Information
# 22. SNMP Information
# 23. Printer Information
# 24. Local NFS information
#
# Usage: sudo ./linuxblueprint.sh
#
# Report Name: YYmmddHHMMSS-{Hostname}-Blueprint.txt
#
##################################################################################
# Hostname
# use the variable $HOSTNAME to show hostname
#Create Date Stamp
mydate=`date +"%Y%m%d%H%M%S"`
#Create Logfiles
myoutfile="$mydate-$HOSTNAME-Blueprint.txt"
# Write file header
echo " " >> $myoutfile
echo " __ _ ____ __ _ __ " >> $myoutfile
echo " / / (_)___ __ ___ __/ __ )/ /_ _____ ____ _____(_)___ / /_" >> $myoutfile
echo " / / / / __ \/ / / / |/_/ __ / / / / / _ \/ __ \/ ___/ / __ \/ __/" >> $myoutfile
echo "/ /___/ / / / / /_/ /> </ /_/ / / /_/ / __/ /_/ / / / / / / / /_ " >> $myoutfile
echo "_____/_/_/ /_/\__,_/_/|_/_____/_/\__,_/\___/ .___/_/ /_/_/ /_/\__/ " >> $myoutfile
echo " /_/ " >> $myoutfile
echo " " >> $myoutfile
echo "---------------------------------------------------------------------" >> $myoutfile
echo "Linux Bluprint for $HOSTNAME on $mydate" >> $myoutfile
echo "---------------------------------------------------------------------" >> $myoutfile
echo " " >> $myoutfile
# Table of contents
echo "Table of Contents:" >> $myoutfile
echo "1. Host Name" >> $myoutfile
echo "2. System Information" >> $myoutfile
echo "3. Hardware Information" >> $myoutfile
echo "4. Banners" >> $myoutfile
echo "5. Host File" >> $myoutfile
echo "6. DNS IInformation" >> $myoutfile
echo "7. User Information" >> $myoutfile
echo "8. Goups Information" >> $myoutfile
echo "9. Home Directories" >> $myoutfile
echo "10. Installed Software" >> $myoutfile
echo "11. Services and Statuses" >> $myoutfile
echo "12. Open Ports" >> $myoutfile
echo "13. Cron Jobs" >> $myoutfile
echo "14. Firewall Setup" >> $myoutfile
echo "15. SSH Setup" >> $myoutfile
echo "16. Webserver Information" >> $myoutfile
echo "17. SSL Information" >> $myoutfile
echo "18. Samba/SMB Informaiton" >> $myoutfile
echo "19. App Armor/SeLinux Informaiton" >> $myoutfile
echo "20. Syslog Information" >> $myoutfile
echo "21. Fail2Ban Information" >> $myoutfile
echo "22. SNMP Information" >> $myoutfile
echo "23. Printer Information" >> $myoutfile
echo "24. Local NFS information" >> $myoutifle
echo " " >> $myoutfile
#### Main ####
echo "Running Linux Blueprint on $HOSTNAME"
echo "Determining the Linux Disribution"
# Determine the OS, then take action.
if [[ `which apt` ]]; then
# Debian Based Commands go Here
IS_DEBIAN=1
echo "Debian Based OS..."
########################
# PUT DEBIAN CODE HERE
#########################
# Hostname
echo "###################################" >> $myoutfile
echo "1 - Host Name" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "Checking Hostname..."
(uname -n) >>$myoutfile
echo " " >> $myoutfile
# System Information
echo "###################################" >> $myoutfile
echo "2 - System Information " >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "OS Release" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Checking OS info..."
echo "info from /etc/os-release.." >> $myoutfile
cat /etc/os-release | grep -E 'ID_LIKE|NAME|VERSION_ID' |grep -v 'PRETTY_NAME' >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Kernal Information" >> $myoutfile
echo "--------------------------------" >> $myoutfile
# Kernal name system ,version, release, hardware Name
echo " " >> $myoutfile
echo "Checking Kernal name and version info..."
uname -a >> $myoutfile
echo " " >> $myoutfile
#Disk Information
echo "--------------------------------" >> $myoutfile
echo "Disk Information" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo " " >> $myoutfile
echo "Checking Disk Mount info..."
lsblk >> $myoutfile
echo " " >> $myoutfile
#Disk Space
echo "--------------------------------" >> $myoutfile
echo "Disk Space" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo " " >> $myoutfile
echo "Checking Disk Space..."
df -H >> $myoutfile
echo " " >> $myoutfile
# Mounted disks
echo "--------------------------------" >> $myoutfile
echo "Mounted Disks" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo " " >> $myoutfile
echo "Checking Disk Mountes..."
mount | column -t >> $myoutfile
echo " " >> $myoutfile
# Fstab config information
echo "--------------------------------" >> $myoutfile
echo "Fstab" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo " " >> $myoutfile
echo "Checking Fstab info..."
blkid >> $myoutfile
echo " " >> $myoutfile
#Network Information
echo "--------------------------------" >> $myoutfile
echo "Network Information" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo " " >> $myoutfile
echo "Checking NW Adapter info..."
#sudo lshw -class network -short >> $myoutfile
ip a >> $myoutfile
echo " " >> $myoutfile
# Hardware Information
echo "###################################" >> $myoutfile
echo "3 - Hardware Information" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "CPU - lscpu" >> $myoutfile
echo "--------------------------------" >> $myoutfile
lscpu >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Memory" >> $myoutfile
echo "--------------------------------" >> $myoutfile
free -m >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Hardware List - lshw" >> $myoutfile
echo "--------------------------------" >> $myoutfile
lshw -short >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Hardware Info - hwinfo" >> $myoutfile
echo "--------------------------------" >> $myoutfile
hwinfo -short >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "List PCI - lspci" >> $myoutfile
echo "--------------------------------" >> $myoutfile
lspci >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "List SCSI - lsscsi" >> $myoutfile
echo "--------------------------------" >> $myoutfile
lsscsi >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "List USB - lsusb" >> $myoutfile
echo "--------------------------------" >> $myoutfile
lsusb >> $myoutfile
echo " " >> $myoutfile
# Banner Info
echo "###################################" >> $myoutfile
echo "4 - Banner Information" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "Checking for Banners..."
# Check /etc/issue
if [ -f /etc/issue ]; then
echo "/etc/issue exists"
# Get/etc/issue
echo "--------------------------------" >> $myoutfile
echo "Contents of /etc/issue:" >> $myoutfile
echo "--------------------------------" >> $myoutfile
cat /etc/issue >> $myoutfile
else
echo "/etc/issue does not exist"
echo "/etc/issue does not exist" >> $myoutfile
fi
echo " " >> $myoutfile
# Check /etc/issue.net
if [ -f /etc/issue.net ]; then
echo "/etc/issue.net exists"
# Get/etc/issue.net
echo "--------------------------------" >> $myoutfile
echo "Contents of /etc/issue.net:" >> $myoutfile
echo "--------------------------------" >> $myoutfile
cat /etc/issue.net >> $myoutfile
else
echo "/etc/issue.net does not exist"
echo "/etc/issue.net does not exist" >> $myoutfile
fi
echo " " >> $myoutfile
# Check /etc/motd
if [ -f /etc/motd ]; then
echo "/etc/motd exists"
# Get /etc/motd
echo "--------------------------------" >> $myoutfile
echo "Contents of /etc/motd:" >> $myoutfile
echo "--------------------------------" >> $myoutfile
cat /etc/motd >> $myoutfile
else
echo "/etc/motd does not exist"
echo "/etc/motd does not exist" >> $myoutfile
fi
echo " " >> $myoutfile
# Check /etc/motd
if [ -f /etc/ssh/ssh_banner ]; then
echo "/etc/ssh/ssh_banner exists"
# Get /etc/ssh/ssh_banner
echo "--------------------------------" >> $myoutfile
echo "Contents of /etc/ssh/ssh_banner:" >> $myoutfile
echo "--------------------------------" >> $myoutfile
cat /etc/ssh/ssh_banner>> $myoutfile
else
echo "/etc/ssh/ssh_banner does not exist"
echo "/etc/ssh/ssh_banner does not exist" >> $myoutfile
fi
echo " " >> $myoutfile
# Host File Info
echo "###################################" >> $myoutfile
echo "5 Host File Information" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "Getting Hosts File..."
echo "-----------------------------------" >> $myoutfile
echo "Contents of /etc/hosts:" >> $myoutfile
echo "-----------------------------------" >> $myoutfile
echo " " >> $myoutfile
cat /etc/hosts >> $myoutfile
echo " " >> $myoutfile
# DNS Info
echo "###################################" >> $myoutfile
echo "6 - DNS Information" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "Getting DNS Info..."
echo "-----------------------------------" >> $myoutfile
echo "Contents of /etc/resolv.conf:" >> $myoutfile
echo "-----------------------------------" >> $myoutfile
echo " " >> $myoutfile
cat /etc/resolv.conf >> $myoutfile
echo " " >> $myoutfile
# User Information
echo "###################################" >> $myoutfile
echo "7 - User Information" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
cat /etc/passwd | cut -d ':' -f 1 >> $myoutfile
echo " " >> $myoutfile
# Groups Information
echo "###################################" >> $myoutfile
echo "8 - Groups & Users in them" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "Getting Groups Info..."
echo "-----------------------------------" >> $myoutfile
echo "Contents of /etc/group:" >> $myoutfile
echo "-----------------------------------" >> $myoutfile
#cat /etc/group | cut -d ':' -f 1 >> $myoutfile
cat /etc/group >> $myoutfile
echo " " >> $myoutfile
# Home Directories
echo "###################################" >> $myoutfile
echo "9 - Home Directories" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
dir /home >> $myoutfile
echo " " >> $myoutfile
# Installed Packages
echo "###################################" >> $myoutfile
echo "Section 10 - Installed Packages" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "-----------------------------------" >> $myoutfile
echo "Listing Packages from APT" >> $myoutfile
echo "-----------------------------------" >> $myoutfile
echo "Getting Installed Packages from APT..."
apt list --installed >> $myoutfile
echo " " >> $myoutfile
echo "-----------------------------------" >> $myoutfile
echo "Listing Packages from dpkg" >> $myoutfile
echo "-----------------------------------" >> $myoutfile
echo "Getting Installed Packages from dpkg..."
dpkg-query -l | less >> $myoutfile
echo " " >> $myoutfile
# Services Info
echo "###################################" >> $myoutfile
echo "Section 11 - Services" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "-----------------------------------" >> $myoutfile
echo "Services" >> $myoutfile
echo "-----------------------------------" >> $myoutfile
echo "Services Legend:" >> $myoutfile
echo "+: the service is running" >> $myoutfile
echo "-: the service is NOT running" >> $myoutfile
echo "?: the service state cannot be determined" >> $myoutfile
echo " " >> $myoutfile
echo "Getting Services Info..."
service --status-all >> $myoutfile
echo " " >> $myoutfile
# Open Ports
echo "###################################" >> $myoutfile
echo "Section 12- Open Ports" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "-----------------------------------" >> $myoutfile
echo "Open Ports" >> $myoutfile
echo "-----------------------------------" >> $myoutfile
echo "Getting Open Ports..."
ss -ltnp >> $myoutfile
# netstat –tuln >> $myoutfile
echo " " >> $myoutfile
# Cron Info
echo "###################################" >> $myoutfile
echo "Section 13 - Cron Jobs" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "-----------------------------------" >> $myoutfile
echo "Daily Cron Jobs" >> $myoutfile
echo "-----------------------------------" >> $myoutfile
echo "Getting Cron Daily..."
ls -la /etc/cron.daily >> $myoutfile
echo " " >> $myoutfile
echo "-----------------------------------" >> $myoutfile
echo "Weekly Cron Jobs" >> $myoutfile
echo "-----------------------------------" >> $myoutfile
echo "Getting Cron Weekly..."
ls -la /etc/cron.weekly >> $myoutfile
echo " " >> $myoutfile
echo "-----------------------------------" >> $myoutfile
echo "Monthly Cron Jobs" >> $myoutfile
echo "-----------------------------------" >> $myoutfile
echo "Getting Cron Monthly..."
ls -la /etc/cron.monthly >> $myoutfile
echo " " >> $myoutfile
# Firewall Info
echo "###################################" >> $myoutfile
echo "14 - Firewall Information" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "Checking for Firewalls..."
echo "Checking for UFW..."
if [[ `which ufw` ]]; then
#Check for Ufw
echo "UFW is installed" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "UFW Rules" >> $myoutfile
echo "--------------------------------" >> $myoutfile
ufw status verbose >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "UFW App List" >> $myoutfile
echo "--------------------------------" >> $myoutfile
ufw app list >> $myoutfile
echo " " >> $myoutfile
else
echo "UfW is not installed"
echo "UfW is not installed" >> $myoutfile
echo " " >> $myoutfile
fi
echo "Checking for Firewalld..."
if [[ `which firewalld` ]]; then
#Check for firewalld
echo "firewalld is installed" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "firewalld rules" >> $myoutfile
echo "--------------------------------" >> $myoutfile
firewall-cmd --list-all>> $myoutfile
echo " " >> $myoutfile
else
echo "firewalld is not installed"
echo "firewalld is not installed" >> $myoutfile
echo " " >> $myoutfile
fi
#Check for iptables
echo "Checking for iptables..."
echo "--------------------------------" >> $myoutfile
echo "iptables Rules" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "*** Note: If there are no rules listed, rules don't exist" >> $myoutfile
echo " " >> $myoutfile
iptables -L >> $myoutfile
echo " " >> $myoutfile
# SSH Info
echo "###################################" >> $myoutfile
echo "15 - SSH Information" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
# Get SSH.config
echo "Getting SSH Config..."
echo "-----------------------------------" >> $myoutfile
echo "Contents of /etc/ssh/sshd_config:" >> $myoutfile
echo "-----------------------------------" >> $myoutfile
echo " " >> $myoutfile
cat /etc/ssh/sshd_config >> $myoutfile
echo " " >> $myoutfile
# Get SSH Parameters of Note
echo "Getting SSH Parameters of Note..."
echo "--------------------------------" >> $myoutfile
echo "SSH Parameters of Note: " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "*** Note: Blank lines indicate the item is not configured" >> $myoutfile
echo "*** Note: # in front of the line means the item is not active" >> $myoutfile
echo " " >> $myoutfile
echo "Allowed Users:" >> $myoutfile
grep "AllowUsers" /etc/ssh/sshd_config >> $myoutfile
echo "Allowed Groups:" >> $myoutfile
grep "AllowGroups" /etc/ssh/sshd_config >> $myoutfile
echo "Is Root Permitted to Login:" >> $myoutfile
grep "PermitRootLogin" /etc/ssh/sshd_config >> $myoutfile
echo "SSH Password Authentication: (no means certificates are in use)" >> $myoutfile
grep "PasswordAuthentication" /etc/ssh/sshd_config >> $myoutfile
echo "Does SSH Allow empty passwords:" >> $myoutfile
grep "PermitEmptyPasswords" /etc/ssh/sshd_config >> $myoutfile
echo "SSH Session Time Out Values:" >> $myoutfile
echo "Client Alive Interval:" >> $myoutfile
grep "ClientAliveInterval" /etc/ssh/sshd_config >> $myoutfile
echo "Client Alive Count:" >> $myoutfile
grep "ClientAliveCountMax" /etc/ssh/sshd_config >> $myoutfile
echo "SSH Port:" >> $myoutfile
grep "Port" /etc/ssh/sshd_config >> $myoutfile
echo "Address Family: (IPV4,IPV6, or Any)" >> $myoutfile
grep "AddressFamily" /etc/ssh/sshd_config >> $myoutfile
echo "Banner" >> $myoutfile
grep "Banner" /etc/ssh/sshd_config >> $myoutfile
echo " " >> $myoutfile
# Webserver Info
echo "###################################" >> $myoutfile
echo "16 - Webserver Information" >> $myoutfile
echo "###################################" >> $myoutfile
echo "*** This check looks for major web servers only (Apache2, NGNIX, lighttpd)" >> $myoutfile
echo "*** Lesser known webservers will not be found by this check" >> $myoutfile
echo " " >> $myoutfile
echo "Checking for Major webservers only (Apache2, NGNIX, lighttpd)..."
#Checking for Apache
echo "Checking for Apache2..."
if [[ `which apache2` ]]; then
#Check for Apache
echo "Apache2 is installed" >> $myoutfile
echo "Apache2 is installed"
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Apache2 Info" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Listing of Apache Packages" >> $myoutfile
echo "--------------------------------" >> $myoutfile
dpkg --get-selections | grep apache >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Listing of Apache2.conf" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "/etc/apache2/apache2.conf" >> $myoutfile
cat /etc/apache2/apache2.conf >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Listing of Apache2 ports configured" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "/etc/apache2/ports.conf" >> $myoutfile
cat /etc/apache2/ports.conf >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo " Listing of Apache2 Sites Available" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo " /etc/apache2/sites-available" >> $myoutfile
ls -la /etc/apache2/sites-available/ >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Listing of Apache2 Conf Available" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "/etc/apache2/conf-available/" >> $myoutfile
ls -la /etc/apache2/conf-available/ >> $myoutfile
echo " " >> $myoutfile
echo "Listing of Apache2 Sites Enabled" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "/etc/apache2/sites-enabled/" >> $myoutfile
echo "--------------------------------" >> $myoutfile
ls -la /etc/apache2/sites-enabled/ >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Listing of Apache2 Conf Enabled" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "/etc/apache2/conf-enabled/" >> $myoutfile
ls -la /etc/apache2/conf-enabled/ >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Listing of Apache2 Mods Available" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "/etc/apache2/mods-available/" >> $myoutfile
ls -la /etc/apache2/mods-available/ >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Listing of Apache2 Mods Enabled" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "/etc/apache2/mods-enabled/" >> $myoutfile
ls -la /etc/apache2/mods-enabled/ >> $myoutfile
echo " " >> $myoutfile
else
echo "Apache2 is not installed"
echo "Apache2 is not installed" >> $myoutfile
echo " " >> $myoutfile
fi
#Checking for Nginx
echo "Checking for Nginx..."
if [[ `which nginx` ]]; then
#Check for Nginx
echo "Nginx is installed" >> $myoutfile
echo "Nginx is installed"
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Nginx Info" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Listing of nginx.conf" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "/etc/nginx/nginx.conf" >> $myoutfile
cat /etc/nginx/nginx.conf >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Listing of nginx Sites Available" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo " /etc/nginx/sites-available" >> $myoutfile
ls -la /etc/nginx/sites-available/ >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Listing of nginx Sites Enabled" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "/etc/nginx/sites-enabled/" >> $myoutfile
ls -la /etc/nginx/sites-enabled/ >> $myoutfile
echo " " >> $myoutfile
else
echo "Nginx is not installed"
echo "Nginx is not installed" >> $myoutfile
echo " " >> $myoutfile
fi
#Checking for Lighttp
echo "Checking for Lighttp..."
if [[ `which lighttpd` ]]; then
#Check for lighttpd
echo "Lighttpd is installed" >> $myoutfile
echo "Lighttpd is installed"
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Lighttpd Info" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Listing of lighttpd.conf" >> $myoutifle
echo "--------------------------------" >> $myoutfile
echo "/etc/lighttpd/lighttpd.conf" >> $myoutfile
cat /etc/lighttpd/lightttp.conf >> $myoutfile
echo " " >> $myoutfile
else
echo "Lighttpd is not installed"
echo "Lighttpd is not installed" >> $myoutfile
echo " " >> $myoutfile
fi
# SSL Info
echo "###################################" >> $myoutfile
echo "17 - SSL Information" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "Getting SSL Info..."
echo "--------------------------------" >> $myoutfile
echo "Listing of /etc/ssl:" >> $myoutfile
echo "--------------------------------" >> $myoutfile
ls -R /etc/ssl >> $myoutfile
#SMB configuration information
echo "#################################################" >> $myoutfile
echo "Section 18 - Samba Configuration" >> $myoutfile
echo "#################################################" >> $myoutfile
echo " " >> $myoutfile
echo "Checking samba Config..."
if [[ `which samba` ]]; then
echo "samba is installed" >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "SMB Status:" >> $myoutfile
echo "--------------------------------" >> $myoutfile
smbstatus >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Contents of /etc/samba/smb.conf:" >> $myoutfile
echo "--------------------------------" >> $myoutfile
cat /etc/samba/smb.conf >> $myoutfile
echo " " >> $myoutfile
else
echo "samba is not installed" >> $myoutfile
echo " " >> $myoutfile
fi
# Security Software
echo "#################################################" >> $myoutfile
echo "Section 19 - App Armor, SELinux" >> $myoutfile
echo "#################################################" >> $myoutfile
echo " " >> $myoutfile
# App Armor
echo "--------------------------------" >> $myoutfile
echo "AppArmor " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Getting App Armor Status..."
aa-status >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "AppArmor Configuration" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Getting App Armor Configuration..."
cat /sys/kernel/security/apparmor/profiles >> $myoutfile
echo " " >> $myoutfile
# SELinux
echo "--------------------------------" >> $myoutfile
echo "SELinux " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Key:" >> $myoutfile
echo "Enforced: Actions contrary to the policy are blocked and the corresponding event is logged in the audit file" >> $myoutfile
echo "Permissive: SeLinux software is loaded but rules are not enforced, only logging is performed" >> $myoutfile
echo "Disabled: The SELinux system is disabled entirely" >> $myoutfile
echo " " >> $myoutfile
echo "If there is no text below the commands getenforce and sestatus were run and did not find SELinux installed." >> $myoutfile
echo "SE Linux may be installed by running sudo apt install selinux-utils" >> $myoutfile
echo "Getting SELinux Status..."
echo " " >> $myoutfile
getenforce >> $myoutfile
echo " " >> $myoutfile
sestatus >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "SELinux Configuration (if installed)" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Getting SELinux Config..."
cat /etc/selinux/config >> $myoutfile
echo " " >> $myoutfile
#Syslog Info
echo "#################################################" >> $myoutfile
echo "Section 20 - syslog/rsyslog" >> $myoutfile
echo "#################################################" >> $myoutfile
echo " " >> $myoutfile
echo "Getting Syslog Info..."
echo "--------------------------------" >> $myoutfile
echo "Syslog/RSyslog Configuration" >> $myoutfile
echo "--------------------------------" >> $myoutfile
cat /etc/rsyslog.conf >> $myoutfile
cat /etc/syslog.conf >> $myoutfile
echo " " >> $myoutfile
#Fail2Ban Info
echo "#################################################" >> $myoutfile
echo "21 - Fail2Ban Information" >> $myoutfile
echo "#################################################" >> $myoutfile
echo " " >> $myoutfile
echo "Checking Fail2Ban...."
if test -f /etc/fail2ban/jail.local; then
echo " " >> $myoutfile
echo "-------------------------------------------------" >> $myoutfile
echo "fail2ban config - " >> $myoutfile
echo "-------------------------------------------------" >> $myoutfile
cat etc/fail2ban/jail.local >> $myoutfile
echo " " >> $myoutfile
else
echo "Fail2ban not installed!" >> $myoutfile
fi
echo " " >> $myoutfile
# SNMP Information
if test -f /etc/snmp/snmp.conf; then
if test -f /etc/snmp/snmpd.conf; then
echo "#################################################" >> $myoutfile
echo "22 - SNMP Information" >> $myoutfile
echo "#################################################" >> $myoutfile
echo " " >> $myoutfile
echo "Checking SNMP...."
echo "-------------------------------------------------" >> $myoutfile
echo "Contents of snmp.conf - " >> $myoutfile
echo "-------------------------------------------------" >> $myoutfile
echo " " >> $myoutfile
cat /etc/snmp/snmp.conf >> $myoutfile
echo " " >> $myoutfile
echo "-------------------------------------------------" >> $myoutfile
echo "Contents of snmpd.conf - " >> $myoutfile
echo "-------------------------------------------------" >> $myoutfile
echo " " >> $myoutfile
cat /etc/snmp/snmpd.conf >> $myoutfile
echo " " >> $myoutfile
else
echo "#################################################" >> $myoutfile
echo "22 - SNMP Information" >> $myoutfile
echo "#################################################" >> $myoutfile
echo " " >> $myoutfile
echo "-------------------------------------------------" >> $myoutfile
echo "snmp.conf located but not snmpd.conf. Contents - " >> $myoutfile
echo "-------------------------------------------------" >> $myoutfile
echo " " >> $myoutfile
cat /etc/snmp/snmp.conf >> $myoutfile
echo " " >> $myoutfile
fi
else
if test -f /etc/snmp/snmpd.conf; then
echo "#################################################" >> $myoutfile
echo "22 - SNMP Information" >> $myoutfile
echo "#################################################" >> $myoutfile
echo " " >> $myoutfile
echo "-------------------------------------------------" >> $myoutfile
echo "snmpd.conf located but not snmp.conf. Contents - " >> $myoutfile
echo "-------------------------------------------------" >> $myoutfile
echo " " >> $myoutfile
cat /etc/snmp/snmpd.conf >> $myoutfile
echo " " >> $myoutfile
else
echo "#################################################" >> $myoutfile
echo "22 - SNMP Information" >> $myoutfile
echo "#################################################" >> $myoutfile
echo " " >> $myoutfile
echo "Neither snmp.conf nor snmpd.conf was located. Are you sure SNMP is installed?" >> $myoutfile
echo " " >> $myoutfile
fi
fi
#Printer Information
echo "###################################" >> $myoutfile
echo "Section 23 - Printer Information" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "Checking for Printers... "
sudo lpstat -s >>$myoutfile
echo " " >> $myoutfile
#NFS Informaiton
echo "###################################" >> $myoutfile
echo "Section 28 - Local NFS Information" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "Checking Local NFS Information..."
showmount -e >>$myoutfile 2>&1
echo " " >> $myoutfile
########################
# END DEBIAN CODE
########################
elif [[ `which yum` ]]; then
# RedHat Based Commands go Here
IS_RHEL=1
echo "RedHat Based OS..."
#########################
# PUT Red HAT CODE HERE
#########################
# Hostname
echo "###################################" >> $myoutfile
echo "1 - Host Name" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "Checking Hostname..."
(uname -n) >>$myoutfile
echo " " >> $myoutfile
# System Information
echo "###################################" >> $myoutfile
echo "2 - System Information " >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "OS Release" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Checking OS info..."
echo "info from /etc/os-release.." >> $myoutfile
cat /etc/os-release | grep -E 'ID_LIKE|NAME|VERSION_ID' |grep -v 'PRETTY_NAME' >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Kernal Information" >> $myoutfile
echo "--------------------------------" >> $myoutfile
# Kernal name system ,version, release, hardware Name
echo " " >> $myoutfile
echo "Checking Kernal name and version info..."
uname -a >> $myoutfile
echo " " >> $myoutfile
#Disk Information
echo "--------------------------------" >> $myoutfile
echo "Disk Information" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo " " >> $myoutfile
echo "Checking Disk Mount info..."
lsblk >> $myoutfile
echo " " >> $myoutfile
#Disk Space
echo "--------------------------------" >> $myoutfile
echo "Disk Space" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo " " >> $myoutfile
echo "Checking Disk Space..."
df -H >> $myoutfile
echo " " >> $myoutfile
# Mounted disks
echo "--------------------------------" >> $myoutfile
echo "Mounted Disks" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo " " >> $myoutfile
echo "Checking Disk Mountes..."
mount | column -t >> $myoutfile
echo " " >> $myoutfile
# Fstab config information
echo "--------------------------------" >> $myoutfile
echo "Fstab" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo " " >> $myoutfile
echo "Checking Fstab info..."
blkid >> $myoutfile
echo " " >> $myoutfile
#Network Information
echo "--------------------------------" >> $myoutfile
echo "Network Information" >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo " " >> $myoutfile
echo "Checking NW Adapter info..."
#sudo lshw -class network -short >> $myoutfile
ip a >> $myoutfile
echo " " >> $myoutfile
# Hardware Information
echo "###################################" >> $myoutfile
echo "3 - Hardware Information" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "CPU - lscpu" >> $myoutfile
echo "--------------------------------" >> $myoutfile
lscpu >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Memory" >> $myoutfile
echo "--------------------------------" >> $myoutfile
free -m >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Hardware List - lshw" >> $myoutfile
echo "--------------------------------" >> $myoutfile
lshw -short >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "Hardware Info - hwinfo" >> $myoutfile
echo "--------------------------------" >> $myoutfile
hwinfo -short >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "List PCI - lspci" >> $myoutfile
echo "--------------------------------" >> $myoutfile
lspci >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "List SCSI - lsscsi" >> $myoutfile
echo "--------------------------------" >> $myoutfile
lsscsi >> $myoutfile
echo " " >> $myoutfile
echo "--------------------------------" >> $myoutfile
echo "List USB - lsusb" >> $myoutfile
echo "--------------------------------" >> $myoutfile
lsusb >> $myoutfile
echo " " >> $myoutfile
# Banner Info
echo "###################################" >> $myoutfile
echo "4 - Banner Information" >> $myoutfile
echo "###################################" >> $myoutfile
echo " " >> $myoutfile
echo "Checking for Banners..."
# Check /etc/issue
if [ -f /etc/issue ]; then
echo "/etc/issue exists"
# Get/etc/issue
echo "--------------------------------" >> $myoutfile
echo "Contents of /etc/issue:" >> $myoutfile
echo "--------------------------------" >> $myoutfile
cat /etc/issue >> $myoutfile
else
echo "/etc/issue does not exist"
echo "/etc/issue does not exist" >> $myoutfile
fi
echo " " >> $myoutfile
# Check /etc/issue.net
if [ -f /etc/issue.net ]; then
echo "/etc/issue.net exists"
# Get/etc/issue.net
echo "--------------------------------" >> $myoutfile
echo "Contents of /etc/issue.net:" >> $myoutfile
echo "--------------------------------" >> $myoutfile
cat /etc/issue.net >> $myoutfile
else
echo "/etc/issue.net does not exist"
echo "/etc/issue.net does not exist" >> $myoutfile
fi
echo " " >> $myoutfile
# Check /etc/motd
if [ -f /etc/motd ]; then
echo "/etc/motd exists"
# Get /etc/motd
echo "--------------------------------" >> $myoutfile
echo "Contents of /etc/motd:" >> $myoutfile
echo "--------------------------------" >> $myoutfile
cat /etc/motd >> $myoutfile
else
echo "/etc/motd does not exist"
echo "/etc/motd does not exist" >> $myoutfile
fi
echo " " >> $myoutfile
# Check /etc/motd
if [ -f /etc/ssh/ssh_banner ]; then