Great! Since you already have Perl installed on your Kali Linux, and you're using it to learn ethical hacking, you're well set up to run this script. Let me walk you through exactly what you need and how to do it safely and effectively.
✅ What You Need to Run the Perl Script
1. Perl Installed
You mentioned you already have Perl — confirm with:
perl -v
This should output the Perl version (e.g., This is perl 5...).
2. Required Perl Modules
The script uses one external module:
LWP::Simple – part of the libwww-perl package, used for HTTP requests.
✅ Check if it’s installed:
perl -MLWP::Simple -e 'print "OK\n"'
- If you see no errors, it's installed.
- If you see something like "
Can't locate LWP/Simple.pm", install it using:
sudo apt update
sudo apt install libwww-perl
3. Save the Script
Create a new file for the script. For example:
nano apache_dir_traversal.pl
Paste the script content into the editor, then save and exit (Ctrl+O, Enter, then Ctrl+X).
Alternatively, download it directly using curl or wget if hosted online (but in this case, you provided the raw source).
4. Run the Script
Make the script executable (optional but good practice):
chmod +x apache_dir_traversal.pl
Run the script against your Kioptrix VM (or any target you're authorized to test):
./apache_dir_traversal.pl Kioptrix_IP_or_hostname
Example:
./apache_dir_traversal.pl 192.168.56.101
🧪 What the Script Does
- It sends HTTP GET requests with an increasing number of
/ characters appended to the URL.
- Compares the responses to detect when a directory listing is shown instead of the default
index.html.
- Prints the number of slashes (
/) that triggered the behavior and the server's response.
⚠️ Legal & Ethical Reminder
Since you're using the Kioptrix machine, which is designed for learning penetration testing:
✅ It's legal and ethical to test it
❌ Never run this against systems you don’t own or have written permission to test
🔍 Tips for Use Against Kioptrix
- The Kioptrix Level 1 machine is vulnerable to this issue.
- Ensure both machines are on the same network (e.g., NAT or Host-only in VirtualBox).
- Turn off firewalls temporarily on Kioptrix if needed (or allow HTTP traffic).
- You can find the IP of Kioptrix with:
ip addr
If you want, I can help you modify the script to automatically fetch a directory listing or combine it with other enumeration tools. Just let me know!