picoCTF 2018 – Forensics 上

題目: Forensics Warmup 1

第一題要你下載一個檔案

解壓縮之後裡面是一張圖片

然後圖片就寫著flag

讓你不禁懷疑這難道是送分題嗎?

果真就只是送分題而已

輸入picoCTF{welcome_to_forensics}

過關


題目: Forensics Warmup 2

第二題要你下載一張圖片

他說他打不開 你有甚麼方法打開嗎

還有給你一些hint

不過這題完全不開玩笑

我也搞不懂到底是要幹嘛XDDDD

因為我直接點開圖片就打開來了

也許是win10 OS有默默幫我做了甚麼吧…

照著圖片內容輸入
picoCTF{extensions_are_a_lie}

過關


題目: Reading Between the Eyes

下載一張哈士奇~

題目說圖片裡面有藏東西

本來想用前陣子學到的小工具StegoSuite

結果那個不支援PNG檔案

找到這個資源
https://github.com/DominicBreuker/stego-toolkit

要解壓縮才行
https://stackabuse.com/python-zlib-library-tutorial/

用binwalk也行

#用binwalk查看圖片裡面有沒有藏檔案
binwalk husky.png
#把檔案分離出來
binwalk -e husky.png

查到python 似乎有個zlib module
應該可以安裝起來然後用python decompress
結果試了一陣子發現…
乾? 怎麼這麼困難
好像沒辦法QQ

又估狗了一下 發現一個工具zsteg
https://github.com/zed-0xff/zsteg

下載安裝起來用一下
答案就出來了!!! 幹 震怒
這工具也太方便


題目: Desrouleaux

連線過去之後被問問題了

You'll need to consult the file `incidents.json` to answer the following questions.

What is the most common source IP address? If there is more than one IP address that is the most common, you may give any of the most common ones.
cat incidents.json | grep src_ip

回答13.198.222.191看看
(如果沒反應 就再nc連一次)

答對了

後來又繼續問
就是滿簡單的問題

其實要看懂英文比較難XD

最後一題還真的是看不懂

What is the number of unique destination ips a file is sent, on average? Needs to be correct to 2 decimal places.

用以下的方法

#整理如下
#把每個file_hash分成一個Group
#清點每個group裡面的unique dst_ip
#清點完剛好都沒重複 所以unique ip是10 group是5
#所以最後用10/5 = 2.00
            "dst_ip": "199.16.77.59"
            "file_hash": "69a2b4d89c73ac3a",
            "dst_ip": "70.53.86.44"
            "file_hash": "172a9e2037d32204",
            "dst_ip": "3.100.196.23"
            "file_hash": "485354ceaaac3905",
            "dst_ip": "164.80.130.176"
            "file_hash": "485354ceaaac3905",
            "dst_ip": "167.26.111.81"
            "file_hash": "485354ceaaac3905",
            "dst_ip": "3.100.196.23"
            "file_hash": "8273bda152e4dc60",
            "dst_ip": "111.208.212.29"
            "file_hash": "8273bda152e4dc60",
            "dst_ip": "174.71.253.65"
            "file_hash": "56120f9b5b465272",
            "dst_ip": "111.208.212.29"
            "file_hash": "56120f9b5b465272",
            "dst_ip": "70.53.86.44"
            "file_hash": "56120f9b5b465272",

輸入2得到flag

flag: picoCTF{J4y_s0n_d3rUUUULo_b6cacd6c}


題目: Recovering From the Snap

下載下來的檔案副檔名是dd

用binwalk看

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
39424         0x9A00          JPEG image data, JFIF standard 1.01
39454         0x9A1E          TIFF image data, big-endian, offset of first image directory: 8
672256        0xA4200         JPEG image data, JFIF standard 1.01
1165824       0x11CA00        JPEG image data, JFIF standard 1.01
1556992       0x17C200        JPEG image data, JFIF standard 1.01
1812992       0x1BAA00        JPEG image data, JFIF standard 1.01
1813022       0x1BAA1E        TIFF image data, big-endian, offset of first image directory: 8
2136576       0x209A00        JPEG image data, JFIF standard 1.01
2136606       0x209A1E        TIFF image data, big-endian, offset of first image directory: 8
2607616       0x27CA00        JPEG image data, JFIF standard 1.01
2607646       0x27CA1E        TIFF image data, big-endian, offset of first image directory: 8
3000832       0x2DCA00        JPEG image data, JFIF standard 1.01
3000862       0x2DCA1E        TIFF image data, big-endian, offset of first image directory: 8

用file指令查看一下這個檔案

https://linux.die.net/man/1/file

顯示結果如下

#root@hackercat:~/CTF/picoCTF2018/Forensics/RecoveringFromtheSnap# file animals.dd 
animals.dd: DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "mkfs.fat", sectors/cluster 4, root entries 512, sectors 20480 (volumes <=32 MB), Media descriptor 0xf8, sectors/FAT 20, sectors/track 32, heads 64, serial number 0x9b664dde, unlabeled, FAT (16 bit)

根據提示去找
有個資料救援工具叫testdisk
看了一下嘗試看看能不能對那個animals.dd使用
https://nwpie.blogspot.com/2012/11/5-testdisk.html

結果試了一下沒反應

絕望again

結果查了一下別人的write up
我的思路沒錯
只是少了一個掛載的動作 不能直接用testdisk

另外多學到了一個指令
fdisk -lu animals.dd

Disk animals.dd: 10 MiB, 10485760 bytes, 20480 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

又看了另一個人的write up
有個比較easy的方法

安裝GUI版本的掛載工具 Disk Image Mounter

#當然 要gnome才行
sudo apt-get install gnome-disk-utility

接著cp animals.dd animals.iso
因為這個工具Disk Image Mounter
他會認副檔名 要iso你點右鍵才可以掛載

會看到有幾張圖片 但是沒有flag

後來玩一陣子發現好像又根本不用掛載?

testdisk animals.dd
進去直接Enter直到看到未刪除的檔案
把theflag復原就好

picoCTF{th3_5n4p_happ3n3d}


題目: admin panel

題目問能找到密碼嗎

下載檔案data.pcap

然後用wireshark打開來看看

root@hackercat:~/CTF/picoCTF2018/Forensics/adminpanel# wireshark data.pcap

用find 直接找Packet details的string關鍵字設password
很快一下就找到了
密碼是p4ssw0rd

試了picoCTF{p4ssw0rd}
結果不對

想想題目有提到login panel
所以關注在login的那個封包上面
結果發現了!

flag就藏在這邊而已
picoCTF{n0ts3cur3_9feedfbc}


題目: hex editor

到shell的路徑/problems/hex-editor_1_10cafee5618ce2cfe32f2188ca1f472e

底下有個檔案hex_editor
也可以下載到本機玩

在win上面習慣用的hex editor是winhex或是010 editor之類
那提示這邊也有推薦你Liunx上面的xxd, hexedit, bvi

順便就把這三個一次下載安裝完成(用apt就可以)

用xxd看看
xxd hex_editor.jpg

發現內容太多
用grep找關鍵字看看
xxd hex_editor.jpg | grep ‘pico’
得到

root@hackercat:~/CTF/picoCTF2018/Forensics/hexeditor# xxd hex_editor.jpg | grep 'pico'
00012940: 3a20 2270 6963 6f43 5446 7b61 6e64 5f74  : "picoCTF{and_t

答案看起來呼之欲出啦XD
繼續用grep 把後三行也叫出來

root@hackercat:~/CTF/picoCTF2018/Forensics/hexeditor# xxd hex_editor.jpg | grep -A 3 'pico'
00012940: 3a20 2270 6963 6f43 5446 7b61 6e64 5f74  : "picoCTF{and_t
00012950: 6861 7473 5f68 6f77 5f75 5f65 6469 745f  hats_how_u_edit_
00012960: 6865 785f 6b69 7474 6f73 5f34 6245 3561  hex_kittos_4bE5a
00012970: 4362 387d 220a                           Cb8}".

就這樣解出來了
picoCTF{and_thats_how_u_edit_hex_kittos_4bE5aCb8}

不過發現其實用cat直接看這個圖片..
就會顯示答案了


題目: Truly an Artist

題目提供了一個照片 2018.png

隨便找一個網站 可以完整顯示netadata info的
把圖片上傳
就找到flag了
https://www.metadata2go.com/

picoCTF{look_in_image_13509d38}

也可以用exiftool


題目: now you don’t

下載檔案下來
看起來是張全紅的圖

用binwalk看沒甚麼特別

安裝看看Stegsolve跟StegDetect
StegDetect似乎是window的?不確定
Stegsolve在下面網址有
https://github.com/zardus/ctf-tools/blob/master/stegsolve/install
基本上後面mkdir bin,然後mv到bin動作沒甚麼差
反正就是個jar檔 有jave開發環境就可以執行

執行後打開圖片
結果我也只是按按左左右右
就突然冒出答案了XD

picoCTF{n0w_y0u_533_m3}

:::success
Stegsolve
圖片通道檢視器,常用參數:
Analyse下拉式功能表:
File Format:查看檔案格式和參數資訊,有時候flag會寫在圖片資訊裡
Data Extract:資料提取,如LSB隱寫等在這個選項中提取資訊
Sterram solver:立體視圖,可以左右移動控制偏移量
Frame Broswer:逐幀流覽,如查看快速閃過的GIF圖中的flag
Image Combiner:圖片結合,可以對兩張圖片做xor、add、sub等運算


StegDetect
數位圖像隱寫分析工具,主要針對JPEG,常用參數:
-q 僅顯示可能包含隱藏內容的圖像。
-n 啟用檢查JPEG檔頭功能,以降低誤報率。如果啟用,所有帶有批註區域的檔將被視為沒有被嵌入資訊。如果JPEG檔的JFIF識別字中的版本號不是1.1,則禁用OutGuess檢測。
-s 修改檢測演算法的敏感度,該值的預設值為1。檢測結果的匹配度與檢測演算法的敏感度成正比,演算法敏感度的值越大,檢測出的可疑檔包含敏感資訊的可能性越大。
-d 列印帶行號的調試資訊。
-t 設置要檢測哪些隱寫工具(默認檢測jopi),可設置的選項如下:
j 檢測圖像中的資訊是否是用jsteg嵌入的。
o 檢測圖像中的資訊是否是用outguess嵌入的。
p 檢測圖像中的資訊是否是用jphide嵌入的。
i 檢測圖像中的資訊是否是用invisible secrets嵌入的。
:::


題目: Ext Super Magic

基本上大概就是連題目都看不懂

副檔名是img
https://zh.wikipedia.org/wiki/IMG%E6%A0%BC%E5%BC%8F

嘗試看看改成iso掛載
結果失敗了

root@hackercat:~/Downloads# cp ext-super-magic.img ext-super-magic.iso
root@hackercat:~/Downloads# sudo mkdir /media/iso
root@hackercat:~/Downloads# sudo mount -o loop ext-super-magic.iso /media/iso
mount: /media/iso: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.

根據提示,研究一下幾個東西
file指令, fsck, Endianness

file去查看ext-super-magic.img
顯示ext-super-magic.img: data

fsck是Linux檢查與修復硬碟檔案系統的工具
https://blog.gtwang.org/linux/linux-fsck-examples/

根據這幾個提示
感覺起來
應該是位元組被移動過導致magic number亂了

不過如果是這樣也太難了吧XD

找看看IMG檔案的magic number
結果怎麼好幾個 = =
https://www.garykessler.net/library/file_sigs.html
還有一個hint的網頁 根本抓不到線索
http://www.nongnu.org/ext2-doc/ext2.html

fsck沒辦法執行對檔案進行修復
利用fsck.ext2

可以確認他回應 bad magic number

可以上網查看看ext2 file的magic number
ext2/ext3/ext4都是 0x53 0xEF 在位置1080-1081

嘗試利用hex editor去修改
直接把內容改成53跟EF
hexedit 按F2存檔 Ctrl加上X 是存檔加退出

稍微注意一下這邊修改位置是0x439跟0x439
其實就是1080跟1081的hex而已

利用file再查看一次 結果似乎正常了

mount起來

裡面一堆圖片
查看裡面的flag圖片
本來想說用strings應該就可以看到
結果還是看不到
用eog開啟flag圖片
成功得到flag

picoCTF{Cd7AB187DF0bA6eE3C3C7ea7E3B9DbEe}

:::info
Hint

https://en.wikipedia.org/wiki/Fsck
https://www.garykessler.net/library/file_sigs.html
https://linux.die.net/man/1/file
http://www.nongnu.org/ext2-doc/ext2.html
https://en.wikipedia.org/wiki/Endianness
:::


題目: Lying Out

兩個檔案
一張圖跟一段文字說明

You've been given a dataset of 4800 internet traffic logs for your
organization's website. This dataset covers the number of unique IP addresses
sending requests to the site in 15-minute "buckets", across a 24-hour day.
The attached plot will help you see the daily pattern of traffic. You should
see 3 spikes of traffic: one in the morning, one at midday, and one in the
evening.
Your organization needs your help to figure out whether some recent activity
indicates unusual behavior. It looks like some logs have higher-than-usual
traffic in their time bucket: many more unique IP addresses are trying to
access the site than usual. This might be evidence that someone is trying to
do something shady on your site.

連線過去之後要回答問題
nc 2018shell.picoctf.com 2245

You'll need to consult the file `traffic.png` 
to answer the following questions.

Which of these logs have significantly higher traffic than is usual for their time of day? You can see usual traffic on the attached plot. 
There may be multiple logs with higher than usual traffic, 
so answer all of them! Give your answer 
as a list of `log_ID` values separated by spaces. 
For example, if you want to answer that 
logs 2 and 7 are the ones with higher than usual traffic, type 2 7.
    log_ID      time  num_IPs
0        0  01:30:00    11603
1        1  03:30:00    10288
2        2  05:00:00    11584
3        3  08:15:00    11523
4        4  13:30:00    11731
5        5  14:30:00    10387
6        6  15:00:00     9744
7        7  15:15:00     9993
8        8  15:15:00    10083
9        9  16:45:00    11907
10      10  18:15:00    14957
11      11  18:15:00    13854
12      12  18:30:00    12918
13      13  20:15:00    10726

其實很單純問題就是給了你一個表,表上附每個時間點的IP數量
然後你要去查看下載的那張圖 看看表中那些時段是超過正常IP數量的
下載下來的那張圖就是顯示正常IP數量的圖 是以15分鐘紀錄一次的


回答正確 達到flag
picoCTF{w4y_0ut_04c41b59}

不過比較麻煩是連線過去沒在一定時間內回答完
就會斷開
然後每次連線過去問題給的表會不一樣

所以其實比較好的方法應該是要寫一個腳本快速去幫你計算答案


題目: What’s My Name

下載下來是一個封包檔 myname.pcap

根據提示應該跟dns有關係

過濾搜尋一下dns

結果隨便就看到答案了 XD

picoCTF{w4lt3r_wh1t3_033ad0f914a0b9d213bcc3ce5566038b}


題目: core

hint

  1. core file
    https://zh.wikipedia.org/wiki/%E6%A0%B8%E5%BF%83%E8%BD%AC%E5%82%A8
    https://medium.com/cubemail88/c-c-gdb-core-dump-debugging-737b83829743
  2. GDB cheat sheet
    http://darkdust.net/files/GDB%20Cheat%20Sheet.pdf
    Try to figure out where the flag was read into memory using the disassembly and strace.
    You should study the format options on the cheat sheet and use the examine (x) or print (p) commands. disas may also be useful.

所以這一題要用到GDB 有提到會用到 disassembly 跟 strace
這題需要下載兩個檔案 print_flag 與 core

用gdb

先用bt 堆疊追蹤找到入口點

跟進print_flag function

觀察

   0x080487c7 <+6>:    mov    DWORD PTR [ebp-0xc],0x539
   0x080487ce <+13>:    mov    eax,DWORD PTR [ebp-0xc]
   0x080487d1 <+16>:    mov    eax,DWORD PTR [eax*4+0x804a080]
   0x080487dc <+27>:    push   0x804894c
   0x080487e1 <+32>:    call   0x8048410 <printf@plt>

flag的內容在eax當中

得到的這一串就是flag
picoCTF{abb6a3b2603654804ed357322c760510}

write-up
https://github.com/Dvd848/CTFs/blob/master/2018_picoCTF/core.md
https://0xswitch.fr/CTF/picoctf-2018-core


題目: Malware Shops

下載兩個檔案
一個是圖 一個是info說明
跟前面流量那題看起來很相似

不…不對XD
哪尼咖?!

這題題目好像有問題

首先連線過去的第一個問題

ou'll need to consult the file `clusters.png` to answer the following questions.
How many attackers created the malware in this dataset?

根本沒有給clusters.png這個答案 總之回答5通過了

接著第二題

In the following sample of files from the larger dataset, which file was made by the same attacker who made the file edff06ab? Indicate your answer by entering that file's hash.
       hash  jmp_count  add_count
0  edff06ab       35.0       24.0
1  87065e4d       22.0       68.0
2  687e386a       37.0       11.0
3  f5b7fded        8.0       43.0
4  8aa00e96       39.0        8.0
5  de66209c       14.0       36.0
6  ebaf5ccd        9.0       16.0
7  6b4deb5b       20.0       68.0
8  75ab42ce       38.0       28.0
9  628e79cf        7.0       29.0

也根本不會用到下載的那張圖
不過下載的那個info倒是有用到
info中最後一段提到

Malware attackers often release many slightly different versions of the same
malware over time. These different versions always have totally different
hashes, but they are likely to have similar numbers of `jmp` and `add`
instructions.

所以題目問說哪個hash的檔案 可能是來自於同一個攻擊者
就找了一個跟題目說的檔案的jmp,add count比較接近的回答
就答對了

得到flag
flag: picoCTF{w4y_0ut_28483c2e}

發佈留言