From f0b78d589301e28d3956ff9a82f7f0a63243bf88 Mon Sep 17 00:00:00 2001 From: Tobias Kessels Date: Wed, 10 Jan 2018 19:51:24 +0100 Subject: [PATCH] added some files at home commands are a few command notes fritzshark2?.sh are scripts to dump fritzbox traffic to wireshark mount_container is my crypsetup automount skript --- commands | 9 +++ fritzshark.sh | 32 +++++++++++ fritzshark2.sh | 30 ++++++++++ mount_container | 143 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 214 insertions(+) create mode 100755 commands create mode 100755 fritzshark.sh create mode 100755 fritzshark2.sh create mode 100755 mount_container diff --git a/commands b/commands new file mode 100755 index 0000000..90ed59b --- /dev/null +++ b/commands @@ -0,0 +1,9 @@ +#!/bin/cat +#uniq without sorting: +awk '{a[$0]+=1; if (a[$0]<2)print}' +#send my mic to remote +arecord -f cd -t raw | oggenc - -r | ssh mplayer - +#and reverse +ssh @ 'arecord -f cd -t raw | oggenc - -r' | mplayer - + + diff --git a/fritzshark.sh b/fritzshark.sh new file mode 100755 index 0000000..745af71 --- /dev/null +++ b/fritzshark.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Stolen from Hippie2000 and modified by Jackfritt ;) +# Stolen from Jackfritt and modified by Chaosmaster :-P +ipddr="fritz.box" +unset dumpfile +unset passwd +if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ ! $1 ]; then + echo "Usage: $0 [] []" + exit 1 +fi + +[ $1 ] && passwd=$1 +[ $2 ] && dumpfile="-w $2" +[ $3 ] && ipaddr=$3 + +# Challenge abholen +ChallengeXML=`wget -O - "http://$ipddr/cgi-bin/webcm?getpage=../html/login_sid.xml" 2>/dev/null| grep Challenge` +Challenge=`echo $ChallengeXML | awk '{match($0,/>[^<>]+/dev/null| grep "name=\"sid\"" | head -1 | awk '{match($0,/value="[^"]+"/); print substr($0,RSTART+7,RLENGTH-8)}'` + +# Internet Capture +wget -O - "http://$ipddr/cgi-bin/capture_notimeout?ifaceorminor=3-17 \ +&snaplen=1600&capture=Start&sid=$SID" 2>/dev/null | \ +wireshark -k $dumpfile -i - diff --git a/fritzshark2.sh b/fritzshark2.sh new file mode 100755 index 0000000..119ea6b --- /dev/null +++ b/fritzshark2.sh @@ -0,0 +1,30 @@ +#!/bin/sh +IP="fritz.box" +echo -n Password: +read -s Passwd + +# Challenge abholen +Challenge=`wget -O - "http://$IP/login_sid.lua" 2>/dev/null | sed 's/.*\(.*\)<\/Challenge>.*/\1/'` + +# login aufbauen und hashen +CPSTR="$Challenge-$Passwd" +MD5=`echo -n $CPSTR | iconv -f ISO8859-1 -t UTF-16LE | md5sum -b | awk '{print substr($0,1,32)}'` +RESPONSE="$Challenge-$MD5" +POSTDATA="?username=&response=$RESPONSE" + +# login senden und SID herausfischen +SID=`wget -O - --post-data="$POSTDATA" "http://$IP/login_sid.lua" 2>/dev/null | sed 's/.*\(.*\)<\/SID>.*/\1/'` + +# Internet Capture +#Schnittstelle 1(Internet)=3-17 +#wget -O - "http://$IP/cgi-bin/capture_notimeout?ifaceorminor=3-17 \ +#alle Schnittstellen =3-0 +#wget -O - "http://$IP/cgi-bin/capture_notimeout?ifaceorminor=3-0 \ +#&snaplen=1600&capture=Start&sid=$SID" 2>/dev/null | \ +#tshark -i - -S -l -N nmtC +#wget -O - "http://$IP/cgi-bin/capture_notimeout?ifaceorminor=3-0 \ +#Externe Schnittstelle +#wget -O - "http://$IP/cgi-bin/capture_notimeout?ifaceorminor=3-17 \ +#Lokal LAN +#wget -O - "http://$IP/cgi-bin/capture_notimeout?ifaceorminor=1-eth0&snaplen=1600&capture=Start&sid=$SID" 2>/dev/null | tshark -i - -S -l -N nmtC +wget -O - "http://$IP/cgi-bin/capture_notimeout?ifaceorminor=1-eth0&snaplen=1600&capture=Start&sid=$SID" 2>/dev/null | tcpdump -r - -w /tmp/trace -W 48 -G 1800 -C 100 -K -n diff --git a/mount_container b/mount_container new file mode 100755 index 0000000..64b2924 --- /dev/null +++ b/mount_container @@ -0,0 +1,143 @@ +#!/bin/bash +## Functions +#find containers +containers="" +commands="" + +function read_containers(){ + containers=$( + [ -e ~/.containers ] && cat ~/.containers 2>/dev/null + find /media/${USER} -maxdepth 2 -iname ".containers" | while read line ; do + cat $line | awk -F';' -v path="$(dirname $line)" '{OFS=";" ; print $1,path"/"$2}' + done) +} + +function mount_container(){ + container_line=$* + name=$(echo $container_line | cut -f1 -d';') + path=$(echo $container_line | cut -f2 -d';') + mount_point="/mnt/${name}" + + #mount only if containerfile is valid + if [ -e ${path} ] && cryptsetup isLuks "${path}" ; then + #if mountpoint is not there create it + [ ! -e ${mount_point} ] && sudo mkdir -p "${mount_point}" && sudo chmod 777 "${mount_point}" + #open luks Container + sudo cryptsetup luksOpen "${path}" "${name}" + #mount Container + sudo mount "/dev/mapper/${name}" "${mount_point}" + else + echo "Container ${path} not found" && continue + fi +} + +function unmount_container(){ + container_line=$* + name=$(echo $container_line | cut -f1 -d';') + path=$(echo $container_line | cut -f2 -d';') + mount_point="/mnt/${name}" + + #unmount only if mounted + if ( mount | grep -q "${mount_point}" ) ; then + #if still in use + if [[ $( lsof "${mount_point}" | wc -l ) -gt 0 ]] ; then + echo "Mountpoint ${mount_point} is still in use:" + lsof "${mount_point}" + continue + else + sudo umount -l "${mount_point}" + sudo rmdir "${mount_point}" + fi + + sudo cryptsetup luksClose "${name}" + fi +} + +function is_open(){ + container_path="${1}" + ls -b /dev/mapper/ | xargs -n1 sudo cryptsetup status | grep loop: | grep -q "${container_path}" + return $? +} + +function is_mounted(){ + mount_point="${1}" + mount | grep -q "${mount_point}" + return $? +} + +function is_used(){ + mount_point="${1}" + lsof ${mount_point} 2>/dev/null 1>&2 + return $? +} + +function is_mounted_container(){ + container_line=$* + name=$(echo $container_line | cut -f1 -d';') + path=$(echo $container_line | cut -f2 -d';') + mount_point="/mnt/${name}" + result=0 + mount | grep -q "${mount_point}" && (( result+=1 )) + sudo cryptsetup status ${name} | grep -q "${path}" && (( result+=2 )) + echo $result + return $result +} + +#mount all containers +function mount_all(){ + read_containers + for line in $containers ; do + mount_container $line + done +} + +#unmount all containers +function unmount_all(){ + read_containers + for line in $containers ; do + unmount_container $line + done +} + +#print status +function print_status(){ + container_line=$* + name=$(echo $container_line | cut -f1 -d';') + path=$(echo $container_line | cut -f2 -d';') + mount_point="/mnt/${name}" + echo "Stats for $name : $path" + is_open ${path} && echo "IS OPENED" + is_mounted ${mount_point} && echo "IS MOUNTED" + is_used ${mount_point} && echo "IS IN USE" +} + +#print status +function print_status_all(){ + read_containers + for line in $containers ; do + print_status $line + done + +} + +##main + +command="show" +[[ $# -eq 1 ]] && command="${1}" +echo "Command: ${command}" + +case $command in + mount) + mount_all + ;; + unmount) + unmount_all + ;; + list) + print_status_all + ;; + *) + read_containers + echo $containers + ;; +esac