利用matlab求解RE中出现的齐次线性方程组
判断输入的flag时,将flag的每一位当成了未知数带入方程进行计算
一共有32位flag,32个32元1次方程
编写脚本将方程转化成矩阵形式
fd=open('bianl.txt') a=[0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] def getmidstring(html, start_str, end): start = html.find(start_str) if start >= 0: start += len(start_str) end = html.find(end, start) if end >= 0: return str(html[start:end]) def geta(b): num=0 i=0 if('*a' in b): i=0 elif('a1[' in b): i=int(str(getmidstring(b,'[',']'))) if('<<6' in b and '+' in b): num='64' elif('<<6' in b and '-' in b): num='-64' elif('+' in b): num=str(getmidstring(b,'+ ',' *')) elif('- ' in b): num='-'+str(getmidstring(b,'- ',' *')) elif('(' in b): num=str(getmidstring(b,'( ',' *')) if('!=' in b): a[32]=int(getmidstring(b,'!=',' )')) a[i]=num #print(a[i]) while(1): b=fd.readline() #print(a) if('ret' in b): final='' for i in range(0,33): final=final+' '+str(a[i]) print(final+';') a=[0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] elif('a1' in b): geta(b)
存在一点bug,把变量里的0和None手动改一下问题不大
得到的矩阵
导入matlab并化简得到方程的解
>> B=[ XXXXX]; %XXXXX矩阵的具体值,元素之间用空格分隔,行之间用分号分隔% >> format rat >> C=rref(B)
打印出C