Last active
October 31, 2024 07:41
-
-
Save RealEnder/ae1330350f612c7f558e9f6533d3842a to your computer and use it in GitHub Desktop.
Verify machine voting files from BG elections
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Verify machine voting files from BG elections | |
# (c) 2021-2024 Alex Stanev <[email protected]>, MIT license | |
# Opendata URLs for different elections: | |
# Parliamentary elections 11 July 2021: https://results.cik.bg/pi2021_07/export.zip | |
# Parliamentary and presidential elections 14 November 2021: https://results.cik.bg/pvrns2021/tur1/export.zip | |
# Presidential elections 21 November 2021: https://results.cik.bg/pvrns2021/tur2/export.zip | |
# Parliamentary elections 11 July 2021: https://results.cik.bg/ns2022/export.zip | |
# Parliamentary elections 2 October 2022: https://results.cik.bg/ns2022/export.zip | |
# Parliamentary elections 2 April 2023: https://results.cik.bg/ns2023/export.zip | |
# Local elections 2023 tour2 5 November 2023: https://results.cik.bg/mi2023/tur2/opendata/export.zip | |
# Euro and Parliamentary elections 9 June 2024: https://results.cik.bg/europe2024/opendata/export.zip | |
# Parliamentary elections 27 October 2024: https://results.cik.bg/pe202410/opendata/export.zip | |
# Change the URL below for the selected election. | |
wget https://results.cik.bg/pe202410/opendata/export.zip -U 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36' -O export.zip | |
unzip -oq export.zip "suemg/*" | |
unzip -oqc suemg/ca.zip > chain.pem | |
TMPDIR=$(mktemp -d) | |
if [ ! -d "$TMPDIR" ]; then echo "Error creating temp dir!"; exit 1; fi | |
for Z in $(find suemg -name '?????????*.zip') | |
do | |
SIKID=${Z%%.*} | |
SIKID=${SIKID##*/} | |
echo -ne $SIKID '\t' | |
unzip -oq "$Z" -d "$TMPDIR" | |
openssl cms -verify -inform PEM -in "$TMPDIR/$SIKID.csv.p7s" -content "$TMPDIR/$SIKID.csv" -CAfile chain.pem -purpose any -out /dev/null | |
if [ $? -ne 0 ]; then exit 1; fi | |
done | |
rm -rf "$TMPDIR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment