Created
November 5, 2018 02:02
-
-
Save hsur/4aa09bdfb481d68e7ff2e7105112b3bf to your computer and use it in GitHub Desktop.
Build mkpasswd for windows
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
@echo off | |
::: Build mkpasswd for windows | |
::: author: hsur | |
::: Distributed under the BSD-2-Clause License | |
::::::::::::::::::: | |
::: download files | |
::::::::::::::::::: | |
curl -s https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/tclkit/sdx-20110317.kit --output sdx-20110317.kit | |
curl -s https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/tclkit/tclkitsh-8.5.9-win32.upx.exe --output tclkitsh-8.5.9-win32.upx.exe | |
curl -s https://core.tcl.tk/expect/raw/example/mkpasswd?name=8d9337848c793e851a8b6981412b6d8d7dba755e --output mkpasswd | |
curl -s https://frippery.org/files/busybox/busybox.exe --output busybox.exe | |
curl -s https://gist.githubusercontent.com/hsur/6015dbddcef7f0152d9ee40e212b47d5/raw/aa3245e05208058fc52c7635a93c30953053f41c/mkpasswd.tcl.patch --output mkpasswd.tcl.patch | |
::::::::::::::::::: | |
::: check sha256 | |
::::::::::::::::::: | |
call :CHECKHASH sdx-20110317.kit 04dc85d4503c037f26c2b8719e45e4e20385674fbc7404481f3c171fce0a26c3 | |
if %ERRORLEVEL% NEQ 0 goto SIGERROR | |
call :CHECKHASH tclkitsh-8.5.9-win32.upx.exe d9b800e204c0a0be90fd018c5dba46d2baed999613f0886f9c778da004a5ab6c | |
if %ERRORLEVEL% NEQ 0 goto SIGERROR | |
call :CHECKHASH mkpasswd 581cb50379e74418bd4dde3254c2338628f14874d559e4d22bfcbad42534dade | |
if %ERRORLEVEL% NEQ 0 goto SIGERROR | |
call :CHECKHASH busybox.exe f89ff320ce50e58ea8859d9acc59d70907ae31d53a2c870e2680a7391faef575 | |
if %ERRORLEVEL% NEQ 0 goto SIGERROR | |
call :CHECKHASH mkpasswd.tcl.patch 232c3017d65079dd246c8571481d6a46433d048ef701c1f25cda1eb9a77e3554 | |
if %ERRORLEVEL% NEQ 0 goto SIGERROR | |
::::::::::::::::::: | |
::: build mkpasswd.exe | |
::::::::::::::::::: | |
copy tclkitsh-8.5.9-win32.upx.exe tclkitsh.exe | |
tclkitsh.exe sdx-20110317.kit qwrap mkpasswd | |
tclkitsh.exe sdx-20110317.kit unwrap mkpasswd.kit | |
busybox.exe patch < mkpasswd.tcl.patch | |
tclkitsh.exe sdx-20110317.kit wrap mkpasswd.exe -runtime tclkitsh-8.5.9-win32.upx.exe | |
echo completed! | |
pause | |
exit /b | |
:SIGERROR | |
echo hash does not match! | |
pause | |
exit /b 1 | |
::: Based on https://stackoverflow.com/questions/42170361/verifying-md5-hashes-in-batch | |
:CHECKHASH | |
call :SHA256SUM %1 | |
if "%2" equ "%hash%" ( | |
echo %hash% %1 : OK | |
) else ( | |
echo %hash% %1 : NG | |
exit /b 1 | |
) | |
exit /b | |
:SHA256SUM | |
set "hash=" | |
for /f "skip=1 tokens=* delims=" %%# in ('certutil -hashfile "%1" SHA256') do ( | |
if not defined hash ( | |
for %%Z in (%%#) do set "hash=%%Z" | |
) | |
) | |
exit /b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment