概要
HackTheBox:Appointmentのflagを入手する手順を記す。
Port Scan
$ nmap -A -sV appointment.htb
Starting Nmap 7.92 ( https://nmap.org ) at 2022-09-15 10:35 EDT
Nmap scan report for appointment.htb (10.129.42.72)
Host is up (0.25s latency).
Not shown: 999 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd 2.4.38 ((Debian))
|_http-title: Login
|_http-server-header: Apache/2.4.38 (Debian)
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 63.48 seconds
port 80でhttpを提供していることが分かる。
Port80にアクセスする
http://appointment.htb にアクセスすると以下のページが現れる。

admin/root/passwordで試してもログインできない。
SQL Injectionを試行する
有名所のSQL Injectionを試してみる。
以下の内容を試してみる。
- Username : admin
- Password : ' or '1'='1
最終的にこのInjectionは成功し、flagが画面に表示される。
SQL Injectionの中身について
先ほど行ったInjectionは以下の原理で成功する。
password='%s'
となる部分の%sに
' or '1'='1
を代入すると
password='' or '1'='1'
という内容になり、条件式が常に真となってしまう。