Commit 40ac61b7 authored by Sophie Brun's avatar Sophie Brun

Imported Upstream version 1.5.3

parents
# How To Contribute
As any other open source projects, there're many ways you can contribute to bettercap depending on your skills as a developer or will to help as a user, but first
of all let me thank you for your help! <3
### Submitting Issues
If you find bugs or inconsistencies while using bettercap, you can create an **Issue** using the [GitHub Issue tracker](https://github.com/evilsocket/bettercap/issues), but before doing that please make sure that:
* You are using a relatively new Ruby version ( >= 1.9 ) : `ruby -v`.
* Your GEM environment is configured properly and updated : `sudo gem update`.
* You are using the latest version of bettercap : `bettercap --check-updates`.
* The bug you're reporting is actually related to bettercap and not to one of the other GEMs.
Once you've gone through this list, open an issue and please give us as much as informations as possible in order for us to fix the bug as soon as possible:
* Your OS version.
* Ruby version you're using.
* Full output of the error ( exception backtrace, error message, etc ).
* Your network configuration: `ifconfig -a`
Also, you should attach to the issue a debug log that you can generate with:
[sudo|rvmsudo] bettercap [arguments you are using for testing] --debug --log=debug.log
Wait for the error to happen then close bettercap and paste the **debug.log** file inside the issue.
### Pull Requests
If you know how to code in Ruby and have ideas to improve bettercap, you're very welcome to send us pull requests, we'll be happy to merge them whenever they comply to the following rules:
* You have at least manually tested your code, ideally you've created actual tests for it.
* Respect our coding standard, 2 spaces indentation and modular code.
* There're no conflicts with the current dev branch.
* Your commit messages are enough explanatory to us.
There're plenty of things you can to do improve the software:
* Implement a new proxy module and push it to the [dedicated repository](https://github.com/evilsocket/bettercap-proxy-modules).
* Implement a new [Spoofer module](https://github.com/evilsocket/bettercap/blob/master/lib/bettercap/spoofers/arp.rb).
* Implement a new [Sniffer credentials parser](https://github.com/evilsocket/bettercap/blob/master/lib/bettercap/sniffer/parsers/post.rb).
* Fix, extend or improve the core.
### What operating system are you using and which version ?
*Insert answer here*
### What Ruby version are you using ( `ruby -v` ) ?
*Insert answer here*
### Is your GEM environment properly configured and updated ( `sudo gem update` ) ?
*Insert answer here*
### Which version of BetterCap are you using ( `bettercap -v` ) ?
*Insert answer here*
### What's the output of BetterCap while the issue happens?
*Insert answer here*
*.swp
*.swo
*.gem
*.sh
.idea
cert.crt
cert.key
cert.pem
test_*.rb
test_*.sj
test_*.conf
.tags*
.DS_Store
hosts
PATH
remote: .
specs:
bettercap (1.4.7b)
colorize (~> 0.7, >= 0.7.5)
em-proxy (~> 0.1, >= 0.1.8)
net-dns (~> 0.8, >= 0.8.0)
network_interface (~> 0.0, >= 0.0.1)
packetfu (~> 1.1, >= 1.1.10)
pcaprub (~> 0.12, >= 0.12.0)
rubydns (~> 1.0, >= 1.0.3)
GEM
remote: https://rubygems.org/
specs:
celluloid (0.16.0)
timers (~> 4.0.0)
celluloid-io (0.16.2)
celluloid (>= 0.16.0)
nio4r (>= 1.1.0)
colorize (0.7.7)
em-proxy (0.1.8)
eventmachine
eventmachine (1.0.8)
hitimes (1.2.3)
net-dns (0.8.0)
network_interface (0.0.1)
nio4r (1.2.0)
packetfu (1.1.11)
network_interface (~> 0.0)
pcaprub (~> 0.12)
pcaprub (0.12.1)
rubydns (1.0.3)
celluloid (= 0.16.0)
celluloid-io (= 0.16.2)
timers (~> 4.0.1)
timers (4.0.4)
hitimes
PLATFORMS
ruby
DEPENDENCIES
bettercap!
BUNDLED WITH
1.11.2
This diff is collapsed.
**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.
<table>
<tr>
<th>Version</th>
<td>
<a href="http://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>
</tr>
<tr>
<th>Blog</th>
<td><a href="http://www.bettercap.org/blog/">http://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>
<tr/>
<tr>
<th>Documentation</th>
<td><a href="http://www.bettercap.org/docs/">http://www.bettercap.org/docs/</a></td>
</tr>
<tr>
<th>Code Documentation</th>
<td>
<a href="http://www.rubydoc.info/github/evilsocket/bettercap">http://www.rubydoc.info/github/evilsocket/bettercap</a>
&nbsp;
<a href="https://codeclimate.com/github/evilsocket/bettercap" target="_blank">
<img src="https://codeclimate.com/github/evilsocket/bettercap/badges/gpa.svg"/>
</a>
</td>
</tr>
<tr>
<th>Author</th>
<td><a href="http://www.evilsocket.net/">Simone Margaritelli</a> (<a href="http://twitter.com/evilsocket">@evilsocket</a>)</td>
</tr>
<tr>
<th>Twitter</th>
<td><a href="http://twitter.com/bettercap">@bettercap</a></td>
</tr>
<tr>
<th>Chat</th>
<td>
<a href="https://gitter.im/evilsocket/bettercap" target="_blank">
<img src="https://badges.gitter.im/evilsocket/bettercap.svg"/>
</a>
</td>
</tr>
<tr>
<th>Copyright</th>
<td>2015-2016 Simone Margaritelli</td>
</tr>
<tr>
<th>License</th>
<td>GPL v3.0 - (see LICENSE file)</td>
</tr>
</table>
Installation
============
**Dependencies**
All dependencies will be automatically installed through the GEM system but in some case you might need to install some system
dependency in order to make everything work:
sudo apt-get install build-essential ruby-dev libpcap-dev
This should solve issues such as [this one](https://github.com/evilsocket/bettercap/issues/22) or [this one](https://github.com/evilsocket/bettercap/issues/100).
**Stable Release ( GEM )**
gem install bettercap
**From Source**
git clone https://github.com/evilsocket/bettercap
cd bettercap
gem build bettercap.gemspec
sudo gem install bettercap*.gem
Documentation and Examples
============
Please refer to the [official website](http://www.bettercap.org/docs/).
require 'rake'
VERSION_FILENAME = 'lib/bettercap/version.rb'
def proxy!( enabled = true )
service = "Wi-Fi"
if enabled
address = `ifconfig en0 | grep netmask | cut -d ' ' -f 2`.strip
port = 8080
`sudo networksetup -setwebproxy '#{service}' #{address} #{port} off`
`sudo networksetup -setwebproxystate '#{service}' off`
`sudo networksetup -setwebproxystate '#{service}' on`
else
`sudo networksetup -setwebproxystate '#{service}' off`
end
end
def get_current_version
current_version = nil
data = File.read( VERSION_FILENAME )
if data =~ /VERSION\s+=\s+'([^']+)'/i
current_version = $1
end
raise 'Could not extract current version.' if current_version.nil?
current_version
end
def change_version( currentv, newv )
puts "@ Upgrading from '#{currentv}' to '#{newv}' ..."
data = File.read( VERSION_FILENAME )
data = data.gsub( currentv, newv )
File.open( VERSION_FILENAME, 'w') {
|file| file.puts data
}
end
namespace :util do
desc "Build a GEM from the current source code and install it locally."
task :sync do
puts "@ Synchronizing codebase with GEM installation ..."
`rm -rf *.gem`
`gem build bettercap.gemspec`
`sudo gem install --no-rdoc --no-ri --local *.gem`
end
desc "Upgrade version to stable, push to github and upload the new GEM release."
task :release do
current_version = get_current_version
raise 'Current version is not a beta.' unless current_version.end_with?'b'
next_version = current_version.gsub('b','')
change_version( current_version, next_version )
current_version = next_version
puts "@ Pushing to github ..."
sh "git add #{VERSION_FILENAME}"
sh "git commit -m \"Version bump to #{current_version}\""
sh "git push"
Rake::Task["util:sync"].invoke
puts "@ Uploading GEM ..."
sh "gem push bettercap-#{current_version}.gem"
`rm -rf *.gem`
Rake::Task["util:sync"].invoke
end
desc "Print a markdown changelog for the current release."
task :changelog do
feats = []
fixes = []
style = []
puts "@ Fetching remote tags ...\n\n"
`git fetch --tags`
lines = `git log \`git describe --tags --abbrev=0\`..HEAD --oneline`.split("\n")
lines.each do |line|
if line =~ /^[^\s]+\s+(.+)$/
msg = $1.gsub( /([^\s]*[A-Z][^\s]*[A-Z][^\s]*)/, '`\1`' ).gsub( /([a-z]+_[a-z]+)/, '`\1`' )
dwn = msg.downcase
next if dwn.include?('version bump') or dwn.include?('rake')
if dwn.include?('fix')
fixes << msg
elsif dwn.include?('new')
feats << msg
else
style << msg
end
end
end
puts "Changelog"
puts "===\n\n"
puts "**New Features**\n\n"
feats.each do |m|
puts "* #{m}"
end
puts "\n**Fixes**\n\n"
fixes.each do |m|
puts "* #{m}"
end
puts "\n**Code Style**\n\n"
style.each do |m|
puts "* #{m}"
end
puts "\n"
end
end
namespace :test do
desc "Test discovery."
task :discovery do
`sudo arp -ad`
system("clear && sudo bettercap --no-spoofing")
end
desc "Test proxy and injectjs module."
task :proxy do
proxy!
begin
system( "clear && sudo bettercap --no-discovery --no-spoofing --proxy -P POST" )
rescue
ensure
proxy! false
end
end
task :ssh_proxy do
puts "Please enter SSH server address:"
addr = STDIN.gets.chomp
system( "clear && sudo bettercap -T 192.168.1.2 --no-discovery --tcp-proxy-upstream-address #{addr} --tcp-proxy-upstream-port 22 --tcp-proxy-module test_tcp_module.rb" )
end
desc "Test DNS spoofing."
task :dns do
File.open('/tmp/hosts','w'){ |f| f.write("local .*google\\.com\n") }
system("clear && sudo bettercap --no-spoofing --no-discovery --dns /tmp/hosts")
end
end
task :default => 'util:sync'
require './lib/bettercap/version'
Gem::Specification.new do |gem|
gem.name = %q{bettercap}
gem.version = BetterCap::VERSION
gem.license = 'GPL-3.0'
gem.summary = %q{A complete, modular, portable and easily extensible MITM framework.}
gem.description = %q{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.}
gem.required_ruby_version = '>= 1.9'
gem.authors = ['Simone Margaritelli']
gem.email = %q{evilsocket@gmail.com}
gem.homepage = %q{http://github.com/evilsocket/bettercap}
gem.add_dependency( 'colorize', '~> 0.7', '>= 0.7.5' )
gem.add_dependency( 'packetfu', '~> 1.1', '>= 1.1.10' )
gem.add_dependency( 'pcaprub', '~> 0.12', '>= 0.12.0' )
gem.add_dependency( 'network_interface', '~> 0.0', '>= 0.0.1' )
gem.add_dependency( 'net-dns', '~> 0.8', '>= 0.8.0' )
gem.add_dependency( 'rubydns', '~> 1.0', '>= 1.0.3' )
gem.add_dependency( 'em-proxy', '~> 0.1', '>= 0.1.8' )
gem.files = Dir.glob("*.md") +
Dir.glob("lib/**/*") +
Dir.glob("bin/**/*")
gem.require_paths = ["lib"]
gem.executables = %w(bettercap)
gem.rdoc_options = ["--charset=UTF-8"]
end
#!/usr/bin/env ruby
# 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
require 'bettercap'
begin
puts BetterCap::BANNER.green.bold
puts "\n\n\n"
# We need this in order to report unhandled exceptions.
original_argv = ARGV.clone
# Create global context, parse command line arguments and perform basic
# error checking.
ctx = BetterCap::Options.parse!
ctx.start!
loop do
sleep 10
end
rescue SystemExit, Interrupt, SignalException
BetterCap::Logger.raw "\n"
rescue OptionParser::InvalidOption,
OptionParser::AmbiguousOption,
OptionParser::MissingArgument => e
BetterCap::Logger.error "'#{e.message.capitalize}', verify your command line arguments executing 'bettercap --help'."
rescue BetterCap::Error => e
BetterCap::Logger.error e.message
rescue Exception => e
puts "\n\n"
BetterCap::Logger.error "Oooops, seems like something weird occurred, please copy paste the following output " \
"and open a new issue on https://github.com/evilsocket/bettercap/issues :\n"
BetterCap::Logger.error "Platform : #{RUBY_PLATFORM}"
BetterCap::Logger.error "Ruby Version : #{RUBY_VERSION}"
BetterCap::Logger.error "BetterCap Version : #{BetterCap::VERSION}"
BetterCap::Logger.error "Command Line : #{original_argv.join(" ")}"
BetterCap::Logger.error "Exception : #{e.class}"
BetterCap::Logger.error "Message : #{e.message}"
BetterCap::Logger.error "Backtrace :\n\n #{e.backtrace.join("\n ")}\n"
ensure
# Make sure all the messages on the logger queue are printed.
BetterCap::Logger.wait!
ctx.finalize unless ctx.nil?
end
_build/
.tags
.DS_Store
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
endif
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/BetterCAP.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/BetterCAP.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/BetterCAP"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/BetterCAP"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
{% extends "!page.html" %}
{% block sidebartitle %}
<a href="https://bettercap.org/" style="margin-bottom: 7px; background: none !important;">
<button class="btn btn-info">
<i class="fa fa-arrow-left"></i>
Return to bettercap.org
</button>
</a>
{{ super() }}
{% endblock %}
{% block footer %}
{{ super() }}
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-65617603-1");
pageTracker._trackPageview();
} catch(err) {}</script>
{% endblock %}
# -*- coding: utf-8 -*-
#