Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts

Thursday, November 24, 2011

Browser Exploitation Framework on Mac OSX 10.6


As you know BeEF is a good framwork for browser exploitation.Here is a guide to install it in Mac,as the original documentation doesnt work most of the times with OSX.


Check your ruby version first (Im assuming you have ruby gem,rvm and svn already installed,if not install them first.)

ruby --version

i had 1.8,updated to 1.9 through rvm and made it default.
create a folder for beef and checkout the latest code,
mkdir beef
cd !$
svn checkout http://beef.googlecode.com/svn/trunk/ beef-read-only
cd beef-read-only
ruby beef
You may see some Load errors,don't be panic..we can easily fix it.

Beef requires some ruby gems,if it is not there inside your system,It will throw load errors,to fix those get what gem is missing and install it using the following command
Lets say you saw one error like ,

/Users/r3dsm0k3/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/
site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- ansi (LoadError)
from /Users/r3dsm0k3/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /users/r3dsm0k3/Desktop/stuffhack/beef/beef-read-only/core/loader.rb:23:in `'
from :29:in `require'
from :29:in `require'
from beef:37:in `
'

from the first line it is sure that,there is no gem called "ansi"
just install it then,
gem install ansi


done, :)
Try running beef again.If it fails,install the missing gem like before.
I got issues with the following gems,
ansi
erubis
term/ansicolor (
gem install term-ansicolor
)
librex (for librex, the installation is quite different as beef needs 0.0.52 version of librex,but when you install from gem it will be the latest,so install the corresponding version like
gem install librex --version 0.0.52 --no-rdoc --no-ri 
)

After all your dependencies are fulfilled run beef.

ruby beef

Enjoy your pwnage,Errr...Pentest :)

Thursday, October 13, 2011

Fibonacci

I wanted to find fibonacci of a large number for one of the Hacking challenges that i was doing,
The number was larger than 1000 so the online calculators were crashing.

If you are writing a recursive function for this task,it will take ages to complete.
So just wrote this stuff in ruby with Matrix.
I know no-one gives a fuck about fibonacci,but it will be useful for someone who is in real need as i were that time.

require 'matrix'

FIBONACCI_MATRIX = Matrix[[1,1],[1,0]]
def fibonacci(n)
 (FIBONACCI_MATRIX**(n-1)) [0,0]
end

31337.times do |j|
 puts "n=#{j} => #{fibonacci(j)}"
end