Author: JiJi, XiaoZhuo, Accelerat0r. All rights reserved.
Reverse
Welcome To Re!
下载得到一个 Signin.zip 的压缩包,解压后找到ELF文件,用ida64反编译后得到
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int __cdecl main(int argc, constchar **argv, constchar **envp) { char s2[8]; // [rsp+0h] [rbp-70h] char s1; // [rsp+30h] [rbp-40h] unsigned __int64 v6; // [rsp+68h] [rbp-8h] v6 = __readfsqword(0x28u); strcpy(s2, "moectf{W3lc0me-T0_th3-W0rld_Of_R3v3rsE!}"); puts("Welcome to MoeCTF! --by Reverier\nPlease Input your flag and I will check it:"); __isoc99_scanf("%41s", &s1); if ( !strcmp(&s1, s2) ) puts("Congratulations!"); else puts("Ruaaaaaaaaaaaaa~~~Wrong!"); return0; }
因此flag为 moectf{W3lc0me-T0_th3-W0rld_Of_R3v3rsE!}
Thank you JavaScript
在 Fxckit.js 发现如下代码
1
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1;};while(c--)if(k[c])p=p.replace(newRegExp('\\b'+e(c)+'\\b','g'),k[c]);return p;}('l 1=m(\'k-4-2\');i j 6(){1.2(\'q r p --n o b\');1.2(5 1.4());1.2(`a ${5 1.d(\'9 h e?\')}!`);f 3=g;F(!3){1.2(\'D E 7 B 8:\');3=5 1.4()===\'G{H\'+\'c\'+\'v\'+\'w\'+\'0\'+\'u-\'+\'s\'+\'t\'+\'z\'+\'A\'+\'!}\'}1.2(\'y! x C 7 8!\')}6();',44,44,'|io|write|saidHi|read|await|main|the|flag|Who|Hello|Reverier||ask|you|let|false|are|async|function|console|const|require|written|by|ThankYouJavaScript|MoeCTF|2020|Jav|aS||k_|Y|You|Congratulations|cr|ipt|true|find|Please|input|while|moectf|Fx'.split('|'),0,{}))
目测应该是经过了js混淆,尝试解析混淆代码
1
const io=require('console-read-write');asyncfunctionmain(){io.write('MoeCTF 2020 ThankYouJavaScript --written by Reverier');io.write(await io.read());io.write(`Hello ${await io.ask('Who are you?')}!`);let saidHi=false;while(!saidHi){io.write('Please input the true flag:');saidHi=await io.read()==='moectf{Fx'+'c'+'k_'+'Y'+'0'+'u-'+'Jav'+'aS'+'cr'+'ipt'+'!}'}io.write('Congratulations! You find the flag!')}main();
key = [115, 76, 50, 116, 90, 50, 116, 90, 115, 110, 48, 47, 87, 48, 103, 50, 106, 126, 90, 48, 103, 116, 126, 90, 85, 126, 115, 110, 105, 104, 35] print('Input your flag: ', end='') flag = input() out = [] for i in flag: out.append((ord(i) >> 4) ^ ord(i))
iflen(out) != len(key): print('TRY AGAIN!') exit() for i inrange(len(out)): if out[i] != key[i]: print('TRY AGAIN!') exit() print('you are right! the flag is : moectf{%s}' % flag)
import base64 flag = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX" xor = ? print(len(xor)) print(base64.b64encode(("".join([chr(ord(i)^ord(xor)) for i inlist(flag)])).encode("ASCII")))
为描述更加清晰,翻译成以下函数形式
1 2 3 4 5 6
defenc(flag, xor): tmp = "" for i inlist(flag): tmp += chr(ord(i)^ord(xor)) result = base64.b64encode(tmp.encode("ASCII")) return result
根据encode方法,很容易写出来decode方法
1 2 3 4 5 6
defdec(src, xor): tmp = base64.b64decode(src).decode("ASCII") flag = "" for i inlist(tmp): flag += chr(ord(i)^ord(xor)) return flag
p = 702642074436764837683441695539 table=[609157021623541347403691228214, 296649570588624720860438742570, 56199496972820506761619039889, 95133897800551968959628311224] a = 1086077784009247 b = 862805818180723 for p2 in table: for i inrange(0, 20000): p3 = (p2 + p * i) - b p4 = p3 % a if p4 == 0: m = p3 // a s='' for i inrange(32, 127): s += chr(m % 256) m = (m - m % 256) // 256 for i inrange(len(s)-1, -1, -1): iford(s[i])>32andord(s[i])<127: print(s[i], end="")
from gmpy2 import * from Crypto.Util.number import *
c = 12786994906832886031173089454539830225421640443805160963440942546071910322282773910135388020414967368794768319321460372875327006020157548651622969466323905189761834455201291838045352561790791600881627927594863932384116760236609096504346833060291203939690475993692410973499329433726175351882818053841075210942250478835641657575946226612389154039920962506062857726362447590070697348315291411570674334126096132112365825105842643843896421848410966564321518660727994853036555116782763422065173850238826345797198901647320210828033061322523971939726188821545177029535860881611210887039411052848607563035583276075332653567834 p = 161719691876167304386300539654699854745688262478039691942271426308613132466937889105173933022986654040443219708318126579048996288583272346602042650222520127626611975688909019632479930508343350314542889627461529623000987307169157443265879212155437165660477850241678385286601587538517091605374764970915451201471 q = 131679150542057883837006988923642169851011066771905140540444762603374903776910595387305441746623070810587630852182725227845916400198693359271062585498062084740896090668288333576457754165324164735966791029516030696195703650691726650990903496820364700241229117883279657833543807874786274886417501405960125022153 n = 21295111652177049852547386222656846645616549922902112221240647622752994625687294739828756977846793220378085163155773051922086862363248151399852421844018730199066331944608000906761112010951655369036878807145188296884981895884278542857120225505310980291226351653588799242142355376939447934804833830853036785704513557039806761305316841740131204576974408869765714675230132247412774215945663807730855436503625577606009921411947891570324777735323489304604987902364932089976811865007609745513534209603256719511305317200247134396733168695387708420206468160279271453425776388025425790010391137010735121696446552257334341187063 e = 65537
d = invert(e, (p-1) * (q-1)) flag = long_to_bytes(pow(c, d, n))
defenc(plain , nlist , e): m = padding(plain) c = [] for i inrange(len(m) // 8): c.append(enc_block(bytes_to_long(m[i*8:i*8+8]) , nlist[i%len(nlist)] , e)) return c
defdec(clist , nlist , e): m = b'' for i inrange(len(clist)): m += long_to_bytes(pow(clist[i] , invert(e , phi(nlist[i%len(nlist)])) , nlist[i%len(nlist)])) return m
defphi(x): if x == p: return p-1 if x == q: return q-1 if x == r: return r-1 if x == p*p: return p*(p-1) if x == p*q: return (p-1)*(q-1) if x == q*r: return (q-1)*(r-1) if x == p*p*r: return p*(p-1)*(r-1) if x == p*q*r: return (p-1)*(q-1)*(r-1) if x == q*q*q*p*r: return q*q*(q-1)*(p-1)*(r-1)
DECIMAL HEXADECIMAL DESCRIPTION -------------------------------------------------------------------------------- 0 0x0 PNG image, 933 x 812, 8-bit/color RGB, non-interlaced 515662 0x7DE4E Zip archive data, at least v2.0 to extract, compressed size: 92, uncompressed size: 416, name: fk u.txt 515882 0x7DF2A End of Zip archive, footer length: 22
123456[]()+! luoq1an recommended a new language to arttnba3 and the following text is the first programme written by him but something may not be right...
if (strpos($xmlfile,"flag1.txt") !== FALSE){ if (strpos($xmlfile,'file:/') === FALSE){ die("Please use file protocol.<br/><br/>"); } } if (strpos($xmlfile,"flag2.php") !== FALSE){ if (strpos($xmlfile,'file:/') !== FALSE){ echo"Why not try php://filter?"; echo'<br/><br/>'; } }
See this to show that the connection is successful! Continue...
Please fill me up~ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA *** stack smashing detected ***: ################################## Great! Take your flag: moectf{W3lc0m3_t0_tH3_w0r1d_0f_PWN!} ##################################
import random flag = 'moectf{xxxxxxxxxxx}' digit = '' for i in flag: digit += str(ord(i)) i = 0 while i < len(digit): n = random.randint(0, 128) iford('a') <= n <= ord('z') orord('A') <= n <= ord('Z'): digit = digit[0:i] + chr(n) + digit[i:] i += 1 withopen('puzzle.txt', 'w') as out: out.write(digit)
import re from os import path defcheck(filepath): length = 0 todo = open(path.dirname(__file__) + "\\" + filepath, "r") status = todo.read(8) if(status[7] == '!'): value = todo.read() pattern = re.compile(r'[A-Za-z0-9]+') result = pattern.findall(value) length = len(result) todo.close() return length paths = [...] # 路径列表 sum = 0 for i in paths: sum += check(i) print(sum)
获取路径列表可使用
1 2 3 4 5 6 7 8 9
import os defget_file(root_path,all_files=[]): files = os.listdir(root_path) for file in files: ifnot os.path.isdir(root_path + '\\' + file): # not a dir all_files.append(root_path + '\\' + file) else: # is a dir get_file((root_path+'\\'+file),all_files) return all_files
根据 A gcjh, A wct, L uspnxwvga. 可能是凯撒大帝的名言 I came, I saw, I conquered. 因此根据密码矩阵对密码,对出来是 secxd ,也用以解密flag得 I came, I saw, I conquered. moectf{s0_whaT_s-N3xt?}