No cON Name CTF Quals 2014 年的一道 CTF 安全杂项题 MISCall 的 Writeup,比较遗憾的是,文中的附件没有了,免费的 OneDriver 果然不稳定呀。

概览

NoConName 2014 Quals: MISCall

环境

  • Linux
  • Code

考察

  • Linux 基础
  • Git 基础
  • Python 基础

描述

No hints :( just go and get the flag.
翻译:没有提示,不要怂,就是干~~ (手动斜眼)

附件

无了,以前用的另类方法白嫖的 OneDriver 云盘被封了,这些附件都不在了,所以本文就当做一个思路来学习吧。

WP

首先看下是什么文件

$ file ctf
ctf: bzip2 compressed data, block size = 900k

其实这里 Ubuntu 已经智能的识别出这个是一个bz2后缀结尾的文件了,从文件图标即可看出:

是一个 bzip2 的压缩文件,解压他再看是什么文件:

$ mv ctf ctf.bz2
$ bzip2 -d ctf.bz2
$ file ctf
ctf: POSIX tar archive (GNU)

是一个tar文件,继续解压:

$ mv ctf ctf.tar
$ tar -xf ctf.tar

一个新的目录被创建

ctf@ubuntu:~/Desktop$ ls
ctf  ctf.tar
ctf@ubuntu:~/Desktop$ cd ctf/
ctf@ubuntu:~/Desktop/ctf$ ls
flag.txt
ctf@ubuntu:~/Desktop/ctf$ cat flag.txt
Nothing to see here, moving along...

文件夹里面的flag.txt是假的,查找隐藏文件看看:

ctf@ubuntu:~/Desktop/ctf$ ls -la
total 16
drwxr-xr-x 3 ctf ctf 4096 Jul 24  2014 .
drwxr-xr-x 3 ctf ctf 4096 Jan 12 08:22 ..
-rw-r--r-- 1 ctf ctf   37 Jul 24  2014 flag.txt
drwxr-xr-x 8 ctf ctf 4096 Jul 24  2014 .git

里面是一个 git 文件夹,看来这里是考我们 git 的基础知识。 关于 Git 的教程,不懂的话可以百度或谷歌一下:“廖雪峰 Git教程”

首先查看 Git 的提交记录:

ctf@ubuntu:~/Desktop/ctf$ git log
commit bea99b953bef6cc2f98ab59b10822bc42afe5abc
Author: Linus Torvalds <[email protected]>
Date:   Thu Jul 24 21:16:59 2014 +0200

    Initial commit

在这里看不到什么,只有一个提交与我们已经看到的文件。 但是 repo 有点太大了,如果只包含这个,所以这里还有其他的东西隐藏起来。 两个明显的位置是分支和储藏。
查看存储,并列出来

ctf@ubuntu:~/Desktop/ctf$ git stash list
stash@{0}: WIP on master: bea99b9 Initial commit
ctf@ubuntu:~/Desktop/ctf$ git stash show
 flag.txt | 25 ++++++++++++++++++++++++-
 s.py     |  4 ++++
 2 files changed, 28 insertions(+), 1 deletion(-)

来恢复这些文件:

ctf@ubuntu:~/Desktop/ctf$ git stash apply
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	new file:   s.py

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   flag.txt

可以看到flag.txt已经被修改了,同时还有一个s.py脚本。

看看脚本内容,运行看看:

ctf@ubuntu:~/Desktop/ctf$ cat s.py
#!/usr/bin/env python
from hashlib import sha1
with open("flag.txt", "rb") as fd:
    print "NCN" + sha1(fd.read()).hexdigest()
ctf@ubuntu:~/Desktop/ctf$ python s.py
NCN4dd992213ae6b76f27d7340f0dde1222888df4d3

拿到flag

NCN4dd992213ae6b76f27d7340f0dde1222888df4d3

总结

多注意细节,基础要扎实。

点评

CTF MISC 部分感觉就得多刷题,如果对 MISC 不感兴趣的话,刷题会比较难受,MISC 题目太杂了,有时候还会出现各种脑洞,还是建议大家用兴趣去刷题,而不是任务式驱动刷题。

本文可能实际上也没有啥技术含量,但是写起来还是比较浪费时间的,在这个喧嚣浮躁的时代,个人博客越来越没有人看了,写博客感觉一直是用爱发电的状态。如果你恰巧财力雄厚,感觉本文对你有所帮助的话,可以考虑打赏一下本文,用以维持高昂的服务器运营费用(域名费用、服务器费用、CDN费用等)

微信
支付宝

没想到文章加入打赏列表没几天 就有热心网友打赏了 于是国光我用 Bootstrap 重写了一个页面 用以感谢 支持我的朋友,详情请看 打赏列表 | 国光