NCTF Crypto WriteUp

http://ctf.nuptzj.cn/challenges

Crypto篇:

第一题、第二题、第七题和CG-CTF一样,不写了…

第三题:

NCTF Crypto WriteUp_第1张图片

说了全家桶,那就python跑吧…

NCTF Crypto WriteUp_第2张图片

Flag:nctf{base64_base32_and_base16}

150分到手

第四题:

NCTF Crypto WriteUp_第3张图片

鬼知道进行了几次…

首先把base.txt中的回车都搞了,Notepad++吧,嗯。\r\n替换为空搞定。

搞完了就写个脚本跑一下,先跑他个100次试试…

# coding: utf-8

import base64

f = open('base64.txt','r')

str = f.read()

for i in range(0,100):

       str = base64.b64decode(str)

       print (str)

跑到出错,flag就出现了

NCTF Crypto WriteUp_第4张图片

Flag:nctf{please_use_python_to_decode_base64}

200分到手。

用Python解base64,嗯,记住了。

第五题:

NCTF Crypto WriteUp_第5张图片

给了个php函数。

NCTF Crypto WriteUp_第6张图片

大概思路就是先反转字符串,然后每一位都把它的ASCII码加一,然后反向打印base64,再rot13编码…

咋这么多步骤,那就php走起吧…

写了个php

放到phpStudy中跑一下,出结果。

Flag:nctf{rot13_and_base64_and_strrev}

250分到手

第六题:

NCTF Crypto WriteUp_第7张图片

给了个py

NCTF Crypto WriteUp_第8张图片

woc你是有毒吗?

人工解密吧,反正就十次…

第一次一看没有小写字母,base32,第二次只有数字,应该是base16,第三次只有数字和A-F字母,base16,第四次大小写都有,base64,第五次,base16,第六次,base64,第七次,base32,第八次,base16,第九次,base32,第十次,base32,然后出来了

真累,有没有别的办法…

百度了一下别的wp,

https://www.jianshu.com/p/b1e1214a72cb

上面那个师傅是按照爆破做的,学习了。

Flag:nctf{random_mixed_base64_encode}

第八题:

Python大法好

# coding: utf-8

import hashlib

str1 = 'TASC'

str2 = 'O3RJMV'

str3 = 'WDJKX'

str4 = 'ZM'

for i in range(ord('A'),ord('Z') + 1):

       for j in range(ord('A'),ord('Z') + 1):

              for k in range(ord('A'),ord('Z') + 1):

                     str = str1 + chr(i) + str2 + chr(j) + str3 + chr(k) + str4

                     md5str = hashlib.md5(str.encode("utf-8")).hexdigest()

                     print (str + ' ' + md5str + '\n')

                     if (md5str[0:5]=='e9032'):

                            exit()

然后就成了

其实应该再跑一次数字的,不过字母出了结果,数字就没必要跑了。

Flag:nctf{e9032994dabac08080091151380478a2}

300分到手

第九题:

NCTF Crypto WriteUp_第9张图片

加密算法看了一下,大概就是:

从一个文件中读取,如果读取不到换行符,就和给定的一个字符数组中的某个数异或,然后再以十六进制输出到另一个文件中。

嗯,好难…

首先我想的就是一个一个试吧…

这个不确定就一个一个试,这个

明文首先是可见的字符吧…所以说可以排除掉几个

上C++,C++大法好…

#define _CRT_SECURE_NO_WARNINGS

#include 

#include 

using namespace std;

const int KEY_LENGTH_MAX = 13;

const int KEY_LENGTH_MIN = 1;

int main() {

    FILE *fpIn;

    unsigned char ch;

    string str = "\x00";

    fpIn = fopen("code.txt", "r");

    while (fscanf(fpIn, "%02X", &ch) != EOF) str += ch;

    fclose(fpIn);

    unsigned char ustr[471] = {};

    unsigned char xstr[471] = {};

    int a, b, c, d, e, f, g, h, k, l, m, n, p, i;

    for (i = 0; i < 471; i++) ustr[i] = str[i];

    unsigned char _key[13] = {};

    int KEY_LENGTH = KEY_LENGTH_MAX;

    for (; KEY_LENGTH != 0; KEY_LENGTH--) {

         for (a = 0; a < 256; a++) {

             _key[0] = a;

             for (b = 0; b < 256; b++) {

                  _key[1] = b;

                  for (c = 0; c < 256; c++) {

                      _key[2] = c;

                      for (d = 0; d < 256; d++) {

                          _key[3] = d;

                          for (e = 0; e < 256; e++) {

                               _key[4] = e;

                               for (f = 0; f < 256; f++) {

                                   _key[5] = f;

                                   for (g = 0; g < 256; g++) {

                                       _key[6] = g;

                                       for (h = 0; h < 256; h++) {

                                            _key[7] = h;

                                            for (k = 0; k < 256; k++) {

                                                _key[8] = k;

                                                for (l = 0; l < 256; l++) {

                                                     _key[9] = l;

                                                     for (m = 0; m < 256; m++) {

                                                         _key[10] = m;

                                                         for (n = 0; n < 256; n++) {

                                                             _key[11] = n;

                                                             for (p = 0; p < 256; p++) {

                                                                  _key[12] = p;

                                                                  unsigned char key[13] = {};

                                                                  for (i = 0; i < 13; i++) key[i] = _key[12 - i];

                                                                  for (i = 0; i < 470; i++) xstr[i] = key[i%KEY_LENGTH] ^ ustr[i];

                                                                  cout << "当KEY_LENGTH=" << KEY_LENGTH << ",密码表的遍历为";

                                                                  for (i = 0; i < KEY_LENGTH; i++) printf("%d ", key[i]);

                                                                  cout << "时,字符串解密如下:" << endl;

                                                                  for (i = 0; i < 470; i++) if (xstr[i] >= 32 && xstr[i] <= 127) printf("%c", xstr[i]);

                                                                  cout << endl;

                                                             }

                                                         }

                                                     }

                                                }

                                            }

                                       }

                                   }

                               }

                          }

                      }

                  }

             }

         }

    }

    return 0;

}

这个算法应该理论上是可行的,但是…按照这个算法跑估计跑到我结婚都跑不出来…

自闭了,还是看百度吧…

https://blog.csdn.net/jakekong/article/details/79884365

这篇文章有详细的解答

--------------------------------------------------

真的能跑出来!!!

---------------------------------------------------

学习中…

你可能感兴趣的:(NCTF Crypto WriteUp)