Du bist hier:Start»CyanogenMod»Fortgeschrittene

Opensource Apps und Einstellungen für Fortgeschrittene

24.10.2014

WLAN mit speziellem DNS-Server einschalten

Nachdem die Firewall AFWall+ konfiguriert wurde, kann jetzt das WLAN eingeschaltet werden. Zur Auflösung von Computernamen (DNS) habe ich die IP-Adresse des Vereins Digitalcourage genommen (85.214.20.141). Dadurch kann die Privatsphäre auf dem Smartphone ein wenig erhöht werden. Bei den Firewall-Regeln weiter unten im Text lasse ich dann diese IP-Adresse durch die Firewall hindurch.

  • Einstellungen von CyanogenMod starten
  • auf WLAN tippen
  • WLAN-Schieber auf "an" nach rechts ziehen
  • WLAN-Verbindung auswählen
  • Passwort eingeben und verbinden lassen
  • jetzt auf die verbundene WLAN-Verbindung tippen und gedrückt halten
  • Netzwerk ändern
  • Erweiterte Optionen einblenden und nach unten scrollen
  • IP-Einstellungen - statisch
  • DNS 1: 85.214.20.141 (das ist die DNS-IP-Adresse des Vereins Digitalcourage)
  • DNS 2: 1.1.1.1 (irgendeine IP-Adresse)

Debian-Kit installieren

Das Debian-Kit ist eher für Entwickler und Linux-Liebhaber geeignet und für den Normalgebrauch nicht notwendig. Es bietet ein echtes GNU/Linux statt des verkrüppelten Androids und kann parallel zu Android beziehungsweise CyanogenMod laufen. Dass die IP-Adresse 85.214.20.141 als DNS 1 im WLAN (siehe oben) für die Namensauflösung explizit eingetragen wurde hat einen Grund. Diese IP-Adresse wird jetzt für die Installation des Debian-Kits in der Firewall explizit eingetragen, damit Datenpakete zur Namensauflösung durchgelassen werden. Die folgenden Kommandozeilen können auf einem Linux-Laptop ausgeführt werden. An dem Laptop muss das Smartphone per USB angeschlossen sein. Die Android Debug Bridge sollte bereits installiert oder in der Pfad-Variablen eingetragen sein.

ACHTUNG ! Die Anleitung funktioniert nicht mehr, da der Server von Sven-Ola Tücke nicht mehr verfügbar ist. Alternativ gibt es eine App fürs Debian-Kit.

# run the following commands from the command line on a Linux laptop with USB-attached smartphone

mkdir -p ~/cyanogenmod/apps
cd ~/cyanogenmod/apps

# the following steps are necessary to allow the download
# of debian kit when the firewall is closed
get_ip_address () {
  nslookup "$1" 85.214.20.141 | grep -i "^address" | tail -n 1 | sed 's|^[aA]ddress[^:]*:[^0-9]*\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*|\1|g'
}
allow_ip_address () {
  if [[ "$ip" =~ ^([0-9]{1,3})[.]([0-9]{1,3})[.]([0-9]{1,3})[.]([0-9]{1,3})$ ]];then
    allowed_ip="$1"
  else
    allowed_ip=$(get_ip "$1")
  fi

  echo "Allowed IP address: $allowed_ip"
  adb shell "/system/bin/iptables -I OUTPUT -m iprange --dst-range $allowed_ip-$allowed_ip -j ACCEPT"
}
adb root
sleep 1
allow_ip_address 85.214.20.141
allow_ip_address sven-ola.dyndns.org
allow_ip_address ftp.de.debian.org
allow_ip_address security.debian.org

# download the debian kit installer
wget debian-kit-1-5.shar
chmod 755 debian-kit-1-5.shar
adb push debian-kit-1-5.shar /data/local

adb shell "mkdir /data/local/deb"

# extract the debian kit
adb shell "/data/local/debian-kit-1-5.shar /data/local/deb"

# create 1 GB debian image on the internal sdcard
# and use a special DNS server
adb shell "/data/local/deb/mk-debian -d squeeze -s 1024 -D 85.214.20.141"

Mit der Option "mk-debian -i" könnte zusätzlich der Dateiname eingestellt werden, in dem das Debian-Image gespeichert werden soll. Auf dem internen Speicher sollt aber 1 GB Platz sein. Jetzt kann das Debian-Image über den Befehl "deb" gemountet beziehungsweise geöffnet und per "deb u" ungemountet beziehungsweise geschlossen werden.

# run the following commands on the smartphone

# on the smartphone in a terminal you can now use
deb
# the first run of deb is going to start the second installation stage

# and to unmount debian
deb u

# mount debian again
deb

# inside debian you can update the package index
apt-get update

# to install a package (software) use apt-get install e.g.
apt-get install tcpdump

cryptsetup zur Verschlüsselung installieren

Zum Verschlüsseln und Entschlüsseln von Container-Dateien gibt es das Programm cryptsetup. Leider läßt sich cryptsetup durch die Bionic lib von Google nicht so einfach für Android bzw. CyanogenMod compilieren. Mit einigen kleinen Veränderungen konnte ich aus dem Quellcode des Guardian-Projekts cryptsetup bauen:
https://github.com/guardianproject/LUKS/tree/master/external

Wenn du meinem compilierten Programm traust, kannst du es von meiner Webseite herunterladen. Ansonsten mußt du cryptsetup selbst aus dem Quellcode compilieren oder aus dem Debian-Kit kopieren.

# download cryptsetup for cyanogenmod 10
wget https://www.torsten-traenkner.de/cyanogenmod/apps/cryptsetup

sha1sum cryptsetup
# should be 3db06da1c4248f8770b9d7a554c4629c0589137e

chmod 755 cryptsetup

# install cryptsetup in cyanogenmod
adb root
sleep 1
adb shell "mount -o remount,rw /system"
adb push cryptsetup /system/xbin/
adb shell "mount -o remount,ro /system"

Anlegen eines verschlüsselten Containers mit Cryptsetup. "sdcard1" muss dabei mit dem tatsächlichen Pfad der SD-Karte ersetzt werden:

# create an empty container on your sdcard (1 GB)
dd if=/dev/zero of=/storage/sdcard1/container.txt bs=1000000 count=1000

# replace /storage/sdcard1 with your mount path

losetup /dev/block/loop0 /storage/sdcard1/container.txt

# set a passphrase for the container
cryptsetup luksFormat /dev/block/loop0

# type YES and enter the passphrase twice


# open the container
cryptsetup luksOpen /dev/block/loop0 decrypted

# output:
# key slot 0 unlocked.
# Command successful.

# create an ext4 file system inside the encrypted container
make_ext4fs -L partition_label /dev/mapper/decrypted

# create a mount directory:
mkdir /data/media/0/mnt/

# mount the directory:
busybox mount /dev/mapper/decrypted /data/media/0/mnt/

# close everything:
umount /data/media/0/mnt/
cryptsetup luksClose decrypted
losetup -d /dev/block/loop0


# mount again:
losetup /dev/block/loop0 /storage/sdcard1/container.txt
cryptsetup luksOpen /dev/block/loop0 decrypted
busybox mount /dev/mapper/decrypted /data/media/0/mnt/

# put the last steps into a script for comfortable usage

Bash als Default Shell von adb einstellen

Die Bourne Again Shell (bash) ist etwas komfortabler als die Standard-Shell der Android Debug Bridge (adb). Diese Einstellung ist eher für Entwickler interessant.

# run the following commands from the command line on a Linux laptop

# make bash the default shell for adb
adb root
sleep 1

adb shell "mount -o remount,rw /system"
adb shell "ln -s /system/xbin/bash /system/bin/si"
adb shell "mount -o remount,ro /system"

adb shell "mkdir -p /data/local/userinit.d/"
adb shell "echo \"mount -o remount,rw /\" > /data/local/userinit.d/10_restart_adbd_with_bash"
adb shell "echo \"stop adbd\" >> /data/local/userinit.d/10_restart_adbd_with_bash"
adb shell "echo \"sed -i 's|/system/bin/sh|/system/bin/si|g' /sbin/adbd\" >> /data/local/userinit.d/10_restart_adbd_with_bash"
adb shell "echo \"mount -o remount,ro /\" >> /data/local/userinit.d/10_restart_adbd_with_bash"
adb shell "echo \"start adbd\" >> /data/local/userinit.d/10_restart_adbd_with_bash"
adb shell "chmod 755 /data/local/userinit.d/10_restart_adbd_with_bash"

# restart patched adbd
adb shell "/data/local/userinit.d/10_restart_adbd_with_bash &"

# now bash is the default shell for adb
adb shell

Viel Spaß beim Ausprobieren der Programme und beim Experimentieren !
Falls noch etwas unklar sein sollte, dann kannst du die Kommentar-Funktion benutzen.

Kommentar schreiben

Ihre Daten werden verschlüsselt übertragen. Der Kommentar wird gelesen und eventuell veröffentlicht.
Wenn der Inhalt des Kommentars oder Teile des Kommentars nicht veröffentlicht werden, dann werden die gespeicherten Daten nach maximal 4 Wochen gelöscht. Um zukünftigen Missbrauch der Kommentarfunktion zu verhindern, werden die zum Kommentar gehörenden IP Adressen maximal 4 Wochen gespeichert.