Commit ee5ba840 authored by Sophie Brun's avatar Sophie Brun

Merge tag 'upstream/1.6.0' into kali/master

Upstream version 1.6.0
parents c3c6492b 474e31c2
**bettercap** is a complete, modular, portable and easily extensible **MITM** tool and framework with every kind of diagnostic **bettercap** is a complete, modular, portable and easily extensible **MITM** tool and framework with every kind of diagnostic
and offensive feature you could need in order to perform a man in the middle attack. and offensive feature you could need in order to perform a man in the middle attack.
Before submitting issues, please read the relevant [section](http://www.bettercap.org/docs/contribute/) in the documentation. Before submitting issues, please read the relevant [section](https://www.bettercap.org/docs/contribute/) in the documentation.
<table> <table>
<tr> <tr>
<th>Version</th> <th>Version</th>
<td> <td>
<a href="http://badge.fury.io/rb/bettercap" target="_blank"> <a href="https://badge.fury.io/rb/bettercap" target="_blank">
<img src="https://badge.fury.io/rb/bettercap.svg"/> <img src="https://badge.fury.io/rb/bettercap.svg"/>
</a> </a>
</td> </td>
</tr> </tr>
<tr> <tr>
<th>Homepage</th> <th>Homepage</th>
<td><a href="http://www.bettercap.org/">http://www.bettercap.org/</a></td> <td><a href="https://www.bettercap.org/">https://www.bettercap.org/</a></td>
</tr> </tr>
<tr> <tr>
<th>Blog</th> <th>Blog</th>
<td><a href="http://www.bettercap.org/blog/">http://www.bettercap.org/blog/</a></td> <td><a href="https://www.bettercap.org/blog/">https://www.bettercap.org/blog/</a></td>
<tr> <tr>
<th>Github</th> <th>Github</th>
<td><a href="https://github.com/evilsocket/bettercap">http://github.com/evilsocket/bettercap</a></td> <td><a href="https://github.com/evilsocket/bettercap">https://github.com/evilsocket/bettercap</a></td>
<tr/> <tr/>
<tr> <tr>
<th>Documentation</th> <th>Documentation</th>
<td><a href="http://www.bettercap.org/docs/">http://www.bettercap.org/docs/</a></td> <td><a href="https://www.bettercap.org/docs/">https://www.bettercap.org/docs/</a></td>
</tr> </tr>
<tr> <tr>
<th>Code Documentation</th> <th>Code Documentation</th>
...@@ -39,11 +39,11 @@ Before submitting issues, please read the relevant [section](http://www.betterca ...@@ -39,11 +39,11 @@ Before submitting issues, please read the relevant [section](http://www.betterca
</tr> </tr>
<tr> <tr>
<th>Author</th> <th>Author</th>
<td><a href="http://www.evilsocket.net/">Simone Margaritelli</a> (<a href="http://twitter.com/evilsocket">@evilsocket</a>)</td> <td><a href="https://www.evilsocket.net/">Simone Margaritelli</a> (<a href="https://twitter.com/evilsocket">@evilsocket</a>)</td>
</tr> </tr>
<tr> <tr>
<th>Twitter</th> <th>Twitter</th>
<td><a href="http://twitter.com/bettercap">@bettercap</a></td> <td><a href="https://twitter.com/bettercap">@bettercap</a></td>
</tr> </tr>
<tr> <tr>
<th>Chat</th> <th>Chat</th>
...@@ -97,4 +97,4 @@ Kali Linux has bettercap packaged and added to the **kali-rolling** repositories ...@@ -97,4 +97,4 @@ Kali Linux has bettercap packaged and added to the **kali-rolling** repositories
Documentation and Examples Documentation and Examples
============ ============
Please refer to the [official website](http://www.bettercap.org/docs/). Please refer to the [official website](https://www.bettercap.org/docs/).
...@@ -5,16 +5,16 @@ ...@@ -5,16 +5,16 @@
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "bettercap" s.name = "bettercap"
s.version = "1.5.9" s.version = "1.6.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Simone Margaritelli"] s.authors = ["Simone Margaritelli"]
s.date = "2016-12-14" s.date = "2016-12-28"
s.description = "BetterCap is the state of the art, modular, portable and easily extensible MITM framework featuring ARP, DNS and ICMP spoofing, sslstripping, credentials harvesting and more." s.description = "BetterCap is the state of the art, modular, portable and easily extensible MITM framework featuring ARP, DNS and ICMP spoofing, sslstripping, credentials harvesting and more."
s.email = "evilsocket@gmail.com" s.email = "evilsocket@gmail.com"
s.executables = ["bettercap"] s.executables = ["bettercap"]
s.files = ["LICENSE.md", "README.md", "bin/bettercap", "lib/bettercap.rb", "lib/bettercap/banner", "lib/bettercap/context.rb", "lib/bettercap/discovery/agents/arp.rb", "lib/bettercap/discovery/agents/base.rb", "lib/bettercap/discovery/agents/icmp.rb", "lib/bettercap/discovery/agents/udp.rb", "lib/bettercap/discovery/thread.rb", "lib/bettercap/error.rb", "lib/bettercap/firewalls/base.rb", "lib/bettercap/firewalls/bsd.rb", "lib/bettercap/firewalls/linux.rb", "lib/bettercap/firewalls/redirection.rb", "lib/bettercap/loader.rb", "lib/bettercap/logger.rb", "lib/bettercap/memory.rb", "lib/bettercap/monkey/celluloid/actor.rb", "lib/bettercap/monkey/celluloid/io/udp_socket.rb", "lib/bettercap/monkey/em-proxy/proxy.rb", "lib/bettercap/monkey/openssl/server.rb", "lib/bettercap/monkey/packetfu/pcap.rb", "lib/bettercap/monkey/packetfu/utils.rb", "lib/bettercap/monkey/system.rb", "lib/bettercap/network/arp_reader.rb", "lib/bettercap/network/hw-prefixes", "lib/bettercap/network/network.rb", "lib/bettercap/network/packet_queue.rb", "lib/bettercap/network/protos/base.rb", "lib/bettercap/network/protos/dhcp.rb", "lib/bettercap/network/protos/mysql.rb", "lib/bettercap/network/protos/ntlm.rb", "lib/bettercap/network/protos/snmp.rb", "lib/bettercap/network/protos/teamviewer.rb", "lib/bettercap/network/servers/dnsd.rb", "lib/bettercap/network/servers/httpd.rb", "lib/bettercap/network/services", "lib/bettercap/network/target.rb", "lib/bettercap/network/validator.rb", "lib/bettercap/options/core_options.rb", "lib/bettercap/options/options.rb", "lib/bettercap/options/proxy_options.rb", "lib/bettercap/options/server_options.rb", "lib/bettercap/options/sniff_options.rb", "lib/bettercap/options/spoof_options.rb", "lib/bettercap/pluggable.rb", "lib/bettercap/proxy/http/module.rb", "lib/bettercap/proxy/http/modules/injectcss.rb", "lib/bettercap/proxy/http/modules/injecthtml.rb", "lib/bettercap/proxy/http/modules/injectjs.rb", "lib/bettercap/proxy/http/modules/redirect.rb", "lib/bettercap/proxy/http/proxy.rb", "lib/bettercap/proxy/http/request.rb", "lib/bettercap/proxy/http/response.rb", "lib/bettercap/proxy/http/ssl/authority.rb", "lib/bettercap/proxy/http/ssl/bettercap-ca.pem", "lib/bettercap/proxy/http/ssl/server.rb", "lib/bettercap/proxy/http/sslstrip/cookiemonitor.rb", "lib/bettercap/proxy/http/sslstrip/lock.ico", "lib/bettercap/proxy/http/sslstrip/strip.rb", "lib/bettercap/proxy/http/streamer.rb", "lib/bettercap/proxy/stream_logger.rb", "lib/bettercap/proxy/tcp/module.rb", "lib/bettercap/proxy/tcp/proxy.rb", "lib/bettercap/proxy/thread_pool.rb", "lib/bettercap/shell.rb", "lib/bettercap/sniffer/parsers/base.rb", "lib/bettercap/sniffer/parsers/cookie.rb", "lib/bettercap/sniffer/parsers/custom.rb", "lib/bettercap/sniffer/parsers/dhcp.rb", "lib/bettercap/sniffer/parsers/dict.rb", "lib/bettercap/sniffer/parsers/ftp.rb", "lib/bettercap/sniffer/parsers/httpauth.rb", "lib/bettercap/sniffer/parsers/https.rb", "lib/bettercap/sniffer/parsers/irc.rb", "lib/bettercap/sniffer/parsers/mail.rb", "lib/bettercap/sniffer/parsers/mpd.rb", "lib/bettercap/sniffer/parsers/mysql.rb", "lib/bettercap/sniffer/parsers/nntp.rb", "lib/bettercap/sniffer/parsers/ntlmss.rb", "lib/bettercap/sniffer/parsers/pgsql.rb", "lib/bettercap/sniffer/parsers/post.rb", "lib/bettercap/sniffer/parsers/redis.rb", "lib/bettercap/sniffer/parsers/rlogin.rb", "lib/bettercap/sniffer/parsers/snmp.rb", "lib/bettercap/sniffer/parsers/snpp.rb", "lib/bettercap/sniffer/parsers/teamviewer.rb", "lib/bettercap/sniffer/parsers/url.rb", "lib/bettercap/sniffer/parsers/whatsapp.rb", "lib/bettercap/sniffer/sniffer.rb", "lib/bettercap/spoofers/arp.rb", "lib/bettercap/spoofers/base.rb", "lib/bettercap/spoofers/icmp.rb", "lib/bettercap/spoofers/none.rb", "lib/bettercap/update_checker.rb", "lib/bettercap/version.rb"] s.files = ["LICENSE.md", "README.md", "bin/bettercap", "lib/bettercap.rb", "lib/bettercap/banner", "lib/bettercap/context.rb", "lib/bettercap/discovery/agents/arp.rb", "lib/bettercap/discovery/agents/base.rb", "lib/bettercap/discovery/agents/icmp.rb", "lib/bettercap/discovery/agents/udp.rb", "lib/bettercap/discovery/thread.rb", "lib/bettercap/error.rb", "lib/bettercap/firewalls/base.rb", "lib/bettercap/firewalls/bsd.rb", "lib/bettercap/firewalls/linux.rb", "lib/bettercap/firewalls/redirection.rb", "lib/bettercap/loader.rb", "lib/bettercap/logger.rb", "lib/bettercap/monkey/celluloid/actor.rb", "lib/bettercap/monkey/celluloid/io/udp_socket.rb", "lib/bettercap/monkey/em-proxy/proxy.rb", "lib/bettercap/monkey/openssl/server.rb", "lib/bettercap/monkey/packetfu/pcap.rb", "lib/bettercap/monkey/packetfu/utils.rb", "lib/bettercap/monkey/system.rb", "lib/bettercap/network/arp_reader.rb", "lib/bettercap/network/hw-prefixes", "lib/bettercap/network/network.rb", "lib/bettercap/network/packet_queue.rb", "lib/bettercap/network/protos/base.rb", "lib/bettercap/network/protos/dhcp.rb", "lib/bettercap/network/protos/mysql.rb", "lib/bettercap/network/protos/ntlm.rb", "lib/bettercap/network/protos/snmp.rb", "lib/bettercap/network/protos/teamviewer.rb", "lib/bettercap/network/servers/dnsd.rb", "lib/bettercap/network/servers/httpd.rb", "lib/bettercap/network/services", "lib/bettercap/network/target.rb", "lib/bettercap/network/validator.rb", "lib/bettercap/options/core_options.rb", "lib/bettercap/options/options.rb", "lib/bettercap/options/proxy_options.rb", "lib/bettercap/options/server_options.rb", "lib/bettercap/options/sniff_options.rb", "lib/bettercap/options/spoof_options.rb", "lib/bettercap/pluggable.rb", "lib/bettercap/proxy/http/module.rb", "lib/bettercap/proxy/http/modules/injectcss.rb", "lib/bettercap/proxy/http/modules/injecthtml.rb", "lib/bettercap/proxy/http/modules/injectjs.rb", "lib/bettercap/proxy/http/modules/redirect.rb", "lib/bettercap/proxy/http/proxy.rb", "lib/bettercap/proxy/http/request.rb", "lib/bettercap/proxy/http/response.rb", "lib/bettercap/proxy/http/ssl/authority.rb", "lib/bettercap/proxy/http/ssl/bettercap-ca.pem", "lib/bettercap/proxy/http/ssl/server.rb", "lib/bettercap/proxy/http/sslstrip/cookiemonitor.rb", "lib/bettercap/proxy/http/sslstrip/lock.ico", "lib/bettercap/proxy/http/sslstrip/strip.rb", "lib/bettercap/proxy/http/streamer.rb", "lib/bettercap/proxy/stream_logger.rb", "lib/bettercap/proxy/tcp/module.rb", "lib/bettercap/proxy/tcp/proxy.rb", "lib/bettercap/proxy/thread_pool.rb", "lib/bettercap/shell.rb", "lib/bettercap/sniffer/parsers/base.rb", "lib/bettercap/sniffer/parsers/cookie.rb", "lib/bettercap/sniffer/parsers/custom.rb", "lib/bettercap/sniffer/parsers/dhcp.rb", "lib/bettercap/sniffer/parsers/dict.rb", "lib/bettercap/sniffer/parsers/ftp.rb", "lib/bettercap/sniffer/parsers/httpauth.rb", "lib/bettercap/sniffer/parsers/https.rb", "lib/bettercap/sniffer/parsers/irc.rb", "lib/bettercap/sniffer/parsers/mail.rb", "lib/bettercap/sniffer/parsers/mpd.rb", "lib/bettercap/sniffer/parsers/mysql.rb", "lib/bettercap/sniffer/parsers/nntp.rb", "lib/bettercap/sniffer/parsers/ntlmss.rb", "lib/bettercap/sniffer/parsers/pgsql.rb", "lib/bettercap/sniffer/parsers/post.rb", "lib/bettercap/sniffer/parsers/redis.rb", "lib/bettercap/sniffer/parsers/rlogin.rb", "lib/bettercap/sniffer/parsers/snmp.rb", "lib/bettercap/sniffer/parsers/snpp.rb", "lib/bettercap/sniffer/parsers/teamviewer.rb", "lib/bettercap/sniffer/parsers/url.rb", "lib/bettercap/sniffer/parsers/whatsapp.rb", "lib/bettercap/sniffer/sniffer.rb", "lib/bettercap/spoofers/arp.rb", "lib/bettercap/spoofers/base.rb", "lib/bettercap/spoofers/icmp.rb", "lib/bettercap/spoofers/none.rb", "lib/bettercap/update_checker.rb", "lib/bettercap/version.rb"]
s.homepage = "http://github.com/evilsocket/bettercap" s.homepage = "https://github.com/evilsocket/bettercap"
s.licenses = ["GPL-3.0"] s.licenses = ["GPL-3.0"]
s.rdoc_options = ["--charset=UTF-8"] s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"] s.require_paths = ["lib"]
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
...@@ -26,6 +26,7 @@ require 'json' ...@@ -26,6 +26,7 @@ require 'json'
require 'net/dns' require 'net/dns'
require 'net/http' require 'net/http'
require 'optparse' require 'optparse'
require 'io/console'
Object.send :remove_const, :Config rescue nil Object.send :remove_const, :Config rescue nil
Config = RbConfig Config = RbConfig
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
...@@ -26,7 +26,9 @@ class Base ...@@ -26,7 +26,9 @@ class Base
@@instance = Firewalls::BSD.new @@instance = Firewalls::BSD.new
elsif RUBY_PLATFORM =~ /linux/ elsif RUBY_PLATFORM =~ /linux/
@@instance = Firewalls::Linux.new @@instance = Firewalls::Linux.new
else end
if @@instance.nil? or not @@instance.supported?
raise BetterCap::Error, 'Unsupported operating system' raise BetterCap::Error, 'Unsupported operating system'
end end
...@@ -45,6 +47,11 @@ class Base ...@@ -45,6 +47,11 @@ class Base
@frwd_initial_state = forwarding_enabled? @frwd_initial_state = forwarding_enabled?
end end
# OS specific checks.
def supported?
true
end
# If +enabled+ is true will enable packet forwarding, otherwise it will # If +enabled+ is true will enable packet forwarding, otherwise it will
# disable it. # disable it.
# Raise NotImplementedError # Raise NotImplementedError
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
...@@ -15,6 +15,10 @@ module BetterCap ...@@ -15,6 +15,10 @@ module BetterCap
module Firewalls module Firewalls
# *BSD and OSX Firewall class. # *BSD and OSX Firewall class.
class BSD < Base class BSD < Base
def initialize
@filename = "/tmp/bettercap_pf_#{Process.pid}.conf"
end
# If +enabled+ is true will enable packet forwarding, otherwise it will # If +enabled+ is true will enable packet forwarding, otherwise it will
# disable it. # disable it.
def enable_forwarding(enabled) def enable_forwarding(enabled)
...@@ -45,30 +49,48 @@ class BSD < Base ...@@ -45,30 +49,48 @@ class BSD < Base
# Apply the +r+ BetterCap::Firewalls::Redirection port redirection object. # Apply the +r+ BetterCap::Firewalls::Redirection port redirection object.
def add_port_redirection( r ) def add_port_redirection( r )
# create the pf config file # create the pf config file
config_file = "/tmp/bettercap_pf_#{Process.pid}.conf" File.open( @filename, 'a+t' ) do |f|
f.write "#{gen_rule(r)}\n"
File.open( config_file, 'a+t' ) do |f|
f.write "rdr pass on #{r.interface} proto #{r.protocol} from any to #{r.src_address.nil? ? 'any' : r.src_address} port #{r.src_port} -> #{r.dst_address} port #{r.dst_port}\n"
end end
# load the rule # load the rule
Shell.execute("pfctl -f #{config_file} >/dev/null 2>&1") Shell.execute("pfctl -f #{@filename} >/dev/null 2>&1")
# enable pf # enable pf
enable true enable true
end end
# Remove the +r+ BetterCap::Firewalls::Redirection port redirection object. # Remove the +r+ BetterCap::Firewalls::Redirection port redirection object.
def del_port_redirection( r ) def del_port_redirection( r )
# FIXME: This should search for multiple rules inside the # remove the redirection rule from the existing file
# file and remove only this one. rule = gen_rule(r)
rules = File.readlines(@filename).collect(&:strip).reject(&:empty?)
# disable pf rules.delete(rule)
enable false
# remove the pf config file # no other rules, delete file and disable firewall.
File.delete( "/tmp/bettercap_pf_#{Process.pid}.conf" ) if rules.empty?
File.delete(@filename)
enable false
# other rules are present in the file, update it
else
File.open( @filename, 'w+t' ) do |f|
rules.each do |rule|
f.write "#{rule}\n"
end
end
# let the firewall know we updated the file
Shell.execute("pfctl -f #{@filename} >/dev/null 2>&1")
end
rescue rescue
end end
private
# Convert +r+ to BSD firewall rule
def gen_rule( r )
"rdr pass on #{r.interface} " +
"proto #{r.protocol} " +
"from any to #{r.src_address.nil? ? 'any' : r.src_address} " +
"port #{r.src_port} -> #{r.dst_address} port #{r.dst_port}"
end
end end
end end
end end
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
...@@ -20,6 +20,12 @@ class Linux < Base ...@@ -20,6 +20,12 @@ class Linux < Base
IP_FORWARD_PATH = IPV4_PATH + "/ip_forward" IP_FORWARD_PATH = IPV4_PATH + "/ip_forward"
ICMP_BCAST_PATH = IPV4_PATH + "/icmp_echo_ignore_broadcasts" ICMP_BCAST_PATH = IPV4_PATH + "/icmp_echo_ignore_broadcasts"
SEND_REDIRECTS_PATH = IPV4_PATH + "/conf/all/send_redirects" SEND_REDIRECTS_PATH = IPV4_PATH + "/conf/all/send_redirects"
def supported?
# Avoids stuff like this https://github.com/evilsocket/bettercap/issues/341
File.file?(IP_FORWARD_PATH)
end
# If +enabled+ is true will enable packet forwarding, otherwise it will # If +enabled+ is true will enable packet forwarding, otherwise it will
# disable it. # disable it.
def enable_forwarding(enabled) def enable_forwarding(enabled)
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
# encoding: UTF-8
=begin
BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
This project is released under the GPL 3 license.
=end
module BetterCap
# This class is responsible for garbage collection and memory stats printing.
class Memory
def initialize
GC.enable
s = GC.stat
@total_allocs = s[:total_allocated_objects]
@total_freed = s[:total_freed_objects]
end
def optimize!
GC.start
begin
s = GC.stat
new_allocs = s[:total_allocated_objects]
new_freed = s[:total_freed_objects]
allocs_d = nil
freed_d = nil
if new_allocs < @total_allocs
allocs_d = new_allocs.to_s.green
elsif new_allocs > @total_allocs
allocs_d = new_allocs.to_s.red
else
allocs_d = new_allocs
end
if new_freed < @total_freed
freed_d = new_freed.to_s.red
elsif new_freed > @total_freed
freed_d = new_freed.to_s.green
else
freed_d = new_freed
end
# Logger.debug "GC: allocd objects: #{allocs_d} freed objects: #{freed_d}"
@total_allocs = new_allocs
@total_freed = new_freed
rescue; end
end
end
end
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
This diff is collapsed.
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
...@@ -85,6 +85,30 @@ class << self ...@@ -85,6 +85,30 @@ class << self
hw hw
end end
def ip2name( address )
begin
names = Resolv.getnames(address)
hostname = names[0]
names.each do |name|
unless name.nil? or name.end_with?('.') or name.strip.empty?
hostname = name
end
end
unless hostname.empty?
return hostname
end
rescue; end
begin
hostname = Resolv.getname(address)
unless hostname.empty?
return hostname
end
rescue; end
address.to_s
end
private private
# Start discovery agents and wait for +ctx.timeout+ seconds for them to # Start discovery agents and wait for +ctx.timeout+ seconds for them to
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/ Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license. This project is released under the GPL 3 license.
......
...@@ -5,7 +5,7 @@ BETTERCAP ...@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com Email : evilsocket@gmail.com