Skip to content

Instantly share code, notes, and snippets.

View elbosso's full-sized avatar

Jürgen Key elbosso

View GitHub Profile
#!/bin/bash
ssid=$1
mac=$2
RAWPSK=$(pwgen -1Bv |tr '/' '$')
ENCODEDPSK=$(wpa_passphrase "${ssid}" "${RAWPSK}" |grep psk|tail -n 1|cut -d '=' -f 2)
echo $mac $ssid $RAWPSK $ENCODEDPSK
# Generate QR code pictures for Android and Windows
qrencode -t PNG -o /tmp/android_${mac}.png -s 4 "WIFI:T:WPA;S:${ssid};P:${RAWPSK};H:${hidden};"
./terminalqr.py "WIFI:T:WPA;S:${ssid};P:${RAWPSK};H:${hidden};" >/tmp/android_${mac}.txt
#!/usr/bin/python
import sys
import pyqrcode
program_name = sys.argv[0]
argument = sys.argv[1]
url = pyqrcode.create(argument)
print(url.terminal(quiet_zone=1))
#!/bin/bash
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Generate new wlan password and safe it. Don't use special chars to make it simpler
WLANPSK=$(pwgen -1Bv |tr '/' '$')
interface=wlp2s0_0
dhcp-range=172.16.15.2,172.16.15.250,255.255.255.0,12h
dhcp-option=3,172.16.15.1
dhcp-option=6,172.16.15.1
server=192.168.10.1
log-queries
log-dhcp
listen-address=127.0.0.1
# Specify the default route
dhcp-option=3,172.16.15.1
interface=wlp2s0
dhcp-range=10.10.10.2,10.10.10.250,255.255.255.0,12h
dhcp-option=3,10.10.10.1
dhcp-option=6,10.10.10.1
server=192.168.10.1
log-queries
log-dhcp
listen-address=127.0.0.1
# Specify the default route
dhcp-option=3,10.10.10.1
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto wlp2s0
iface wlp2s0 inet static
address 10.10.10.1
netmask 255.255.255.0
interface=wlp2s0
bssid=02:16:3e:24:31:30
driver=nl80211
ssid=<the one SSID>
hw_mode=a
country_code=DE
ieee80211n=1
ieee80211d=1
#channel=6
macaddr_acl=0
apt-get update && apt-get -y upgrade && apt-get -y autoremove
apt-get -y install wireless-tools joe iptables dnsmasq hostapd iw wpa-supplicant pwgen qrencode python-qrcode python-pip
pip install pyqrcode
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface wlp2s0 -j ACCEPT
iptables --append FORWARD --in-interface wlp2s0_0 -j ACCEPT
TERM="vt102"
apt-get -y install iptables-persistent
apt-get clean
# Network configuration
lxc.network.type = phys
lxc.network.link = wlp2s0
lxc.network.flags = up
# Set first Byte to 02 and the last nibble to 0 - makes it possible to have more than 1 ssids on one adapter!
lxc.network.hwaddr = 02:16:3e:24:31:30
lxc.network.type = veth
lxc.network.link = br0
lxc.network.flags = up
@elbosso
elbosso / AnnotationIntrospector.java
Created January 3, 2018 15:39
This is a helper class that produces a BeanInfo instance for a given JavaBean - given it is provisioned with special annotations (for example https://gist.github.com/elbosso/72ae18205214675b2ab5c0795b7a7e57). The beauty here is that one does not need to have an actual BeanInfo class cluttering up ones class path - the magic happens at runtime. P…
package de.elbosso.scratch.util.lang.annotations;
//This is by no means production-ready code!
/*Copyright (c) 2012-2018.
Juergen Key. Alle Rechte vorbehalten.
Weiterverbreitung und Verwendung in nichtkompilierter oder kompilierter Form,
mit oder ohne Veraenderung, sind unter den folgenden Bedingungen zulaessig:
1. Weiterverbreitete nichtkompilierte Exemplare muessen das obige Copyright,
die Liste der Bedingungen und den folgenden Haftungsausschluss im Quelltext
enthalten.