找回密码
 立即注册
首页 业界区 业界 fowsniff WP

fowsniff WP

钱闲华 昨天 15:05
下载地址:
https://download.vulnhub.com/fowsniff/Fowsniff_CTF_ova.7z
category:重要
awk剪切得到字典,巩固awk使用技巧
motd提权,有意思的提权方式
这篇WP详细讲了motd提权,感兴趣可以看看,带有一定推测,欢迎大佬指点纠正
一两个月前打的,凭记忆复现,可能攻击链的体现不是特别流畅,望海涵
1.png

扫描,开了通信服务,稍后可能会用得到
访问web服务:
2.png

给了一个账户,查看
3.png

且文中说用户的用户名和密码都已泄露
所以去谷歌搜索看是否有相关信息
4.png

可以找到这样一个文件:
  1. FOWSNIFF CORP PASSWORD LEAK
  2.             ''~``
  3.            ( o o )
  4. +-----.oooO--(_)--Oooo.------+
  5. |                            |
  6. |          FOWSNIFF          |
  7. |            got             |
  8. |           PWN3D!!!         |
  9. |                            |         
  10. |       .oooO                |         
  11. |        (   )   Oooo.       |         
  12. +---------\ (----(   )-------+
  13.            \_)    ) /
  14.                  (_/
  15. FowSniff Corp got pwn3d by B1gN1nj4!
  16. No one is safe from my 1337 skillz!
  17. mauer@fowsniff:8a28a94a588a95b80163709ab4313aa4
  18. mustikka@fowsniff:ae1644dac5b77c0cf51e0d26ad6d7e56
  19. tegel@fowsniff:1dc352435fecca338acfd4be10984009
  20. baksteen@fowsniff:19f5af754c31f1e2651edde9250d69bb
  21. seina@fowsniff:90dc16d47114aa13671c697fd506cf26
  22. stone@fowsniff:a92b8a29ef1183192e3d35187e0cfabd
  23. mursten@fowsniff:0e9588cb62f4b6f27e33d449e2ba0b3b
  24. parede@fowsniff:4d6e42f56e127803285a0a7649b5ab11
  25. sciana@fowsniff:f7fd98d380735e859f8b2ffbbede5a7e
  26. Fowsniff Corporation Passwords LEAKED!
  27. FOWSNIFF CORP PASSWORD DUMP!
  28. Here are their email passwords dumped from their databases.
  29. They left their pop3 server WIDE OPEN, too!
  30. MD5 is insecure, so you shouldn't have trouble cracking them but I was too lazy haha =P
  31. l8r n00bz!
  32. B1gN1nj4
  33. -------------------------------------------------------------------------------------------------
  34. This list is entirely fictional and is part of a Capture the Flag educational challenge.
  35. --- THIS IS NOT A REAL PASSWORD LEAK ---
  36. All information contained within is invented solely for this purpose and does not correspond
  37. to any real persons or organizations.
  38. Any similarities to actual people or entities is purely coincidental and occurred accidentally.
复制代码
虽然说让员工修改密码,不排除有漏网之鱼
我们可以剪切得到字典进行爆破
Here are their email passwords dumped from their databases.
They left their pop3 server WIDE OPEN, too!
这段话的意思是这些账户是邮箱的密码,pop3完全开放,也就是不需要其他验证(没有其他认证保护)就可以就可以凭借凭据登录
接下来思路很明确了
爆破一下这些md5
应该是raw-md5
raw-md5的特征
特征项描述长度32 个十六进制字符(128 位)编码纯小写或大写十六进制(无 Base64、无前缀)字符集只包含 0-9
和 a-f
(或 A-F
)示例8a28a94a588a95b80163709ab4313aa4John 会自动解析文件中的每行,识别冒号分割的字段,将哈希字段提取出来用于爆破。
所以这里不用awk,直接拿给john爆破
5.png

拿到很多用户凭据,先试试碰撞ssh,不成再找找别的地方是否能用上
6.png

可以看到碰撞失败
(这里用crackmapexec效果差不多)
继续回到80端口
7.png

如果能扫到登录页面,就可以继续碰撞
扫描完发现不成,这时想到pop3服务是否可以爆破,查询hydra 爆破pop3
空格的awk可以直接指定字段不指定分隔符
8.png

9.png

爆破成功
pop3尝试登录查看邮件信息
pop3语法总结
命令作用STAT查看邮件数量和总字节数LIST列出所有邮件编号和大小LIST 列出第 n 封邮件的大小RETR 取回第 n 封邮件的内容DELE 删除第 n 封邮件(退出前不生效)NOOP空操作,保持连接RSET取消已标记删除的邮件TOP  查看第 n 封邮件前 x 行正文(不含附件)可以看到有两封邮件,第一封写道:
  1. nc 10.10.10.129 110
  2. +OK Welcome to the Fowsniff Corporate Mail Server!
  3. USER seina
  4. +OK
  5. PASS scoobydoo2
  6. +OK Logged in.
  7. STAT
  8. +OK 2 2902
  9. LIST
  10. +OK 2 messages:
  11. 1 1622
  12. 2 1280
  13. .
  14. LIST 1
  15. +OK 1 1622
  16. RETR 1
  17. +OK 1622 octets
  18. Return-Path: <stone@fowsniff>
  19. X-Original-To: seina@fowsniff
  20. Delivered-To: seina@fowsniff
  21. Received: by fowsniff (Postfix, from userid 1000)
  22.         id 0FA3916A; Tue, 13 Mar 2018 14:51:07 -0400 (EDT)
  23. To: baksteen@fowsniff, mauer@fowsniff, mursten@fowsniff,
  24.     mustikka@fowsniff, parede@fowsniff, sciana@fowsniff, seina@fowsniff,
  25.     tegel@fowsniff
  26. Subject: URGENT! Security EVENT!
  27. Message-Id: <20180313185107.0FA3916A@fowsniff>
  28. Date: Tue, 13 Mar 2018 14:51:07 -0400 (EDT)
  29. From: stone@fowsniff (stone)
  30. Dear All,
  31. A few days ago, a malicious actor was able to gain entry to
  32. our internal email systems. The attacker was able to exploit
  33. incorrectly filtered escape characters within our SQL database
  34. to access our login credentials. Both the SQL and authentication
  35. system used legacy methods that had not been updated in some time.
  36. We have been instructed to perform a complete internal system
  37. overhaul. While the main systems are "in the shop," we have
  38. moved to this isolated, temporary server that has minimal
  39. functionality.
  40. This server is capable of sending and receiving emails, but only
  41. locally. That means you can only send emails to other users, not
  42. to the world wide web. You can, however, access this system via
  43. the SSH protocol.
  44. The temporary password for SSH is "S1ck3nBluff+secureshell"
  45. You MUST change this password as soon as possible, and you will do so under my
  46. guidance. I saw the leak the attacker posted online, and I must say that your
  47. passwords were not very secure.
  48. Come see me in my office at your earliest convenience and we'll set it up.
  49. Thanks,
  50. A.J Stone
复制代码
可以看到,这里给了员工 ssh的临时密码并且让他们尽快修改,这是我们要碰撞一下看是否有员工尚未修改,有的话可以直接拿到shell
10.png

可以看到,这位员工没有修改密码,尝试ssh连接
连接成功:
11.png

这时再看一下第二封信,说不定可以决定提权的方向
第二封信写道:
  1. RETR 2
  2. +OK 1280 octets
  3. Return-Path: <baksteen@fowsniff>
  4. X-Original-To: seina@fowsniff
  5. Delivered-To: seina@fowsniff
  6. Received: by fowsniff (Postfix, from userid 1004)
  7.         id 101CA1AC2; Tue, 13 Mar 2018 14:54:05 -0400 (EDT)
  8. To: seina@fowsniff
  9. Subject: You missed out!
  10. Message-Id: <20180313185405.101CA1AC2@fowsniff>
  11. Date: Tue, 13 Mar 2018 14:54:05 -0400 (EDT)
  12. From: baksteen@fowsniff
  13. Devin,
  14. You should have seen the brass lay into AJ today!
  15. We are going to be talking about this one for a looooong time hahaha.
  16. Who knew the regional manager had been in the navy? She was swearing like a sailor!
  17. I don't know what kind of pneumonia or something you brought back with
  18. you from your camping trip, but I think I'm coming down with it myself.
  19. How long have you been gone - a week?
  20. Next time you're going to get sick and miss the managerial blowout of the century,
  21. at least keep it to yourself!
  22. I'm going to head home early and eat some chicken soup.
  23. I think I just got an email from Stone, too, but it's probably just some
  24. "Let me explain the tone of my meeting with management" face-saving mail.
  25. I'll read it when I get back.
  26. Feel better,
  27. Skyler
  28. PS: Make sure you change your email password.
  29. AJ had been telling us to do that right before Captain Profanity showed up.
复制代码
第二封信可以看出,这个署名为Skyler的人应该就是没有修改密码的员工baksteen, 因为他使用自己的昵称Skyler作为他自己的邮箱密码。之所以没改密码是因为他觉得不舒服,要回家先喝鸡汤再看,不巧被我们捷足先登了;以及stone管理员因为数据库泄露被区域经理骂了。总之,应该没有什么重要线索,不过不得不说这个靶机的情景设计十分用心
所以接下来常规提权
提权

枚举
sudo -l:baksteen没有权限使用
suid:
12.png

crontab: 无定时任务
kernel: fowsniff 4.4.0-116-generic,基本不会考虑内核提权了
writable:
13.png

发现了有趣的可写文件,cube.sh
14.png

可以看到baksteen属于文件所属的用户组,也就是可以对它施行读写执行
15.png

这个ascii很眼熟,就是我们ssh连接成功会输出的内容
这就很有意思了,应该是有一个高权限的文件(ssh连接相关)运行了cube.sh,
才使得它在每次成功登录时都输出这些信息
这里怀疑和motd提权有关
于是使用grep -R '/opt/cube/cube.sh' /etc 2>/dev/null递归查找是谁在运行cube.sh的文件
果然:
16.png

再一看权限:
17.png

虽然都是root,但是这还不够,一般这种权限的脚本,其他用户执行也只能以普通用户的身份执行,只有suid,sudo或者定时任务才能真正以root的身份执行
以root身份执行的脚本,反弹回来的shell才是root shell,
反弹shell的本质是在目标主机上启动一个 shell,然后通过网络连接将这个 shell 的输入/输出“重定向”到攻击者主机上。
因为脚本是由root启动的进程执行的,反弹回去的shell就继承了这个进程的身份,也就是root
推测这些脚本是在用户登录完成前执行的,用于生成欢迎信息,看刚登录的状态:
18.png

是先输出欢迎信息再有用户的提示符的,
也就是说,在执行者作为指定普通用户时,它还没分配给普通用户的身份,是root身份的,因此也会以root身份运行,这样一来
注:下一个wp也会用到motd提权,可以结合着一起看
所以现在的思路就是,在cube.sh中写入一些东西,让root身份的脚本执行这个脚本从而达到提权的目的
(不过关于以root身份这点,似乎要视系统而定,有的系统是有的好像不是)
在cube.sh写入
  1. #!/bin/sh
  2. /bin/bash
复制代码
再ssh连接,似乎不行,大概还是因为登录完成后身份重新分配
(很多结论是结合我的实验现象得出的,欢迎讨论指正)
总之,反弹shell
19.png

20.png

这样就成了
21.png

心得:这台机子的提权方式很有趣,motd提权有待后续遇到时验证

来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
您需要登录后才可以回帖 登录 | 立即注册