Ruby is a dynamic, general-purpose programming language created by Yukihiro "Matz" Matsumoto in Japan around the mid-90's. It has many uses but with it's flexibility, it makes a great language to write exploits in. In fact, the entire Metasploit Framework is written in Ruby! The sole purpose of this series is to teach hackers the basics of Ruby, along with some more advanced concepts that are important in hacking.
Before we can work with Ruby, we need to download it. Kali Linux, and most hacking distros have it preinstalled, but if you don't have it, use your package manager. For Ubuntu, you need to do the following:
sudo apt-get install ruby-full
This will download & install ruby
In Ruby, there are 4 data types:
1) Numbers (1,2,3,4,5...)
2) Strings ("Null Byte", "Ruby")
3) Boolean Values (true, false)
4) nil (Ruby version on Null)
Having all this information is great, but how are we going to use it if we can't store it? That is where the Data storage comes into place!
Variables are words/letters that hold some type of data. These are the simplest of the storage's. They are defined by putting the letter/word equal to a number, string, Boolean, or even a method! Examples:
Simply put, arrays are lists of different data. While variables hold only one value, arrays can hold however many you please of any data type you want. These are defined by a letter/word that are equal to brackets (). You can access the values by typing the array name along with the index of the value. For example:
Hashes are the Ruby equivalent to Python's dictionaries. They store a key/value pair. There are two ways to define them. The first way:
The second way:
You can access them by calling the name of the hash with the key in brackets...
Basics of Ruby: Part 2 (loops) will be out sometime by the end of this week. I am becoming very busy as this is the last day of my summer break, but my plans have two lessons being published a week.