Created
November 28, 2021 19:23
-
-
Save Shugabuga/da39b3ad637b1afe3cac20a69023ab3a to your computer and use it in GitHub Desktop.
"Port" of SignTool to Bash script.
This file contains 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 | |
if [ $1 != "" ] && [ $2 != "" ] | |
then | |
rm $1/signature | |
rm $1/manifest.json | |
echo "{" > signature.json.tmp | |
for fileEntry in $1/* | |
do | |
echo -n \" >> signature.json.tmp | |
echo -n $fileEntry | cut -d "/" -f2 >> signature.json.tmp | |
echo -n \":\" >> signature.json.tmp | |
sha1sum $fileEntry | cut -d " " -f1 >> signature.json.tmp | |
echo \", >> signature.json.tmp | |
done | |
echo "}" >> signature.json.tmp | |
tr --delete '\n' < signature.json.tmp > signature.tmp.json | |
rm signature.json.tmp | |
sed -i -e '$a\' signature.tmp.json | |
cat signature.tmp.json | sed s/",}"/"}"/ > $1/manifest.json | |
rm signature.tmp.json | |
openssl smime -binary -sign -certfile PKI/WWDR.pem -signer PKI/pass.pem -inkey PKI/private.key -in $1/manifest.json -out $1/signature -outform DER #-passin pass:12345 | |
cd $1 | |
zip -r $OLDPWD/$2 * | |
else | |
echo Invalid argument: $0 \<inputPass\> \<outputPass\> | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment