Skip to content

Instantly share code, notes, and snippets.

@achateigner
Created October 24, 2017 13:05
Show Gist options
  • Save achateigner/0e7eb18f682424a69dfdf6ca212f7603 to your computer and use it in GitHub Desktop.
Save achateigner/0e7eb18f682424a69dfdf6ca212f7603 to your computer and use it in GitHub Desktop.
excelRemoveProtection(){
echo "Usage: exelRemoveProtection fichier.xlsx"
unzip "$1" -d tmp
cd tmp/xl/worksheets/
for i in "$(ls *.xml)" ; do
sed -i 's/Protection password="[A-Za-z0-9]*"/Protection password=""/' $i
echo "Hacked $i"
done
cd ..
sed -i 's/Protection workbookPassword="[A-Za-z0-9]*"/Protection workbookPassword=""/' workbook.xml
cd ..
zip -r "../$1" *
cd ..
rm -r tmp
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment