Labs / Web Attacks / The web app's attack surface

Lab 1 of 5 · The web app's attack surface

Content discovery: finding what a site serves but never links

Brute-force a box-office server's unlinked paths with gobuster — find a login-free deprecated API and a database dump left at the web root.

Start this lab 5 steps

The idea

Juna has an authorised engagement against Fairholme Tickets, and the booking site at 10.0.1.20 looks tiny: a home page, a seat picker, a login. But a web server answers for every path it is configured to, not only the ones a page links to, and the interesting parts are almost always the unlinked ones.

So Juna does not click around. She asks the server for thousands of likely names — admin, backup, old, api — and keeps whatever answers with anything other than "not found". It is called content discovery, and it is how you find the copy of the app someone forgot to delete.

The status code sorts the hits
The status code sorts the hits

Steps

  1. Ask for names the site never gave you

    A link is an invitation; it is not the only way in. The server answers any path it is configured for, linked or not, and "unlinked" is not "hidden"; it only means you have to guess the name. So you guess a lot of names, fast, from a list of the ones that pay off most often.

    gobuster dir does exactly that: it requests every word in a wordlist as a path and prints the ones the server does not answer with 404 Not Found. The list here is dirb's common.txt, about 4,600 names drawn from real sites. Point it at the server and read what comes back — and read the status code beside each hit, because that is the server telling you what kind of thing it found.

    kali:~# gobuster dir -u http://10.0.1.20 -w /usr/share/wordlists/dirb/common.txt -q
  2. Follow the directory nobody links

    /old answered 301, nginx's way of saying "that is a directory, ask again with a slash". So ask: fetch /old/ and read what the server hands back. A directory with no index page might list its files; one with an index.html, like most, serves that instead — and an index page written for developers often explains exactly what the directory is.

    This is the moment content discovery pays off. A name in a wordlist got you to a directory the site never mentions; now you read it like any page and let it tell you what it is.

    kali:~# curl -s http://10.0.1.20/old/
  3. The copy nobody turned off

    The old index named /old/customers. The current API guards customer data behind the 401 you saw; this deprecated copy was written before that guard existed. Ask it for the customer list the same way you would ask the real API — a plain GET — and see whether anything checks who you are.

    kali:~# curl -s http://10.0.1.20/old/customers
  4. Hunt files, not just folders

    Directories are half of it. The other half is loose files — a config saved with a .bak extension, a database dump, an editor's swap file — dropped at the web root by a careless deploy and linked by nothing.

    A wordlist of bare names misses them, because the name is export but the file is export.sql. So you sweep extensions: for every word in the list, also try word.sql, word.bak, word.zip. ffuf is built for this. -u http://10.0.1.20/FUZZ puts each word where FUZZ is, -e .sql adds the extension to every try, and -mc 200 keeps only the ones that actually answer 200 OK.

    kali:~# ffuf -w /usr/share/wordlists/dirb/common.txt -u http://10.0.1.20/FUZZ -e .sql -mc 200 -s
    kali:~# curl -s http://10.0.1.20/export.sql
  5. Swap seats: the noise it made

    Now you run Fairholme's server. Two things have to happen: close the holes, and ask whether you could even have seen Juna doing this.

    The holes close by deletion — the deprecated /old API off the server, the export.sql dump off the web root — because both are surface that should not exist, not settings to tune. Then read the access log. Unlike plain recon, content discovery is loud: every miss is a 404, and 4,600 of them in a few seconds is a signature nothing legitimate produces.

    web:~# rm -rf /srv/www/old
    web:~# rm -f /srv/www/export.sql
    kali:~# curl -s http://10.0.1.20/old/customers
    web:~# grep -c " 404 " /var/log/nginx/access.log

Run these steps on real machines

Keep reading

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab