We were able to gain SSH access to a Linux machine whose password was reused by another machine during our penetration test.思路:这是一个假设的情景,目标主机存在一个叫做“leave_msg”的自研程序,该程序带参运行后会把留言写入到“msg.txt”文件中。而"leave_msg"文件设置了SUID位且该文件属主是root最高权限。
On this machine, we have a standard user "htb-student" who can leave a message to the administrator using a self-written program called "leave_msg." Since the target company pays a lot of attention to defense from outside their network, and the administrator's appearance showed high self-confidence, it may indicate that local security was disregarded.
After our research, we found out that these messages are stored in "/htb-student/msg.txt," which is binary owned by the user root, and the SUID bit is set.
Examine the program and find out if it is vulnerable to a Stack-Based Buffer Overflow. If you have found the vulnerability, then use it to read the file "/root/flag.txt" placed on the system as proof.
Determine the file type of "leave_msg" binary and submit it as the answer.这个问题没有给回答的格式属实有点脑残,我们可以得到一长串对于文件类型的描述,但是我试了好几个都错误,最后不得不去HTB社区求助。
How many bytes in total must be sent before reaching EIP?首先我们把“leave_msg”这个程序文件放到GDB进行调试。
Submit the size of the stack space after overwriting the EIP as the answer. (Format: 0x00000)按照上一个问题得到的结果,我们填充2060个垃圾字符(\x55),然后EIP填充4个垃圾字符(\x66)。填充后查看寄存器,EIP=0x666666。
Read the file "/root/flag.txt" and submit the content as the answer.首先我们要识别保留字符或者叫无效字符(bad characters),先在调用leavemsg函数处设置断点,避免我们填充中包含的无效字符使得程序意外中断并报错。
欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) | Powered by Discuz! X3.4 |