WebGoat 靶场通关笔记 Cryptographic Failures
Cryptographic Failures
Crypto Basics
2
base64加密解密,没啥说的。
3
题目给出的密文 {xor}Oz4rPj0+LDovPiwsKDAtOw==
使用了IBM WebSphere Application Server的 XOR编码 加密。需要拿到默认加密的密钥来解密。
Google一下,找到了XOR编码的加密解密脚本。
上面的代码有点小问题,修复后的代码如下:
1 | # Decode and Encode WebSphere XOR Password |
直接运行脚本解密python.exe .\Untitled-2.py -d "{xor}Oz4rPj0+LDovPiwsKDAtOw=="
,得到:databasepassword
。
4
未加盐的普通hash值破解。
直接MD5破解网站查,如cmd5。
6
题目中出给出了一个私钥,需要我们提供对应的公钥的modulus值以及使用私钥对该modulus进行签名后的签名值。
保存网页提供的私钥到本地文件private.txt
,文件内容如下:
1 | -----BEGIN PRIVATE KEY----- |
使用openssl命令,通过私钥生成公钥文件:
1 | openssl rsa -in private.txt -pubout > public.txt |
公钥文件public.txt
内容如下:
1 | -----BEGIN PUBLIC KEY----- |
提取公钥中的modulus值:
1 | openssl rsa -in public.txt -pubin -modulus -noout | cut -c 9- | tr -d '\r\n' > pm.txt |
得到:
1 | B63CD16AF49ABE78211C92A461447EEF48796B463B7ED90783AD7BF2090FC151375FD829C3DA521E66CB6E40ACB818F2B2BA5B276822CB3A442201C5A30DC7B7B174D4D32B850211F7D370E0508D6868DB73539103A8ACDA7002D5C499F20815E5858C3AF268B7E9E271E1B6D1902F79C59D1F4CD3B2AEF828B33E95C4DCDAC1BB4B418959B817DA7CF502609188261870606508389E4743D6AFAAB4C183BEEF6CFF813D4DDB35CCADDC7940AC56CD4471C89CECB99126F39054F162ADD792784064C62A3BC268CFA79343725D01CC60BB30C5A714F525D94DD21B8B2C6625A4F2DA50FD9B0403483DDF1611D3263ABD79EB6DE3BA1DC673E4A115271F69C6C7 |
使用私钥对该modulus信息进行签名计算,并将结果进行base64编码,得到一个私钥签名的签名值的base64编码结果。
1 | openssl dgst -sign private.txt -sha256 pm.txt| base64 |
得到:
1 | KIEji62u9Jkd07x3PeyA6qbK1nJ/X3If/0HhsDXsQm0FA2bTt2+1wrVfOBdFfANyHqgYpodZQ2s4 |
注意:请在Linux系统下运行上面的这些openssl命令!
输入框分别填上这两个值,提交。
8
题目提供了一个docker镜像,这个镜像的/root目录下保存了密码,拿到这个密码,可以解开题目中的加密字符。
运行容器:
1 | docker run -d webgoat/assignments:findthesecret |
以root用户登录容器:
1 | docker exec -it --user root 容器id /bin/bash |
找到密码文件:
1 | cd /root |
显示密码:
1 | ThisIsMySecretPassw0rdF0rY0u |
解密加密的字符串:
1 | echo "U2FsdGVkX199jgh5oANElFdtCxIEvdEvciLi+v+5loE+VCuy6Ii0b+5byb5DXp32RPmT02Ek1pf55ctQN+DHbwCPiVRfFQamDmbHBUpD7as=" | openssl enc -aes-256-cbc -d -a -kfile default_secret |
得到解密后的原文:
1 | Leaving passwords in docker images is not so secure |
把解密后的原文和密码文件名分别填到输入框,提交。
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZgAAACgCAYAAAAxZXohAAAgAElEQVR4Ae1dTYslx5X1zzC2x2qNpDHCjWUbGYMKCWwGrbSwYRhv1JZX3rTU2s1CdINnYQphMz24MQ2FcIthGqqFCxphqBFUjxjXpv5VDDcibsS5NyLzfWVWvY+zKN7LlxE37seJcyIiX1V947sv/2OQn29+69v8YQ6IAWKAGCAGJsPANygwFFYuLogBYoAYmAMDFBiuViZbrcwBUNok8REDu4sBCgwFhgJDDBADxMAsGKDAEFizAIurzt1ddbJ2rN1UGKDAUGAoMMQAMUAMzIIBCgyBNQuwploB0Q5X08TA7mJgI4F57aVb4ee3b4dfvflm+O3RUbj39tvh43fe4Q9zQAwQA8QAMRDWEhgRll/86McEEAFEDBADxAAxMIiBlQXmrddfNzuVX775k/DW7dvh9X/6Xnj51dfCrVde5Q9zQAwQA8QAMbDaDkaOw/QITIRFRIWCQkElBogBYoAY6GFg6R2M7FxUXH72gzcoLFydEAPEADFADIxiYCmBkWcu+gCf4sKVSm+lws+IC2KAGP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