科来杯培训

本文最后更新于:1 年前

Misc


流量分析


  1. Q3.pcap
  • 查看http协议对应流量,跳过多个404流量包发现200 ok响应包
    • tip:点击Protocol自动根据协议分类

image-20210908131154447

  • 追踪流–>http流,得到

image-20210908131545509

  • 其中1、3表示将名为括号内字符串文件的文件名base64编码后被包含再压缩

  • 2、4为压缩结果

  • 通过命令行python解码

1
2
import base64
base64.b64decode('str')
  • 1为index.php,干扰项忽略;3为flag.txt,目标流量
  • 导出分组字节流
image-20210908132720451
  • 使用php分析
1
2
3
4
<?php
$b = file_get_contents('./flag.bin'); #将文件包含
$a = gzuncompress($b); #解压文件
echo $a;

  1. R1.pcap(大流量数据包)
  • 方法一:TCP追踪流,耐心寻找可疑流量
  • 方法二:统计–>conversations
image-20210908140338715
  • 按字节大小排序查看TCP流,从大到小找出可疑流量并追踪包
image-20210908215953740
  • 发现第二个为一压缩包(图中1)

image-20210908220224478

  • “.”表示不可见字符
  • 3处选择原始数据,由于文件较大,2位置加载需要一定时间,不要着急,点5保存为rar文件
  • 使用010editor打开,删除http报文相关内容,提取rar
image-20210910090657988
  • 文件有加密,4位置表示21流,密码向前面的流寻找,加密过程在21流之前
image-20210910091223908
  • 目标集中于此,进行url解码+base64解码
  • 19、20流结果C:\\inetpub\\wwwroot\\backup\\无用
  • 18流结果中,z1解码为cmd,z2为
image-20210910092544960
  • 其中-hp命令后接密码,打开压缩包得到1.gif但无法查看

  • 查看文件类型为MDMP crash data,是内存得dump文件

  • 载入到mimikatz,使用以下命令:

1
2
3
log d:\1.txt	//将回显输出到文件
sekurlsa::minidump 1.gif //载入dmp文件
sekurlsa::logonpasswords full //读取登陆密码
  • 得到flag

  1. Attachment.pcap(https加密)
  • 从FTP、SMTP协议入手
  • FTP导出字节流文件无用
  • 文件->导出对象->IMF
image-20210910143327330
  • 按大小排序,并依次追踪流查看
  • 找到如下
image-20210910143652273
  • 图片base64解码
1
2
3
4
5
6
7
8
9
10
import base64

fp = open('2.txt','r')
png = open('misc1.png','wb')

bin_png = base64.b64decode(fp.read())
png.write(bin_png)

fp.close()
png.close()
misc1
  • 所得图片即为RSA私钥
  • 使用ocr等其他方式提取字符内容,添加RSA key开头和结尾标识(流量分析.txt)
image-20210910152043700
  • 将私钥载入wireshark流量包,编辑->首选项->Protocols->TLS->Edit->key file
  • 追踪http流,得到flag
image-20210910160440806
  1. lx100.pcap
  • 首先追踪http流
image-20210910162446010
  • 发现与MP4有关,但MP4视频流为UDP协议传输,因此转向UDP流
image-20210910162720399
  • 发现jpg标识,导出原始数据
  • 使用脚本分离多张图片
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
f = open('lx100', 'rb')

data = f.read()
sub = 0
f.seek(0)

while 1:
if f.read(3) == b'\xff\xd8\xff':
f1 = open(str(sub) + '.jpg', 'wb')
f1.write(data[f.tell()-3:])
f1.close()
sub += 1
else:
f.seek(-2, 1)
# 图片后即使有其他无关数据也不影响正常显示,因此从头开始每个文件头依次提取其后所有数据
  • 分离得到400+图片,寻找得到flag

USB流量分析

  • tshark->*.py->gnuplot
鼠标协议

一般为四个字节:

  • 第一个代表按键:0x00没有按键,0x01左键,0x02右键
  • 第二个代表左右移动像素:<127右移,127~255左移
  • 垂直上下移动像素
  • 拓展字节,代表滚轮数据:0无滚轮运动,1垂直向上一下,0xFF垂直向下一下,2水平滚动右键一次,0xFE水平滚动左键单击一下

工具:Tshark(提取数据),gnuplot(作图工具)

  • tshark -r xxxx.pcapng -T fields -e usb.capdata >21321.txt

  • ```python
    #mouse.py

    -- coding: utf-8 --

    nums = []
    keys = open(‘usb.txt’,’r’)
    result = open(‘result.txt’,’w’) # 最后生成的result.txt 是一个xxx xxx 形式的坐标集合,直接用gnuplot 画图即可
    posx = 0
    posy = 0
    for line in keys:

    if len(line) != 24 :
         continue
    x = int(line[6:8],16) #这是代表第三个字节,如果生成的usb.txt没有: 的话,这个改为 x = int(line[4:6],16)
    y = int(line[12:14],16) # 这是代表第五个字节,如需修改,与上面同理修改
    if x > 127 :
        x -= 256
    if y > 127 :
        y -= 256
    posx += x
    posy += y
    btn_flag = int(line[0:2],16)  # 1 for left(左键) , 2 for right(右键) , 0 for nothing(无按键)
    if btn_flag == 1 :
        result.write(str(posx)+' '+str(-posy)+'\n')
    

    keys.close()

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42

    + `gnuplot`

    + `plot '1.txt'`

    + 流量包时间差0.001

    ##### 键盘协议

    ---

    统一八个字节:

    + 第一个字节判断是否按下Shift、Alt、Control等键
    + 保留位
    + 3~8字节为普通按键,击键信息集中在第3个字节

    工具同鼠标

    + ```python
    #keyboard.p
    # -*- coding: utf-8 -*-
    # Python2
    mappings = {0x04:"A", 0x05:"B", 0x06:"C", 0x07:"D", 0x08:"E", 0x09:"F", 0x0a:"G", 0x0b:"H", 0x0c:"I", 0x0d:"J", 0x0e:"K", 0x0f:"L", 0x10:"M", 0x11:"N", 0x12:"O", 0x13:"P", 0x14:"Q", 0x15:"R", 0x16:"S", 0x17:"T", 0x18:"U", 0x19:"V", 0x1a:"W", 0x1b:"X", 0x1c:"Y", 0x1d:"Z",0x1e:"!", 0x1f:"@", 0x20:"#", 0x21:"$", 0x22:"%", 0x23:"^",0x24:"&",0x25:"*",0x26:"(",0x27:")",0x28:"<RET>",0x29:"<ESC>",0x2a:"<DEL>", 0x2b:"\t",0x2c:"<SPACE>",0x2d:"_",0x2e:"+",0x2f:"{",0x30:"}",0x31:"|",0x32:"<NON>",0x33:"\"",0x34:":",0x35:"<GA>",0x36:"<",0x37:">",0x38:"?",0x39:"<CAP>",0x3a:"<F1>",0x3b:"<F2>", 0x3c:"<F3>",0x3d:"<F4>",0x3e:"<F5>",0x3f:"<F6>",0x40:"<F7>",0x41:"<F8>",0x42:"<F9>",0x43:"<F10>",0x44:"<F11>",0x45:"<F12>"}
    nums = []
    keys = open('usbout.txt') # 这里填写提取出来并处理好的keyusb.txt
    for line in keys:
    if line[0]!='0' or line[1]!='0' or line[2]!='0' or line[3]!='0' or line[6]!='0' or line[7]!='0' or line[8]!='0' or line[9]!='0' or line[10]!='0' or line[11]!='0' or line[12]!='0' or line[13]!='0' or line[14]!='0' or line[15]!='0':
    # 如果提取出来的数据没有: 的话,上面一行就将改为:
    # if line[0]!='0' or line[1]!='0' or line[2]!='0' or line[3]!='0' or line[6]!='0' or line[7]!='0' or line[8]!='0' or line[9]!='0' or line[10]!='0' or line[11]!='0' or line[12]!='0' or line[13]!='0' or line[14]!='0' or line[15]!='0':
    continue
    nums.append(int(line[4:6],16)) # 如果提取出来的数据没有: 的话,这里就将改为 nums.append(int(line[4:6],16))
    keys.close()
    output = ""
    for n in nums:
    if n == 0 :
    continue
    if n in mappings:
    output += mappings[n]
    else:
    output += '[unknown]'
    print 'output :\n' + output
  • 流量包时间差0.4-1.0

无线流量


cacosmia.cap

  • aircrack-ng -w password.txt -b [MAC][capfile]

aircrack-ng -w /usr/share/wordlists/rockyou.txt -b 1A:D7:17:98:D0:51 cacosmia.cap

  • KEY FOUND!
  • airdecap-ng [capfile] -e [ESSID] -p [password]
  • airdecap-ng cacosmia.cap -e mamawoxiangwantiequan -p 12345678
  • 生成cacosmia-dec.cap
  • 打开追踪http流发现png+rar流量包
image-20210916212202795 image-20210916212405932
  • 提取原始数据,并将压缩文件提出,发现需要密码且并非伪加密

image-20210916212703310

image-20210916213547620
  • 解密后有提示,ping的网站去找DNS,找到最近解析的网址,输入得到flag

取证


  1. encrypt.vmdk(rctf)
  • 首先使用winhex无法打开,7zip等压缩工具打开验证,确实为套壳
  • (010打开可以直接查看但挂载会出问题)
  • 提取文件,winhex查看发现部分flag,使用VeraCrypt挂载,得到另一个密码,继续挂载
  • 磁盘为隐藏类型,使用X-Ways打开,找到另一半flag
image-20210910160630355

image-20210910161625863


本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!