-
Notifications
You must be signed in to change notification settings - Fork 45
/
postenum.sh
1861 lines (1692 loc) · 58.7 KB
/
postenum.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
clear
# License: MIT
# Version 1.2
# Linux enumeration and privilege escalation tool.
# Be more than a normal user. Be the ROOT.
# variables
white=$'\e[0m'
blu=$'\e[0;94m'
cyan=$'\e[0;96m'
boldgrn=$'\e[1;92m'
yellowintensy=$'\e[0;93m'
grnintensy=$'\e[0;92m'
whiteboldintensy=$'\e[1;97m'
redintensy=$'\e[0;91m'
echo $whiteboldintensy"----------------------------------------------------------------------------"
echo "
_
_ __ ___ ___| |_ ___ _ __ _ _ _ __ ___
| '_ \ / _ \/ __| __/ _ \ '_ \| | | | '_ ' _ \
| |_) | (_) \__ \ || __/ | | | |_| | | | | | | version : 1.2
| .__/ \___/|___/\__\___|_| |_|\__,_|_| |_| |_|
|_|
"$white
echo "POST-EXPLOITATION Tool$grnintensy by @mostaphabahadou"$white
echo $whiteboldintensy"----------------------------------------------------------------------------"$white
echo ""
echo " postenum - be the ROOT"
echo " For help or reporting issues, visit https://github.com/mostaphabahadou/postenum"
echo ""
function DirtyCow(){
echo "$redintensy Linux Kernel 2.6.22 < 3.9 Dirty Cow$white - https://www.exploit-db.com/exploits/40839"
echo "$redintensy Linux Kernel 2.6.22 < 3.9 Dirty Cow (x86-x64)$white - https://www.exploit-db.com/exploits/40616"
}
function Exploits1x(){
echo "$redintensy Linux Kernel < 4.4.0-116 (Ubuntu 16.04.4)$white - https://www.exploit-db.com/exploits/44298"
echo "$redintensy Linux kernel < 4.10.15 Race Condition$white - https://www.exploit-db.com/exploits/43345"
echo "$redintensy Linux Kernel < 4.13.9 (Ubuntu 16.04 / Fedora 27)$white - https://www.exploit-db.com/exploits/45010"
echo "$redintensy Linux Kernel < 4.4.0-21 (Ubuntu 16.04 x64) - 'netfilter target_offset'$white - https://www.exploit-db.com/exploits/44300"
echo "$redintensy Linux Kernel < 3.5.0-23 (Ubuntu 12.04.2 x64) - 'SOCK_DIAG' SMEP Bypass$white - https://www.exploit-db.com/exploits/44299"
}
function Exploits2x(){
echo "$redintensy Linux Kernel 2.4.x/2.6.x$white - https://www.exploit-db.com/exploits/9545"
echo "$redintensy UDEV < 1.4.1 (1)$white - https://www.exploit-db.com/exploits/8478"
echo "$redintensy UDEV < 1.4.1 (2)$white - https://www.exploit-db.com/exploits/8572"
echo "$redintensy UDEV < 1.4.1 (Metasploit)$white - https://www.exploit-db.com/exploits/21848"
echo "$redintensy Linux Kernel 2.6 < 2.6.19$white - https://www.exploit-db.com/exploits/9542"
echo "$redintensy Linux Kernel 2.6.0 < 2.6.31(1)$white - https://www.exploit-db.com/exploits/33321"
echo "$redintensy Linux Kernel 2.6.x (2)$white - https://www.exploit-db.com/exploits/33322"
echo "$redintensy Linux Kernel 2.6.x$white - https://www.exploit-db.com/exploits/30604"
echo "$redintensy Linux Kernel 2.6.39 < 3.2.2 Gentoo / Ubuntu x86-x64 Mempodipper(1)$white - https://www.exploit-db.com/exploits/18411"
echo "$redintensy Linux Kernel 2.6.39 < 3.2.2 x86-x64 Mempodipper(2)$white - https://www.exploit-db.com/exploits/35161"
echo "$redintensy Linux kernel < 4.10.15 Race Condition$white - https://www.exploit-db.com/exploits/43345"
echo "$redintensy Linux Kernel < 4.4.0-116 (Ubuntu 16.04.4)$white - https://www.exploit-db.com/exploits/44298"
echo "$redintensy Linux Kernel < 4.13.9 (Ubuntu 16.04 / Fedora 27)$white - https://www.exploit-db.com/exploits/45010"
echo "$redintensy Linux Kernel < 4.4.0-21 (Ubuntu 16.04 x64) - 'netfilter target_offset'$white - https://www.exploit-db.com/exploits/44300"
echo "$redintensy Linux Kernel < 3.5.0-23 (Ubuntu 12.04.2 x64) - 'SOCK_DIAG' SMEP Bypass$white - https://www.exploit-db.com/exploits/44299"
}
function Exploits3x(){
echo "$redintensy Linux Kernel 2.6.39 < 3.2.2 Gentoo / Ubuntu x86-x64 Mempodipper(1)$white - https://www.exploit-db.com/exploits/18411"
echo "$redintensy Linux Kernel 2.6.39 < 3.2.2 x86-x64 Mempodipper(2)$white - https://www.exploit-db.com/exploits/35161"
echo "$redintensy Linux Kernel 3.7.6 (RedHat x86/x64)$white - https://www.exploit-db.com/exploits/27297"
echo "$redintensy Linux Kernel 3.13 < 3.19 Ubuntu 12.04/14.04/14.10/15.04$white - https://www.exploit-db.com/exploits/37292"
echo "$redintensy Linux Kernel 3.13 SGID$white - https://www.exploit-db.com/exploits/33824"
echo "$redintensy Linux Kernel 3.13.1 (Metasploit)$white - https://www.exploit-db.com/exploits/40503"
echo "$redintensy Linux Kernel 3.14.5 (CentOS 7 / RHEL)$white - https://www.exploit-db.com/exploits/35370"
echo "$redintensy Linux Kernel 3.x (Ubuntu 14.04/Mint 17.3/Fedora 22)$white https://www.exploit-db.com/exploits/41999"
echo "$redintensy Linux Kernel < 4.4.0-116 (Ubuntu 16.04.4)$white - https://www.exploit-db.com/exploits/44298"
echo "$redintensy Linux kernel < 4.10.15 Race Condition$white - https://www.exploit-db.com/exploits/43345"
echo "$redintensy Linux Kernel < 4.13.9 (Ubuntu 16.04 / Fedora 27)$white - https://www.exploit-db.com/exploits/45010"
echo "$redintensy Linux Kernel < 4.4.0-21 (Ubuntu 16.04 x64) - 'netfilter target_offset'$white - https://www.exploit-db.com/exploits/44300"
echo "$redintensy Linux Kernel < 3.5.0-23 (Ubuntu 12.04.2 x64) - 'SOCK_DIAG' SMEP Bypass$white - https://www.exploit-db.com/exploits/44299"
}
function Exploits4x(){
echo "$redintensy Linux Kernel 4.3.3 Overlayfs$white - https://www.exploit-db.com/exploits/39230"
echo "$redintensy Linux Kernel 4.3.3 (Ubuntu 14.04/15.10)$white - https://www.exploit-db.com/exploits/39166"
echo "$redintensy Linux Kernel 4.4.0 (Ubuntu 14.04/16.04 x86-64)$white - https://www.exploit-db.com/exploits/40871"
echo "$redintensy Linux Kernel 4.4.0-21 < 4.4.0-51 (Ubuntu 14.04/16.04 x86-64)$white - https://www.exploit-db.com/exploits/47170"
echo "$redintensy Linux Kernel < 4.4.0-83 / < 4.8.0-58 (Ubuntu 14.04/16.04)$white - https://www.exploit-db.com/exploits/43418"
echo "$redintensy Linux Kernel < 4.4.0-116 (Ubuntu 16.04.4)$white - https://www.exploit-db.com/exploits/44298"
echo "$redintensy Linux Kernel 4.4.1$white - https://www.exploit-db.com/exploits/40003"
echo "$redintensy Linux Kernel 4.8.0 (UDEV < 232) - https://www.exploit-db.com/exploits/41886"
echo "$redintensy Linux kernel < 4.10.15 Race Condition$white - https://www.exploit-db.com/exploits/43345"
echo "$redintensy Linux Kernel 4.13 (Debian 9)$white - https://www.exploit-db.com/exploits/44303"
echo "$redintensy Linux Kernel < 4.13.9 (Ubuntu 16.04 / Fedora 27)$white - https://www.exploit-db.com/exploits/45010"
echo "$redintensy Linux Kernel 4.14.0-rc4+$white - https://www.exploit-db.com/exploits/43029"
echo "$redintensy Linux Kernel 4.15.x < 4.19.2 (polkit Method)$white - https://www.exploit-db.com/exploits/47167"
echo "$redintensy Linux Kernel 4.15.x < 4.19.2 (cron Method)$white - https://www.exploit-db.com/exploits/47164"
echo "$redintensy Linux Kernel 4.10 < 5.1.17$white - https://www.exploit-db.com/exploits/47163"
echo "$redintensy Linux Kernel < 4.4.0-21 (Ubuntu 16.04 x64) - 'netfilter target_offset'$white - https://www.exploit-db.com/exploits/44300"
echo "$redintensy Linux Kernel 4.13 (Ubuntu 17.10) - 'waitid()' SMEP/SMAP/Chrome Sandbox$white - https://www.exploit-db.com/exploits/43127"
}
function Exploits5x(){
echo "$redintensy Linux Kernel 4.10 < 5.1.17$white - https://www.exploit-db.com/exploits/47163"
echo "$redintensy Linux 5.3$white - https://www.exploit-db.com/exploits/47779"
echo "$redintensy Linux 5.3 - Privilege Escalation via io_uring Offload of sendmsg() onto Kernel Thread with Kernel Creds$white - https://www.exploit-db.com/exploits/47779"
}
function OperatingSystem(){
echo $boldgrn"[-] OPERATING SYSTEM"$white
echo $cyan"[+] - Check current user and group information:"$white
echo $yellowintensy"[x] The current user and group information:"$white
ID=$(id 2>/dev/null)
if [ "$ID" ];
then
echo -e "$ID\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'id' not found or empty output!\n"
fi
echo $yellowintensy"[x] The current user:"$white
WHOAMI=$(whoami 2>/dev/null)
if [ "$WHOAMI" ];
then
echo -e "$WHOAMI\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'whoami' not found or empty output!\n"
fi
echo $cyan"[+] - Check distribution type and version number:"$white
echo $yellowintensy"[x] The distribution type and version:"$white
RELEASE=$(cat /etc/*-release 2>/dev/null)
if [ "$RELEASE" ];
then
echo -e "$RELEASE\n"
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $cyan"[+] - CPU information:"$white
echo $yellowintensy"[x] CPU architecture information from sysfs and /proc/cpuinfo:"$white
CPUINFO=$(lscpu 2>/dev/null)
if [ "$CPUINFO" ];
then
echo -e "$CPUINFO\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'lscpu' not found or empty output!\n"
fi
echo $cyan"[+] - Check kernel version:"$white
echo $yellowintensy"[x] Kernel version and (32-bit/64-bit):"$white
UNAME=$(uname -a 2>/dev/null)
if [ "$UNAME" ];
then
echo -e "$UNAME\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'uname' not found or empty output!\n"
fi
echo $yellowintensy"[x] Kernel version and gcc version used to compile the kernel:"$white
PROCVERSION=$(cat /proc/version 2>/dev/null)
if [ "$PROCVERSION" ];
then
echo -e "$PROCVERSION\n"
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $cyan"[+] - Check mounted partitions:"$white
echo $yellowintensy"[x] Mounted partitions:"$white
LSBLK=$(lsblk 2>/dev/null)
if [ "$LSBLK" ];
then
echo -e "$LSBLK\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'lsblk' not found or empty outpu!\tn"
fi
echo ""
}
function KernelExploits(){
echo $boldgrn"[-] KERNEL EXPLOITS"$white
echo $cyan"[+] - Exploits:"$white
underversion2=2.0.0
kernel=$(uname -a | cut -d " " -f "3" | cut -d "-" -f "1")
OPERATOR=$(echo "$kernel $underversion2" | awk '{if ($1 < $2) print "2"; else print "3"}')
if [ "$OPERATOR" == "2" ];
then
echo $yellowintensy"[x] Possible exploits for linux kernel $kernel:"$white
echo "Popular 'possible not sure' exploits for kernel $kernel"
echo "-----------------------------------------------------------"
Exploits1x
echo -e "\nThe most specific exploits for your kernel $kernel"
echo "-----------------------------------------------------------"
Exploits1x > exploits1.txt
minimumsize=42
actualsize=$(wc -c exploits1.txt|cut -d " " -f 1)
if [ "$actualsize" -ge "$minimumsize" ];
then
grep "$kernel" exploits1.txt > exploit.txt
shred -n 5 -u -z exploits1.txt
exploitfilesize=$(wc -c exploit.txt|cut -d " " -f 1)
if [ "$exploitfilesize" -ge "$minimumsize" ];
then
cat exploit.txt
shred -n 5 -u -z exploit.txt
else
echo "No accurate exploit, for kernel $kernel - use manual approaches (Google, Searchsploit)"
fi
else
echo "Nothing here! But don't give up."
fi
else
underversion3=3.0.0
OPERATOR=$(echo "$kernel $underversion3" | awk '{if ($1 < $2) print "3"; else print "4"}')
if [ "$OPERATOR" == "3" ];
then
echo $yellowintensy"[x] Possible exploits for linux kernel $kernel:"$white
echo "Popular 'possible not sure' exploits for kernel $kernel"
echo "-----------------------------------------------------------"
Exploits3x
DirtyCow
echo -e "\nThe most specific exploits for your kernel $kernel"
echo "-----------------------------------------------------------"
Exploits3x > exploits2.txt
DirtyCow >> exploits2.txt
minimumsize=42
actualsize=$(wc -c exploits2.txt|cut -d " " -f 1)
if [ "$actualsize" -ge "$minimumsize" ];
then
grep "$kernel" exploits2.txt > exploit.txt
shred -n 5 -u -z exploits2.txt
exploitfilesize=$(wc -c exploit.txt|cut -d " " -f 1)
if [ "$exploitfilesize" -ge "$minimumsize" ];
then
cat exploit.txt
shred -n 5 -u -z exploit.txt
else
echo "No accurate exploit, for kernel $kernel - use manual approaches (Google, Searchsploit)"
fi
else
echo "Nothing here! But don't give up."
fi
else
underversion4=4.0.0
OPERATOR=$(echo "$kernel $underversion4" | awk '{if ($1 < $2) print "4"; else print "5"}')
if [ "$OPERATOR" == "4" ];
then
echo $yellowintensy"[x] Possible exploits for linux kernel $kernel:"$white
echo "Popular 'possible not 100% sure' exploits for kernel $kernel"
echo "-----------------------------------------------------------"
Exploits3x
DirtyCow
echo -e "\nThe most specific exploits for your kernel $kernel"
echo "-----------------------------------------------------------"
Exploits3x > exploits3.txt
DirtyCow >> exploits3.txt
minimumsize=42
actualsize=$(wc -c exploits3.txt|cut -d " " -f 1)
if [ "$actualsize" -ge "$minimumsize" ];
then
grep "$kernel" exploits3.txt > exploit.txt
shred -n 5 -u -z exploits3.txt
exploitfilesize=$(wc -c exploit.txt|cut -d " " -f 1)
if [ "$exploitfilesize" -ge "$minimumsize" ];
then
cat exploit.txt
shred -n 5 -u -z exploit.txt
else
echo "No accurate exploit, for kernel $kernel - use manual approaches (Google, Searchsploit)"
fi
else
echo "Nothing here! But don't give up."
fi
else
underversion5=5.0.0
OPERATOR=$(echo "$kernel $underversion5" | awk '{if ($1 < $2) print "5"; else print "6"}')
if [ "$OPERATOR" == "5" ];
then
echo $yellowintensy"[x] Possible exploits for linux kernel $kernel:"$white
echo "Popular 'possible not sure' exploits for kernel $kernel"
echo "-----------------------------------------------------------"
Exploits4x
echo -e "\nThe most specific exploits for your kernel $kernel"
echo "-----------------------------------------------------------"
Exploits4x > exploits4.txt
minimumsize=42
actualsize=$(wc -c exploits4.txt|cut -d " " -f 1)
if [ "$actualsize" -ge "$minimumsize" ];
then
grep "$kernel" exploits4.txt > exploit.txt
shred -n 5 -u -z exploits4.txt
exploitfilesize=$(wc -c exploit.txt|cut -d " " -f 1)
if [ "$exploitfilesize" -ge "$minimumsize" ];
then
cat exploit.txt
shred -n 5 -u -z exploit.txt
else
echo "No accurate exploit, for kernel $kernel - use manual approaches (Google, Searchsploit)"
fi
else
echo "Nothing here! But don't give up."
fi
else
underversion6=6.0.0
OPERATOR=$(echo "$kernel $underversion6" | awk '{if ($1 < $2) print "6"; else print "7"}')
if [ "$OPERATOR" == "6" ];
then
echo $yellowintensy"[x] Possible exploits for linux kernel $kernel:"$white
echo "Popular 'possible not sure' exploits for kernel $kernel"
echo "-----------------------------------------------------------"
Exploits5x
echo -e "\nThe most specific exploits for your kernel $kernel"
echo "-----------------------------------------------------------"
Exploits5x > exploits5.txt
minimumsize=42
actualsize=$(wc -c exploits5.txt|cut -d " " -f 1)
if [ "$actualsize" -ge "$minimumsize" ];
then
grep "$kernel" exploits5.txt > exploit.txt
shred -n 5 -u -z exploits5.txt
exploitfilesize=$(wc -c exploit.txt|cut -d " " -f 1)
if [ "$exploitfilesize" -ge "$minimumsize" ];
then
cat exploit.txt
shred -n 5 -u -z exploit.txt
else
echo "No accurate exploit, for kernel $kernel - use manual approaches (Google, Searchsploit)"
fi
else
echo "Nothing here! But don't give up."
fi
else
echo $yellowintensy"[x] Possible exploits for linux kernel $kernel:"$white
echo $redintensy"Nothing in our database on kernel $kernel. You still need to check using google search."$white
fi
fi
fi
fi
fi
echo ""
}
function AppsAndServices(){
echo $boldgrn"[-] APPS and SERVICES"$white
echo $cyan"[+] - Check jobs scheduled:"$white
echo $yellowintensy"[x] Search on cron in /etc:"$white
CRON=$(for x in "/etc"; do ls -l "$x"; done | grep cron 2>/dev/null)
if [ "$CRON" ];
then
echo -e "$CRON\n"
else
echo -e "None -> Probably needs more privileges(sudo), the '*cron* path' not found or empty output!\n"
fi
echo $yellowintensy"[x] Custom jobs or tasks configured as root and are world-writeable:"$white
CRONWRASROOT=$(find /etc/cron* -type f -perm -o+w -exec ls -l {} \; 2>/dev/null)
if [ "$CRONWRASROOT" ];
then
echo -e $redintensy"$CRONWRASROOT\n"$white
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $yellowintensy"[x] List /etc/cron.d/:"$white
CROND=$(for x in "/etc/cron.d/"; do ls -l "$x"; done | grep -v "total " 2>/dev/null)
if [ "$CROND" ];
then
echo -e "$CROND\n"
echo $yellowintensy"[x] Root's cron jobs:"$white
crontab -l
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
echo $yellowintensy"[x] Root's cron jobs:"$white
crontab -l
fi
echo ""
echo $yellowintensy"[x] The content of /etc/crontab:"$white
CRONTAB=$(cat /etc/crontab 2>/dev/null)
if [ "$CRONTAB" ];
then
echo -e "$CRONTAB\n"
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $yellowintensy"[x] View daily cron jobs:"$white
CRONDAILY=$(for x in "/etc/cron.daily"; do ls -l "$x"; done | grep -v "total " 2>/dev/null)
if [ "$CRONDAILY" ];
then
echo -e "$CRONDAILY\n"
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $yellowintensy"[x] View hourly cron jobs:"$white
CRONDHOURLY=$(for x in "/etc/cron.hourly"; do ls -l "$x"; done | grep -v "total " 2>/dev/null)
if [ "$CRONDHOURLY" ];
then
echo -e "$CRONDHOURLY\n"
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $yellowintensy"[x] View monthly cron jobs:"$white
CRONDMONTHLY=$(for x in "/etc/cron.monthly"; do ls -l "$x"; done | grep -v "total " 2>/dev/null)
if [ "$CRONDMONTHLY" ];
then
echo -e "$CRONDMONTHLY\n"
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $yellowintensy"[x] View weekly cron jobs:"$white
CRONDWEEKLY=$(for x in "/etc/cron.weekly"; do ls -l "$x"; done | grep -v "total " 2>/dev/null)
if [ "$CRONDWEEKLY" ];
then
echo -e "$CRONDWEEKLY\n"
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $yellowintensy"[x] Find world-writeable cron jobs:"$white
WRITEABLECRONJOB=$(find /etc/cron* -type f -perm -o+w -exec ls -l {} \;)
if [ "$WRITEABLECRONJOB" ];
then
echo -e "$WRITEABLECRONJOB\n"
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $cyan"[+] - Check for running services, and which service(s) are been running by root:"$white
echo $yellowintensy"[x] Display every process on the system:"$white
AUX=$(ps aux 2>/dev/null)
if [ "$AUX" ];
then
echo -e "$AUX\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'ps' not found or empty output!\n"
fi
echo $yellowintensy"[x] Process binaries and permissions:"$white
PROCESSBINARY=$(ps aux | awk '{print $11}'| xargs -r ls -la 2>/dev/null | awk '!x[$0]++' 2>/dev/null)
if [ "$PROCESSBINARY" ];
then
echo -e "$PROCESSBINARY\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'ps,xargs,awk' not found or empty output!\n"
fi
echo $yellowintensy"[x] Display every process running by root on the system:"$white
AUXROOT=$(ps aux | grep root 2>/dev/null)
if [ "$AUXROOT" ];
then
echo -e "$AUXROOT\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'ps' not found or empty output!\n"
fi
echo $yellowintensy"[x] Is mysql running by root:"$white
MYSQL=$(ps aux | grep mysql 2>/dev/null)
if [ "$MYSQL" ];
then
echo -e $redintensy"$MYSQL\n"$white
else
echo -e "None -> Probably needs more privileges(sudo), the command 'ps' not found or empty output!\n"
fi
}
function CommAndNet(){
echo $boldgrn"[-] COMMUNICATING and NETWORKING"$white
echo $cyan"[+] - Check NIC(s) does the system have:"$white
echo $yellowintensy"[x] Display all interfaces which are currently available:"$white
IFCONFIG=$(ifconfig -a 2>/dev/null)
if [ "$IFCONFIG" ];
then
echo -e "$IFCONFIG\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'ifconfig' not found or empty output!\n"
fi
echo $yellowintensy"[x] Available network interfaces on the system:"$white
INTERFACE=$(cat /etc/network/interfaces 2>/dev/null)
if [ "$INTERFACE" ];
then
echo -e "$INTERFACE\n"
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $yellowintensy"[x] Hosts:"$white
HOST=$(cat /etc/hosts 2>/dev/null)
if [ "$HOST" ];
then
echo -e "$HOST\n"
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $cyan"[+] - Check network configuration settings:"$white
echo $yellowintensy"[x] DNS name servers:"$white
RESOLV=$(cat /etc/resolv.conf 2>/dev/null)
if [ "$RESOLV" ];
then
echo -e "$RESOLV\n"
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $yellowintensy"[x] Networks:"$white
NETWORK=$(cat /etc/networks 2>/dev/null)
if [ "$NETWORK" ];
then
echo -e "$NETWORK\n"
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $yellowintensy"[x] SELinux enabled - status:"$white
SELinux=$(sestatus 2>/dev/null)
if [ "$SELinux" ];
then
echo -e "$SELinux\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'sestatus' not found or empty output!\n"
fi
echo $yellowintensy"[x] Execshield enabled:"$white
Execshield=$(grep "exec-shield" /etc/sysctl.conf)
if [ "$Execshield" ];
then
echo -e "$Execshield\n"
else
echo -e "None -> Probably needs more privileges(sudo), the 'exec-shield' not found in /etc/sysctl.conf or empty output!\n"
fi
echo $yellowintensy"[x] Packet filter rules:"$white
IPTABLE=$(iptables -L 2>/dev/null)
if [ "$IPTABLE" ];
then
echo -e "$IPTABLE\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'iptables' not found or empty output!\n"
fi
echo $yellowintensy"[x] hostname:"$white
HOSTNAME=$(hostname 2>/dev/null)
if [ "$HOSTNAME" ];
then
echo -e "$HOSTNAME\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'hostname' not found or empty output!\n"
fi
echo $yellowintensy"[x] Get DNS domain or the FQDN:"$white
DNS=$(dnsdomainname 2>/dev/null)
if [ "$DNS" ];
then
echo -e "$DNS\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'dnsdomainname' not found or empty output!\n"
fi
echo $cyan"[+] - Check users and hosts communicating with the system:"$white
echo $yellowintensy"[x] Display all TCP/UDP connected socket, PID/program:"$white
NETSTAT=$(netstat -antup 2>/dev/null)
if [ "$NETSTAT" ];
then
echo -e "$NETSTAT\n"
else
#alternative to netstat
SS=$(ss -tuln 2>/dev/null)
echo -e "$SS\n"
fi
echo $yellowintensy"[x] List files based on their Internet address:"$white
LSOF=$(lsof -Pi 2>/dev/null)
if [ "$LSOF" ];
then
echo -e "$LSOF\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'lsof' not found or empty output!\n"
fi
echo $yellowintensy"[x] Last logged on users:"$white
LAST=$(last -a 2>/dev/null)
if [ "$LAST" ];
then
echo -e "$LAST\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'last' not found or empty output!\n"
fi
echo $yellowintensy"[x] Most Recent Logins:"$white
LASTLOG=$(lastlog 2>/dev/null)
if [ "$LASTLOG" ];
then
echo -e "$LASTLOG\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'lastlog' not found or empty output!\n"
fi
echo $yellowintensy"[x] Who is currently logged onto the system:"$white
W=$(w 2>/dev/null)
if [ "$W" ];
then
echo -e "$W\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'w' not found or empty output!\n"
fi
echo $cyan"[+] - Check cached IP and/or MAC addresses:"$white
echo $yellowintensy"[x] Display all hosts based on ARP:"$white
ARP=$(arp -a 2>/dev/null)
if [ "$ARP" ];
then
echo -e "$ARP\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'arp' not found or empty output!\n"
fi
echo $yellowintensy"[x] Display IP routing table:"$white
ROUTE=$(route -nee 2>/dev/null)
if [ "$ROUTE" ];
then
echo -e "$ROUTE\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'route' not found or empty output!\n"
fi
}
function ConfidentialInfoAndUser(){
echo $boldgrn"[-] CONFIDENTIAL INFO and USER"$white
echo $cyan"[+] - Check list of users and super users:"$white
SUPERUSER1=$(awk -F: '($3 == "0") {print}' /etc/passwd 2>/dev/null)
SUPERUSER2=$(grep -v -E "^#" /etc/passwd 2>/dev/null | awk -F: '$3 ==0 { print $1}' 2>/dev/null)
if [ "$SUPERUSER1" ] || [ "$SUPERUSER2" ];
then
echo $yellowintensy"[x] Super user:"$white
echo "$SUPERUSER1"; echo "$SUPERUSER2"
echo ""
else
:
fi
echo $yellowintensy"[x] Useful home users:"$white
HOMEUSERS=$(ls -ld /home/* 2>/dev/null)
if [ "$HOMEUSERS" ];
then
echo -e $redintensy"$HOMEUSERS\n"$white
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $yellowintensy"[x] From /etc/passwd - /bin/bash /bin/sh /bin/zsh /bin/dash:"$white
PASSWD=$(cat /etc/passwd | grep "/bin/bash\|/bin/sh\|/bin/dash\|/bin/zsh" 2>/dev/null)
if [ "$PASSWD" ];
then
echo -e "$PASSWD\n"
else
echo -e "None -> Probably needs more privileges(sudo) or empty output!\n"
fi
echo $cyan"[+] - Check /etc for config files (recursive 1 level):"$white
echo $yellowintensy"[x] All *.conf files in /etc (recursive 1 level):"$white
CHECKETC=$(find /etc/ -maxdepth 1 -name "*.conf" -type f -exec ls -la {} \; 2>/dev/null)
if [ "$CHECKETC" ];
then
echo -e "$CHECKETC\n"
else
echo -e "None -> Probably needs more privileges(sudo), the command 'find' not found or empty output!\n"
fi
echo $yellowintensy"[x] Check to see if we can read master.passwd:"$white
MASTERPASS=$(cat /etc/master.passwd 2>/dev/null)
if [ "$MASTERPASS" ];
then
echo $redintensy"[/] Readable - /etc/master.passwd"$white
echo -e "$MASTERPASS\n"
else
echo -e "None -> Probably needs more privileges(sudo) or the 'path' not found!\n"
fi
echo $yellowintensy"[x] Sudo permissions"$white
SUDOPASS=$(echo '' | sudo -S -l 2>/dev/null)
if [ "$SUDOPASS" ];
then
echo $redintensy"[/] We can run sudo without supplying a password:"$white
echo -e "$SUDOPASS\n"
else
echo -e "None -> Probably needs more privileges(sudo)!\n"
fi
echo $cyan"[+] - Check sensitive files:"$white
echo $yellowintensy"[x] From /etc - /etc/passwd /etc/shadow /etc/group /etc/sudoers:"$white
WRPASS=$(ls -l /etc/passwd 2>/dev/null)
if [ -w /etc/passwd ];
then
echo $redintensy"$WRPASS"$white
else
echo "$WRPASS"
fi
WXSHADOW=$(ls -l /etc/shadow 2>/dev/null)
if [ -w /etc/shadow ] || [ -r /etc/shadow ];
then
echo $redintensy"$WXSHADOW"$white
else
echo "$WXSHADOW"
fi
WRGROUP=$(ls -l /etc/group 2>/dev/null)
if [ -w /etc/group ];
then
echo $redintensy"$WRGROUP"$white
else
echo "$WRGROUP"
fi
WRSUDOERS=$(ls -l /etc/sudoers 2>/dev/null)
if [ -w /etc/sudoers ] || [ -r /etc/sudoers ];
then
echo $redintensy"$WRSUDOERS"$white
else
echo "$WRSUDOERS"
fi
echo ""
if [ -r /var/backups/passwd.bak ] || [ -r /var/backups/group.bak ] || [ -r /var/backups/shadow.bak ] || [ -r /var/backups/gshadow.bak ];
then
echo $cyan"[+] - Check backup files:"$white
BACKUPPASS=$(ls -l /var/backups/passwd.bak 2>/dev/null)
if [ -r /var/backups/passwd.bak ];
then
echo $redintensy"$BACKUPPASS"$white
else
echo "$BACKUPPASS"
fi
BACKUPGROUP=$(ls -l /var/backups/group.bak 2>/dev/null)
if [ -r /var/backups/group.bak ];
then
echo $redintensy"$BACKUPGROUP"$white
else
echo "$BACKUPGROUP"
fi
BACKUPSHADOW=$(ls -l /var/backups/shadow.bak 2>/dev/null)
if [ -r /var/backups/shadow.bak ];
then
echo $redintensy"$BACKUPSHADOW"$white
else
echo "$BACKUPSHADOW"
fi
BACKUPGSHADOW=$(ls -l /var/backups/gshadow.bak 2>/dev/null)
if [ -r /var/backups/gshadow.bak ];
then
echo $redintensy"$BACKUPGSHADOW"$white
else
echo "$BACKUPGSHADOW"
fi
else
echo $cyan"[+] - Check backup files - /var/backups/:"$white
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $yellowintensy"[x] From / - any interesting folder/files:"$white
UNUSUALF=$(ls -la / | grep -v 'total ' 2>/dev/null)
if [ "$UNUSUALF" ];
then
echo -e "$UNUSUALF\n"$white
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $cyan"[+] - Check if anything interesting in the mail directory:"$white
echo $yellowintensy"[x] Interesting mail in /var/mail:"$white
if [ -d /var/mail ];
then
MAILVAR=$(for x in "/var/mail"; do ls -lh "$x"; done | grep -v "total " 2>/dev/null)
if [ "$MAILVAR" ];
then
echo -e "$MAILVAR\n"
else
echo -e "None -> Probably needs more privileges(sudo) or empty output!\n"
fi
else
echo -e "None -> Probably needs more privileges(sudo) or the 'path' not found!\n"
fi
echo $yellowintensy"[x] Is /var/mail/root exist - you can try to read it:"$white
if [ -e /var/mail/root ];
then
$ROOTMAIL=$(ls -l /var/mail/root | grep -v "total " 2>/dev/null)
echo -e $redintensy"$ROOTMAIL"$white
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $cyan"[+] - Check if anything interesting in the home/root directories:"$white
echo $yellowintensy"[x] Check if /root is accessible:"$white
ROOTDIR=$(for x in "/root"; do ls -lh "$x"; done 2>/dev/null)
if [ "$ROOTDIR" ];
then
echo $redintensy"[/] Root directory can be accessible"$white
echo -e "$ROOTDIR\n"
else
echo -e "None -> Probably needs more privileges(sudo) or empty output!\n"
fi
echo $yellowintensy"[x] Interesting /home/* directory:"$white
HOMEDIR=$(for x in "/home"; do ls -lh "$x"; done 2>/dev/null)
if [ "$HOMEDIR" ];
then
echo -e $redintensy"$HOMEDIR\n"$white
else
echo -e "None -> Probably needs more privileges(sudo) or empty output!\n"
fi
echo $yellowintensy"[x] History files of /home/*/:"$white
HOMEHISTORY=$(find /home/* -name *.*history* -print 2> /dev/null)
if [ "$HOMEHISTORY" ];
then
echo -e $redintensy"$HOMEHISTORY\n"$white
else
echo -e "None -> Probably needs more privileges(sudo) the 'path' not found or empty output!\n"
fi
echo $yellowintensy"[x] History files of /root:"$white
ROOTHISTORY=$(for x in /root/.*_history; do ls -lh "$x"; done 2>/dev/null)
if [ "$ROOTHISTORY" ];
then
echo -e $redintensy"$ROOTHISTORY\n"$white
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $yellowintensy"[x] Grep passwd from .bash_history:"$white
GREPPASSWDHISTORY=$(grep passwd /home/*/.bash_history 2>/dev/null)
if [ "$GREPPASSWDHISTORY" ];
then
echo -e $redintensy"$GREPPASSWDHISTORY\n"$white
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $cyan"[+] - Check for plain text password:"$white
if [ -e ~/.bash_history ];
then
echo $yellowintensy"[x] ~/.bash_history - snippet below:"$white
BASHHISTORY=$(head ~/.bash_history)
echo -e $redintensy"$BASHHISTORY\n"$white
else
echo -e $blu"~/.bash_history not found!\n"$white
fi
if [ -e ~/.nano_history ];
then
echo $yellowintensy"[x] ~/.nano_history - snippet below:"$white
NANOHISTORT=$(head ~/.nano_history)
echo -e $redintensy"$NANOHISTORT\n"$white
else
:
fi
if [ -e ~/.mysql_history ];
then
echo $yellowintensy"[x] ~/.mysql_history - snippet below:"$white
MYSQLHISTORY=$(head ~/.mysql_history)
echo -e $redintensy"$MYSQLHISTORY\n"$white
else
:
fi
if [ -e ~/.php_history ];
then
echo $yellowintensy"[x] ~/.php_history - snippet below:"$white
PHPHISTORY=$(head ~/.php_history)
echo -e $redintensy"$PHPHISTORY\n"$white
else
:
fi
echo $cyan"[+] - Check SSH Dir/Files:"$white
echo $yellowintensy"[x] Any private-key info - /home/*/.ssh/:"$white
for usersshfolder in /home/*/.ssh
do
ls -ld "$usersshfolder"
for files in $usersshfolder
do
if [ -r "$files" ];
then
sshfile=$(ls -l "$files" | grep -v "total " 2>/dev/null)
echo -e $redintensy"$sshfile READABLE\n"$white
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
done
done
if [ -d /root/.ssh ];
then
echo $yellowintensy"[x] Any private-key info - /root/.ssh/:"$white
ls -ld /root/.ssh/
for rootsshfiles in "/root/.ssh"
do
if [ -r "$rootsshfiles" ];
then
rootsshfile=$(ls -l "$files" | grep -v "total " 2>/dev/null)
echo -e $redintensy"$rootsshfile [READABLE]\n"$white
else
LISTSSHROOT=$(ls -ld /root/.ssh/)
echo -e "$LISTSSHROOT\n"
fi
done
else
echo $yellowintensy"[x] Any private-key info - /root/.ssh/:"$white
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $yellowintensy"[x] Check if PermitRootLogin is on:"$white
ROOTLOGIN=$(grep "PermitRootLogin" /etc/ssh/sshd_config | grep -v "#" | awk '{print $2}')
if [ "$ROOTLOGIN" ];
then
echo $redintensy"[/] Root is allowed to login via SSH"$white
echo -e "$ROOTLOGIN\n"
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
PGPKEY=$(ls -l /home/*/.gnupg/secring.gpgs 2>/dev/null)
Kerberos1=$(ls -l /tmp/krb5.keytab 2>/dev/null)
Kerberos2=$(ls -l /tmp/krb5cc_* 2>/dev/null)
if [ "$PGPKEY" ] || [ "$Kerberos1" ] || [ "$Kerberos2" ];
then
echo $cyan"[+] - Check PGP keys and Kerberos tickets:"$white
if [ "$PGPKEY" ];
then
echo $yellowintensy"[x] PGP keys:"$white
echo -e $redintensy"$PGPKEY\n"$white
else
echo $yellowintensy"[x] PGP keys:"$white
echo -e "None -> Probably needs more privileges(sudo) or the 'path' not found!\n"
fi
if [ "$Kerberos1" ] || [ "$Kerberos2" ];
then
if [ "$Kerberos1" ];
then
echo $yellowintensy"[x] Kerberos tickets - krb5.keytab:"$white
echo -e $redintensy"$Kerberos1\n"$white
else
echo $yellowintensy"[x] Kerberos tickets - krb5.keytab:"$white
echo -e "None -> Probably needs more privileges(sudo) or the 'path' not found!\n"
fi
if [ "$Kerberos2" ];
then
echo $yellowintensy"[x] Kerberos tickets - krb5cc_*:"$white
echo -e $redintensy"$Kerberos2\n"$white
else
echo $yellowintensy"[x] Kerberos tickets - krb5cc_*:"$white
echo -e "None -> Probably needs more privileges(sudo) or the 'path' not found!\n"
fi
fi
else
echo $cyan"[+] - Check PGP keys and Kerberos tickets:"$white
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"
fi
echo $cyan"[+] - Check password policy information and Umask value:"$white
echo $yellowintensy"[x] Password Policy:"$white
LOGINDEFS=$(grep "^PASS_MAX_DAYS\|^PASS_MIN_DAYS\|^PASS_WARN_AGE\|^ENCRYPT_METHOD" /etc/login.defs 2>/dev/null)
if [ "$LOGINDEFS" ];
then
echo -e "$LOGINDEFS\n"
else
echo -e "None -> Probably needs more privileges(sudo) or the 'path' not found!\n"
fi
UMASKVALUE=$(umask 2>/dev/null & umask -S 2>/dev/null)
if [ "$UMASKVALUE" ];
then
echo $yellowintensy"[x] Current umask value:"$white
echo -e "$UMASKVALUE\n"
else
echo -e "None -> Probably needs more privileges(sudo) or the command 'umask' not found!\n"
fi
echo $cyan"[+] - Accessible .rhosts files"$white
echo $yellowintensy"[x] Rhost config file(s):"$white
RHOSTUSR=$(find /home -iname "*.rhosts" -exec ls -la {} \; 2>/dev/null)
if [ "$RHOSTUSR" ];
then
echo -e $redintensy"$RHOSTUSR\n"$white
else
echo -e "None -> Probably needs more privileges(sudo), the 'path' not found or empty output!\n"