Compare commits

...

21 Commits

Author SHA1 Message Date
e2151345d7 Typo: C3Reg-> c3Reg 2021-01-10 16:39:06 +01:00
8dbc8c6605 C3Reg-Renaming; adding devtal's passport 2021-01-05 19:27:13 +01:00
e675a78b10 Document: Renaming to C3Reg 2021-01-05 18:59:43 +01:00
333d5c9e3c Fix: GPG-Search 2021-01-04 22:04:43 +01:00
7bb30f09f5 Check for empty string 2021-01-04 20:36:16 +01:00
36eb4564a3 Y42: Extract the GPG part to another form 2021-01-04 20:33:52 +01:00
4468db389f "Press enter" for first connect 2021-01-02 19:41:29 +01:00
414ff4a546 Documents and applications 2020-12-28 19:39:06 +01:00
f1b804d0ee dialog is not compatible with VT52, beginning to rewrite UI 2020-11-22 19:30:29 +01:00
cad7fb1649 Surename->Surname 2020-10-31 23:22:29 +01:00
1d71a42d3c dialog can now be black/white, lockfile, cheap password protection 2020-10-30 18:40:33 +01:00
4a637a9b39 Galactic -> Intergalactic 2020-06-14 14:12:45 +02:00
9599d9370c Want yours to be supported? 2020-06-14 14:11:34 +02:00
24979969b6 jhp: Intergal. Reg. Office 2020-06-13 21:39:15 +02:00
80e0d2ee9c GPG search (usage of keys.openpgp.org), deleting keys after getting FP, removing code duplication, corrected layout for jhp 2020-06-13 15:22:26 +02:00
dfd9cda104 Adafruit 2020-06-11 17:55:15 +02:00
d2a2c43386 Adafruit added 2020-06-11 17:54:10 +02:00
f98164f8e6 Missing FILE 2020-06-11 15:20:25 +02:00
822d58734c makeLeft and makeNewline put into include 2020-06-11 12:13:23 +02:00
da8dcc7222 ./gro -> ./iro 2020-06-03 19:23:36 +02:00
6c27e4ee9d GlacticRegistrationOffice -> IntergalacticRegistrationOffice 2020-06-02 19:42:09 +02:00
22 changed files with 1806 additions and 240 deletions

4
.pw/README.md Normal file
View File

@ -0,0 +1,4 @@
# IRO's insecure passwords
- Filename: username
- File's content: password, plain text!

View File

@ -1,10 +1,14 @@
# Galactic Registration Office
# c3Reg
Fill out your hacker passport using a professional dot matrix printer.
## Set event name
To set the event name, just change the `EVENT` variable in `./start` at the top.
## Supported Passports
The following passports are supported atm:
- CmS Junghackerpass
- Bound Diplomatic passport by Mitch Altman (TVBGone) Matthew Borgatti (har.ms)
- Stapled Diplomatic passport Mitch/Matthew and Nils-Arne Pohlandt (devtal.de)
## Set event name
To set the event name, just change the `EVENT` variable in `./start` at the top.
Do you want yours to be supported, too?
Talk to me and send me 3 example pieces. :)

108
bounddipl/c3reg Executable file
View File

@ -0,0 +1,108 @@
#!/bin/bash
FILE=/tmp/$RANDOM
TOP=1
LEFT=5
# Additional heading space
HEADINGNEXTPAGE=19
HEADINGLEFT=1
HEADINGRIGHT=10
# GPG Space
NEXTPAGE=34
NEXTPAGESMALL=60
NEXTFIELDBOTTOM=13
NEXTFIELDRIGHT=18
NEXTFIELDRIGHTSMALL=30
if [ $# -eq 0 ]; then
echo -e "$0: Syntax:\n$0 FIELD\n\nExample:\n$0 7\n\n\nFields:
==================
| VISAS || VISAS |
==================
| 0 | 1 || 4 | 5 |
|---|---||---|---|
| 2 | 3 || 6 | 7 |
==================
"
exit 1
fi
PAGE=$(($1 / 4))
FIELD=$(($1 % 4))
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 heading() {
moveDown
if [ $(($FIELD % 2)) -eq 0 ]; then
HSPACE=$HEADINGLEFT
SPACE=0
else
HSPACE=$HEADINGRIGHT
SPACE=$NEXTFIELDRIGHT
fi
bigLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $HEADINGNEXTPAGE $FILE
if [ $(($FIELD % 2)) -eq 1 ]; then
makeLeft $(($HSPACE - 1)) $FILE
fi
else
makeLeft 1 $FILE
makeLeft $HSPACE $FILE
fi
printf "c3Reg\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 $FILE
fi
makeLeft $LEFT $FILE
makeLeft $(($SPACE + 2)) $FILE
if [ -n "$EVENT" ]; then
printf "$EVENT, $(date -I)" >> $FILE
else
printf "$(date -I)" >> $FILE
fi
}
source ../include/nixdorf
init
makeNewline $TOP $FILE
heading
insertDate
printFile $FILE
rm $FILE

134
bounddipl/gpgkey Executable file
View File

@ -0,0 +1,134 @@
#!/bin/bash
FILE=/tmp/$RANDOM
TOP=1
LEFT=3
# Additional heading space
HEADINGNEXTPAGE=36
HEADINGLEFT=1
HEADINGRIGHT=20
# GPG Space
NEXTPAGE=62
NEXTFIELDBOTTOM=11
NEXTFIELDRIGHT=31
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:
==================
| VISAS || VISAS |
==================
| 0 | 1 || 4 | 5 |
|---|---||---|---|
| 2 | 3 || 6 | 7 |
==================
"
exit 1
fi
PAGE=$(($1 / 4))
FIELD=$(($1 % 4))
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 heading() {
moveDown
if [ $(($FIELD % 2)) -eq 0 ]; then
SPACE=$HEADINGLEFT
else
SPACE=$HEADINGRIGHT
fi
if [ $PAGE -eq 1 ]; then
makeLeft $HEADINGNEXTPAGE $FILE
fi
makeLeft $LEFT $FILE
makeLeft $SPACE $FILE
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 $FILE
fi
makeLeft $LEFT $FILE
makeLeft $(($SPACE + 2)) $FILE
printf "$1 $2 $3 $4" >> $FILE
resetLetters $FILE
printf "\n" >> $FILE
shift 4
smallLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGE $FILE
fi
makeLeft $LEFT $FILE
makeLeft $(($SPACE + 2)) $FILE
printf "$1 $2 $3 $4" >> $FILE
resetLetters $FILE
printf "\n" >> $FILE
shift 4
smallLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGE $FILE
fi
makeLeft $LEFT $FILE
makeLeft $(($SPACE + 2)) $FILE
printf "$1 $2" >> $FILE
resetLetters $FILE
printf "\n" >> $FILE
shift 2
smallLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGE $FILE
fi
makeLeft $LEFT $FILE
makeLeft $(($SPACE + 2)) $FILE
if [ -n "$EVENT" ]; then
printf "$EVENT, $(date -I)" >> $FILE
else
printf "$(date -I)" >> $FILE
fi
}
source ../include/nixdorf
init
makeNewline $TOP $FILE
heading
insertFP $@
printFile $FILE
rm $FILE

52
bounddipl/reg Executable file
View File

@ -0,0 +1,52 @@
#!/bin/bash
FILE=/tmp/$RANDOM
TOP=56
NEXTFIELD=5
LEFT=22
AUTHLEFT=66
DATELEFT=37
MAXLENGTH=17
GIVENNAME=$1
SURNAME=$2
HOME=$3
if [ ${#GIVENNAME} -gt $MAXLENGTH ] || [ ${#SURNAME} -gt $MAXLENGTH ] || [ ${#HOME} -gt $MAXLENGTH ]; then
echo "MAXLENGTH EXCEEDED."
exit 1
fi
source ../include/nixdorf
init
smallLetters $FILE
printf "\x1b\x33\x0e" >> $FILE
makeNewline $TOP $FILE
makeLeft $LEFT $FILE
printf "$GIVENNAME" >> $FILE
# Authority field
makeNewline 2 $FILE
makeLeft $AUTHLEFT $FILE
printf "C3Reg" >> $FILE
makeNewline 3 $FILE
makeLeft $LEFT $FILE
printf "$SURNAME" >> $FILE
makeNewline $NEXTFIELD $FILE
makeLeft $LEFT $FILE
printf "$HOME" >> $FILE
makeNewline 4 $FILE
makeLeft $DATELEFT $FILE
if [ -n "$EVENT" ]; then
printf "/ $EVENT, $(date -I)" >> $FILE
else
printf "/ $(date -I)" >> $FILE
fi
printFile $FILE
rm $FILE

144
dialogrc Normal file
View File

@ -0,0 +1,144 @@
#
# Run-time configuration file for dialog
#
# Automatically generated by "dialog --create-rc <file>"
#
#
# Types of values:
#
# Number - <number>
# String - "string"
# Boolean - <ON|OFF>
# Attribute - (foreground,background,highlight?,underline?,reverse?)
# Set aspect-ration.
aspect = 0
# Set separator (for multiple widgets output).
separate_widget = ""
# Set tab-length (for textbox tab-conversion).
tab_len = 0
# Make tab-traversal for checklist, etc., include the list.
visit_items = OFF
# Shadow dialog boxes? This also turns on color.
use_shadow = OFF
# Turn color support ON or OFF
use_colors = OFF
# Screen color
screen_color = (CYAN,BLUE,OFF)
# Shadow color
shadow_color = (BLACK,BLACK,ON)
# Dialog box color
dialog_color = (BLACK,WHITE,OFF)
# Dialog box title color
title_color = (BLUE,WHITE,OFF)
# Dialog box border color
border_color = (WHITE,WHITE,ON)
# Active button color
button_active_color = (WHITE,BLACK,ON)
# Inactive button color
button_inactive_color = dialog_color
# Active button key color
button_key_active_color = button_active_color
# Inactive button key color
button_key_inactive_color = (RED,WHITE,OFF)
# Active button label color
button_label_active_color = (YELLOW,BLUE,OFF)
# Inactive button label color
button_label_inactive_color = (BLACK,WHITE,ON)
# Input box color
inputbox_color = dialog_color
# Input box border color
inputbox_border_color = dialog_color
# Search box color
searchbox_color = dialog_color
# Search box title color
searchbox_title_color = title_color
# Search box border color
searchbox_border_color = border_color
# File position indicator color
position_indicator_color = title_color
# Menu box color
menubox_color = dialog_color
# Menu box border color
menubox_border_color = border_color
# Item color
item_color = dialog_color
# Selected item color
item_selected_color = button_active_color
# Tag color
tag_color = title_color
# Selected tag color
tag_selected_color = button_label_active_color
# Tag key color
tag_key_color = button_key_inactive_color
# Selected tag key color
tag_key_selected_color = (RED,BLUE,ON)
# Check box color
check_color = dialog_color
# Selected check box color
check_selected_color = button_active_color
# Up arrow color
uarrow_color = (GREEN,WHITE,ON)
# Down arrow color
darrow_color = uarrow_color
# Item help-text color
itemhelp_color = (WHITE,BLACK,OFF)
# Active form text color
form_active_text_color = button_active_color
# Form text color
form_text_color = (WHITE,CYAN,OFF)
# Readonly form item color
form_item_readonly_color = (CYAN,WHITE,OFF)
# Dialog box gauge color
gauge_color = title_color
# Dialog box border2 color
border2_color = dialog_color
# Input box border2 color
inputbox_border2_color = dialog_color
# Search box border2 color
searchbox_border2_color = dialog_color
# Menu box border2 color
menubox_border2_color = dialog_color

80
docs/A23.tex Normal file
View File

@ -0,0 +1,80 @@
\documentclass[11pt,a4paper]{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
left=20mm,
top=20mm,
}
\usepackage{pgf}
\pgfmathsetseed{\number\pdfrandomseed} % to ensure that it is randomized
% use \randomseed for xelatex
\newcommand{\randomnum}[1]{%
\pgfmathsetmacro{\thenum}{int(random(ceil(#1-#1/4),floor(#1+#1/4)))}%
\thenum%
}%
\newcommand{\answerbox}[1]{%%
\fbox{\rule{#1in}{0pt}\rule[-0.5ex]{0pt}{4ex}}}
\title{\textbf{Application Form A23}}
\author{c3Reg}
\date{Control no. \randomnum{1000}}
\addtolength{\topmargin}{-2cm}
\begin{document}
\maketitle
\thispagestyle{empty}
\section*{}
I hereby applicate for the registration of being a hacker.
\\
The passport document has been \ \ \ \answerbox{0.1} already issued in a blank state \ \ \ \answerbox{0.1} not yet issued
\section*{Personal data}
\
Forename/Nick (max. 17 characters)
\\
\answerbox{6.5}
\\
Surname (max. 17 characters) [optional]
\\
\answerbox{6.5}
\\
Home(-hackerspace) (max. 17 characters)
\\
\answerbox{6.5}
\\
\section*{Current situation}
\subsection*{Chaos events}
This is my \ \ \ \ \answerbox{0.1} first \ \ \ \ \answerbox{0.1} second \ \ \ \ \answerbox{0.1} $\{\exists x \in \mathbb{N} \ |\ x > 2 \}$ \ \ \ Chaos event I've ever visited.
\subsection*{The Chaos}
I know \ \ \ \answerbox{0.1} nothing$^{1)}$ \ \ \ \answerbox{0.1} somewhat \ \ \ \answerbox{0.1} the secret \ \ \ \ about the Chaos.
\\
$^{1)}$Please fill out form R22
\section*{Additional hints}
\begin{itemize}
\item To register your \textbf{GPG fingerprint} on your passport, please fill out \textbf{Form PKSR20}.
\end{itemize}
\end{document}

95
docs/PKSR20.tex Normal file
View File

@ -0,0 +1,95 @@
\documentclass[11pt,a4paper]{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
left=20mm,
top=20mm,
}
\usepackage{pgf}
\pgfmathsetseed{\number\pdfrandomseed} % to ensure that it is randomized
% use \randomseed for xelatex
\newcommand{\randomnum}[1]{%
\pgfmathsetmacro{\thenum}{int(random(ceil(#1-#1/4),floor(#1+#1/4)))}%
\thenum%
}%
\newcommand{\answerbox}[1]{%%
\fbox{\rule{#1in}{0pt}\rule[-0.5ex]{0pt}{4ex}}}
\title{\textbf{Application Form PKSR20}}
\author{c3Reg}
\date{Control no. \answerbox{1}}
\addtolength{\topmargin}{-2cm}
\begin{document}
\maketitle
\thispagestyle{empty}
\section*{}
I hereby applicate to register my GPG fingerprint.
I fullfil the requirement that I have either
\begin{itemize}
\item[1.] uploaded the public key to the \textbf{keys.openpgp.org} keyserver \textbf{using the following mail address} or
\item[2.] I can state the \textbf{full GPG fingerprint}, which is
\end{itemize}
\
Mail address or full GPG fingerprint (e.g. 1234-2234-3234-4234-5234-6234-7234-8234-9234-0234)
\\
\answerbox{6.5}
\\
\\
I state that I am certain about the requirements given above and checked that these requirements are given during the registration process.
\section*{Additional information}
The following colour is applicable on this fingerprint:
\\
Colour of fingerprint
\\
\answerbox{6.5}
\\
\\
\\
Please reason the chosen color in a small sentence.
\\
Reason
\\
\answerbox{6.5}
\\
\\
\\
From a scale from 1 (definitely not) to 5 (definitely), how private is your public key?
\\
\\
\answerbox{0.1} 1 \ \ \ \answerbox{0.1} 2 \ \ \ \answerbox{0.1} 3 \ \ \ \answerbox{0.1} 4 \ \ \ \answerbox{0.1} 5 \ \ \
\\
\\
\\
From a scale from 1 (definitely not) to 5 (definitely), how private is your private key?
\\
\\
\answerbox{0.1} 1 \ \ \ \answerbox{0.1} 2 \ \ \ \answerbox{0.1} 3 \ \ \ \answerbox{0.1} 4 \ \ \ \answerbox{0.1} 5 \ \ \
\\
\\
\\
From a scale from 1 (definitely not) to 5 (definitely), how public is your public key?
\\
\\
\answerbox{0.1} 1 \ \ \ \answerbox{0.1} 2 \ \ \ \answerbox{0.1} 3 \ \ \ \answerbox{0.1} 4 \ \ \ \answerbox{0.1} 5 \ \ \
\end{document}

46
docs/PrivacyPolicy.tex Normal file
View File

@ -0,0 +1,46 @@
\documentclass[11pt,a4paper]{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
left=20mm,
top=20mm,
}
\title{\textbf{Privacy Policy}}
\author{c3Reg}
\date{}
\addtolength{\topmargin}{-2cm}
\begin{document}
\maketitle
\thispagestyle{empty}
\section*{Statement}
This office is compliant with the GDPR.
\\
\section*{Reasoning}
\begin{itemize}
\item The gathered information will not kept in the office after finishing the process. They will be always hand over to the applicant. If, how ever, the applicant fails to pick up their documents after the end of the running event, it
\begin{itemize}
\item will be kept save until the next event,
\item can be requested via mail
\end{itemize}
\item The information requiring the usage of the computer are always saved volatilely for issuing the passport document.
\end{itemize}
\section*{Contact}
Contact information:
\begin{itemize}
\item Bandie \textless bandie at chaospott.de\textgreater, DECT: 2263
\end{itemize}
\end{document}

81
docs/Y42.tex Normal file
View File

@ -0,0 +1,81 @@
\documentclass[11pt,a4paper]{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
left=20mm,
top=20mm,
}
\usepackage{pgf}
\pgfmathsetseed{\number\pdfrandomseed} % to ensure that it is randomized
% use \randomseed for xelatex
\newcommand{\randomnum}[1]{%
\pgfmathsetmacro{\thenum}{int(random(ceil(#1-#1/4),floor(#1+#1/4)))}%
\thenum%
}%
\newcommand{\answerbox}[1]{%%
\fbox{\rule{#1in}{0pt}\rule[-0.5ex]{0pt}{4ex}}}
\title{\textbf{Application Form Y42}}
\author{c3Reg}
\date{Control no. \randomnum{1000}}
\addtolength{\topmargin}{-1cm}
\addtolength{\textheight}{1cm}
\begin{document}
\maketitle
\thispagestyle{empty}
\section*{}
I hereby applicate for the registration of being a hacker.
\\
The passport document has been \ \ \ \answerbox{0.1} already issued in a blank state \ \ \ \answerbox{0.1} not yet issued
\section*{Personal data}
\
Forename/Nick (max. 17 characters)
\\
\answerbox{6.5}
\\
Surname (max. 17 characters) [optional]
\\
\answerbox{6.5}
\\
Home(-hackerspace) (max. 17 characters)
\\
\answerbox{6.5}
\\
\section*{Current situation}
\subsection*{Chaos events}
This is my \ \ \ \ \answerbox{0.1} first \ \ \ \ \answerbox{0.1} second \ \ \ \ \answerbox{0.1} $\{\exists x \in \mathbb{N} \ |\ x > 2 \}$ \ \ \ Chaos event I've ever visited.
\subsection*{The Chaos}
I know \ \ \ \answerbox{0.1} nothing \ \ \ \answerbox{0.1} somewhat \ \ \ \answerbox{0.1} the secret \ \ \ \ about the Chaos.
\\
\section*{Additional hints}
\begin{itemize}
\item To register your \textbf{GPG fingerprint} on your passport, please fill out \textbf{Form PKSR20}.
\end{itemize}
\end{document}

View File

@ -1,12 +1,13 @@
#!/bin/bash
DEVICE=/dev/ttyUSB0
DEVICE=/dev/ttyUSB2
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"
# \x1b\x33\x20 - 20/180 inch line spacing (standard)
printf "\x1b\x47\x1b\x78\x01\x1b\x52\x02\x1b\x33\x20" >> "$DEVICE"
}
@ -39,5 +40,17 @@ function italicLetters() {
printf "\x1b\x34" >> "$1"
}
function makeNewline() {
for((i=0; i<$1; i++)); do
printf "\n" >> "$2"
done
}
function makeLeft() {
for((i=0; i<$1; i++)); do
printf " " >> "$2"
done
}
init
resetLetters $DEVICE

View File

@ -11,10 +11,9 @@ HEADINGRIGHT=8
# GPG Space
NEXTPAGE=30
NEXTPAGESMALL=48
NEXTFIELDBOTTOM=7
NEXTFIELDBOTTOM=6
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:
@ -47,18 +46,6 @@ function moveDown() {
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
@ -73,34 +60,20 @@ function heading() {
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
makeLeft $HEADINGNEXTPAGE $FILE
if [ $(($FIELD % 2)) -eq 1 ]; then
makeLeft $(($HSPACE - 1))
makeLeft $(($HSPACE - 1)) $FILE
fi
else
if [ $(($FIELD % 2)) -eq 0 ]; then
makeLeft 1
makeLeft 1 $FILE
fi
makeLeft $HSPACE
makeLeft $HSPACE $FILE
fi
printf "OFFICE\n" >> $FILE
printf "c3Reg\n" >> $FILE
resetLetters $FILE
}
@ -114,10 +87,10 @@ function insertDate() {
smallLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGESMALL
makeLeft $NEXTPAGESMALL $FILE
fi
makeLeft $LEFT
makeLeft $(($SPACE + 2))
makeLeft $LEFT $FILE
makeLeft $(($SPACE + 2)) $FILE
if [ -n "$EVENT" ]; then
printf "$EVENT, $(date -I)" >> $FILE
else
@ -129,7 +102,7 @@ function insertDate() {
source ../include/nixdorf
init
makeNewline $TOP
makeNewline $TOP $FILE
heading
insertDate

View File

@ -10,7 +10,7 @@ HEADINGRIGHT=15
# GPG Space
NEXTPAGE=48
NEXTFIELDBOTTOM=7
NEXTFIELDBOTTOM=6
NEXTFIELDRIGHT=25
MAXLENGTH=22
@ -45,18 +45,6 @@ function moveDown() {
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
@ -69,11 +57,11 @@ function heading() {
fi
if [ $PAGE -eq 1 ]; then
makeLeft $HEADINGNEXTPAGE
makeLeft $HEADINGNEXTPAGE $FILE
fi
makeLeft $LEFT
makeLeft $SPACE
makeLeft $LEFT $FILE
makeLeft $SPACE $FILE
bigLetters $FILE
printf "GPG" >> $FILE
@ -90,10 +78,10 @@ function insertFP() {
smallLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGE
makeLeft $NEXTPAGE $FILE
fi
makeLeft $LEFT
makeLeft $(($SPACE + 2))
makeLeft $LEFT $FILE
makeLeft $(($SPACE + 2)) $FILE
printf "$1 $2 $3 $4" >> $FILE
resetLetters $FILE
printf "\n" >> $FILE
@ -101,10 +89,10 @@ function insertFP() {
smallLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGE
makeLeft $NEXTPAGE $FILE
fi
makeLeft $LEFT
makeLeft $(($SPACE + 2))
makeLeft $LEFT $FILE
makeLeft $(($SPACE + 2)) $FILE
printf "$1 $2 $3 $4" >> $FILE
resetLetters $FILE
printf "\n" >> $FILE
@ -112,10 +100,10 @@ function insertFP() {
smallLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGE
makeLeft $NEXTPAGE $FILE
fi
makeLeft $LEFT
makeLeft $(($SPACE + 2))
makeLeft $LEFT $FILE
makeLeft $(($SPACE + 2)) $FILE
printf "$1 $2" >> $FILE
resetLetters $FILE
printf "\n" >> $FILE
@ -123,10 +111,10 @@ function insertFP() {
smallLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGE
makeLeft $NEXTPAGE $FILE
fi
makeLeft $LEFT
makeLeft $(($SPACE + 2))
makeLeft $LEFT $FILE
makeLeft $(($SPACE + 2)) $FILE
if [ -n "$EVENT" ]; then
printf "$EVENT, $(date -I)" >> $FILE
@ -138,7 +126,7 @@ function insertFP() {
source ../include/nixdorf
init
makeNewline $TOP
makeNewline $TOP $FILE
heading
insertFP $@

View File

@ -1,30 +0,0 @@
#!/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

View File

@ -8,18 +8,6 @@ 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."
@ -30,20 +18,26 @@ fi
source ../include/nixdorf
init
makeNewline $TOP
makeLeft
makeNewline 1 $FILE
makeLeft $(($LEFT + 12)) $FILE
smallLetters $FILE
printf "/ C3Reg" >> $FILE
resetLetters $FILE
makeNewline $(($TOP - 1)) $FILE
makeLeft $LEFT $FILE
printf "$GIVENNAME" >> $FILE
makeNewline 4
makeLeft
makeNewline 3 $FILE
makeLeft $LEFT $FILE
printf "$SURNAME" >> $FILE
makeNewline 3
makeLeft
makeNewline 3 $FILE
makeLeft $LEFT $FILE
printf "$HOME" >> $FILE
makeNewline 4
makeLeft
makeNewline 4 $FILE
makeLeft $LEFT $FILE
if [ -n "$EVENT" ]; then
printf "$EVENT, $(date -I)" >> $FILE

View File

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

108
stapleddipl/c3reg Executable file
View File

@ -0,0 +1,108 @@
#!/bin/bash
FILE=/tmp/$RANDOM
TOP=1
LEFT=5
# Additional heading space
HEADINGNEXTPAGE=19
HEADINGLEFT=1
HEADINGRIGHT=10
# GPG Space
NEXTPAGE=34
NEXTPAGESMALL=60
NEXTFIELDBOTTOM=13
NEXTFIELDRIGHT=18
NEXTFIELDRIGHTSMALL=30
if [ $# -eq 0 ]; then
echo -e "$0: Syntax:\n$0 FIELD\n\nExample:\n$0 7\n\n\nFields:
==================
| VISAS || VISAS |
==================
| 0 | 1 || 4 | 5 |
|---|---||---|---|
| 2 | 3 || 6 | 7 |
==================
"
exit 1
fi
PAGE=$(($1 / 4))
FIELD=$(($1 % 4))
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 heading() {
moveDown
if [ $(($FIELD % 2)) -eq 0 ]; then
HSPACE=$HEADINGLEFT
SPACE=0
else
HSPACE=$HEADINGRIGHT
SPACE=$NEXTFIELDRIGHT
fi
bigLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $HEADINGNEXTPAGE $FILE
if [ $(($FIELD % 2)) -eq 1 ]; then
makeLeft $(($HSPACE - 1)) $FILE
fi
else
makeLeft 1 $FILE
makeLeft $HSPACE $FILE
fi
printf "c3Reg\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 $FILE
fi
makeLeft $LEFT $FILE
makeLeft $(($SPACE + 2)) $FILE
if [ -n "$EVENT" ]; then
printf "$EVENT, $(date -I)" >> $FILE
else
printf "$(date -I)" >> $FILE
fi
}
source ../include/nixdorf
init
makeNewline $TOP $FILE
heading
insertDate
printFile $FILE
rm $FILE

134
stapleddipl/gpgkey Executable file
View File

@ -0,0 +1,134 @@
#!/bin/bash
FILE=/tmp/$RANDOM
TOP=1
LEFT=3
# Additional heading space
HEADINGNEXTPAGE=36
HEADINGLEFT=1
HEADINGRIGHT=20
# GPG Space
NEXTPAGE=62
NEXTFIELDBOTTOM=11
NEXTFIELDRIGHT=31
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:
==================
| VISAS || VISAS |
==================
| 0 | 1 || 4 | 5 |
|---|---||---|---|
| 2 | 3 || 6 | 7 |
==================
"
exit 1
fi
PAGE=$(($1 / 4))
FIELD=$(($1 % 4))
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 heading() {
moveDown
if [ $(($FIELD % 2)) -eq 0 ]; then
SPACE=$HEADINGLEFT
else
SPACE=$HEADINGRIGHT
fi
if [ $PAGE -eq 1 ]; then
makeLeft $HEADINGNEXTPAGE $FILE
fi
makeLeft $LEFT $FILE
makeLeft $SPACE $FILE
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 $FILE
fi
makeLeft $LEFT $FILE
makeLeft $(($SPACE + 2)) $FILE
printf "$1 $2 $3 $4" >> $FILE
resetLetters $FILE
printf "\n" >> $FILE
shift 4
smallLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGE $FILE
fi
makeLeft $LEFT $FILE
makeLeft $(($SPACE + 2)) $FILE
printf "$1 $2 $3 $4" >> $FILE
resetLetters $FILE
printf "\n" >> $FILE
shift 4
smallLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGE $FILE
fi
makeLeft $LEFT $FILE
makeLeft $(($SPACE + 2)) $FILE
printf "$1 $2" >> $FILE
resetLetters $FILE
printf "\n" >> $FILE
shift 2
smallLetters $FILE
if [ $PAGE -eq 1 ]; then
makeLeft $NEXTPAGE $FILE
fi
makeLeft $LEFT $FILE
makeLeft $(($SPACE + 2)) $FILE
if [ -n "$EVENT" ]; then
printf "$EVENT, $(date -I)" >> $FILE
else
printf "$(date -I)" >> $FILE
fi
}
source ../include/nixdorf
init
makeNewline $TOP $FILE
heading
insertFP $@
printFile $FILE
rm $FILE

52
stapleddipl/reg Executable file
View File

@ -0,0 +1,52 @@
#!/bin/bash
FILE=/tmp/$RANDOM
TOP=54
NEXTFIELD=5
LEFT=23
AUTHLEFT=66
DATELEFT=35
MAXLENGTH=17
GIVENNAME=$1
SURNAME=$2
HOME=$3
if [ ${#GIVENNAME} -gt $MAXLENGTH ] || [ ${#SURNAME} -gt $MAXLENGTH ] || [ ${#HOME} -gt $MAXLENGTH ]; then
echo "MAXLENGTH EXCEEDED."
exit 1
fi
source ../include/nixdorf
init
smallLetters $FILE
printf "\x1b\x33\x0e" >> $FILE
makeNewline $TOP $FILE
makeLeft $LEFT $FILE
printf "$GIVENNAME" >> $FILE
# Authority field
makeNewline 2 $FILE
makeLeft $AUTHLEFT $FILE
printf "C3Reg" >> $FILE
makeNewline 3 $FILE
makeLeft $LEFT $FILE
printf "$SURNAME" >> $FILE
makeNewline $NEXTFIELD $FILE
makeLeft $LEFT $FILE
printf "$HOME" >> $FILE
makeNewline 5 $FILE
makeLeft $DATELEFT $FILE
if [ -n "$EVENT" ]; then
printf "/ $EVENT, $(date -I)" >> $FILE
else
printf "/ $(date -I)" >> $FILE
fi
printFile $FILE
rm $FILE

367
start
View File

@ -1,55 +1,60 @@
#!/bin/bash
export LANG=C
export EVENT=DiVOC
export DIALOGRC=dialogrc
LOCKFILE=/tmp/irolock
TMP=/tmp/$RANDOM
BT="Galactic Registration Office - v0.1"
BT="Intergalactic Registration Office - v0.3\n========================================"
cd $(dirname "$0")
function clr() {
printf "\033H\033J"
}
function infoBox() {
clr
echo -e "$BT\n\n$1\n\n\n$2"
read -n 1 -s -r -p "Press any key to continue"
}
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
clr
echo -e "$BT\n\n$1\n\n\n$2"
read -r -p "Okay? [(o)kay/(a)bort] " resp
echo "$resp" > $TMP
}
function ynBox() {
h=8
w=60
if [ -n "$3" ]; then
h=$3
clr
echo -e "$BT\n\n$1\n\n\n$2"
read -r -p "Are you sure? [y/N] " resp
if [ "$resp" = "" ]; then
resp="N"
fi
if [ -n "$4" ]; then
w=$4
fi
dialog --title "$1" \
--backtitle "$BT" \
--yesno "$2" $h $w
return $?
echo "$resp" > $TMP
}
function askStr() {
h=12
w=60
if [ -n "$5" ]; then
h=$5
fi
if [ -n "$6" ]; then
w=$6
fi
clr
echo -e "$BT\n\n$2\n\n\n$3"
read resp
dialog --title "$2" \
--backtitle "$BT" \
--max-input $1 \
--inputbox "$3" $h $w "$4" 2> $TMP
return $?
echo "$resp" > $TMP
}
function askPw() {
clr
echo -e "$BT\n\n$2\n\n"
stty -echo
read -r -p "$3 " resp
echo "$resp" > $TMP
}
function confirm() {
@ -68,8 +73,142 @@ function confirm() {
return $?
}
function jhpAskForField() {
text="$1: Please choose a free field on the passport.\n
function askStrThird() {
h=12
w=60
if [ -n "$6" ]; then
h=$5
fi
if [ -n "$7" ]; then
w=$6
fi
dialog --backtitle "$BT" \
--max-input $1 \
--title "$2" \
--extra-button --extra-label "$4" \
--inputbox "$3" $h $w "$5" 2> $TMP
return $?
}
function gpgSearch() {
askStr 255 "GPG Search" "Type in the mail address you'd like to look up on keys.openpgp.org."
if [ $? -eq 0 ]; then
if [[ "$(cat $TMP)" =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$ ]]; then
clear
echo "Searching for GPG key..."
gpg --keyserver "hkps://keys.openpgp.org" --search "$(cat $TMP)"
if [ $? -eq 0 ]; then
FFP=$(gpg -k "$(cat $TMP)" | head -n 2 | tail -n 1 | awk '{print $1}' | sed 's/.\{4\}/& /g;s/^\(.*\) $/\1/g')
gpg --batch --delete-key "$FFP"
if [ "$FFP" = "" ]; then
diaBox "GPG Search" "No fingerprint has been found for $(cat $TMP)"
return 1
else
return 0
fi
else
diaBox "GPG Search" "No fingerprint has been found for $(cat $TMP)"
return 1
fi
else
diaBox "GPG Search" "This is on vaild mail address."
return 1
fi
fi
return 1
}
function enterGPG() {
askStrThird 49 "GPG Fingerprint" "Enter GPG fingerprint WITH SPACES. E.g.:\n 1234 5678 9ABC DEF0 1234 5678 9ABC DEF0 1234 5678" "Search..." "$1"
ret=$?
case $ret in
0)
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."
enterGPG
fi
FP=$(echo "$FP" | tr [a-f] [A-F])
;;
1)
return 1
;;
3)
gpgSearch
if [ $? -eq 0 ]; then
enterGPG "$FFP" "no-confirm"
return 0
else
return 1
fi
;;
esac
if [ "$2" == "no-confirm" ]; then
return 0
else
confirm "GPG Fingerprint" " GPG:\n $FP"
return $?
fi
}
function checkLockFile() {
while [ -f $LOCKFILE ]; do
infoBox "Printer is in use..." "Printer is in use. Please wait."
sleep 1
done
touch $LOCKFILE
}
function printGPG() {
askForField "GPG fingerprint" "$1"
if [ $? -eq 0 ]; then
checkLockFile
diaBox "Insert Passport" "Please insert passport (Visas) into the printer."
cd "$1"
./gpgkey $FIELD $FP
cd ..
rm $LOCKFILE
return 0
else
return 1
fi
}
function printReg() {
checkLockFile
diaBox "Insert Passport" "Please insert passport (First page, name, place) into the printer."
cd "$1"
./reg "$FNAME" "$SNAME" "$PLANET"
cd ..
rm $LOCKFILE
return 0
}
function printIROStamp() {
askForField "IRO stamp" "$1"
if [ $? -eq 0 ]; then
checkLockFile
diaBox "Insert Passport" "Please insert passport (Visas) into the printer."
cd "$1"
./iro $FIELD
cd ..
rm $LOCKFILE
return 0
else
return 1
fi
}
function askForField() {
declare -A layout
declare -A maxfield
text="$1: Please choose a free field on the passport.\n"
layout[jhp]="
------------------\n
| Archievements |\n
==================\n
@ -80,96 +219,60 @@ function jhpAskForField() {
| 4 | 5 || 10| 11|\n
==================\n
"
askStr 2 "Select a field" "$text" "" 18
layout[adafruit]="
------------------\n
| VISAS || VISAS |\n
==================\n
| 0 | 1 || 4 | 5 |\n
|---|---||---|---|\n
| 2 | 3 || 6 | 7 |\n
==================\n
"
maxfield[jhp]=11
maxfield[adafruit]=7
askStr 2 "Select a field" "$text ${layout[$2]}" "" 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
if ! [[ "$FIELD" =~ ^[0-9]+$ ]] || [ -z "$FIELD" ] || [ $FIELD -lt 0 ] || [ $FIELD -gt ${maxfield[$2]} ]; then
askForField "$1" "$2"
else
return 0
fi
}
function jhpPrintGPG() {
jhpAskForField "GPG fingerprint"
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 askReg() {
# Max length of passport fields
declare -A MAXLENGTH
MAXLENGTH[jhp]=25
MAXLENGTH[adafruit]=17
function jhpGROStamp() {
jhpAskForField "GRO stamp"
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"
askStr ${MAXLENGTH[$1]} "Forename/Nickname" "Enter forename/nickname"
if [ $? -eq 1 ]; then
return 1
fi
FNAME=$(cat $TMP)
askStr 25 "Surename" "Enter surename"
askStr ${MAXLENGTH[$1]} "Surname" "Enter surname"
if [ $? -eq 1 ]; then
return 1
fi
SNAME=$(cat $TMP)
askStr 25 "Planet" "Enter planet" "Earth, Chaospott"
askStr ${MAXLENGTH[$1]} "Place" "Enter place"
if [ $? -eq 1 ]; then
return 1
fi
PLANET=$(cat $TMP)
confirm=" Forename: $FNAME\n Surename: $SNAME\n Planet: $PLANET"
confirm=" Forename: $FNAME\n Surname: $SNAME\n Place: $PLANET"
ynBox "GRO Stamp" "Does this being wants to have a GRO stamp?"
ynBox "IRO Stamp" "Does this being want to have a IRO stamp?"
if [ $? -eq 0 ]; then
STAMP=true
else
@ -178,7 +281,7 @@ function jhpReg() {
ynBox "GPG" "Does the being have a GPG key to register?"
if [ $? -eq 0 ]; then
jhpGPG no-confirm
enterGPG "" no-confirm
if [ $? -eq 0 ]; then
confirm="$confirm\n GPG:\n $FP"
fi
@ -189,33 +292,33 @@ function jhpReg() {
}
function jhpmenu() {
function menuFor() {
dialog --backtitle "$BT" \
--menu "Select ID type:" 14 40 3 \
1 "Registration" \
2 "GRO Stamp" \
2 "IRO Stamp" \
3 "GPG" \
9 "Back" 2> $TMP
choice=$(cat $TMP)
case $choice in
1) jhpReg
1) askReg "$1"
if [ $? -eq 0 ]; then
jhpPrintReg
printReg "$1"
if [ "$STAMP" == "true" ]; then
jhpGROStamp
printIROStamp "$1"
fi
if [ -n "$FP" ]; then
jhpPrintGPG
printGPG "$1"
fi
fi
;;
2) jhpGROStamp
2) printIROStamp "$1"
;;
3) jhpGPG
3) enterGPG
if [ $? -eq 0 ]; then
jhpPrintGPG
printGPG "$1"
fi
;;
@ -225,16 +328,44 @@ function jhpmenu() {
unset PLANET
unset FP
unset FIELD
unset FFP
}
function askForFunnyUserCreds() {
clr
echo "Press Enter to start."
read -s
askStr 12 "Login" "Username:" ""
username=$(cat $TMP)
askPw 12 "Login" "Password:" ""
password=$(cat $TMP)
if [ -f .pw/$username ]; then
if [ "$password" != $(cat .pw/$username) ]; then
clr
echo "Wrong credentials."
sleep 3
exit 1
fi
else
echo "Wrong credentials."
sleep 3
exit 1
fi
}
askForFunnyUserCreds
while [ true ]; do
dialog --backtitle "$BT" \
--menu "Select ID type:" 10 40 3 \
1 "Junghackerpass" \
2 "Usual" 2> $TMP
2 "New Adafruit passport" \
9 "Logout" 2> $TMP
if [ $? -eq 1 ]; then
if [ $? -eq 9 ]; then
break
fi
@ -242,9 +373,11 @@ while [ true ]; do
case $TYPE in
1) jhpmenu
1) menuFor jhp
;;
2) exit 0
2) menuFor adafruit
;;
9) break
;;
esac
done

436
start_dialog Executable file
View File

@ -0,0 +1,436 @@
#!/bin/bash
export LANG=C
export EVENT=DiVOC
export TERM=vt220
export DIALOGRC=dialogrc
LOCKFILE=/tmp/c3reglock
TMP=/tmp/$RANDOM
BT="c3Reg - v0.4"
cd $(dirname "$0")
function infoBox() {
h=8
w=60
if [ -n "$3" ]; then
h=$3
fi
if [ -n "$4" ]; then
w=$4
fi
dialog --title "$1" \
--backtitle "$BT" \
--infobox "$2" $h $w
}
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 askPw() {
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 \
--insecure \
--passwordbox "$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 askStrThird() {
h=12
w=60
if [ -n "$6" ]; then
h=$5
fi
if [ -n "$7" ]; then
w=$6
fi
dialog --backtitle "$BT" \
--max-input $1 \
--title "$2" \
--extra-button --extra-label "$4" \
--inputbox "$3" $h $w "$5" 2> $TMP
return $?
}
function gpgSearch() {
askStr 255 "GPG Search" "Type in the mail address you'd like to look up on keys.openpgp.org."
if [ $? -eq 0 ]; then
if [[ "$(cat $TMP)" =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$ ]]; then
clear
echo "Searching for GPG key..."
gpg --keyserver "hkps://keys.openpgp.org" --search "$(cat $TMP)"
if [ $? -eq 0 ]; then
FFP=$(gpg -k "$(cat $TMP)" | head -n 2 | tail -n 1 | awk '{print $1}' | sed 's/.\{4\}/& /g;s/^\(.*\) $/\1/g')
gpg --batch --delete-key "$FFP"
if [ "$FFP" = "" ]; then
diaBox "GPG Search" "No fingerprint has been found for $(cat $TMP)"
return 1
else
return 0
fi
else
diaBox "GPG Search" "No fingerprint has been found for $(cat $TMP)"
return 1
fi
else
diaBox "GPG Search" "This is on vaild mail address."
return 1
fi
fi
return 1
}
function enterGPG() {
askStrThird 49 "GPG Fingerprint" "Enter GPG fingerprint WITH SPACES. E.g.:\n 1234 5678 9ABC DEF0 1234 5678 9ABC DEF0 1234 5678" "Search..." "$1"
ret=$?
case $ret in
0)
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."
enterGPG
fi
FP=$(echo "$FP" | tr [a-f] [A-F])
;;
1)
return 1
;;
3)
gpgSearch
if [ $? -eq 0 ]; then
enterGPG "$FFP" "no-confirm"
return 0
else
return 1
fi
;;
esac
if [ "$2" == "no-confirm" ]; then
return 0
else
confirm "GPG Fingerprint" " GPG:\n $FP"
return $?
fi
}
function checkLockFile() {
while [ -f $LOCKFILE ]; do
infoBox "Printer is in use..." "Printer is in use. Please wait."
sleep 1
done
touch $LOCKFILE
}
function printGPG() {
askForField "GPG fingerprint" "$1"
if [ $? -eq 0 ]; then
checkLockFile
diaBox "Insert Passport" "Please insert passport (Visas) into the printer."
cd "$1"
./gpgkey $FIELD $FP
cd ..
rm $LOCKFILE
return 0
else
return 1
fi
}
function printReg() {
checkLockFile
diaBox "Insert Passport" "Please insert passport (First page, name, place) into the printer."
cd "$1"
./reg "$FNAME" "$SNAME" "$PLANET"
cd ..
rm $LOCKFILE
return 0
}
function printC3RegStamp() {
askForField "c3Reg stamp" "$1"
if [ $? -eq 0 ]; then
checkLockFile
diaBox "Insert Passport" "Please insert passport (Visas) into the printer."
cd "$1"
./c3reg $FIELD
cd ..
rm $LOCKFILE
return 0
else
return 1
fi
}
function askForField() {
declare -A layout
declare -A maxfield
text="$1: Please choose a free field on the passport.\n"
layout[jhp]="
------------------\n
| Archievements |\n
==================\n
| 0 | 1 || 6 | 7 |\n
|---|---||---|---|\n
| 2 | 3 || 8 | 9 |\n
|---|---||---|---|\n
| 4 | 5 || 10| 11|\n
==================\n
"
layout[bounddipl]="
------------------\n
| VISAS || VISAS |\n
==================\n
| 0 | 1 || 4 | 5 |\n
|---|---||---|---|\n
| 2 | 3 || 6 | 7 |\n
==================\n
"
layout[stapleddipl]="
------------------\n
| VISAS || VISAS |\n
==================\n
| 0 | 1 || 4 | 5 |\n
|---|---||---|---|\n
| 2 | 3 || 6 | 7 |\n
==================\n
"
maxfield[jhp]=11
maxfield[bounddipl]=7
maxfield[stapleddipl]=7
askStr 2 "Select a field" "$text ${layout[$2]}" "" 18
if [ $? -eq 1 ]; then
return 1
fi
FIELD=$(cat $TMP)
if ! [[ "$FIELD" =~ ^[0-9]+$ ]] || [ -z "$FIELD" ] || [ $FIELD -lt 0 ] || [ $FIELD -gt ${maxfield[$2]} ]; then
askForField "$1" "$2"
else
return 0
fi
}
function askReg() {
# Max length of passport fields
declare -A MAXLENGTH
MAXLENGTH[jhp]=25
MAXLENGTH[bounddipl]=17
MAXLENGTH[stapleddipl]=17
askStr ${MAXLENGTH[$1]} "Forename/Nickname" "Enter forename/nickname"
if [ $? -eq 1 ]; then
return 1
fi
FNAME=$(cat $TMP)
askStr ${MAXLENGTH[$1]} "Surname" "Enter surname"
if [ $? -eq 1 ]; then
return 1
fi
SNAME=$(cat $TMP)
askStr ${MAXLENGTH[$1]} "Place" "Enter place"
if [ $? -eq 1 ]; then
return 1
fi
PLANET=$(cat $TMP)
confirm=" Forename: $FNAME\n Surname: $SNAME\n Place: $PLANET"
ynBox "c3Reg Stamp" "Does this being want to have a c3Reg stamp?"
if [ $? -eq 0 ]; then
STAMP=true
else
STAMP=false
fi
ynBox "GPG" "Does the being have a GPG key to register?"
if [ $? -eq 0 ]; then
enterGPG "" no-confirm
if [ $? -eq 0 ]; then
confirm="$confirm\n GPG:\n $FP"
fi
fi
confirm "Everything" "$confirm"
return $?
}
function menuFor() {
dialog --backtitle "$BT" \
--menu "Select ID type:" 14 40 3 \
1 "Registration" \
2 "c3Reg Stamp" \
3 "GPG" \
9 "Back" 2> $TMP
choice=$(cat $TMP)
case $choice in
1) askReg "$1"
if [ $? -eq 0 ]; then
printReg "$1"
if [ "$STAMP" == "true" ]; then
printC3RegStamp "$1"
fi
if [ -n "$FP" ]; then
printGPG "$1"
fi
fi
;;
2) printC3RegStamp "$1"
;;
3) enterGPG
if [ $? -eq 0 ]; then
printGPG "$1"
fi
;;
esac
unset FNAME
unset SNAME
unset PLANET
unset FP
unset FIELD
unset FFP
}
function askForFunnyUserCreds() {
clear
echo "Press Enter to start."
read -s
askStr 12 "Login" "Username:" ""
username=$(cat $TMP)
askPw 12 "Login" "Password:" ""
password=$(cat $TMP)
if [ -f .pw/$username ]; then
if [ "$password" != $(cat .pw/$username) ]; then
clear
echo "Wrong credentials."
sleep 3
exit 1
fi
else
echo "Wrong credentials."
sleep 3
exit 1
fi
}
askForFunnyUserCreds
while [ true ]; do
dialog --backtitle "$BT" \
--menu "Select ID type:" 10 40 3 \
1 "Junghackerpass" \
2 "Bound diplomatic passport" \
3 "Stapled diplomatic passport" \
9 "Logout" 2> $TMP
if [ $? -eq 9 ]; then
break
fi
TYPE=$(cat $TMP)
case $TYPE in
1) menuFor jhp
;;
2) menuFor bounddipl
;;
3) menuFor stapleddipl
;;
9) break
;;
esac
done
rm $TMP
clear

18
test/msg5 Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
FILE=/tmp/$RANDOM
source ../include/nixdorf
init
smallLetters $FILE
#printf "\x1b\x33\x0a" >> $FILE
printf "\x1b\x33\x0e" >> $FILE
#for j in $(seq 0 10); do
for i in $(seq 0 100); do
printf " $i\n" >> $FILE
done
#done
printFile $FILE
rm $FILE