tag:support.arachni-scanner.com,2012-07-01:/discussions/questions/143-using-arachni-as-a-libraryArachni: Discussion 2013-03-05T17:32:30Ztag:support.arachni-scanner.com,2012-07-01:Comment/255874582013-03-05T04:30:07Z2013-03-05T04:30:07ZUsing Arachni as a library<div><p>I guess this is partly my fault for not having made the notice
more visible (making mental note to fix this) but had you scrolled
down a bit you'd have seen this:<br></p>
<hr>
<br>
To make scripting easier you can run the above snippets using:
<p><code>arachni_script my_script.rb</code></p>
<p>The "arachni_script" executable will run the given script under
the Arachni namespace.<br></p>
<hr>
<p>There isn't anything magical to the <code>arachni_script</code>
executable, it just pulls in the root Arachni namespace (along with
some utility ones) so that you won't have to keep referring to
objects like <code>Arachni::Framework</code> and
<code>Arachni::Page</code> and stuff like that.</p>
<p>So it requires Arachni and sets up the env to make things more
convenient.</p>
<p>But, If you want to use Arachni in your Ruby app you can:</p>
<pre>
<code>require 'arachni'
f = Arachni::Framework.new
f.opts.url = 'http://testfire.net'
# only audit the first page
f.opts.link_count_limit = 1
f.opts.audit :forms</code>
</pre>
<p>Now if that doesn't work (like you mentioned in your tweet) you
may want to look into your system's Ruby environment.</p>
<p>Since you are new to Ruby I don't want to make any assumptions
about how you went about setting things up so let's start with the
basics like, how did you install Arachni?</p>
<p>Cheers</p></div>Tasos Laskostag:support.arachni-scanner.com,2012-07-01:Comment/255874582013-03-05T17:23:02Z2013-03-05T17:23:05ZUsing Arachni as a library<div><p>Thank you for a quick response.</p>
<p>I installed Arachni as ruby gem, here is a trace from the
terminal:<br>
$ sudo gem install arachni Password:<br>
Fetching: mime-types-1.21.gem (100%)<br>
Fetching: typhoeus-0.3.3.gem (100%)<br>
Building native extensions. This could take a while...<br>
Fetching: polyglot-0.3.3.gem (100%)<br>
Fetching: treetop-1.4.12.gem (100%)<br>
Fetching: i18n-0.6.4.gem (100%)<br>
Fetching: mail-2.5.3.gem (100%)<br>
Fetching: pony-1.4.gem (100%)<br>
Fetching: awesome_print-1.1.0.gem (100%)<br>
Fetching: rb-readline-0.4.2.gem (100%)<br>
Fetching: sys-proctable-0.9.2-universal-darwin.gem (100%)<br>
Building native extensions. This could take a while...<br>
Fetching: terminal-table-1.4.5.gem (100%)<br>
Fetching: rack-1.5.2.gem (100%)<br>
Fetching: rack-protection-1.4.0.gem (100%)<br>
Fetching: tilt-1.3.4.gem (100%)<br>
Fetching: sinatra-1.3.5.gem (100%)<br>
Fetching: backports-3.0.3.gem (100%)<br>
Fetching: rack-test-0.6.2.gem (100%)<br>
Fetching: eventmachine-1.0.1.gem (100%)<br>
Building native extensions. This could take a while...<br>
Fetching: sinatra-contrib-1.3.2.gem (100%)<br>
Fetching: sinatra-flash-0.3.0.gem (100%)<br>
Fetching: async_sinatra-1.0.0.gem (100%)<br>
Fetching: daemons-1.1.9.gem (100%)<br>
Fetching: thin-1.5.0.gem (100%)<br>
Building native extensions. This could take a while...<br>
Fetching: addressable-2.2.8.gem (100%)<br>
Fetching: dm-core-1.2.0.gem (100%)<br>
Fetching: dm-aggregates-1.2.0.gem (100%)<br>
Fetching: dm-constraints-1.2.0.gem (100%)<br>
Fetching: dm-migrations-1.2.0.gem (100%)<br>
Fetching: dm-transactions-1.2.0.gem (100%)<br>
Fetching: fastercsv-1.5.5.gem (100%)<br>
Fetching: multi_json-1.6.1.gem (100%)<br>
Fetching: json_pure-1.7.7.gem (100%)<br>
Fetching: dm-serializer-1.2.2.gem (100%)<br>
Fetching: dm-timestamps-1.2.0.gem (100%)<br>
Fetching: dm-validations-1.2.0.gem (100%)<br>
Fetching: bcrypt-ruby-3.0.1.gem (100%)<br>
Building native extensions. This could take a while...<br>
Fetching: stringex-1.5.1.gem (100%)<br>
Fetching: uuidtools-2.1.3.gem (100%)<br>
Fetching: dm-types-1.2.2.gem (100%)<br>
Fetching: datamapper-1.2.0.gem (100%)<br>
Fetching: data_objects-0.10.12.gem (100%)<br>
Fetching: do_sqlite3-0.10.12.gem (100%)<br>
Building native extensions. This could take a while...<br>
Fetching: dm-do-adapter-1.2.0.gem (100%)<br>
Fetching: dm-sqlite-adapter-1.2.0.gem (100%)<br>
Fetching: net-ssh-2.6.6.gem (100%)<br>
Fetching: net-scp-1.1.0.gem (100%)<br>
Fetching: em-synchrony-1.0.3.gem (100%)<br>
Fetching: arachni-rpc-0.1.2.gem (100%)<br>
Fetching: arachni-rpc-em-0.1.2.gem (100%)<br>
Fetching: arachni-0.4.1.3.gem (100%)</p>
<p>Thank you for installing Arachni, here are some resources which
should<br>
help you make the best of it:</p>
<p>Homepage - <a href=
"http://arachni-scanner.com">http://arachni-scanner.com</a><br>
Blog - <a href=
"http://arachni-scanner.com/blog">http://arachni-scanner.com/blog</a><br>
Documentation - <a href=
"http://arachni-scanner.com/wiki">http://arachni-scanner.com/wiki</a><br>
Support - <a href=
"http://support.arachni-scanner.com">http://support.arachni-scanner.com</a><br>
GitHub page - <a href=
"http://github.com/Arachni/arachni">http://github.com/Arachni/arachni</a><br>
Code Documentation - <a href=
"http://rubydoc.info/github/Arachni/arachni">http://rubydoc.info/github/Arachni/arachni</a><br>
Author - Tasos "Zapotek" Laskos (<a href=
"http://twitter.com/Zap0tek">http://twitter.com/Zap0tek</a>)<br>
Twitter - <a href=
"http://twitter.com/ArachniScanner">http://twitter.com/ArachniScanner</a><br>
Copyright - 2010-2012 Tasos Laskos<br>
License - Apache License v2</p>
<p>Please do not hesitate to ask for assistance (via the support
portal)<br>
or report a bug (via GitHub Issues) if you come across any
problem.</p>
<p>Successfully installed mime-types-1.21<br>
Successfully installed typhoeus-0.3.3<br>
Successfully installed polyglot-0.3.3<br>
Successfully installed treetop-1.4.12<br>
Successfully installed i18n-0.6.4<br>
Successfully installed mail-2.5.3<br>
Successfully installed pony-1.4<br>
Successfully installed awesome_print-1.1.0<br>
Successfully installed rb-readline-0.4.2<br>
Successfully installed sys-proctable-0.9.2-universal-darwin<br>
Successfully installed terminal-table-1.4.5<br>
Successfully installed rack-1.5.2<br>
Successfully installed rack-protection-1.4.0<br>
Successfully installed tilt-1.3.4<br>
Successfully installed sinatra-1.3.5<br>
Successfully installed backports-3.0.3<br>
Successfully installed rack-test-0.6.2<br>
Successfully installed eventmachine-1.0.1<br>
Successfully installed sinatra-contrib-1.3.2<br>
Successfully installed sinatra-flash-0.3.0<br>
Successfully installed async_sinatra-1.0.0<br>
Successfully installed daemons-1.1.9<br>
Successfully installed thin-1.5.0<br>
Successfully installed addressable-2.2.8<br>
Successfully installed dm-core-1.2.0<br>
Successfully installed dm-aggregates-1.2.0<br>
Successfully installed dm-constraints-1.2.0<br>
Successfully installed dm-migrations-1.2.0<br>
Successfully installed dm-transactions-1.2.0<br>
Successfully installed fastercsv-1.5.5<br>
Successfully installed multi_json-1.6.1<br>
Successfully installed json_pure-1.7.7<br>
Successfully installed dm-serializer-1.2.2<br>
Successfully installed dm-timestamps-1.2.0<br>
Successfully installed dm-validations-1.2.0<br>
Successfully installed bcrypt-ruby-3.0.1<br>
Successfully installed stringex-1.5.1<br>
Successfully installed uuidtools-2.1.3<br>
Successfully installed dm-types-1.2.2<br>
Successfully installed datamapper-1.2.0<br>
Successfully installed data_objects-0.10.12<br>
Successfully installed do_sqlite3-0.10.12<br>
Successfully installed dm-do-adapter-1.2.0<br>
Successfully installed dm-sqlite-adapter-1.2.0<br>
Successfully installed net-ssh-2.6.6<br>
Successfully installed net-scp-1.1.0<br>
Successfully installed em-synchrony-1.0.3<br>
Successfully installed arachni-rpc-0.1.2<br>
Successfully installed arachni-rpc-em-0.1.2<br>
Successfully installed arachni-0.4.1.3<br>
50 gems installed</p>
<p>Here is my ruby version:<br>
$ ruby -v ruby 1.9.3p374 (2013-01-15) [x86_64-darwin11.4.0]</p>
<p>then I went ahead and checked my gems folder to see if the gem
was installed:<br>
$ cd /Users/blah/.rvm/gems/ruby-1.9.3-p374/gems $ pwd
/Users/blah/.rvm/gems/ruby-1.9.3-p374/gems $ls -l . . drwxr-xr-x 29
root staff 986 Mar 4 19:36 arachni-0.4.1.3<br>
drwxr-xr-x 7 root staff 238 Mar 4 19:32 arachni-rpc-0.1.2<br>
drwxr-xr-x 9 root staff 306 Mar 4 19:32 arachni-rpc-em-0.1.2<br>
. . .</p>
<p>So i see the gem being installed but I can't essentially require
'arachni'. Do you see anything problematic here ? Thanks much for
your help.</p></div>arhn7tag:support.arachni-scanner.com,2012-07-01:Comment/255874582013-03-05T17:25:20Z2013-03-05T17:25:20ZUsing Arachni as a library<div><p>Since you installed as root, have you tried to run your script
as root?</p></div>Tasos Laskostag:support.arachni-scanner.com,2012-07-01:Comment/255874582013-03-05T17:28:43Z2013-03-05T17:28:44ZUsing Arachni as a library<div><p>:facepalm:</p>
<p>Damnit !! That was it, i just did sudo to my script and it
works. Sorry about wasting your time. Thanks a lot !</p></div>arhn7tag:support.arachni-scanner.com,2012-07-01:Comment/255874582013-03-05T17:32:29Z2013-03-05T17:32:29ZUsing Arachni as a library<div><p>No worries. I'll update the instructions in the download page
with a notice.</p>
<p>Let me know if you need more help.</p></div>Tasos Laskos