Last active
May 16, 2018 14:11
-
-
Save evilsocket/bfdb1af7e6bf9d9d0bfe to your computer and use it in GitHub Desktop.
BetterCAP example HTTP(S) Proxy Module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HackTitle < BetterCap::Proxy::HTTP::Module | |
meta( | |
'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.*/ | |
BetterCap::Logger.info "Hacking http://#{request.host}#{request.url}" | |
# make sure to use sub! or gsub! to update the instance | |
response.body.sub!( '<title>', '<title> !!! HACKED !!! ' ) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 method
url' for #BetterCap::Proxy::HTTP::Request:0x00000001dd3230...