新手写的 writeup

0.前言

CTF(Capture The Flag,夺旗赛)起源于 1996 年 DEFCON 全球黑客大会,是网络安全爱好者之间的竞技游戏。

CTF 竞赛涉及众多领域,内容繁杂。目前,安全技术发展地越来越快,CTF 题目的难度越来越高,初学者需要面对的门槛因此也越来越高。而网上资料大都零散琐碎,初学者往往并不知道该如何系统性地学习 CTF 相关领域知识,常需要花费大量时间,苦不堪言。

以上引用的内容来自 https://ctf-wiki.github.io/ctf-wiki/,更多相关内容请自行查看。

1 和 2 是 CTF 安全杂项里图片相关的。3~9 都是实验吧的题目,是关于 CTF 密码学的。

1.图片隐写

下面这张图片是隐写了之后的图片,里面有 Flag。

http://ctfs.github.io/resources/topics/steganography/invisible-text/example.png

这个链接里面是一个 jar 包,需要 java 环境才能使用。

https://www.wechall.net/forum/show/thread/527/Stegsolve_1.3/page-1

打开就可以找到 flag,也可以使用 GIMPPhotoshop 通过使用不同的滤镜和颜色范围找到 flag。但是不建议,因为太麻烦了。

flag

2.这题不是 WEB

题目链接:https://cgctf.nuptsast.com/challenges#Web

通关链接:http://chinalover.sinaapp.com/web2

其实这个是 gif,http://chinalover.sinaapp.com/web2/2.gif

flag 是隐藏在信息里面的,这里的 flag 的格式有点不太一样,因为是南邮的题目,所以是 nctf {}

用工具就能查看,请拉到最下面,不然看不到 flag。Windows 用 HxD 或者 WinHex ,linux 用 xxd

flag

3.变异凯撒

题目链接:http://www.shiyanbar.com/ctf/2038

加密密文:afZ_r9VYfScOeO_UL^RWUc 格式:flag{ }

afZ_ 的 ASCII 码分别是:97、102、90、95;

flag 的 ASCII 码分别是:102、108、97、103;

下面的 ASCII 码减上面的 ASCII 码,结果是5、6、7、8;

写个代码求一下就出来了,下面的是 C++ 代码。

#include<iostream>
using namespace std;
int main()
{
	int i;
	char a[30] = "afZ_r9VYfScOeO_UL^RWUc";
	for (i = 0; a[i]; i++) {
		a[i] = a[i] + i + 5;
		cout << a[i];
	}
	return 0;
}

flag

4.传统知识+古典密码

题目链接:http://www.shiyanbar.com/ctf/1991

小明某一天收到一封密信,信中写了几个不同的年份

​ 辛卯,癸巳,丙戌,辛未,庚辰,癸酉,己卯,癸巳。

​ 信的背面还写有“+甲子”,请解出这段密文。

key值:CTF{XXX}

甲子顺序表

图片链接

辛卯,癸巳,丙戌,辛未,庚辰,癸酉,己卯,癸巳分别是:28、30、23、8、17、10、16、30

信的背面还写有“+甲子”,所以都要加60,

即:88、90、83、68、77、70、76、90

对应的 ASCII 码的值是:X、Z、S、D、M、F、L、Z

栅栏密码解码:XMZFSLDZ,不是 flag。

然后在这个的基础上再试试凯撒密码,多次尝试,也可以运行代码,下面的还是 C++ 代码。

#include<iostream>
#include<string>
using namespace std;

//加密
void encrypt(string &s, int key) {
	char ch = '\0';
	for (unsigned int i = 0; i < s.length(); i++) {
		if ('a' <= s[i] && s[i] <= 'z')
			ch = 'a';
		else
			ch = 'A';
		if ('A' <= s[i] && s[i] <= 'Z' || 'a' <= s[i] && s[i] <= 'z')
			s[i] = ch + (s[i] - ch + key) % 26;//实现字母之间的循环移位
	}
}
//解密
void decrypt(string &s, int key) {
	char ch = '\0';
	for (unsigned int i = 0; i < s.length(); i++) {
		if ('a' <= s[i] && s[i] <= 'z')
			ch = 'z';
		else if ('A' <= s[i] && s[i] <= 'Z')
			ch = 'Z';
		if ('A' <= s[i] && s[i] <= 'Z' || 'a' <= s[i] && s[i] <= 'z')
			s[i] = ch - (ch - s[i] + key) % 26; //实现字母之间的循环移位</span>
	}
}


int main(int argc, char const *argv[])
{
	string s = "";
	cout << "请输入明文:" << endl;
	getline(cin, s, '\n');
	cout << "可能的密码:" << endl;
	for (int i = 0; i <= 25; ++i) {	
		encrypt(s, i);
		cout << "	" << s << endl;
	}
	system("pause");
	return 0;
}

运行了以后,一个一个试,或者先找看起来像个密码的试一下。

SHUANGYU

5.try them all

题目链接:http://www.shiyanbar.com/ctf/1981

You have found a passwd file containing salted passwords. An unprotected configuration file has revealed a salt of 5948. The hashed password for the ‘admin’ user appears to be 81bdf501ef206ae7d3b92070196f7e98, try to brute force this password.

对 81bdf501ef206ae7d3b92070196f7e98 进行解密。觉得像 MD5 ,于是去尝试。

http://www.dmd5.com/md5-decrypter.jsp

解密结果:sniper5948,注意题目中的 has revealed a salt of 5948.,所以去掉盐,是 sniper。

sniper

6.he Flash-14

题目链接:http://www.shiyanbar.com/ctf/1946

这些数字都是什么呢~ 54433252224455342251522244342223113412

答案形式 ctf{XXX}

解这道题需要下图这个表,5*5敲击码,两个数字一组,第一个是行、第二个是列。

需要去看The Flash(闪电侠)第二季的第 14 集获得这个表,因此,我看了第一季的第 14 集、第二季的第 14 集,顺便还看了不少剧。

  1 2 3 4 5
1 A B C/K D E
2 F G H I J
3 L M N O P
4 Q R S T U
5 V W X Y Z

解出来是:YSMWGTZOGVWGTOGHAOB,不需要用栅栏,直接用凯撒。

C++ 代码:

#include<iostream>
#include<string>
using namespace std;

//加密
void encrypt(string &s, int key) {
	char ch = '\0';
	for (unsigned int i = 0; i < s.length(); i++) {
		if ('a' <= s[i] && s[i] <= 'z')
			ch = 'a';
		else
			ch = 'A';
		if ('A' <= s[i] && s[i] <= 'Z' || 'a' <= s[i] && s[i] <= 'z')
			s[i] = ch + (s[i] - ch + key) % 26;//实现字母之间的循环移位
	}
}
//解密
void decrypt(string &s, int key) {
	char ch = '\0';
	for (unsigned int i = 0; i < s.length(); i++) {
		if ('a' <= s[i] && s[i] <= 'z')
			ch = 'z';
		else if ('A' <= s[i] && s[i] <= 'Z')
			ch = 'Z';
		if ('A' <= s[i] && s[i] <= 'Z' || 'a' <= s[i] && s[i] <= 'z')
			s[i] = ch - (ch - s[i] + key) % 26; //实现字母之间的循环移位</span>
	}
}


int main(int argc, char const *argv[])
{
	string s = "";
	cout << "请输入明文:" << endl;
	getline(cin, s, '\n');
	cout << "可能的密码:" << endl;
	for (int i = 0; i <= 25; ++i) {	
		decrypt(s, i);
		cout << "	" << s << endl;
	}
	system("pause");
	return 0;
}

然后就能找到 key,注意,不是大写,是小写。

key

7.robomunication

题目链接:http://www.shiyanbar.com/ctf/1978

We recorded the following file between two robots. Find out what evil things they are plotting, and recover their secret key!

解题链接:

http://ctf5.shiyanbar.com/crypto/robomunication/robo.rar

摩斯电码,解出来就包含 key,注意,是大写。

图片来源:wikihow

图片来源:wikihow

8.奇怪的短信

题目链接:http://www.shiyanbar.com/ctf/1920

收到一条奇怪的短信:

​ 335321414374744361715332

​ 你能帮我解出隐藏的内容嘛?!

格式:CTF{xxx}

手机英文 9 宫格,然后两两分开 33 53 21 41 43 74 74 43 61 71 53 32。33 表示第 3 个键第 3 个字母,也就是 f。

以此类推,解出来就是 flag 了。

9.围在栅栏中的爱

题目链接:http://www.shiyanbar.com/ctf/1917

最近一直在好奇一个问题,QWE到底等不等于ABC?

-.- .. –.- .-.. .– - ..-. -.-. –.- –. -. … — —

flag格式:CTF{xxx}

摩斯电码解码得到 KIQLWTFCQGNSOO.

图片来源:wikihow

图片来源:wikihow

QWE到底等不等于ABC?其实是提示。

QWE解密表:(按照电脑键盘排序)

a b c d e f g h i j k l m
Q W E R T Y U I O P A S D
n o p q r s t u v w x y z
F G H J K L Z X C V B N M

解出来是 AOJSVZYEJUFLGG、RHASBENVAOYLII 两个,分别进行栅栏解码。

试了很久都不行,发现要倒叙再进行栅栏

flag