How to provide variable to irb session

T

Thomas B.

Bryan said:
Hello all,

Can anyone tell me how I would go about providing a variable to an irb
session? For example, see the following screenshot from the Metasploit
Meterpreter in irb mode.

http://www.metasploit.com/images/gallery/msf3-meterp-irb.jpg

Does anyone know how they are actually providing the 'client' variable
to the irb session?

You can run your script at Ruby startup by specifying env variables
(http://al2o3-cr.blogspot.com/2008/09/class-array.html, scroll to Add to
load path), or you can specify env variable IRBRC pointing to a Ruby
file that will be executed at the start of irb only.

TPR.
 
B

Brian Candler

Bryan said:
Hello all,

Can anyone tell me how I would go about providing a variable to an irb
session? For example, see the following screenshot from the Metasploit
Meterpreter in irb mode.

http://www.metasploit.com/images/gallery/msf3-meterp-irb.jpg

Does anyone know how they are actually providing the 'client' variable
to the irb session?

Is it definitely a variable, not a method?

This post shows how to start an IRb session within the context of an
arbitary object:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/244139

So you can create your own object class with a "client" method, create
an instance of this object, and start IRb such that "self" is this
object.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,048
Members
47,650
Latest member
IanTylor5

Latest Threads

Top