Before we write any code, we need a place to work.
Think of this like setting up your workshop before you build a robot.
Letβs organize our tools and build the simplest thing we can:
a script that says "Hello, Hacker!"
π§° What are we building?
Weβre creating a Ruby project with:
- ποΈ Folders to keep things organized
 - π Logic we can reuse later
 - π₯οΈ Scripts we can run from the terminal
 
π§ Think of this like a kitchen:
Youβll have drawers (code) and buttons (scripts) that do things.
π¦ Project Structure
ruby/
βββ Chapter 01 β Setting Up a Ruby Environment/
    βββ bin/
    β   βββ hello_world.rb
    βββ lib/
        βββ hacking/
            βββ core.rb
π» Installing Ruby
Choose the method for your OS:
  
  
  β
 Option 1 β Using rbenv (Linux/macOS)
sudo apt update && sudo apt install -y git curl build-essential libssl-dev libreadline-dev zlib1g-dev
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init - bash)"' >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install 3.3.5
rbenv global 3.3.5
ruby -v
  
  
  β
 Option 2 β Using rvm (macOS or Linux)
sudo apt install curl gpg
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
\curl -sSL https://get.rvm.io | bash -s stable --ruby
source ~/.rvm/scripts/rvm
rvm install 3.3.5
rvm use 3.3.5 --default
ruby -v
β Option 3 β Windows (RubyInstaller)
- Download from https://rubyinstaller.org
 - Run installer (check "add to PATH")
 - Open PowerShell or CMD:
 
ruby -v
π lib/hacking/core.rb
module Hacking
  module Core
    def self.greet
      "Hello, Hacker! Ready to break things? π₯"
    end
  end
end
π bin/hello_world.rb
#!/usr/bin/env ruby
# frozen_string_literal: true
require_relative '../lib/hacking/core'
puts Hacking::Core.greet
βΆοΈ Run it!
cd ruby/Chapter\ 01\ β\ Setting\ Up\ a\ Ruby\ Environment
ruby bin/hello_world.rb
β
 Output:
Hello, Hacker! Ready to break things? π₯
π§ Final Recap
| Concept | What it means | 
|---|---|
rbenv / rvm / RubyInstaller | 
Install Ruby safely | 
bin/ | 
Where your scripts live | 
lib/ | 
Where your logic lives | 
module | 
Group of code | 
self.method | 
Call a method directly | 
require_relative | 
Load local file | 
puts | 
Print message | 
β You now have:
- Ruby installed (on any OS)
 - A clean project structure
 - Your first script up and running
 - The foundation for your Ruby offensive tools!
 
    
Top comments (0)