Initial commit

This commit is contained in:
Sebastian 2022-01-11 23:03:29 +01:00
parent 860c1f2f8b
commit 2ac5aed8c6
8 changed files with 197 additions and 2 deletions

View File

@ -1,3 +1,21 @@
# wifi-printer
# Wi-Fi Printer
Thermal printer automatically prints addresses and vendors of Wi-Fi devices nearby.
This project prints all SSIDs, MAC addresses, and their vendors on a thermal printer using a Wi-Fi adaptor in monitor mode.
## Overview
## Usage
1. Setup a Raspberry Pi with Raspbian/Raspberry OS
2. Connect to Internet
3. Run ``install.sh``-Script
4. Wait
5. Set up for further usage, i.e.:
* Remove Internet connectivity (not needed anymore)
* Connect printer and Wi-Fi adaptor
* Include everything into nice device :)
## Important
* You might need to adapt the printer configuration in ``cms.py`` depending on the printer you use
* You might need to change the name of the network adaptor in ``install.sh``

BIN
cms.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

128
cms.py Normal file
View File

@ -0,0 +1,128 @@
# Chaos macht Schule
# Wi-Fi Printer
# Prints SSIDs, MAC addresses, and their vendors on a thermal printer.
import os, sys
import pickle
import collections
import trackerjacker
from escpos import printer
__config__ = {'trigger_cooldown': 10} # No need to call more than once for a single device
REPORT_FILE = 'top_manufacturers.txt'
class Trigger:
def __init__(self):
self.manufacturer_to_count = collections.Counter()
self.devices_seen = set()
self.packets_seen = 0
self.ssids_seen = []
path = os.path.dirname(trackerjacker.__file__)
self.p = printer.Usb(0x0493, 0x8760, in_ep=0x81, out_ep=0x03)
self.p.text("\n\n")
self.p.image(path+"/plugins/cms.png")
self.p.text("Chaospott Essen\n")
self.p.text("Wir sind da wat am hacken dran!\n")
self.p.text("https://www.chaospott.de/\n")
self.p.text("\n\n")
print("")
print("")
print("Chaos macht Schule")
print("Chaospott Essen - Wir sind da wat am hacken dran")
print("https://www.chaospott.de")
print("")
# Called when new device is found
def __call__(self, dev_id=None, vendor=None, ssid=None, bssid=None, iface=None, power=None, **kwargs):
# Store SSID in list if its not already in there
if ssid not in self.ssids_seen:
self.ssids_seen.append(ssid)
# Output on screen
print('Neues Netzwerk: {}, Netzwerke insgesamt: {}\n\n'
.format(ssid, len(self.ssids_seen)))
# Output on printer
self.p.text('SSID: {},\nNetzwerke insgesamt: {}\n\n'
.format(ssid, len(self.ssids_seen)))
# Check if the device's new
if vendor and dev_id not in self.devices_seen:
self.devices_seen |= {dev_id}
self.manufacturer_to_count[vendor] += 1
# Output on screen
print('Neues Gerät: {}) von Hersteller: {};\n Anzahl Geräte von Hersteller {}: {}\n'
.format(dev_id, vendor, vendor, self.manufacturer_to_count[vendor]))
# Output on printer
self.p.text('Ger\20\204\04t: {}\nHersteller: {}\n\n'.format(dev_id, vendor))
# Print each n packets a summary
self.packets_seen += 1
if self.packets_seen % 100 == 0:
self.output_report()
# Print report
def output_report(self):
# Calculate results
descending_order = sorted([(count, vendor) for vendor, count in self.manufacturer_to_count.items()], reverse=True)
total_ssid_count = len(self.ssids_seen)
total_device_count = 0
for (count, vendor) in descending_order:
total_device_count += count
# Output to file for plot and further evaluation
with open(REPORT_FILE, 'w') as f:
for (count, vendor) in descending_order:
f.write('{}: {}\n'.format(count, vendor))
# Output on printer
self.p.text("\n\n")
self.p.text("############\n")
self.p.text("# Ergebnis #\n")
self.p.text("############\n\n")
self.p.text('Netzwerke gefunden: {}\n\n'
.format(total_ssid_count))
self.p.text('Ger\20\204\04te gefunden: {}\n\n'
.format(total_device_count))
for (count, vendor) in descending_order:
self.p.text('{0:1}: {1}\n'.format(count, vendor))
self.p.text("\n\n\n")
# Output to screen
print('\n{}\n Ergebnis\n {}\n\n'.format('='*100, '='*100))
print('Netzwerke gefunden: {}\n\n'
.format(total_ssid_count))
print('Geräte gefunden: {}\n\n'
.format(total_device_count))
for (count, vendor) in descending_order:
print('{0:8}: {1}\n'.format(count, vendor))

BIN
cms275.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
cms300.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
cms350.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

45
install.sh Normal file
View File

@ -0,0 +1,45 @@
#!/bin/bash
########################################################
# Installation Script for CMS Plugin for Trackerjacker #
########################################################
# Check if root
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
# Update OS
apt-get update
apt-get dist-upgrade --yes
# Install Python3 and additional stuff
apt-get install python3-pip libopenjp2-7-dev python3-serial python3-pil --yes
# Remove old trackerjacker
pip3 uninstall -y trackerjacker
# Fix bug in current ubuntu
ln -s -f /usr/lib/arm-linux-gnueabihf/libc.a /usr/lib/arm-linux-gnueabihf/liblibc.a
# Get trackerjacker, add plugin and install it
cd /tmp
git clone https://github.com/calebmadrigal/trackerjacker.git
git clone https://git.chaospott.de/sirgoofy/wifi-printer.git
cp wifi-printer/cms.py trackerjacker/trackerjacker/plugins
cp wifi-printer/*.png trackerjacker/trackerjacker/plugins
pip3 install escpos
cd trackerjacker
python3 setup.py install
# Automatically start trackerjacker on startup
cp wifi-printer/trackerjacker.sh /etc/rc.local/
chmod +x /etc/rc.local/trackerjacker.sh
reboot

4
trackerjacker.sh Normal file
View File

@ -0,0 +1,4 @@
#!/bin/bash
# Run trackerjacker with cms plugin
trackerjacker -i wlan1 --trigger-plugin cms --track