tag:support.arachni-scanner.com,2012-07-01:/discussions/questions/11974-log-redirects-to-external-sitesArachni: Discussion 2015-05-06T13:19:28Ztag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T09:17:13Z2015-04-28T09:17:13ZLog redirects to external sites.<div><p>Hello,</p>
<p>There's no existing feature that does that but you can write a
plugin to log out of scope HTTP requests.</p>
<p>I can give you some pointers if you'd like.</p>
<p>Cheers</p></div>Tasos Laskostag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T09:28:16Z2015-04-28T09:28:16ZLog redirects to external sites.<div><p>That would be great! I am currently wondering whether adding
output to file around #out? = True though it's a little bit unclear
whether that would do the trick.</p>
<p>Any pointers towards writing a plugin is greatly
appreciated.</p></div>Kevintag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T09:41:30Z2015-04-28T09:41:30ZLog redirects to external sites.<div><p>You can intercept all requests via <code>http.on_queue</code>
and check for <code>HTTP::Request#in_domain?</code>, if it's false
you can log it.</p>
<p>You can use <a href="https://github.com/Arachni/arachni/blob/experimental/components/plugins/script.rb">
this plugin</a> to see the minimal structure and replace the
contents of its <code>#run</code> method with your code.</p>
<p>If you care about what subsystem or component performed the
request you can get that via
<code>HTTP::Request#performer</code>.</p></div>Tasos Laskostag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T10:35:09Z2015-04-28T10:35:13ZLog redirects to external sites.<div><p>Thanks for the quick support.<br>
How is "HTTP::Request#in_domain?" evaluated in code?<br>
Is it a variable or function or what ? Newbie to ruby incase you
wondered :)</p></div>Kevintag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T10:38:44Z2015-04-28T10:38:44ZLog redirects to external sites.<div><p>Ah, no worries:</p>
<pre>
<code>http.on_queue do |request|
next if request.in_domain?
// Log stuff...
// You probably want request.url
end</code>
</pre></div>Tasos Laskostag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T11:27:46Z2015-04-28T11:27:46ZLog redirects to external sites.<div><p>I cannot get this to work. in_domain not found</p></div>Kevintag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T11:28:41Z2015-04-28T11:28:41ZLog redirects to external sites.<div><p>My bad, it's <code>request.scope.in_domain?</code>.</p></div>Tasos Laskostag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T11:33:33Z2015-04-28T11:33:33ZLog redirects to external sites.<div><p>Fair enough. Thanks again :)</p></div>Kevintag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T11:41:34Z2015-04-28T11:41:35ZLog redirects to external sites.<div><p>The plugins works and runs "as expected".<br>
I have created a website where there is only located a index.php
with an iframe to google.<br>
What i expected to see was the iframe evaluated and a request
trying to be made.<br>
However this is not the case.<br>
Do you have any idea where i'm missing something ?</p>
<p>I don't know whether the plugin should have different hooks or
if the iframe even gets executed.</p></div>Kevintag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T11:42:43Z2015-04-28T11:42:43ZLog redirects to external sites.<div><p>Can you show me how you're running arachni?</p></div>Tasos Laskostag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T11:44:42Z2015-04-28T11:44:43ZLog redirects to external sites.<div><p>bin/arachni --browser-cluster-pool-size 1 --plugin 'ooscope'
<a href="http://sitewith1iframe">http://sitewith1iframe</a></p></div>Kevintag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T11:47:31Z2015-04-28T11:47:31ZLog redirects to external sites.<div><p>I thought the site was live, can you show me the HTML
please?</p></div>Tasos Laskostag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T11:48:15Z2015-04-28T11:48:16ZLog redirects to external sites.<div><p>herroo</p>
<p></p></div>Kevintag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T11:49:27Z2015-04-28T11:49:27ZLog redirects to external sites.<div><p>Lol i think it gets removed.<br>
It's a plain iframe. Only iframe.</p></div>Kevintag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T12:03:50Z2015-04-28T12:03:50ZLog redirects to external sites.<div><p>You're right, the request gets cut-off before it reaches the
HTTP client. That's a good thing in general but prevents the
use-case you want.</p>
<p>Is this feature critical?</p></div>Tasos Laskostag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T12:08:20Z2015-04-28T12:08:21ZLog redirects to external sites.<div><p>Yea it is critical because i would like to make a map of where
the website (connects to)/(redirect users to)</p></div>Kevintag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T12:19:12Z2015-04-28T12:19:15ZLog redirects to external sites.<div><p>Can't you point me to the place where it cuts it off and then i
can add some logging there ? That should be possible right ? It may
get hacky but that's ok</p></div>Kevintag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-28T12:31:18Z2015-04-28T12:31:18ZLog redirects to external sites.<div><p>All browser traffic passes through: <a href="https://github.com/Arachni/arachni/blob/master/lib/arachni/browser.rb#L1200">
https://github.com/Arachni/arachni/blob/master/lib/arachni/browser....</a></p>
<p>There may be other places that redirect to external resources
though that get triggered by non-browser interactions so you'll
probably also need to monitor responses like so:</p>
<pre>
<code>http.on_response do |response|
next if !response.redirection?
# Sometimes there are multiple locations provided.
location = [response.headers.location].flatten.first
# Make sure the location is a full and absolute URL.
location = URI.to_absolute( location, response.effective_url )
next if Arachni::URI( location ).in_domain?
# Log stuff
end</code>
</pre></div>Tasos Laskostag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-30T09:10:04Z2015-04-30T09:10:06ZLog redirects to external sites.<div><p>So this:<br>
def request_handler( request , response )<br>
print_debug "aaaaa"</p>
<p>Should give me aaaaa if i set --output-debug</p></div>Kevintag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-30T09:14:52Z2015-04-30T09:14:52ZLog redirects to external sites.<div><p>And btw, it does not give me aaaaa output.</p></div>Kevintag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-30T09:23:00Z2015-04-30T09:23:00ZLog redirects to external sites.<div><p>I tested what you mentioned and if the page just has an iframe
element it will not be passed to the browsers, this is a bug I'll
fix in a bit -- an optimization cuts it off too soon.</p>
<p>Try including <code><script></script></code> and see
if it works this time.</p></div>Tasos Laskostag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-30T09:28:27Z2015-04-30T09:28:28ZLog redirects to external sites.<div><p>With a script src= it works :)</p></div>Kevintag:support.arachni-scanner.com,2012-07-01:Comment/366945612015-04-30T09:43:59Z2015-04-30T09:43:59ZLog redirects to external sites.<div><p>Come to think about it the optimization was right, if there's no
script in the parent nor the iframe then the browser should skip
it.</p>
<p>As you can see Arachni tries to ignore out of scope resources
ASAP so I don't know if it fits your requirements.</p></div>Tasos Laskos