---
title: "2. Fuzzing"
date: 2024-09-25
draft: false
---

```bash
 ffuf -w /opt/useful/SecLists/Discovery/Web-Content/directory-list-2.3-small.txt:FUZZ -u http://SERVER_IP:PORT/FUZZ
```
we can place the `FUZZ` keyword where the directory would be within our URL 

This example looks for directories.

We can even make it go faster if we are in a hurry by increasing the number of threads to 200, for example, with `-t 200`, but this is not recommended, especially when used on a remote site, as it may disrupt it, and cause a `Denial of Service`, or bring down your internet connection in severe cases. We do get a couple of hits, and we can visit one of them to verify that it exists

## ffuf - extensions
```shell-session
ffuf -w /usr/share/wordlists/secLists/Discovery/Web-Content/web-extensions.txt:FUZZ -u http://94.237.54.201:39593/blog/indexFUZZ
```
self explanatory

in example, we see that we get some php file exts.
We now know that this website runs on `PHP` to start fuzzing for `PHP` files.
## ffuf - page fuzzing
```shell-session
 ffuf -w /usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-small.txt:FUZZ -u http://94.237.54.201:39593/blog/FUZZ.php

```

## ffuf - recursive flags
scanning recursively auto starts new scan under newly identified directories
websites may have a big tree of sub-directories, like `/login/user/content/uploads/...etc`, and this will expand the scanning tree and may take a very long time to scan them all. This is why it is always advised to specify a `depth` to our recursive scan
use `-recurse` and `-recursion-depth` 

```bash
ffuf -w /usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-small.txt:FUZZ -u http://SERVER_IP:PORT/FUZZ -recursion -recursion-depth 1 -e .php -v
```

## ffuf - dns records
![](/img/Pasted image 20240925121817.png)

browsers only know how to access ips, if we provide a url they map it by looking into `/etc/hosts`

## ffuf - subdomain fuzzing
A sub-domain is any website underlying another domain. For example, `https://photos.google.com` is the `photos` sub-domain of `google.com`.

In this case, we are simply checking different websites to see if they exist by checking if they have a public DNS record that would redirect us to a working server IP. So, let's run a scan and see if we get any hits. Before we can start our scan, we need two things:

- A `wordlist`
- A `target`

common wordlists for subdomain fuzzing: 
`/usr/share/wordlists/seclists/Discovery/DNS` 
we're using a shorter list - `subdomains-top1million-5000.txt`

```bash
ffuf -w /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-5000.txt:FUZZ -u https://FUZZ.inlanefreight.com/
```

if we fuzz subdomains and get nothing, that doesn't mean there isn't any. 
this means there's no `public` subds under that domain, and it doesn't have a public DNS record. 
even though we added `academy.htb` to /etc/hosts; we only added main domain, so when we look for other subds in /etc/hosts they are not found. 
\
## ffuf - vhost fuzzing

As we saw in the previous section, we were able to fuzz public sub-domains using public DNS records. However, when it came to fuzzing sub-domains that do not have a public DNS record or sub-domains under websites that are not public, we could not use the same method. In this section, we will learn how to do that with `Vhost Fuzzing`.

Key difference between VHosts and Subdomains: 
- Vhost is basically a `sub-domain` hosted on the `same server` and has the `same IP` 
	- Such that: A single IP could be serving two/more websites. 
- Vhosts MAY or MAY NOT have public DNS records. 

In many cases websites would actually have sub-domains that are not public and will not publish them in DNS records. 
- Hence, unable to connect - public dns doesn't know their IP. 
- With subdomain fuzzing we could identify public subdomains but will not identify private ones. 
- This is where we fuzz VHosts on IPs we already have. 

Without adding the entire wordlist to our `/etc/hosts` file, we can fuzz using the HTTP `Host:` header. 

```bash
ffuf -w /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-5000.txt:FUZZ -u http://academy.htb:PORT/ -H 'Host: FUZZ.academy.htb'
```


## ffuf - filtering 
```bash
  -fc              Filter HTTP status codes from response. Comma separated list of codes and ranges
  -fl              Filter by amount of lines in response. Comma separated list of line counts and ranges
  -fr              Filter regexp
  -fs              Filter HTTP response size. Comma separated list of sizes and ranges
  -fw              Filter by amount of words in response. Comma separated list of word counts and ranges
```

```bash
  -mc              Match HTTP status codes, or "all" for everything. (default: 200,204,301,302,307,401,403)
  -ml              Match amount of lines in response
  -mr              Match regexp
  -ms              Match HTTP response size
  -mw              Match amount of words in response
```

---

## ffuf - parameter fuzzing - GET
If we run a recursive `ffuf` scan on `admin.academy.htb`, we should find `http://admin.academy.htb:PORT/admin/admin.php`. If we try accessing this page, we see the following:
![](/img/Pasted image 20240925153047.png)
- Indicates mechanism for user verification 
- Perhaps there is a key we can pass to the page to read the flag 
	- Such keys would be passed as a parameter in a GET / POST HTTP request 

```bash
Tip: Fuzzing parameters may expose unpublished parameters that are publicly accessible. Such parameters tend to be less tested and less secured, so it is important to test such parameters for the web vulnerabilities we discuss in other modules.
```

**GET request fuzzing**

Usually passed right after url with a `?` symbol: 

```bash
http://admin.academy.htb:PORT/admin/admin.php?param1=key
```

We replace `param1` with `FUZZ` and rerun our scans. 
- Pick appropriate wordlists. 
- For starters: 
```bash
/usr/share/wordlists/seclists/Discovery/Web-Content/burp-parameter-names.txt
```

```bash
ffuf -w /usr/share/wordlists/seclists/Discovery/Web-Content/burp-parameter-names.txt:FUZZ -u http://admin.academy.htb:PORT/admin/admin.php?FUZZ=key -fs xxx
```

---
## ffuf - Parameter fuzzing - POST

POST requests are not passed with the URL and cannot simply be appended after a `?` symbol. 
Post reqs passed in `data` field within an HTTP request. 

To fuzz `data` with `ffuf` we use the `-d` flag. 
We also need to add `-X POST` to send post requests. 

- In PHP - `POST` data `"content-type"` can only accept `"application/x-www-form-urlencoded"` 
	- set this in ffuf with `-H 'Content-Type: application/x-www-form-urlencoded'` 

```bash
ffuf -w /usr/share/wordlists/seclists/Discovery/Web-Content/burp-parameter-names.txt:FUZZ -u http://admin.academy.htb:PORT/admin/admin.php -X POST -d 'FUZZ=key' -H 'Content-Type: application/x-www-form-urlencoded' -fs xxx
```
As we can see this time, we got a couple of hits, the same one we got when fuzzing GET and another parameter, which is id. Let's see what we get if we send a POST request with the id parameter. We can do that with curl, as follows:
```bash
curl http://admin.academy.htb:42635/admin/admin.php -X POST -d 'id=key' -H 'Content-Type: application/x-www-form-urlencoded'
```
![](/img/Pasted image 20240925154014.png)

## ffuf - Value fuzzing

After fuzzing a working parameter we now have to fuzz a correct value that would return the flag content we need. 

We may not always find a premade wordlist that works for us - Each parameter would expect a certain type of value. 
- With username parameters, use a potential username wordlist. 
	- Or create our own using osint 
	- Look for various wordlists in seclists. 
- Custom parameters may require us to develop our own wordlist. 
	- We can guess that the `id` parameter can accept a number input of some sort. 
	- May be in a custom format, or sequential like 1-1000 or 1-1000000 etc.
```bash
for i in $(seq 1 1000); do echo $i >> ids.txt; done
```

```bash
ffuf -w ids.txt:FUZZ -u http://admin.academy.htb:PORT/admin/admin.php -X POST -d 'id=FUZZ' -H 'Content-Type: application/x-www-form-urlencoded' -fs xxx
```

![](/img/Pasted image 20240925154537.png)
```bash
curl -X POST -d 'username=harry' -H 'Content-Type: application/x-www-form-urlencoded' http://faculty.academy.htb:56795/courses/linux-security.php7
```

