当前位置:网站首页>[buuctf.reverse] 121-125
[buuctf.reverse] 121-125
2022-06-25 09:38:00 【Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi】
Catalog
122_[b01lers2020]little_engine
121_[FlareOn2]starter
The first time I saw such a question ,IDA I haven't found anything useful after reading for a long time , Try to run it and find that it is an installer , One will be released after running 32 Bit program . The procedure is very simple , Compare the input XOR directly
BOOL start()
{
int v0; // ecx
HANDLE StdHandle; // [esp+4h] [ebp-Ch]
HANDLE hFile; // [esp+8h] [ebp-8h]
DWORD NumberOfBytesWritten; // [esp+Ch] [ebp-4h] BYREF
StdHandle = GetStdHandle(0xFFFFFFF6);
hFile = GetStdHandle(0xFFFFFFF5);
WriteFile(hFile, aLetSStartOutEa, 0x2Au, &NumberOfBytesWritten, 0);
ReadFile(StdHandle, byte_402158, 0x32u, &NumberOfBytesWritten, 0);
v0 = 0;
while ( ((unsigned __int8)byte_402158[v0] ^ 0x7D) == byte_402140[v0] )
{
if ( ++v0 >= 24 )
return WriteFile(hFile, aYouAreSuccess, 0x12u, &NumberOfBytesWritten, 0);
}
return WriteFile(hFile, aYouAreFailure, 0x12u, &NumberOfBytesWritten, 0);
}So it can be decrypted directly
# Run the program first , After selecting the input file directory, a 32 Bit program and exit , Process generated programs
c = bytes.fromhex('1F08131304220E114D0D183D1B111C0F18501213531E1210')
print(bytes([i^0x7d for i in c]))
#[email protected]
#flag{[email protected]}122_[b01lers2020]little_engine
IDA in main To encrypt and check
__int64 __fastcall main(__int64 a1, char **a2, char **a3)
{
void *vars0[5]; // [rsp+0h] [rbp+0h] BYREF
vars0[3] = (void *)__readfsqword(0x28u);
sub_16B0();
sub_1830((__int64)vars0);
sub_1510((__int64 *)vars0); // Encrypt input
if ( (unsigned __int8)sub_15A0(vars0) )
std::__ostream_insert<char,std::char_traits<char>>(
std::cout,
"Chugga chugga choo choo you're the little engine that CAN!",
58LL);
else
std::__ostream_insert<char,std::char_traits<char>>(
std::cout,
"I guess you don't know anything about trains...go do some TRAINing you non-conductor :(",
87LL);
std::endl<char,std::char_traits<char>>(std::cout);
if ( vars0[0] )
operator delete(vars0[0]);
return 0LL;
}1510 Encryption in
unsigned __int64 __fastcall sub_1510(__int64 *a1)
{
......
v2 = *a1;
if ( *a1 != a1[1] )
{
v3 = 0LL;
v4 = -111;
do
{
v5 = (_BYTE *)(v3 + v2);
......
*v5 ^= v4;
v6 = v4 + v3++;
v2 = *a1;
v4 = v6 + v6 / 0xFF;
}
while ( v3 < a1[1] - *a1 );
}
return __readfsqword(0x28u) ^ v8;
}Not complicated
data = open('engine', 'rb').read()
v4 = -111 & 0xff
t = []
for i in range(75):
t.append( v4^data[0x2220+ 4*i] )
v6 = v4+i
v4 = (v6 + v6//0xff )&0xff
print(bytes(t))
#pctf{th3_m0d3rn_st34m_3ng1n3_w45_1nv3nt3d_1n_1698_buT_th3_b3st_0n3_in_1940}
#flag{th3_m0d3rn_st34m_3ng1n3_w45_1nv3nt3d_1n_1698_buT_th3_b3st_0n3_in_1940}
123_[GKCTF 2021]SoMuchCode
The main program is 2000 That's ok , I'm too lazy to watch it , I saw WP be supposed to xxtea encryption , Because in the SEH, I can't find how to make this one , Found from WP I found one in the library c Program
#include <stdio.h>
#include <stdint.h>
void XXTeaDecrypt(int n, uint32_t* v, uint32_t const key[4])
{
uint32_t y, z, sum;
unsigned p, rounds, e;
uint32_t DELTA = 0x33445566;
rounds = 6 + 52 / n;
sum = rounds * DELTA;
y = v[0];
do {
e = (sum >> 2) & 3;
for (p = n - 1; p > 0; p--)
{
z = v[p - 1];
y = v[p] -= (((z >> 5 ^ y << 2) + (y >> 3 ^ z << 4)) ^ ((sum ^ y) + (key[(p & 3) ^ e] ^ z)));
}
z = v[n - 1];
y = v[0] -= (((z >> 5 ^ y << 2) + (y >> 3 ^ z << 4)) ^ ((sum ^ y) + (key[(p & 3) ^ e] ^ z)));
sum -= DELTA;
} while (--rounds);
}
int main()
{
uint8_t enc_data[] = { 0x5c, 0xab, 0x3c, 0x99, 0x29, 0xe1, 0x40, 0x3f, 0xde, 0x91, 0x77, 0x77, 0xa6, 0xfe, 0x7d, 0x73, 0xe6, 0x59, 0xcf, 0xec, 0xe3, 0x4c, 0x60, 0xc9, 0xa5, 0xc0, 0x82, 0x96, 0x1e, 0x2a, 0x6f, 0x55, 0};
uint32_t key[] = { 14000, 79894, 16, 123123 };
XXTeaDecrypt(8, (uint32_t*)enc_data, key);
puts((char*)enc_data); //9b34a61df773acf0e4dec25ea5fb0e29
return 0;
} 124_[SWPU2019]EasiestRe
This is really complicated , After watching it for a long time, I followed a little tune
This is used here. int3 Dynamic adjustment , Execute to int3 Call the function to modify the code
The procedure involves ini3 There are 3 Time , The first 1 be in main in , The details are as follows int3 It's over , Modify the data here according to the data in the function 7 The byte points to the lower program
Of v16 front 7 A modification sub_408A40 in int3 At the beginning 7 byte , Get call encryption function and check function
.text:00408AF5 89 45 F8 mov [ebp+var_8], eax
.text:00408AF8 CC int 3 ; Trap to Debugger
.text:00408AF9 90 nop
.text:00408AFA 90 nop
.text:00408AFB 90 nop
.text:00408AFC 90 nop
.text:00408AFD 90 nop
.text:00408AFE 90 nop
.text:00408AFF 68 80 1E 4C 00 push offset aYouAreTooShort ; "you are too short!"
.text:00408AF8 90 nop
.text:00408AF9 83 7D F8 18 cmp [ebp+var_8], 18h
.text:00408AFD 7D 11 jge short loc_408B10 Run to the bottom to perform encryption and checking
.text:00408AFD
The first 2 block sub_4087e0 408824 At the beginning 30 byte
The first 3 Block check sub_4083c0 408432 Start 5 byte , No, patch The content of , Down 40845A Start to find the corresponding comparison data 408635 Start for data
408536 This is a ciphertext , Then reverse the procedure , The reverse of multiplication is inverse
iv=0x1234
inv=12 #gmpy2.invert(41,491)
c=[0x3d1,0x2f0,0x52,0x475,0x1d2,0x2f0,0x224,0x51c,0x4e6,0x29f,0x2ee,0x39b,0x3f9,0x32b,0x2f2,0x5b5,0x24c,0x45a,0x34c,0x56d,0xa,0x4e6,0x476,0x2d9]
key=[2,3,7,14,30,57,120,251] #sub_408A40
flag=[]
for i in range(len(c)):
t=c[i]*inv%491
p=""
for i in range(8):
if key[7-i]>t:
p+="0"
else:
p+="1"
t-=key[7-i]
flag.append(int(p[::-1],2))
print(chr((flag[0]^0x1234)&0xff),end="")
for i in range(1,len(flag)):
print(chr((flag[i]^c[i-1])&0xff),end="")
#swpuctf{[email protected]_s0_coo1}
#flag{[email protected]_s0_coo1}125_[QCTF2018]babyre
This is linux Lower dynamic adjustment , Enter a data and follow it , The first treatment is every 4 A sequential exchange of characters , The second time is every 4 Add... Respectively 4 Number , The first 3 The second is that the first and last digits of characters in each group are interchanged . Then compare it with the ciphertext
Get the ciphertext when moving
gdb-peda$ x/32c 0x7ffff781c0a0
0x7ffff781c0a0: 0xda 0xd8 0x3d 0x4c 0xe3 0x63 0x97 0x3d
0x7ffff781c0a8: 0xc1 0x91 0x97 0xe 0xe3 0x5c 0x8d 0x7e
0x7ffff781c0b0: 0x5b 0x91 0x6f 0xfe 0xdb 0xd0 0x17 0xfe
0x7ffff781c0b8: 0xd3 0x21 0x99 0x4b 0x73 0xd0 0xab 0xfe
And then process it back
a=bytes.fromhex("DAD83D4CE363973DC191970EE35C8D7E5B916FFEDBD017FED321994B73D0ABFE")
flag = ''
for i in range(0, len(a), 4):
d1 = a[i]
d1 = (d1>>3)|(d1<<5) & 0xff
d1 = (d1 - 7)& 0xff
d2 = a[i+1]
d2 = (d2>>6)|(d2<<2) & 0xff
d2 = (d2 - 18)& 0xff
d3 = a[i+2]
d3 = (d3>>1)|(d3<<7) & 0xff
d3 = (d3 - 88)& 0xff
d4 = a[i+3]
d4 = (d4>>4)|(d4<<4) & 0xff
d4 = (d4-129)& 0xff
flag+=chr(d2)+chr(d4)+chr(d1)+chr(d3)
print(flag)
#QCTF{Rus4_1s_fun4nd_1nt3r3st1ng}
#flag{Rus4_1s_fun4nd_1nt3r3st1ng}边栏推荐
- Voiceprint Technology (I): the past and present life of voiceprint Technology
- TLAB mechanism of JVM object memory allocation and TLAB process in G1
- Numpy numpy中的meshgrid()函数
- [Ruby on rails full stack course] course directory
- Prepare for the 1000 Android interview questions and answers that golden nine silver ten must ask in 2022, and completely solve the interview problems
- 2、 Training fashion_ MNIST dataset
- [competition -kab micro entrepreneurship competition] KAB National College Students' micro entrepreneurship action participation experience sharing (including the idea of writing the application form)
- Reasons for Meiye to choose membership system
- Is it safe to open an account on the compass?
- Specific usage of sklearn polynomialfeatures
猜你喜欢

微服务调用组件Ribbon底层调用流程分析

瑞吉外卖项目(二)

Remittance international empowers cross-border e-commerce: to be a compliant cross-border payment platform!

CYCA 2022少儿形体礼仪初级师资班 深圳总部站圆满结束

3 big questions! Redis cache exceptions and handling scheme summary

Huipay international permet au commerce électronique transfrontalier de devenir une plate - forme de paiement transfrontalière conforme!

纳米数据世界杯数据接口,中超数据,体育数据比分,世界杯赛程api,足球比赛实时数据接口

Summarize two methods of configuring pytorch GPU environment

Etcd教程 — 第四章 Etcd集群安全配置

首期Techo Day腾讯技术开放日,628等你!
随机推荐
Test Development Engineer
[buuctf.reverse] 121-125
Voiceprint Technology (II): Fundamentals of audio signal processing
Huipay international permet au commerce électronique transfrontalier de devenir une plate - forme de paiement transfrontalière conforme!
What functions should smart agriculture applet system design have
Online notes on Mathematics for postgraduate entrance examination (9): a series of courses on probability theory and mathematical statistics
Data-driven anomaly detection and early warning of item C in the May 1st mathematical modeling competition in 2021
Match a mobile number from a large number of mobile numbers
How to download the school logo, school name and corporate logo on a transparent background without matting
Wallys/MULTI-FUNCTION IPQ6010 (IPQ6018 FAMILY) EMBEDDED BOARD WITH ON-BOARD WIFI DUAL BAND DUAL
Lvs-dr mode single network segment case
Atguigu---17-life cycle
《JVM》对象内存分配的TLAB机制与G1中的TLAB流程
sklearn 高维数据集制作make_circles 和 make_moons
4、 Convolution neural networks
浅谈Mysql底层索引原理
puzzle(019.2)六边锁
matplotlib matplotlib中决策边界绘制函数plot_decision_boundary和plt.contourf函数详解
可穿戴设备或将会泄露个人隐私
SQL高级