Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
BetterCAP example HTTP(S) Proxy Module
class HackTitle < BetterCap::Proxy::HTTP::Module
'Name' => 'HackTitle',
'Description' => 'Adds a "!!! HACKED !!!" string to every webpage title.',
'Version' => '1.0.0',
'Author' => "Simone 'evilsocket' Margaritelli",
'License' => 'GPL3'
# called before the request is performed
def on_pre_request( request ); end
# this method is called after the request is performed
def on_request( request, response )
# is it a html page?
if response.content_type =~ /^text\/html.*/ "Hacking http://#{}#{request.url}"
# make sure to use sub! or gsub! to update the instance
response.body.sub!( '<title>', '<title> !!! HACKED !!! ' )
Copy link

g4z commented May 1, 2016

I think that in this code snippet, "#{request.url}" should be changed to "#{request.path}".
Running this snippet (as found in the documentation) throws this warning...

[W] Error with proxy module: undefined method url' for #<BetterCap::Proxy::HTTP::Request:0x00000001dd3230> [W] Exception : NoMethodError Message : undefined methodurl' for #BetterCap::Proxy::HTTP::Request:0x00000001dd3230

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment