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
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>
<tr>
<th>Version</th>
<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"/>
</a>
</td>
</tr>
<tr>
<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>
<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>
<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>
<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>
<th>Code Documentation</th>
......@@ -39,11 +39,11 @@ Before submitting issues, please read the relevant [section](http://www.betterca
</tr>
<tr>
<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>
<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>
<th>Chat</th>
......@@ -97,4 +97,4 @@ Kali Linux has bettercap packaged and added to the **kali-rolling** repositories
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 @@
Gem::Specification.new do |s|
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.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.email = "evilsocket@gmail.com"
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.homepage = "http://github.com/evilsocket/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/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 = "https://github.com/evilsocket/bettercap"
s.licenses = ["GPL-3.0"]
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
......
......@@ -7,7 +7,7 @@
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......@@ -26,6 +26,7 @@ require 'json'
require 'net/dns'
require 'net/http'
require 'optparse'
require 'io/console'
Object.send :remove_const, :Config rescue nil
Config = RbConfig
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......@@ -26,7 +26,9 @@ class Base
@@instance = Firewalls::BSD.new
elsif RUBY_PLATFORM =~ /linux/
@@instance = Firewalls::Linux.new
else
end
if @@instance.nil? or not @@instance.supported?
raise BetterCap::Error, 'Unsupported operating system'
end
......@@ -45,6 +47,11 @@ class Base
@frwd_initial_state = forwarding_enabled?
end
# OS specific checks.
def supported?
true
end
# If +enabled+ is true will enable packet forwarding, otherwise it will
# disable it.
# Raise NotImplementedError
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......@@ -15,6 +15,10 @@ module BetterCap
module Firewalls
# *BSD and OSX Firewall class.
class BSD < Base
def initialize
@filename = "/tmp/bettercap_pf_#{Process.pid}.conf"
end
# If +enabled+ is true will enable packet forwarding, otherwise it will
# disable it.
def enable_forwarding(enabled)
......@@ -45,30 +49,48 @@ class BSD < Base
# Apply the +r+ BetterCap::Firewalls::Redirection port redirection object.
def add_port_redirection( r )
# create the pf config file
config_file = "/tmp/bettercap_pf_#{Process.pid}.conf"
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"
File.open( @filename, 'a+t' ) do |f|
f.write "#{gen_rule(r)}\n"
end
# 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 true
end
# Remove the +r+ BetterCap::Firewalls::Redirection port redirection object.
def del_port_redirection( r )
# FIXME: This should search for multiple rules inside the
# file and remove only this one.
# disable pf
enable false
# remove the redirection rule from the existing file
rule = gen_rule(r)
rules = File.readlines(@filename).collect(&:strip).reject(&:empty?)
rules.delete(rule)
# remove the pf config file
File.delete( "/tmp/bettercap_pf_#{Process.pid}.conf" )
# no other rules, delete file and disable firewall.
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
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
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......@@ -20,6 +20,12 @@ class Linux < Base
IP_FORWARD_PATH = IPV4_PATH + "/ip_forward"
ICMP_BCAST_PATH = IPV4_PATH + "/icmp_echo_ignore_broadcasts"
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
# disable it.
def enable_forwarding(enabled)
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
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
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
This diff is collapsed.
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......@@ -85,6 +85,30 @@ class << self
hw
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
# Start discovery agents and wait for +ctx.timeout+ seconds for them to
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
SNMP network protos:
Author : Matteo Cantoni
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......@@ -97,7 +97,7 @@ class Target
# Return a compact string representation of this object.
def to_s_compact
return "#{@name}/#{@ip}" if @name
return "#{@name.light_blue}/#{@ip}" if @name
@ip
end
......@@ -122,21 +122,31 @@ private
# Attempt to perform a NBNS name resolution for this target.
def resolve!
resp, sock = nil, nil
begin
sock = UDPSocket.open
sock.send( NBNS_REQUEST, 0, @ip, NBNS_PORT )
resp = if select([sock], nil, nil, NBNS_TIMEOUT)
sock.recvfrom(NBNS_BUFSIZE)
hostname = Network.ip2name(@ip)
if hostname == @ip
resp, sock = nil, nil
begin
sock = UDPSocket.open
sock.send( NBNS_REQUEST, 0, @ip, NBNS_PORT )
resp = if select([sock], nil, nil, NBNS_TIMEOUT)
sock.recvfrom(NBNS_BUFSIZE)
end
if resp
@name = parse_nbns_response resp
Logger.info "Found NetBIOS name '#{@name}' for address #{@ip}"
end
rescue Exception => e
Logger.debug e
ensure
sock.close if sock
end
if resp
@name = parse_nbns_response resp
Logger.info "Found NetBIOS name '#{@name}' for address #{@ip}"
else
if not Network::Validator.is_ip?(hostname) and hostname.include?('.')
@name = hostname.split('.')[0]
else
@name = hostname
end
rescue Exception => e
Logger.debug e
ensure
sock.close if sock
Logger.info "Found hostname #{@name.green} for address #{@ip}"
end
end
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......@@ -105,10 +105,18 @@ class CoreOptions
opts.on( '--check-updates', 'Will check if any update is available and then exit.' ) do
@check_updates = true
end
opts.on( '-R', '--rainbows', 'Rainbow output, because that\'s a really helpful thing to have (requires the "lolize" gem to be installed).' ) do
begin
require 'lolize/auto'
rescue LoadError
raise BetterCap::Error, "GEM lolize not found, please install it in order to use this option"
end
end
opts.on( '-h', '--help', 'Display the available options.') do
puts opts
puts "\nFor examples & docs please visit " + "http://bettercap.org/docs/".bold
puts "\nFor examples & docs please visit " + "https://bettercap.org/docs/".bold
exit
end
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......
......@@ -5,7 +5,7 @@ BETTERCAP
Author : Simone 'evilsocket' Margaritelli
Email : evilsocket@gmail.com
Blog : http://www.evilsocket.net/
Blog : https://www.evilsocket.net/
This project is released under the GPL 3 license.
......@@ -181,7 +181,6 @@ class ProxyOptions