Lion Cipher Lab
Write a small Python TCP checker for your own host: timeouts, banners, JSON output, and a rate limit
- Penetration Testing / Red Team
- Intermediate
- ~55 min
- Free · no account required
Why it matters
Anyone doing authorized testing ends up writing small scripts, because tools do not always fit the job. A TCP connect check is the smallest useful one: it shows what a host exposes. Writing it yourself teaches what the big tools do for you: timeouts, parallelism, results you can process and limits that stop you from hurting a fragile network. It also teaches the habit that matters most: the script should refuse targets outside your scope, in code, so a typo cannot turn a check of your own machine into a probe of someone else's.
What you'll learn
- opening a TCP connection from Python with a timeout
- telling an open port, a refused port and a timed-out port apart
- reading a service banner without sending anything
- running many checks at once with a thread pool and a worker cap
- emitting results as JSON and reading them with jq
- reading targets from a file, refusing anything that is not private or loopback
- adding a rate limit and explaining why a good neighbour keeps one
Steps in this lab
- The authorization rule, built into the code
- Start some things to find
- Write the first version: threads, timeout, banner, JSON
- Run it on your own host and read the result
- Break the scope guard on purpose
- Adapt it: read targets from a file
- Rate limiting, and being a good neighbour
- What a professional does differently, and when not to run this
- What a defender would see, and the fix
- Clean up
Open the full interactive lab →