While learning HTTP in Detail, I thought it’d be fun to put it to the test in the terminal.
Here’s a quick exercise to practice learning HTTP Requests, Responses and Headers.
- Difficulty: Easy – new to Linux.
- Environment: local Debian-based Linux installation e.g. Ubuntu in VirtualBox.
Here’s everything you need to do, note, you’ll need two terminals to do this:
- Terminal 1:
git clone https://github.com/mrashleyball/HTTP.git,
python3 -m http.server
- Terminal 2:
nc 0.0.0.0 8000,
GET / HTTP/1.1
nc 0.0.0.0 8000,
GET /flag.txt HTTP/1.1
Wow, pretty easy to spin up web servers and test HTTP Requests, hey?
This is a good exercise to take a step beyond the theory, TryHackMe does a great job with interactive static web pages within their platform.
But I thought it’d be fun to go one step further and test it out within the terminal.
Using the python webserver with netcat, you can clearly see the request making it to the server and it responds with the
index.html file, very cool.
And for the
flag.txt you simply need to specify the file path to get the response:
For more help, here’s a list of links to helpful guides/articles/forums I used in my research:
- HTTP in detail – How the web works
- Networking Fundamentals – Practical Networking
- How to make an HTTP GET request manually with netcat?
- Using nc (netcat) to make an HTTP request
- How to Remove a Directory in Linux –
rm -rf <dir>(if you forget like me)
This was a really fun little exercise to think up and put together, I love doing mini-projects like this. It combines all the skills I believe are important in tech like writing, teaching and having a grasp on the fundamentals.
“It is important to view knowledge as sort of a semantic tree — make sure you understand the fundamental principles, ie the trunk and big branches, before you get into the leaves/details or there is nothing for them to hang on to.” – Elon Musk.
Thanks for reading and I hope you learned something from this little exercise. This is day 47 of #100DaysOfHacking on the Hackers Learning Path. Subscribe for CyberSec updates or read more, happy hacking.