当前位置:网站首页>[buuctf.reverse] 159_[watevrCTF 2019]Watshell
[buuctf.reverse] 159_[watevrCTF 2019]Watshell
2022-07-06 04:43:00 【石氏是时试】
这个题应该叫c语言入门
__int64 __fastcall main(int a1, char **a2, char **a3)
{
int v4; // [rsp+Ch] [rbp-3A4h]
const char *nptr; // [rsp+18h] [rbp-398h]
char *s1; // [rsp+20h] [rbp-390h]
FILE *stream; // [rsp+28h] [rbp-388h]
char v8[32]; // [rsp+30h] [rbp-380h] BYREF
char v9[32]; // [rsp+50h] [rbp-360h] BYREF
__int64 v10[25]; // [rsp+70h] [rbp-340h] BYREF
char delim[2]; // [rsp+13Eh] [rbp-272h] BYREF
char v12[80]; // [rsp+140h] [rbp-270h] BYREF
char s[504]; // [rsp+190h] [rbp-220h] BYREF
unsigned __int64 v14; // [rsp+388h] [rbp-28h]
v14 = __readfsqword(0x28u);
signal(14, handler);
alarm(0x3Cu);
strcpy(delim, " ");
v4 = 0;
sub_13A5();
sub_157F();
puts("Welcome to watshell, we ofcourse use our own super secure cryptographic functions to ensure user privacy!");
printf("%s", "Command: ");
fflush(stdout);
fgets(s, 500, stdin);
strlen(s);
for ( nptr = strtok(s, delim); nptr && v4 != 25; nptr = strtok(0LL, delim) )// 空格分隔的数字
v10[v4++] = atol(nptr);
sub_EB7(v8, v9);
s1 = (char *)sub_11AF(v10, 8 * (v4 + 1), (__int64)(8 * (v4 + 1)) >> 63, v9);
if ( !strcmp(s1, "give_me_the_flag_please") )
{
stream = fopen("/home/ctf/flag.txt", "r");
if ( !stream )
printf("The file does not exist!");
fgets(v12, 74, stream);
printf("Alright, alright %s\n", v12);
fclose(stream);
}
free(s1);
return 0LL;
}
在main里边直接将输入用空格分开,然后转成整型。用了一个入门但不常用的函数strok,这个函数将空格(分隔符)的位置改为0并每次传回前一段的指针。
然后sub_EB7()看不明白,但由于没用到输入的内容,所以一定是个固定值,用gdb跟到这就能得到结果.
然后调用11AF进行加密,逐个对刚转出来的整数处理
for ( i = 0uLL; size >> 3 > i; i += 1uLL )
ptr[i] = sub_DC3(*(_QWORD *)(8 * i + a1), a4[2], *a4);// 加密 pow(n,0x71,0x8f)
sub_DC3也是入门级的算法:快速降幂法
__int64 __fastcall sub_DC3(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
__int64 v4; // [rsp+18h] [rbp-8h]
if ( a1 < 0 || a2 < 0 || a3 <= 0 )
exit(1);
v4 = a1 % a3;
if ( !a2 )
return 1LL;
if ( a2 == 1 )
return a1 % a3;
if ( (a2 & 1) == 0 )
return sub_DC3(v4 * v4 % a3, a2 / 2, a3) % a3;
result = a2 % 2;
if ( a2 % 2 == 1 )
return v4 * sub_DC3(v4, a2 - 1, a3) % a3;
return result;
}
程序加密方法很是明了:要求输入一串数字空格分隔,然后每个数字作Rsa加密(e:0x71,n:0x8f)得到字符串"give_me_the_flag_please" 然后后台就会将flag给出来。
麻雀虽小五脏俱全。
边栏推荐
- Patent | subject classification method based on graph convolution neural network fusion of multiple human brain maps
- Etcd database source code analysis -- etcdserver bootstrap initialization storage
- RTP gb28181 document testing tool
- Quatre méthodes de redis pour dépanner les grandes clés sont nécessaires pour optimiser
- MIT CMS. 300 session 8 – immersion / immersion
- Platformio create libopencm3 + FreeRTOS project
- Redis has four methods for checking big keys, which are necessary for optimization
- MPLS experiment
- word封面下划线
- Guitar Pro 8.0最详细全面的更新内容及全部功能介绍
猜你喜欢
Flink kakfa data read and write to Hudi
Yyds dry inventory automatic lighting system based on CC2530 (ZigBee)
[detailed steps of FreeRTOS shift value for the first time]
Database - MySQL storage engine (deadlock)
Implementation of knowledge consolidation source code 1: epoll implementation of TCP server
[数学建模] 微分方程--捕鱼业的持续发展
CADD课程学习(7)-- 模拟靶点和小分子相互作用 (柔性对接 AutoDock)
行业专网对比公网,优势在哪儿?能满足什么特定要求?
IPv6 comprehensive experiment
Jd.com 2: how to prevent oversold in the deduction process of commodity inventory?
随机推荐
Supreme Court, judgment standard of divorce cases
Is the mode of education together - on campus + off campus reliable
2328. Number of incremental paths in the grid graph (memory search)
【HBZ分享】云数据库如何定位慢查询
Visio draw fan
Platformio create libopencm3 + FreeRTOS project
优秀PM必须经历这3层蜕变!
Quick sort
Case of Jiecode empowerment: professional training, technical support, and multiple measures to promote graduates to build smart campus completion system
Quatre méthodes de redis pour dépanner les grandes clés sont nécessaires pour optimiser
Weng Kai C language third week 3.1 punch in
[NOIP2009 普及组] 分数线划定
Crazy God said redis notes
Bill Gates posted his 18-year-old resume and expected an annual salary of $12000 48 years ago
DMA use of stm32
acwing周赛58
最高法院,离婚案件判决标准
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Yyds dry goods inventory OSI & tcp/ip
English Vocabulary - life scene memory method