Support for Junghackerpass

This commit is contained in:
Bandie 2020-06-01 17:02:43 +02:00
commit d7c7c76e07
Signed by: Bandie
GPG Key ID: 843D7FA93BA46312
12 changed files with 742 additions and 0 deletions

6
README.md Normal file
View File

@ -0,0 +1,6 @@
# Galactic Registration Office
Fill out your hacker passport using a professional dot matrix printer.
## Supported Passports
The following passports are supported atm:
- CmS Junghackerpass

43
include/nixdorf Executable file
View File

@ -0,0 +1,43 @@
#!/bin/bash
DEVICE=/dev/ttyUSB0
function init() {
stty -F $DEVICE 1:0:80000dbd:0:3:1c:7f:15:4:5:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
# \x1b\x47 - Double Strike
# \x1b\x78\x01 - Standard Letter Mode
# \x1b\x52\x02 - German
printf "\x1b\x47\x1b\x78\x01\x1b\x52\x02" >> "$DEVICE"
}
function printFile() {
# Replace charset stuff
sed -i 's/╔/\xc9/g;s/═/\xcd/g;s/╗/\xbb/g;s/║/\xba/g;s/╚/\xc8/g;s/╝/\xbc/g;s/§/\x40/g;s/Ä/\x5b/g;s/Ö/\x5c/g;s/Ü/\x5d/g;s/ä/\x7b/g;s/ö/\x7c/g;s/ü/\x7d/g;s/ß/\x7e/g' "$1"
# Eject
printf "\x0c" >> "$1"
# Print
cat $1 >> "$DEVICE"
}
function resetLetters() {
printf "\x12\x14\x1b\x35" >> "$1"
}
function bigLetters() {
resetLetters "$1"
printf "\x0e" >> "$1"
}
function smallLetters() {
resetLetters "$1"
printf "\x0f" >> "$1"
}
function italicLetters() {
printf "\x1b\x34" >> "$1"
}
init
resetLetters $DEVICE

59
jhp/JunghackerPass Executable file
View File

@ -0,0 +1,59 @@
#!/bin/bash
FILE=/tmp/$RANDOM
TOP=7
LEFT=2
MAXLENGTH=25
GIVENNAME=$1
SURNAME=$2
HOME=$3
function makeNewline() {
for((i=0; i<$1; i++)); do
printf "\n" >> $FILE
done
}
function makeLeft() {
for((i=0; i<$LEFT; i++)); do
printf " " >> $FILE
done
}
if [ ${#GIVENNAME} -gt $MAXLENGTH ] || [ ${#SURNAME} -gt $MAXLENGTH ] || [ ${#HOME} -gt $MAXLENGTH ]; then
echo "MAXLENGTH EXCEEDED."
exit 1
fi
source ../include/nixdorf
init
makeNewline $TOP
makeLeft
printf "$GIVENNAME" >> $FILE
makeNewline 4
makeLeft
printf "$SURNAME" >> $FILE
makeNewline 3
makeLeft
printf "$HOME" >> $FILE
makeNewline 3
makeLeft
if [ -n "$EVENT" ]; then
printf "$EVENT, $(date -I)" >> $FILE
else
printf "$(date -I)" >> $FILE
fi
makeNewline 1
makeLeft
printf "Galactic Registr. Office" >> $FILE
printFile $FILE
rm $FILE

146
jhp/gpgkey Executable file
View File

@ -0,0 +1,146 @@
#!/bin/bash
FILE=/tmp/$RANDOM
TOP=0
LEFT=3
# Additional heading space
HEADINGNEXTPAGE=28
HEADINGLEFT=1
HEADINGRIGHT=15
# GPG Space
NEXTPAGE=48
NEXTFIELDBOTTOM=7
NEXTFIELDRIGHT=25
MAXLENGTH=22
if [ $# -eq 0 ]; then
echo -e "$0: Syntax:\n$0 FIELD GPG FINGERPRINT WITH SPACES\n\nExample:\n$0 7 1234 5678 1234 1234 1234 1234 1234 1234 1234 ABCD\n\n\nFields:
==================
| 0 | 1 || 6 | 7 |
|---|---||---|---|
| 2 | 3 || 8 | 9 |
|---|---||---|---|
| 4 | 5 || 10| 11|
==================
"
exit 1
fi
PAGE=$(($1 / 6))
FIELD=$(($1 % 6))
shift 1
echo "PAGE: $PAGE, FIELD: $FIELD"
function moveDown() {
for((i=0; i<$(($FIELD / 2)); i++)); do
for((j=0; j<$NEXTFIELDBOTTOM; j++)); do
printf "\n" >> $FILE
done
done
}
function makeNewline() {
for((i=0; i<$1; i++)); do
printf "\n" >> $FILE
done
}
function makeLeft() {
for((i=0; i<$1; i++)); do
printf " " >> $FILE
done
}
function heading() {
moveDown
if [ $(($FIELD % 2)) -eq 0 ]; then
SPACE=$HEADINGLEFT
else
SPACE=$HEADINGRIGHT
fi
if [ $PAGE -eq 1 ]; then
makeLeft $HEADINGNEXTPAGE
fi
makeLeft $LEFT
makeLeft $SPACE
bigLetters $FILE
printf "GPG" >> $FILE
resetLetters $FILE
printf "\n" >> $FILE
}
function insertFP() {
if [ $(($FIELD % 2 )) -eq 0 ]; then
SPACE=0
else
SPACE=$NEXTFIELDRIGHT
fi
smallLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGE
fi
makeLeft $LEFT
makeLeft $(($SPACE + 2))
printf "$1 $2 $3 $4" >> $FILE
resetLetters $FILE
printf "\n" >> $FILE
shift 4
smallLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGE
fi
makeLeft $LEFT
makeLeft $(($SPACE + 2))
printf "$1 $2 $3 $4" >> $FILE
resetLetters $FILE
printf "\n" >> $FILE
shift 4
smallLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGE
fi
makeLeft $LEFT
makeLeft $(($SPACE + 2))
printf "$1 $2" >> $FILE
resetLetters $FILE
printf "\n" >> $FILE
shift 2
smallLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGE
fi
makeLeft $LEFT
makeLeft $(($SPACE + 2))
if [ -n "$EVENT" ]; then
printf "$EVENT, $(date -I)" >> $FILE
else
printf "$(date -I)" >> $FILE
fi
}
source ../include/nixdorf
init
makeNewline $TOP
heading
insertFP $@
printFile $FILE
rm $FILE

137
jhp/gro Executable file
View File

@ -0,0 +1,137 @@
#!/bin/bash
FILE=/tmp/$RANDOM
TOP=0
LEFT=3
# Additional heading space
HEADINGNEXTPAGE=16
HEADINGLEFT=0
HEADINGRIGHT=8
# GPG Space
NEXTPAGE=30
NEXTPAGESMALL=48
NEXTFIELDBOTTOM=7
NEXTFIELDRIGHT=14
NEXTFIELDRIGHTSMALL=25
MAXLENGTH=22
if [ $# -eq 0 ]; then
echo -e "$0: Syntax:\n$0 FIELD\n\nExample:\n$0 7\n\n\nFields:
==================
| 0 | 1 || 6 | 7 |
|---|---||---|---|
| 2 | 3 || 8 | 9 |
|---|---||---|---|
| 4 | 5 || 10| 11|
==================
"
exit 1
fi
PAGE=$(($1 / 6))
FIELD=$(($1 % 6))
shift 1
echo "PAGE: $PAGE, FIELD: $FIELD"
function moveDown() {
for((i=0; i<$(($FIELD / 2)); i++)); do
for((j=0; j<$NEXTFIELDBOTTOM; j++)); do
printf "\n" >> $FILE
done
done
}
function makeNewline() {
for((i=0; i<$1; i++)); do
printf "\n" >> $FILE
done
}
function makeLeft() {
for((i=0; i<$1; i++)); do
printf " " >> $FILE
done
}
function heading() {
moveDown
if [ $(($FIELD % 2)) -eq 0 ]; then
HSPACE=$HEADINGLEFT
SPACE=0
else
HSPACE=$HEADINGRIGHT
SPACE=$NEXTFIELDRIGHT
fi
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGE
fi
makeLeft 1
makeLeft $SPACE
italicLetters $FILE
printf "GALACTIC\n" >> $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGE
fi
makeLeft 1
makeLeft $SPACE
printf "REGISTRATION\n" >> $FILE
bigLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $HEADINGNEXTPAGE
if [ $(($FIELD % 2)) -eq 1 ]; then
makeLeft $(($HSPACE - 1))
fi
else
if [ $(($FIELD % 2)) -eq 0 ]; then
makeLeft 1
fi
makeLeft $HSPACE
fi
printf "OFFICE\n" >> $FILE
resetLetters $FILE
}
function insertDate() {
if [ $(($FIELD % 2 )) -eq 0 ]; then
SPACE=0
else
SPACE=$NEXTFIELDRIGHTSMALL
fi
smallLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGESMALL
fi
makeLeft $LEFT
makeLeft $(($SPACE + 2))
if [ -n "$EVENT" ]; then
printf "$EVENT, $(date -I)" >> $FILE
else
printf "$(date -I)" >> $FILE
fi
}
source ../include/nixdorf
init
makeNewline $TOP
heading
insertDate
printFile $FILE
rm $FILE

30
jhp/msg5 Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
FILE=/tmp/$RANDOM
source ../include/nixdorf
init
echo "1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1" > $FILE
printFile $FILE
rm $FILE

1
jhp/test Normal file
View File

@ -0,0 +1 @@
./JunghackerPass "Foobert" "van Barbert" "Erde / Earth" "37C3, $(date -I)"

243
start Executable file
View File

@ -0,0 +1,243 @@
#!/bin/bash
export EVENT=37C3
TMP=/tmp/$RANDOM
BT="Galactic Registration Office - v0.1"
function diaBox() {
h=8
w=60
if [ -n "$3" ]; then
h=$3
fi
if [ -n "$4" ]; then
w=$4
fi
dialog --title "$1" \
--backtitle "$BT" \
--msgbox "$2" $h $w
}
function ynBox() {
h=8
w=60
if [ -n "$3" ]; then
h=$3
fi
if [ -n "$4" ]; then
w=$4
fi
dialog --title "$1" \
--backtitle "$BT" \
--yesno "$2" $h $w
return $?
}
function askStr() {
h=12
w=60
if [ -n "$5" ]; then
h=$5
fi
if [ -n "$6" ]; then
w=$6
fi
dialog --title "$2" \
--backtitle "$BT" \
--max-input $1 \
--inputbox "$3" $h $w "$4" 2> $TMP
return $?
}
function confirm() {
h=12
w=60
if [ -n "$3" ]; then
h=$3
fi
if [ -n "$4" ]; then
w=$4
fi
dialog --title "Confirm: $1" \
--backtitle "$BT" \
--yesno "Please confirm those information:\n$2" $h $w
return $?
}
function jhpAskForField() {
text="Please choose a free field on the passport.\n
------------------\n
| Archievements |\n
==================\n
| 0 | 1 || 6 | 7 |\n
|---|---||---|---|\n
| 2 | 3 || 8 | 9 |\n
|---|---||---|---|\n
| 4 | 5 || 10| 11|\n
==================\n
"
askStr 2 "Select a field" "$text" "" 18
if [ $? -eq 1 ]; then
return 1
fi
FIELD=$(cat $TMP)
if ! [[ "$FIELD" =~ ^[0-9]+$ ]] || [ -z "$FIELD" ] || [ $FIELD -lt 0 ] || [ $FIELD -gt 11 ]; then
jhpAskForField
else
return 0
fi
}
function jhpPrintGPG() {
jhpAskForField
if [ $? -eq 0 ]; then
diaBox "Insert Passport" "Please insert passport (Archivements) into the printer."
cd jhp
./gpgkey $FIELD $FP
cd ..
return 0
else
return 1
fi
}
function jhpPrintReg() {
diaBox "Insert Passport" "Please insert passport (First page, name, planet, date) into the printer."
cd jhp
./JunghackerPass "$FNAME" "$SNAME" "$PLANET"
cd ..
return 0
}
function jhpGROStamp() {
jhpAskForField
if [ $? -eq 0 ]; then
diaBox "Insert Passport" "Please insert passport (Archivements) into the printer."
cd jhp
./gro $FIELD
cd ..
return 0
else
return 1
fi
}
function jhpGPG() {
askStr 49 "GPG Fingerprint" "Enter GPG fingerprint WITH SPACES. E.g.:\n 1234 5678 9ABC DEF0 1234 5678 9ABC DEF0 1234 5678"
if [ $? -eq 0 ]; then
FP=$(cat $TMP)
rm $TMP
if ! [[ $FP =~ ^([[:xdigit:]]{4} ){9}[[:xdigit:]]{4}$ ]]; then
diaBox "GPG Fingerprint" "This does not match the RegEx of a GPG fingerprint.\nPlease type in the whole fingerprint."
jhpGPG
fi
FP=$(echo "$FP" | tr [a-f] [A-F])
else
return 1
fi
if [ "$1" == "no-confirm" ]; then
return 0
else
confirm "GPG Fingerprint" " GPG:\n $FP"
return $?
fi
}
function jhpReg() {
askStr 25 "Forename/Nickname" "Enter forename/nickname"
if [ $? -eq 1 ]; then
return 1
fi
FNAME=$(cat $TMP)
askStr 25 "Surename" "Enter surename"
if [ $? -eq 1 ]; then
return 1
fi
SNAME=$(cat $TMP)
askStr 25 "Planet" "Enter planet" "Earth, Chaospott"
if [ $? -eq 1 ]; then
return 1
fi
PLANET=$(cat $TMP)
confirm=" Forename: $FNAME\n Surename: $SNAME\n Planet: $PLANET"
ynBox "GPG" "Does the being have a GPG key to register?"
if [ $? -eq 0 ]; then
jhpGPG no-confirm
if [ $? -eq 0 ]; then
confirm="$confirm\n GPG:\n $FP"
fi
fi
confirm "Everything" "$confirm"
return $?
}
function jhpmenu() {
dialog --backtitle "$BT" \
--menu "Select ID type:" 14 40 3 \
1 "Registration" \
2 "GPG" \
3 "GRO Stamp" \
9 "Back" 2> $TMP
choice=$(cat $TMP)
case $choice in
1) jhpReg
if [ $? -eq 0 ]; then
jhpPrintReg
if [ -n "$FP" ]; then
jhpPrintGPG
fi
fi
;;
2) jhpGPG
if [ $? -eq 0 ]; then
jhpPrintGPG
fi
;;
3) jhpGROStamp
esac
unset FNAME
unset SNAME
unset PLANET
unset FP
unset FIELD
}
while [ true ]; do
dialog --backtitle "$BT" \
--menu "Select ID type:" 10 40 3 \
1 "Junghackerpass" \
2 "Usual" 2> $TMP
if [ $? -eq 1 ]; then
break
fi
TYPE=$(cat $TMP)
case $TYPE in
1) jhpmenu
;;
2) exit 0
;;
esac
done
rm $TMP
clear

34
test/msg Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
./wincor
TEMP=/tmp/$RANDOM
printf "\t\t\t\t╔═════════════════════╗\n" | sed 's/╔/\xc9/g;s/═/\xcd/g;s/╗/\xbb/g;s/║/\xba/g;s/╚/\xc8/g;s/╝/\xbc/g' >> $TEMP
printf "\t\t\t\t║ SECRET DOCUMENT ║\n" | sed 's/╔/\xc9/g;s/═/\xcd/g;s/╗/\xbb/g;s/║/\xba/g;s/╚/\xc8/g;s/╝/\xbc/g' >> $TEMP
printf "\t\t\t\t╚═════════════════════╝\n" | sed 's/╔/\xc9/g;s/═/\xcd/g;s/╗/\xbb/g;s/║/\xba/g;s/╚/\xc8/g;s/╝/\xbc/g' >> $TEMP
printf "
\tThe following information you see below are classified as \n\t\t\t\t\xeTOP SECRET\xf.\n\n\n" >> $TEMP
printf "\t%s\n" "$(cat /dev/urandom | tr -dc 'A-Za-z0-9 ' | head -c115)" >> $TEMP
printf "\t%s\n" "$(cat /dev/urandom | tr -dc 'A-Za-z0-9 ' | head -c115)" >> $TEMP
printf "\t%s\n" "$(cat /dev/urandom | tr -dc 'A-Za-z0-9 ' | head -c115)" >> $TEMP
printf "\t%s\n" "$(cat /dev/urandom | tr -dc 'A-Za-z0-9 ' | head -c115)" >> $TEMP
printf "\t%s\n" "$(cat /dev/urandom | tr -dc 'A-Za-z0-9 ' | head -c115)" >> $TEMP
printf "\t%s\n" "$(cat /dev/urandom | tr -dc 'A-Za-z0-9 ' | head -c115)" >> $TEMP
printf "\t%s\n" "$(cat /dev/urandom | tr -dc 'A-Za-z0-9 ' | head -c115)" >> $TEMP
printf "\t%s\n" "$(cat /dev/urandom | tr -dc 'A-Za-z0-9 ' | head -c115)" >> $TEMP
printf "\t%s\n" "$(cat /dev/urandom | tr -dc 'A-Za-z0-9 ' | head -c115)" >> $TEMP
printf "\t%s\n" "$(cat /dev/urandom | tr -dc 'A-Za-z0-9 ' | head -c115)" >> $TEMP
printf "\t%s\n" "$(cat /dev/urandom | tr -dc 'A-Za-z0-9 ' | head -c115)" >> $TEMP
printf "\t%s\n" "$(cat /dev/urandom | tr -dc 'A-Za-z0-9 ' | head -c115)" >> $TEMP
printf "\t%s\n" "$(cat /dev/urandom | tr -dc 'A-Za-z0-9 ' | head -c115)" >> $TEMP
printf "\xc" >> $TEMP
cat $TEMP >> /dev/ttyUSB0
rm $TEMP

11
test/msg2 Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
./wincor
#printf "\t12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n" >> /dev/ttyUSB0
#printf "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" >> /dev/ttyUSB0
printf "\n\n\n\n\n\t12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n" >> /dev/ttyUSB0
printf "\t x x x x x x x x x x x x x x\n" >> /dev/ttyUSB0
printf "\tt\tt\tt\tt\tt\tt\tt\tt\tt\tt\tt\tt\tt\tt\tt\tt\tt\tt\tt\tt\tt\tt" >> /dev/ttyUSB0
printf "\xc" >> /dev/ttyUSB0

20
test/msg3 Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
./wincor
TEMP=/tmp/$RANDOM
printf "
\x1b\x78\x01
\x1b\x52\x02
\x0fx\x1b\x53\x01asdf\x1b\x54 = x\x1b\x53\x00asdf\x1b\x54\x12
\x5b\x5c\x5d\x7b\x7c\x7d\x7e
" >> $TEMP
printf "\xc" >> $TEMP
cat $TEMP >> /dev/ttyUSB0
rm $TEMP

12
test/msg4 Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
source ./wincor
TEMP=/tmp/$RANDOM
init
printf "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" >> $TEMP
#bigLetters $TEMP
#printf "123456789012345678901234567890123456789012345678901234567890" >> $TEMP
printf " 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" >> $TEMP
printFile $TEMP
rm $TEMP