Ruby
Ruby is one of many interpreted languages written in C used in Linux systems for command line tools and serving web applications. Ruby on Rails is an object-oriented MVC framework written in ruby served by WEBRICK and mongrel on Linux systems.
This article needs immediate attention, and is in desperate need of content. |
Contents
Development Environment
ruby cli
irb
gem
Your first application
Variables and data types
Boolean Logic
Loops
User Input
User-Defined Functions
Security
Examples of Useful Programs
Many times a hacker has stopped to ask how a character is represented in ascii, possibly for alphanumeric shellcode. Rather than having to resort to wikipedia, why not throw together a script? We'll call it asciispeek.rb
#!/usr/bin/ruby def asciispeek(x) x.each_byte do |c| puts c.to_s(2) end end asciispeek(ARGV.join(' ').to_s)
This script takes the arguments from the shell (ARGV) and joins them into one string. The act of joining removes the whitespace between them, so we add it back in, and then convert it to a string. The result is then passed to our function. Our function calls an enumerable method of the string class, each_byte, which gets at the byte representation of the character. We then pipe it into a block which converts it into a base 2 number and then prints it. A simple edit could make this spit out the hex representation, or the octal. This is a good example of the idea of reusing code. By encapsulating the actual actions into a function, we can copy this function into a class or script that we make in the future.