題目內容:這裡有一段丟失的md5密文 e9032???da???08????911513?0???a2 要求你還原出他並且加上nctf{}提交 已知線索 明文為: TASC?O3RJMV?WDJKX?ZM 題目來源:安恒杯
簡單的MD5密碼碰撞,通過對比密文e9032 與加密後的資料 定位相關資訊
解題代碼如下
GO語言版
package mainimport ( "crypto/md5" "io" "encoding/hex" "strings" "fmt")var Enable = []rune{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','1','2','3','4','5','6','7','8','9',' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '@','[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'}func main() { var( rune1 rune rune2 rune rune3 rune ) for i:=0; i< len(Enable);i++ { rune1 = Enable[i] for j:=0; j< len(Enable);j++ { rune2 = Enable[j] for k:=0; k< len(Enable);k++ { rune3 = Enable[k] strToDecode := "TASC"+string(rune1)+"O3RJMV"+string(rune2)+"WDJKX"+string(rune3)+"ZM" str := md5.New() io.WriteString(str, strToDecode) hexStr := str.Sum(nil) code := hex.EncodeToString(hexStr) result := "e9032" com01 := strings.Contains(code,result) if com01 == true { fmt.Println(strToDecode,code) } } } }}
PHP版
<?php $list = array( 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','1','2','3','4','5','6','7','8','9',' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '@','[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~' ); for ($i=0;$i<count($list);$i++){ $str1 = $list[$i]; for ($j=0;$j<count($list);$j++){ $str2 = $list[$j]; for ($k=0;$k<count($list);$k++){ $str3 = $list[$k]; $str = "TASC".$str1."O3RJMV".$str2."WDJKX".$str3."ZM"; $md5 = md5($str); if(strstr($md5,"e9032")){ echo $str."---".$md5."\n"; } } } }