欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 手游 > [CTF]-Reverse:Reverse做题笔记

[CTF]-Reverse:Reverse做题笔记

2024/11/30 5:40:13 来源:https://blog.csdn.net/2301_79326813/article/details/141473878  浏览:    关键词:[CTF]-Reverse:Reverse做题笔记

Tea:

[HNCTF 2022 WEEK2]TTTTTTTTTea:

找出关键数据,运行脚本

#include <stdio.h>
int main(){unsigned int l,r;unsigned int v4[6]={-1054939302,-1532163725,-165900264,853769165,768352038,876839116};int flag[6]={0};unsigned int delta;unsigned int key[4]={0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f};int i,j;for(i=0;i<6;i+=2){l=v4[i];r=v4[i+1];delta=-32*1640531527;for(j=0;j<32;j++){r -= (((l >> 5) ^ (l*16)) + l) ^ (key[(delta>>11)&3]+ delta);//*16==<<4 delta += 1640531527;l -= (((r >> 5) ^ (r*16)) + r) ^ (key[delta&3]+ delta);}flag[i]=l;flag[i+1]=r;}char *p = (char*)flag;for(i=0;i<24;i++){printf("%c",*p);p++;}
}

[MoeCTF 2022]ezTea:

运行脚本

#include <stdio.h>
#include <stdint.h>void encrypt (uint32_t* v, uint32_t* k) {                       // 主要加密函数,试着搞定它uint32_t v0 = v[0], v1 = v[1], sum = 0;uint32_t delta = 0xd33b470;for (int i = 0; i < 32; i++) {sum += delta;v0 += ((v1<<4) + k[0]) ^ (v1 + sum) ^ ((v1>>5) + k[1]);v1 += ((v0<<4) + k[2]) ^ (v0 + sum) ^ ((v0>>5) + k[3]);}v[0] = v0;v[1] = v1;
}void decrypt(uint32_t* v, uint32_t* k) {uint32_t v0 = v[0], v1 = v[1], sum = 0xd33b470*32, i;uint32_t delta = 0xd33b470;uint32_t k0 = k[0], k1 = k[1], k2 = k[2], k3 = k[3];for (i = 0; i<32; i++) {v1 -= ((v0 << 4) + k2) ^ (v0 + sum) ^ ((v0 >> 5) + k3);v0 -= ((v1 << 4) + k0) ^ (v1 + sum) ^ ((v1 >> 5) + k1);sum -= delta;}v[0] = v0; v[1] = v1;
}int main() {uint32_t k[4] = {1, 2, 3, 4};int8_t input[33] = {0x17, 0x65, 0x54, 0x89, 0xed, 0x65, 0x46, 0x32, 0x3d, 0x58, 0xa9, 0xfd, 0xe2, 0x5e,
0x61, 0x97, 0xe4, 0x60, 0xf1, 0x91, 0x73, 0xe9, 0xe9, 0xa2, 0x59, 0xcb, 0x9a, 0x99,
0xec, 0xb1, 0xe1, 0x7d};//scanf("%32s", input);for (int i = 0; i < 32; i+=8) {uint32_t v[2] = {*(uint32_t *)&input[i], *(uint32_t *)&input[i+4]};decrypt(v, k);for (int j = 0; j < 2; j++) {                           // 这一段主要是把 v 按单字节输出,另外可以了解一下 “大小端序” 在这题是如何体现的for (int k = 0; k < 4; k++) {printf("%c", v[j] & 0xff);v[j] >>= 8;}}}return 0;
}

[HGAME 2023 week1]a_cup_of_tea:

#include <stdio.h>
#include <string.h>
#include <emmintrin.h>
#include <stdint.h>void decrypt(unsigned int *v, unsigned int *k) {unsigned int v0 = v[0],v1 = v[1];int delta = -1412567261;int sum =delta*32;unsigned int k0 = k[0],k1 = k[1],k2 = k[2],k3 = k[3];for (int i = 0; i < 32; i++) {v1 -= ((v0 << 4) + k2) ^ (v0 + sum) ^ ((v0 >> 5) + k3);v0 -= ((v1 << 4) + k0) ^ (v1 + sum) ^ ((v1 >> 5) + k1);sum -= delta;}v[0] = v0;v[1] = v1;
}int __cdecl main() {int Buf2[8];unsigned int key[] = {0x12345678, 0x23456789, 0x34567890, 0x45678901};Buf2[0] = 778273437;Buf2[1] = -1051836401;Buf2[2] = -1690714183;Buf2[3] = 1512016660;Buf2[4] = 1636330974;Buf2[5] = 1701168847;Buf2[6] = -1626976412;Buf2[7] = 594166774;char buf[50] = {0};memcpy(buf, Buf2, sizeof Buf2);for(int i=0;i<=6;i+=2){decrypt((unsigned int *)&buf+i, key);}printf("%s", buf);return 0;
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com