我希望能够解码一个base64编码的文本并用它来登录网站。这个base64编码的文本是用户名和密码。我已经找到了类似Base64.exe和b64.exe这样的工具,但它们的输入是文件,而在我的情况下输入是字符串。请帮忙解决。所有这些都应该在批处理文件中完成,并且我正在从config.txt文件中读取编码后的文本。
我希望能够解码一个base64编码的文本并用它来登录网站。这个base64编码的文本是用户名和密码。我已经找到了类似Base64.exe和b64.exe这样的工具,但它们的输入是文件,而在我的情况下输入是字符串。请帮忙解决。所有这些都应该在批处理文件中完成,并且我正在从config.txt文件中读取编码后的文本。
CERTUTIL
命令而无需安装外部软件(虽然它需要临时文件):@echo off
del /q /f "%temp%\b64" >nul 2>nul
del /q /f "%temp%\decoded" >nul 2>nul
set "base64string=YmFzZTY0c3RyaW5n"
echo -----BEGIN CERTIFICATE----->"%temp%\b64"
<nul set /p=%base64string% >>"%temp%\b64"
echo -----END CERTIFICATE----->>"%temp%\b64"
certutil /decode "%temp%\b64" "%temp%\decoded" >nul 2>nul
for /f "useback tokens=* delims=" %%# in ("%temp%\decoded") do set "decoded=%%#"
echo %decoded%
del /q /f "%temp%\b64" >nul 2>nul
del /q /f "%temp%\decoded" >nul 2>nul
您也可以使用PowerShell,尽管不需要临时文件,但速度会较慢:
set "base64string=YmFzZTY0c3RyaW5n"
for /f "tokens=* delims=" %%# in ('powershell [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("""%base64string%"""^)^)') do set "decoded=%%#"
echo %decoded%
您还可以尝试使用atob.bat:
call atob.bat YmFzZTY0c3RyaW5n decoded
echo %decoded%
for /f "tokens=* delims=" %%# in ('base64.bat -decode YmFzZTY0c3RyaW5n') do set "decoded=%%#"
echo %decoded%
echo "string" | base64
- Elliott Bcertutil
应该安装在所有版本的 Windows 上,从 Vista / Server 2008 开始。https://social.technet.microsoft.com/Forums/en-US/09fb7a70-69c2-4cc0-ad82-173c06774261/availbility-of-certutil-on-different-windows-versions?forum=winserversecurity - BuvinJ你可以使用由@jeb、@dbenham和@Ed Dyreen发明的宏样式:
@echo off
====SETLOCAL DisableDelayedExpansion EnableExtensions
set ^"LF=^
%===EXPANDS TO NOTHING===%
"
REM \n is an escaped LF + caret
set ^"\n=^^^%LF%%LF%^%LF%%LF%^^"
REM Initalize macro
set ^"$b64d=FOR %%$ in (%%$ MainMacro) do if "%%$" == "MainMacro" (%\n%
^>nul %__APPDIR__%CERTUTIL.EXE -f -decodehex args.tmp proc.tmp 1%\n%
type proc.tmp%\n%
del args.tmp proc.tmp%\n%
) ELSE ^>args.tmp echo("
echo BEFORE :: %time%
%$b64d%dGhpcwppcwpzaWNrIQo=
echo AFTER :: %time%
输出:
BEFORE :: 21:13:31.94
this
is
sick!
AFTER :: 21:13:32.02