// Tutorials
Ruby for Pentesters
Ruby from your first HTTP request to a working Metasploit module, taught by building a full exploit chain against the retired HackTheBox machine Bizness — recon, auth bypass, RCE, a reverse shell, looting, cracking, becoming root, tooling, testing, and the module.
-
Part 1Your first recon tool
7 min readInstall Ruby 4, meet irb, and write your very first script — an HTTP client that fingerprints a target. We point it at the retired HackTheBox machine Bizness and confirm what's running.
-
Part 2Walking past the login
5 min readOFBiz has an authentication bypass (CVE-2023-51467). We turn that into a reusable Ruby method, learn how functions and constants work, and confirm we're past the login gate.
-
Part 3First code execution
5 min readWe point the auth bypass at OFBiz's ProgramExport screen, POST a Groovy payload, and run our first command on the box. Along the way you learn POST requests, hashes, and pulling data back out of a response.
-
Part 4Catching a shell
5 min readReflected output is clumsy. We write our own TCP listener in Ruby to catch an interactive reverse shell — and learn sockets and threads doing it.
-
Part 5Looting the database
5 min readWith a shell as ofbiz, we go after the admin password hash. OFBiz's embedded Derby database sits in flat files on disk — we grep them, then learn regex and file handling to pull the hash out cleanly.
-
Part 6Cracking a nonstandard hash
6 min readThe admin hash isn't in any standard format hashcat ships with, so we reimplement OFBiz's exact hashing in Ruby and brute it against a wordlist. Then we build a thread pool to parallelize it — and meet the GVL, the reason Part 4's threads sped up network work but won't speed up pure hashing.
-
Part 7Becoming root
4 min readThe cracked password is root's too — plain password reuse. We spend it to escalate, and learn the handful of ways Ruby runs external programs — system, backticks, Open3 — ending with a PTY to drive an interactive su.
-
Part 8From scripts to a tool
5 min readSeveral throwaway scripts that all rebuild the same HTTP client. We fold them into one reusable class and give it a real command-line interface with OptionParser — the jump from scripting to tooling.
-
Part 9Testing your tool
4 min readA tool you'll rerun deserves a safety net. We meet minitest, Ruby's built-in test framework, and learn to write code that's testable — separating the logic you can check from the network you can't.
-
Part 10Shipping it as a Metasploit module
6 min readThe finale. A Metasploit module is just a Ruby class in the framework's shape — so we lift the exact OFBiz chain into one, and let the framework hand us HTTP, options, payloads, and a shell for free.