当前位置:网站首页>[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给出来。
麻雀虽小五脏俱全。
边栏推荐
- Knowledge consolidation source code implementation 3: buffer ringbuffer
- 729. My schedule I (set or dynamic open point segment tree)
- Orm-f & Q object
- 饼干(考试版)
- P2022 interesting numbers (binary & digit DP)
- Redis 排查大 key 的4種方法,優化必備
- ORM aggregate query and native database operation
- Programmers' position in the Internet industry | daily anecdotes
- Etcd database source code analysis -- etcdserver bootstrap initialization storage
- Crazy God said redis notes
猜你喜欢
ORM aggregate query and native database operation
Use sentinel to interface locally
L'introduction en bourse de MSK Electronics a pris fin: 800 millions de RMB d'actifs de Henan étaient des actionnaires
Case of Jiecode empowerment: professional training, technical support, and multiple measures to promote graduates to build smart campus completion system
Postman关联
Delete subsequence < daily question >
Basic knowledge and examples of binary tree
Redis —— Redis In Action —— Redis 实战—— 实战篇一 —— 基于 Redis 的短信登录功能 —— Redis + Token 的共享 session 应用— 有代码
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
Crazy God said redis notes
随机推荐
ISP学习(2)
Yyds dry goods inventory OSI & tcp/ip
Postman测试报告
CADD course learning (8) -- virtual screening of Compound Library
Excellent PM must experience these three levels of transformation!
Sorting out the latest Android interview points in 2022 to help you easily win the offer - attached is the summary of Android intermediate and advanced interview questions in 2022
Lagrange polynomial
Sentinel sliding window traffic statistics
How do programmers teach their bosses to do things in one sentence? "I'm off duty first. You have to work harder."
Case of Jiecode empowerment: professional training, technical support, and multiple measures to promote graduates to build smart campus completion system
Implementation of knowledge consolidation source code 2: TCP server receives and processes half packets and sticky packets
Easyrecovery靠谱不收费的数据恢复电脑软件
Knowledge consolidation source code implementation 3: buffer ringbuffer
程序员在互联网行业的地位 | 每日趣闻
729. My schedule I (set or dynamic open point segment tree)
[network] channel attention network and spatial attention network
Platformio create libopencm3 + FreeRTOS project
win10电脑系统里的视频不显示缩略图
Can CDC pull the Oracle table in full
Uva1592 Database