Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Reconnaissance: what the target already shows

After this lesson: I can gather what a target shows the public and record it as notes.

50 min lesson6 commandsPenetration testing lab: from scope to retest

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

The front door has a map on it

Before anyone tries a lock, they read the building's signs. Which door is for staff? Is there a back way in?

A college web site often says more than its owners meant. A tester reads it first, slowly, and writes everything down.

The one rule

Warning

Gather from your own lab copy only. On a real test, reading public pages is allowed, but touching a host needs it in the written scope. In the UK, access without permission can be a crime under the Computer Misuse Act 1990.

Quick check: the rule

Have a go

Quick check: the rule

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

By the end of this lesson

Note

I can gather what a target shows the public and record it as notes.

Key words

WordWhat it meansExample
Reconnaissancegathering facts about a target before testing it
Passivereading what is published, without touching the target
Activesending requests to the target itself
OSINTfacts from open, public sources
Bannerwhat a service says about itselfServer: Apache/2.4.49

The cells students fill in are left blank in this preview.

Starter

Have a go

Starter

4 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Passive first, then active

On a real test, passive reconnaissance comes first: public DNS records, certificate logs, job adverts and the client's own site. None of it touches the target.

Active reconnaissance sends requests to the target. The lab has no internet, so the college's public site stands in for both: read it as any visitor would.

Read the home page

Command
curl -s http://www:8080/

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Follow the staff link

Command
curl -s http://www:8080/staff/

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

robots.txt is a signpost, not a lock

robots.txt asks search engines to keep away from some paths. It cannot stop a visitor, and it tells everyone where the interesting paths are.

The headers come before the page. -I asks for the headers alone, and the Server header is the site's banner.

Read robots.txt

Command
curl -s http://www:8080/robots.txt

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Read the headers alone

Command
curl -sI http://www:8080/

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

A common mistake

Warning

Many people think a banner tells you what is really running. A banner is only what the service chooses to say, and it can be wrong or old. Write it down as a claim, and check it before you rely on it. Lesson 4 checks this one.

Notes keep the test honest

Each note says what you learnt, where from, and whether it is in scope. A note without a source cannot go in a report.

Anything outside the scope is written down and left alone. Run the notes below.

Try it: recon notes with their sources

Code: python
# Recon notes: each fact, where it came from, and whether it is in scope.
scope = ["www", "intranet", "cache"]
notes = [
    ("intranet", "staff page link"),
    ("/backup/", "robots.txt"),
    ("Apache 2.4.49", "Server header"),
]

for fact, source in notes:
    host = fact if fact.isalpha() else "www"
    print(fact, "| from", source, "| in scope:", host in scope)

# Add ("printer", "home page") to notes. What does it print?

Make a free account to save your work and track your progress.

How a defender sees reconnaissance

Every request you sent is a line in the site's log, with your address and the path. A request for robots.txt followed by its hidden paths is a pattern a defender can alert on.

The fixes are small: keep sensitive files off the server, not just out of robots.txt, and stop the header naming a version.

Read the site's log, without its health checks

Command
docker logs www 2>&1 | grep -v 127.0.0.1

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Check nothing reached the supplier

Command
docker logs hr

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Assignment: sort recon notes by scope

Recon text holds host names in two shapes: in a web address such as http://intranet:8000/, and as name:port such as cache:6379. Write two functions.

hosts_in(text) returns the host names found in the text, lower case, each once, sorted. A host name is letters, digits, dots and hyphens; take it from after :// up to the next : or /, and from before : and a port number. sort_hosts(names, scope) returns {"in": [...], "out": [...], "unknown": [...]}, each list sorted: a name in scope["exclude"] is out, a name in scope["hosts"] is in, any other is unknown.

Code: python
def hosts_in(text):
    return []


def sort_hosts(names, scope):
    return {"in": [], "out": [], "unknown": []}

Make a free account to save your work and track your progress.

Exit quiz

Have a go

Exit quiz

5 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.