当前位置:网站首页>[buuctf.reverse] 159_ [watevrCTF 2019]Watshell
[buuctf.reverse] 159_ [watevrCTF 2019]Watshell
2022-07-06 04:46:00 【Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi】
This question should be called c Introduction to language
__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) )// Space separated numbers
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;
}
stay main Directly separate the input with spaces , Then convert to integer . It uses a function that is not commonly used but is introductory strok, This function will space ( Separator ) The position of is changed to 0 And return the pointer of the previous paragraph each time .
then sub_EB7() Can't understand , But because the input content is not used , So it must be a fixed value , use gdb Follow here and you will get the result .
And then call 11AF To encrypt , Process the integer just transferred one by one
for ( i = 0uLL; size >> 3 > i; i += 1uLL )
ptr[i] = sub_DC3(*(_QWORD *)(8 * i + a1), a4[2], *a4);// encryption pow(n,0x71,0x8f)
sub_DC3 It is also an entry-level Algorithm : Fast power reduction method
__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;
}
The method of program encryption is very clear : You are required to enter a string of numbers separated by spaces , Then each number is Rsa encryption (e:0x71,n:0x8f) Get a string "give_me_the_flag_please" Then the backstage will flag Give it out .
The sparrow is all ready .
边栏推荐
- The underlying structure of five data types in redis
- Etcd database source code analysis -- etcdserver bootstrap initialization storage
- 比尔·盖茨晒18岁个人简历,48年前期望年薪1.2万美元
- The most detailed and comprehensive update content and all functions of guitar pro 8.0
- C'est un petit résumé de l'étude.
- web工程导入了mysql驱动jar包却无法加载到驱动的问题
- ue5 小知识 FreezeRendering 查看视锥内渲染的物体
- Project manager, can you draw prototypes? Does the project manager need to do product design?
- Certbot failed to update certificate solution
- Microservice resource address
猜你喜欢
Delete subsequence < daily question >
Canal synchronizes MySQL data changes to Kafka (CentOS deployment)
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
Bill Gates posted his 18-year-old resume and expected an annual salary of $12000 48 years ago
CADD course learning (7) -- Simulation of target and small molecule interaction (flexible docking autodock)
Redis —— Redis In Action —— Redis 实战—— 实战篇一 —— 基于 Redis 的短信登录功能 —— Redis + Token 的共享 session 应用— 有代码
[Zhao Yuqiang] deploy kubernetes cluster with binary package
Yyds dry inventory automatic lighting system based on CC2530 (ZigBee)
Postman管理测试用例
Zynq learning notes (3) - partial reconfiguration
随机推荐
Chip debugging of es8316 of imx8mp
How to estimate the population with samples? (mean, variance, standard deviation)
Bubble sort
Platformio create libopencm3 + FreeRTOS project
内核判断i2c地址上是否挂载外设
Can CDC pull the Oracle table in full
Implementation of knowledge consolidation source code 2: TCP server receives and processes half packets and sticky packets
RTP GB28181 文件测试工具
Postman关联
Visio draws Tai Chi
Crazy God said redis notes
Mysql database storage engine
CADD课程学习(7)-- 模拟靶点和小分子相互作用 (柔性对接 AutoDock)
最高法院,离婚案件判决标准
[NOIP2009 普及组] 分数线划定
[Yu Yue education] reference materials of complex variable function and integral transformation of Northwestern Polytechnic University
ISP学习(2)
[Chongqing Guangdong education] engineering fluid mechanics reference materials of southwestjiaotonguniversity
newton interpolation
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