Welcome back! In the previous chapter, Tool Use - Read Pre-Recon Data, our agent learned how to read the initial, high-level background report about the target.
Now, we need to get specific. To find security holes, we need a detailed map of the website. We need to know every page, every link, and every input box. This is where Recon Data comes in.
Imagine you are an explorer entering an ancient temple.
Without this detailed map, the agent is blind. It knows what the target is, but not where to step.
Our agent is testing http://localhost:33081. A previous tool has already crawled this website and saved a list of every URL and parameter it found into a file called deliverables/recon_deliverable.md.
In this chapter, the agent will read this file to memorize the layout of the website.
Just like in the previous chapters, we use the agent's file-reading capabilities. However, the value of this step is in the specific file we target.
We define the path to the detailed reconnaissance file.
# This file contains the full map of the website
recon_path = "deliverables/recon_deliverable.md"
print(f"Loading website blueprint from: {recon_path}")
Output: Loading website blueprint from: deliverables/recon_deliverable.md
We command the agent to read the file. This loads the map into the agent's brain.
# The agent reads the file contents
recon_data = agent.tools.read_file(recon_path)
# Let's check the size of the data we found
print(f"Data loaded. File length: {len(recon_data)} characters.")
Output:
Data loaded. File length: 4502 characters.
To prove the agent really "sees" the map, let's print the first few lines.
# Print the first 100 characters of the file
print(recon_data[:100])
Output:
# Reconnaissance Report
## URLs Found
- http://localhost:33081/login.php
- http://localhost:33081/search.php?q=test
The agent now knows exactly which pages exist (login.php, search.php) and which parameters to test (q=test).
What happens inside the system when we ask for this data?
The agent acts as a data processor. It requests the file, and the file system serves it up.
The code powering this is the same robust file reader we used in Chapter 4. It relies on Python's ability to safely open and close files using the with statement.
Let's look at shannon/tools/file_reader.py again, focusing on how it ensures the file is closed properly.
class FileTool:
def read_file(self, file_path):
# 'with' acts like a safety wrapper
with open(file_path, 'r') as f:
# Read the map data
content = f.read()
# As soon as we exit the 'with' block,
# the file is automatically closed.
return content
Explanation:
with open(...): This is a best practice in Python. It guarantees that even if an error happens while reading, the file won't get "stuck" open in the operating system.f.read(): Extracts the detailed list of URLs and parameters.Agent class, which usually stores it in a variable like self.context.recon_data.Our agent is becoming formidable.
The agent has almost all the information it needs. However, there is one final piece of intelligence that might be available: specific analysis on how to perform injections (hacking attempts) on this specific target.
In the next chapter, we will look at how the agent reads detailed vulnerability analysis reports.
Next Chapter: Tool Use - Read Injection Analysis
Generated by Code IQ