南京郵電大學CTF密碼學之MD5-golang與php代碼實現

來源:互聯網
上載者:User

題目內容:這裡有一段丟失的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";                }            }        }    }
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.