17 Commits

Author SHA1 Message Date
Simone Margaritelli
3c32bbb582 releasing v1.1.1 2019-10-31 14:50:03 +01:00
Simone Margaritelli
03067da005 misc: small fix or general refactoring i did not bother commenting 2019-10-31 14:49:44 +01:00
Simone Margaritelli
64aad56fba releasing v[3~1.1.1 2019-10-31 14:47:51 +01:00
Simone Margaritelli
4240d05872 misc: small fix or general refactoring i did not bother commenting 2019-10-31 14:20:35 +01:00
evilsocket
f03e07f0cf Merge pull request #472 from neutralinsomniac/grid_handle_malformed_filenames
fix: don't attempt to parse/upload pcaps with malformed filenames
2019-10-31 14:17:00 +01:00
Simone Margaritelli
13064879e0 fix: fixed, refactored and centralized launchers logic (closes #473) 2019-10-31 14:14:13 +01:00
Simone Margaritelli
96c617e152 misc: small fix or general refactoring i did not bother commenting 2019-10-31 12:56:27 +01:00
Simone Margaritelli
783ac61594 fix: the auto-update plugin now also installs launchers and service files via setup.py (closes #470) 2019-10-31 12:48:15 +01:00
evilsocket
279d885ec6 Merge pull request #479 from deveth0/patch-2
Change memory splitting to have more memory available
2019-10-31 10:52:59 +01:00
evilsocket
a8705c1d3c Merge pull request #476 from dadav/fix/provisioning
Change the ordering of the provisioners of packer
2019-10-31 10:50:30 +01:00
Alex Muthmann
90386c7a64 Change memory splitting to have more memory available
As most users won't use a big GUI, it should be sufficient to have 16MB assigned to the GPU and have some more for the system.
2019-10-31 08:49:58 +01:00
dadav
c7931450c3 change ordering 2019-10-30 22:28:12 +01:00
Jeremy O'Brien
3714899e95 fix: don't attempt to parse/upload pcaps with malformed filenames
Signed-off-by: Jeremy O'Brien <neutral@fastmail.com>
2019-10-30 15:33:09 -04:00
Simone Margaritelli
be414e57b3 fix: builder now uses files provisioners and auto-update installs project data (ref #470) 2019-10-30 19:24:12 +01:00
Simone Margaritelli
1600d8cbd1 fix: skipping open access points (fixes #463) 2019-10-30 17:50:56 +01:00
Simone Margaritelli
965416483d fix: more robust version parsing in auto-update (fixes #469) 2019-10-30 17:37:17 +01:00
Simone Margaritelli
78a036ed1a fix: fixed Slack invite link (fixes #466) 2019-10-30 16:49:20 +01:00
22 changed files with 276 additions and 206 deletions

View File

@@ -1,14 +1,12 @@
# Pwnagotchi
<p align="center">
<p align="center">
<a href="https://github.com/evilsocket/pwnagotchi/releases/latest"><img alt="Release" src="https://img.shields.io/github/release/evilsocket/pwnagotchi.svg?style=flat-square"></a>
<a href="https://github.com/evilsocket/pwnagotchi/blob/master/LICENSE.md"><img alt="Software License" src="https://img.shields.io/badge/license-GPL3-brightgreen.svg?style=flat-square"></a>
<a href="https://github.com/evilsocket/pwnagotchi/graphs/contributors"><img alt="Contributors" src="https://img.shields.io/github/contributors/evilsocket/pwnagotchi"/></a>
<a href="https://travis-ci.org/evilsocket/pwnagotchi"><img alt="Travis" src="https://img.shields.io/travis/evilsocket/pwnagotchi/master.svg?style=flat-square"></a>
<a href="https://pwnagotchi.herokuapp.com/"><img alt="Slack" src="https://pwnagotchi.herokuapp.com/badge.svg"></a>
<a href="https://invite.pwnagotchi.ai/"><img alt="Slack" src="https://invite.pwnagotchi.ai/badge.svg"></a>
<a href="https://twitter.com/intent/follow?screen_name=pwnagotchi"><img src="https://img.shields.io/twitter/follow/pwnagotchi?style=social&logo=twitter" alt="follow on Twitter"></a>
</p>
</p>
[Pwnagotchi](https://pwnagotchi.ai/) is an [A2C](https://hackernoon.com/intuitive-rl-intro-to-advantage-actor-critic-a2c-4ff545978752)-based "AI" leveraging [bettercap](https://www.bettercap.org/) that learns from its surrounding WiFi environment to maximize the crackable WPA key material it captures (either passively, or by performing authentication and association attacks). This material is collected as PCAP files containing any form of handshake supported by [hashcat](https://hashcat.net/hashcat/), including [PMKIDs](https://www.evilsocket.net/2019/02/13/Pwning-WiFi-networks-with-bettercap-and-the-PMKID-client-less-attack/),
@@ -32,7 +30,7 @@ https://www.pwnagotchi.ai
&nbsp; | Official Links
---------|-------
Slack | [pwnagotchi.slack.com](https://pwnagotchi.herokuapp.com)
Slack | [pwnagotchi.slack.com](https://invite.pwnagotchi.ai/)
Twitter | [@pwnagotchi](https://twitter.com/pwnagotchi)
Subreddit | [r/pwnagotchi](https://www.reddit.com/r/pwnagotchi/)
Website | [pwnagotchi.ai](https://pwnagotchi.ai/)

View File

@@ -0,0 +1,2 @@
allow-hotplug eth0
iface eth0 inet dhcp

View File

@@ -0,0 +1,2 @@
auto lo
iface lo inet loopback

View File

@@ -0,0 +1,7 @@
allow-hotplug usb0
iface usb0 inet static
address 10.0.0.2
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
gateway 10.0.0.1

View File

@@ -0,0 +1,2 @@
allow-hotplug wlan0
iface wlan0 inet static

View File

@@ -0,0 +1,14 @@
[Unit]
Description=bettercap api.rest service.
Documentation=https://bettercap.org
Wants=network.target
[Service]
Type=simple
PermissionsStartOnly=true
ExecStart=/usr/bin/bettercap-launcher
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,15 @@
[Unit]
Description=pwnagotchi Deep Reinforcement Learning instrumenting bettercap for WiFI pwning.
Documentation=https://pwnagotchi.ai
Wants=network.target
After=pwngrid-peer.service
[Service]
Type=simple
PermissionsStartOnly=true
ExecStart=/usr/bin/pwnagotchi-launcher
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,15 @@
[Unit]
Description=pwngrid peer service.
Documentation=https://pwnagotchi.ai
Wants=network.target
After=bettercap.service
[Service]
Type=simple
PermissionsStartOnly=true
ExecStart=/usr/bin/pwngrid -keys /etc/pwnagotchi -address 127.0.0.1:8666 -client-token /root/.api-enrollment.json -wait -log /var/log/pwngrid-peer.log -iface mon0
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bash
source /usr/bin/pwnlib
# start mon0
start_monitor_interface
if is_auto_mode; then
/usr/bin/bettercap -no-colors -caplet pwnagotchi-auto -iface mon0
else
/usr/bin/bettercap -no-colors -caplet pwnagotchi-manual -iface mon0
fi

2
builder/data/usr/bin/hdmioff Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bash
sudo /opt/vc/bin/tvservice -o

2
builder/data/usr/bin/hdmion Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bash
sudo /opt/vc/bin/tvservice -p

3
builder/data/usr/bin/monstart Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
source /usr/bin/pwnlib
start_monitor_interface

3
builder/data/usr/bin/monstop Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
source /usr/bin/pwnlib
stop_monitor_interface

View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bash
source /usr/bin/pwnlib
# blink 10 times to signal ready state
blink_led 10 &
if is_auto_mode; then
/usr/local/bin/pwnagotchi
else
/usr/local/bin/pwnagotchi --manual
fi

View File

@@ -0,0 +1,54 @@
#!/usr/bin/env bash
# well ... it blinks the led
blink_led() {
for i in $(seq 1 "$1"); do
echo 0 >/sys/class/leds/led0/brightness
sleep 0.3
echo 1 >/sys/class/leds/led0/brightness
sleep 0.3
done
echo 0 >/sys/class/leds/led0/brightness
sleep 0.3
}
# starts mon0
start_monitor_interface() {
iw phy phy0 interface add mon0 type monitor && ifconfig mon0 up
}
# stops mon0
stop_monitor_interface() {
ifconfig mon0 down && iw dev mon0 del
}
# returns 0 if the specificed network interface is up
is_interface_up() {
if grep -qi 'up' /sys/class/net/$1/operstate; then
return 0
fi
return 1
}
# returns 0 if conditions for AUTO mode are met
is_auto_mode() {
# check override file first
if [ -f /root/.pwnagotchi-auto ]; then
# remove the override file if found
rm -rf /root/.pwnagotchi-auto
return 0
fi
# if usb0 is up, we're in MANU
if is_interface_up usb0; then
return 1
fi
# if eth0 is up (for other boards), we're in MANU
if is_interface_up eth0; then
return 1
fi
# no override, but none of the interfaces is up -> AUTO
return 0
}

View File

@@ -1,12 +1,14 @@
{
"builders": [{
"name": "pwnagotchi",
"type": "arm-image",
"iso_url" : "https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2019-07-12/2019-07-10-raspbian-buster-lite.zip",
"iso_checksum_type":"sha256",
"iso_checksum":"9e5cf24ce483bb96e7736ea75ca422e3560e7b455eee63dd28f66fa1825db70e",
"last_partition_extra_size" : 3221225472
}],
"builders": [
{
"name": "pwnagotchi",
"type": "arm-image",
"iso_url": "https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2019-07-12/2019-07-10-raspbian-buster-lite.zip",
"iso_checksum_type": "sha256",
"iso_checksum": "9e5cf24ce483bb96e7736ea75ca422e3560e7b455eee63dd28f66fa1825db70e",
"last_partition_extra_size": 3221225472
}
],
"provisioners": [
{
"type": "shell",
@@ -18,7 +20,77 @@
]
},
{
"type":"ansible-local",
"type": "file",
"source": "data/usr/bin/pwnlib",
"destination": "/usr/bin/pwnlib"
},
{
"type": "file",
"source": "data/usr/bin/bettercap-launcher",
"destination": "/usr/bin/bettercap-launcher"
},
{
"type": "file",
"source": "data/usr/bin/pwnagotchi-launcher",
"destination": "/usr/bin/pwnagotchi-launcher"
},
{
"type": "file",
"source": "data/usr/bin/monstop",
"destination": "/usr/bin/monstop"
},
{
"type": "file",
"source": "data/usr/bin/monstart",
"destination": "/usr/bin/monstart"
},
{
"type": "file",
"source": "data/usr/bin/hdmion",
"destination": "/usr/bin/hdmion"
},
{
"type": "file",
"source": "data/usr/bin/hdmioff",
"destination": "/usr/bin/hdmioff"
},
{
"type": "file",
"source": "data/etc/network/interfaces.d/lo-cfg",
"destination": "/etc/network/interfaces.d/lo-cfg"
},
{
"type": "file",
"source": "data/etc/network/interfaces.d/wlan0-cfg",
"destination": "/etc/network/interfaces.d/wlan0-cfg"
},
{
"type": "file",
"source": "data/etc/network/interfaces.d/usb0-cfg",
"destination": "/etc/network/interfaces.d/usb0-cfg"
},
{
"type": "file",
"source": "data/etc/network/interfaces.d/eth0-cfg",
"destination": "/etc/network/interfaces.d/eth0-cfg"
},
{
"type": "file",
"source": "data/etc/systemd/system/pwngrid-peer.service",
"destination": "/etc/systemd/system/pwngrid-peer.service"
},
{
"type": "file",
"source": "data/etc/systemd/system/pwnagotchi.service",
"destination": "/etc/systemd/system/pwnagotchi.service"
},
{
"type": "file",
"source": "data/etc/systemd/system/bettercap.service",
"destination": "/etc/systemd/system/bettercap.service"
},
{
"type": "ansible-local",
"playbook_file": "pwnagotchi.yml",
"command": "ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 PWN_VERSION={{user `pwn_version`}} PWN_HOSTNAME={{user `pwn_hostname`}} ansible-playbook"
},

View File

@@ -13,6 +13,7 @@
- "dtparam=spi=on"
- "dtparam=i2c_arm=on"
- "dtparam=i2c1=on"
- "gpu_mem=16"
modules:
- "i2c-dev"
services:
@@ -279,93 +280,6 @@
remote_src: yes
mode: 0755
- name: create bootblink script
copy:
dest: /usr/bin/bootblink
mode: 0755
content: |
#!/usr/bin/env bash
for i in $(seq 1 "$1");
do
echo 0 >/sys/class/leds/led0/brightness
sleep 0.3
echo 1 >/sys/class/leds/led0/brightness
sleep 0.3
done
echo 0 >/sys/class/leds/led0/brightness
sleep 0.3
- name: create pwnagotchi-launcher script
copy:
dest: /usr/bin/pwnagotchi-launcher
mode: 0755
content: |
#!/usr/bin/env bash
# blink 10 times to signal ready state
/usr/bin/bootblink 10 &
# start a detached screen session with bettercap
if [[ $(ifconfig | grep usb0 | grep RUNNING) ]] || [[ !$(grep '1' /sys/class/net/eth0/carrier) ]]; then
# if override file exists, go into auto mode
if [ -f /root/.pwnagotchi-auto ]; then
rm /root/.pwnagotchi-auto
/usr/local/bin/pwnagotchi
else
/usr/local/bin/pwnagotchi --manual
fi
else
/usr/local/bin/pwnagotchi
fi
- name: create bettercap-launcher script
copy:
dest: /usr/bin/bettercap-launcher
mode: 0755
content: |
#!/usr/bin/env bash
/usr/bin/monstart
if [[ $(ifconfig | grep usb0 | grep RUNNING) ]] || [[ !$(grep '1' /sys/class/net/eth0/carrier) ]]; then
# if override file exists, go into auto mode
if [ -f /root/.pwnagotchi-auto ]; then
/usr/bin/bettercap -no-colors -caplet pwnagotchi-auto -iface mon0
else
/usr/bin/bettercap -no-colors -caplet pwnagotchi-manual -iface mon0
fi
else
/usr/bin/bettercap -no-colors -caplet pwnagotchi-auto -iface mon0
fi
- name: create monstart script
copy:
dest: /usr/bin/monstart
mode: 0755
content: |
#!/usr/bin/env bash
iw phy phy0 interface add mon0 type monitor && ifconfig mon0 up
- name: create monstop script
copy:
dest: /usr/bin/monstop
mode: 0755
content: |
#!/usr/bin/env bash
ifconfig mon0 down && iw dev mon0 del
- name: create hdmion script
copy:
dest: /usr/bin/hdmion
mode: 0755
content: |
#!/usr/bin/env bash
sudo /opt/vc/bin/tvservice -p
- name: create hdmioff script
copy:
dest: /usr/bin/hdmioff
mode: 0755
content: |
#!/usr/bin/env bash
sudo /opt/vc/bin/tvservice -o
- name: add HDMI powersave to rc.local
blockinfile:
path: /etc/rc.local
@@ -399,39 +313,6 @@
#
when: not user_config.stat.exists
- name: configure lo interface
copy:
dest: /etc/network/interfaces.d/lo-cfg
content: |
auto lo
iface lo inet loopback
- name: configure wlan interface
copy:
dest: /etc/network/interfaces.d/wlan0-cfg
content: |
allow-hotplug wlan0
iface wlan0 inet static
- name: configure usb interface
copy:
dest: /etc/network/interfaces.d/usb0-cfg
content: |
allow-hotplug usb0
iface usb0 inet static
address 10.0.0.2
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
gateway 10.0.0.1
- name: configure eth0 interface (pi2/3/4)
copy:
dest: /etc/network/interfaces.d/eth0-cfg
content: |
allow-hotplug eth0
iface eth0 inet dhcp
- name: enable ssh on boot
file:
path: /boot/ssh
@@ -471,7 +352,7 @@
copy:
dest: /etc/motd
content: |
(◕‿‿◕) {{pwnagotchi.hostname}} (pwnagotchi-{{pwnagotchi.version}})
(◕‿‿◕) {{pwnagotchi.hostname}}
Hi! I'm a pwnagotchi, please take good care of me!
Here are some basic things you need to know to raise me properly!
@@ -507,71 +388,6 @@
apt:
autoremove: yes
- name: add pwngrid-peer service to systemd
copy:
dest: /etc/systemd/system/pwngrid-peer.service
content: |
[Unit]
Description=pwngrid peer service.
Documentation=https://pwnagotchi.ai
Wants=network.target
[Service]
Type=simple
PermissionsStartOnly=true
ExecStart=/usr/bin/pwngrid -keys /etc/pwnagotchi -address 127.0.0.1:8666 -client-token /root/.api-enrollment.json -wait -log /var/log/pwngrid-peer.log -iface mon0
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
notify:
- reload systemd services
- name: add bettercap service to systemd
copy:
dest: /etc/systemd/system/bettercap.service
content: |
[Unit]
Description=bettercap api.rest service.
Documentation=https://bettercap.org
Wants=network.target
After=pwngrid.service
[Service]
Type=simple
PermissionsStartOnly=true
ExecStart=/usr/bin/bettercap-launcher
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
notify:
- reload systemd services
- name: add pwnagotchi service to systemd
copy:
dest: /etc/systemd/system/pwnagotchi.service
content: |
[Unit]
Description=pwnagotchi Deep Reinforcement Learning instrumenting bettercap for WiFI pwning.
Documentation=https://pwnagotchi.ai
Wants=network.target
After=bettercap.service
[Service]
Type=simple
PermissionsStartOnly=true
ExecStart=/usr/bin/pwnagotchi-launcher
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
notify:
- reload systemd services
- name: enable services
systemd:
name: "{{ item }}"

View File

@@ -6,7 +6,7 @@ import re
import pwnagotchi.ui.view as view
import pwnagotchi
version = '1.1.0'
version = '1.1.1'
_name = None

View File

@@ -170,7 +170,9 @@ class Agent(Client, Automata, AsyncAdvertiser, AsyncTrainer):
s = self.session()
plugins.on("unfiltered_ap_list", self, s['wifi']['aps'])
for ap in s['wifi']['aps']:
if ap['hostname'] not in whitelist:
if ap['encryption'] == '' or ap['encryption'] == 'OPEN':
continue
elif ap['hostname'] not in whitelist:
if self._filter_included(ap):
aps.append(ap)
except Exception as e:

View File

@@ -1,10 +1,11 @@
__author__ = 'evilsocket@gmail.com'
__version__ = '1.1.0'
__version__ = '1.1.1'
__name__ = 'auto-update'
__license__ = 'GPL3'
__description__ = 'This plugin checks when updates are available and applies them when internet is available.'
import os
import re
import logging
import subprocess
import requests
@@ -142,11 +143,21 @@ def install(display, update):
if not os.path.exists(source_path):
source_path = "%s-%s" % (source_path, update['available'])
# setup.py is going to install data files for us
os.system("cd %s && pip3 install ." % source_path)
return True
def parse_version(cmd):
out = subprocess.getoutput(cmd)
for part in out.split(' '):
part = part.replace('v', '').strip()
if re.search(r'^\d+\.\d+\.\d+.*$', part):
return part
raise Exception('could not parse version from "%s": output=\n%s' % (cmd, out))
def on_internet_available(agent):
global STATUS
@@ -167,9 +178,8 @@ def on_internet_available(agent):
to_install = []
to_check = [
('bettercap/bettercap', subprocess.getoutput('bettercap -version').split(' ')[1].replace('v', ''),
True, 'bettercap'),
('evilsocket/pwngrid', subprocess.getoutput('pwngrid -version').replace('v', ''), True, 'pwngrid-peer'),
('bettercap/bettercap', parse_version('bettercap -version'), True, 'bettercap'),
('evilsocket/pwngrid', parse_version('pwngrid -version'), True, 'pwngrid-peer'),
('evilsocket/pwnagotchi', pwnagotchi.version, False, 'pwnagotchi')
]

View File

@@ -9,6 +9,7 @@ import os
import logging
import time
import glob
import re
import pwnagotchi.grid as grid
from pwnagotchi.utils import StatusFile, WifiInfo, extract_from_pcap
@@ -36,6 +37,10 @@ def parse_pcap(filename):
# /root/handshakes/BSSID.pcap
essid, bssid = '', net_id
mac_re = re.compile('[0-9a-fA-F]{12}')
if not mac_re.match(bssid):
return '', ''
it = iter(bssid)
bssid = ':'.join([a + b for a, b in zip(it, it)])

View File

@@ -1,7 +1,29 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
import pwnagotchi
import os
import glob
import shutil
setup_path = os.path.dirname(__file__)
data_path = os.path.join(setup_path, "builder/data")
for source_filename in glob.glob("%s/**" % data_path, recursive=True):
if os.path.isfile(source_filename):
dest_filename = source_filename.replace(data_path, '')
dest_folder = os.path.dirname(dest_filename)
print("installing %s to %s ..." % (source_filename, dest_filename))
try:
if not os.path.isdir(dest_folder):
os.makedirs(dest_folder)
shutil.copyfile(source_filename, dest_filename)
except Exception as e:
print("error installing %s: %s" % (source_filename, e))
# reload systemd units
os.system("systemctl daemon-reload")
required = []
with open('requirements.txt') as fp:
@@ -10,6 +32,8 @@ with open('requirements.txt') as fp:
if line != "":
required.append(line)
import pwnagotchi
setup(name='pwnagotchi',
version=pwnagotchi.version,
description='(⌐■_■) - Deep Reinforcement Learning instrumenting bettercap for WiFI pwning.',