前言
想学IOT 之前打算入门一下 re 和 pwn
以后一天一题 不求多 orz
1.easyre
直接拖进IDA 按 shift + F12 查看flag
2. reverse1
先 shift + F12
然后搜索 flag
双击进入 右键 再跟进
F5 查看源码
分析后 得到flag
3.reverse2
emm F5 后 我们拿到了一个类似c的代码
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
int stat_loc; // [rsp+4h] [rbp-3Ch] BYREF
int i; // [rsp+8h] [rbp-38h]
__pid_t pid; // [rsp+Ch] [rbp-34h]
char s2[24]; // [rsp+10h] [rbp-30h] BYREF
unsigned __int64 v8; // [rsp+28h] [rbp-18h]
v8 = __readfsqword(0x28u);
pid = fork();
if ( pid )
{
waitpid(pid, &stat_loc, 0);
}
else
{
for ( i = 0; i <= strlen(&flag); ++i )
{
if ( *(&flag + i) == 105 || *(&flag + i) == 114 )
*(&flag + i) = 49;
}
}
printf("input the flag:");
__isoc99_scanf("%20s", s2);
if ( !strcmp(&flag, s2) )
result = puts("this is the right flag!");
else
result = puts("wrong flag!");
return result;
}
看到这里有个 一半的flag?
选中数字后按 R 可将 数字转化为字符串
双击&flag发现内容就是之前的hacking_for_fun}
再分析循环,会将flag中的i和r替换成1,使用最后得到flag
flag{hack1ng_fo1_fun}
4.内涵的软件
5.新年快乐
提前过新年了 233
完了 看不懂了 233
emmm 看到了 说加了什么 UPX壳
学习一下
UPX是一款先进的可执行程序文件压缩器。压缩过的可执行文件体积缩小50%-70% ,这样减少了磁盘占用空间、网络上传下载的时间和其它分布以及存储费用。 通过 UPX 压缩过的程序和程序库完全没有功能损失,和压缩之前一样可正常地运行。对于支持的大多数格式没有运行时间或内存的UPX不利后果。它支持许多不同的可执行文件格式 :包含 Windows95/98/ME/NT/2000/XP/CE程序和动态链接库、DOS 程序、Linux 可执行文件和核心。
使用 upxshell
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
char Str2[14]; // [esp+12h] [ebp-3Ah] BYREF
__int16 Str1; // [esp+20h] [ebp-2Ch] BYREF
_BYTE v6[30]; // [esp+22h] [ebp-2Ah] BYREF
__main();
strcpy(Str2, "HappyNewYear!");
Str1 = 0;
memset(v6, 0, sizeof(v6));
printf("please input the true flag:");
scanf("%s", &Str1);
if ( !strncmp((const char *)&Str1, Str2, strlen(Str2)) )
result = puts("this is true flag!");
else
result = puts("wrong!");
return result;
}
nice 解压后再用IDA打开 就能看懂了
strncmp函数为字符串比较函数,字符串大小的比较是以ASCII 码表上的顺序来决定
如果返回值 < 0,则表示 str1 小于 str2。
如果返回值 > 0,则表示 str2 小于 str1。
如果返回值 = 0,则表示 str1 等于 str2。
so 我们输入 HappyNewYear!
即可返回1
6.xor
直接可以拿到代码
int __cdecl main(int argc, const char **argv, const char **envp)
{
int i; // [rsp+2Ch] [rbp-124h]
char __b[264]; // [rsp+40h] [rbp-110h] BYREF
memset(__b, 0, 0x100uLL);
printf("Input your flag:\n");
get_line(__b, 256LL);
if ( strlen(__b) != 33 )
goto LABEL_7;
for ( i = 1; i < 33; ++i )
__b[i] ^= __b[i - 1];
if ( !strncmp(__b, global, 0x21uLL) )
printf("Success");
else
LABEL_7:
printf("Failed");
return 0;
}
貌似长度要等于 33 然后
与前一位异或 然后和 global相等
查一下 global
写个python脚本提取一下
helloworld
来了个 apk
shift + f12 搜了一下字符串 看到了一个像flag的东西 对了。。。
reverse3
int __cdecl main_0(int argc, const char **argv, const char **envp)
{
size_t v3; // eax
const char *v4; // eax
size_t v5; // eax
char v7; // [esp+0h] [ebp-188h]
char v8; // [esp+0h] [ebp-188h]
signed int j; // [esp+DCh] [ebp-ACh]
int i; // [esp+E8h] [ebp-A0h]
signed int v11; // [esp+E8h] [ebp-A0h]
char Destination[108]; // [esp+F4h] [ebp-94h] BYREF
char Str[28]; // [esp+160h] [ebp-28h] BYREF
char v14[8]; // [esp+17Ch] [ebp-Ch] BYREF
for ( i = 0; i < 100; ++i )
{
if ( (unsigned int)i >= 0x64 )
j____report_rangecheckfailure();
Destination[i] = 0;
}
sub_41132F("please enter the flag:", v7);
sub_411375("%20s", (char)Str);
v3 = j_strlen(Str);
v4 = (const char *)sub_4110BE(Str, v3, v14);
strncpy(Destination, v4, 0x28u);
v11 = j_strlen(Destination);
for ( j = 0; j < v11; ++j )
Destination[j] += j;
v5 = j_strlen(Destination);
if ( !strncmp(Destination, Str2, v5) )
sub_41132F("rigth flag!\n", v8);
else
sub_41132F("wrong flag!\n", v8);
return 0;
}
str2 为 e3nifIH9b_C@n@dH
跟进加密函数中出现较多次数的一个函数
猜测是base64 加密
反过来解密即可