Welcome to Hackcon 2017. This is organised by a couple of students from IIIT Delhi, along with our techfest esya.
Some of us are organising our first CTF, have fun and let us know how it was.
$ curl http://esya.iiitd.edu.in/ | grep d4rk % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 2 52017 2 1193 0 0 1835 0 0:00:28 --:--:-- 0:00:28 1835 <!----The flag is d4rk{w3lc0m3_t0_35y4_2017}c0de---->
File is a long hex string, we must xor it to decode it:
$ xortool -x file.txtThe most probable key lengths: 2: 11.8% 6: 19.8% 8: 9.2% 12: 14.8% 14: 6.9% 18: 11.1% 20: 5.3% 24: 8.6% 30: 6.9% 36: 5.6%Key-length can be 3*nKey-length can be 4*nKey-length can be 6*nMost possible char is needed to guess the key!$ xortool -x -l 6 -o file.txt && grep -ri d4rk xortool_out100 possible key(s) of length 6:rxqbqdsypcpepzs`sfq{rargv|ufu`...Found 58 plaintexts with 95.0%+ printable charactersSee files filename-key.csv, filename-char_used-perc_printable.csvxortool_out/94.out:and maces, the Asuras in large numbers vomited blood and lay prostrate on the earth. Cut off from the trunks with sharp double-edged swords, heads adorned with bright gold, fell continually on the field of battle. Their bodies drenched in gore, the great Asuras lay dead everywhere. It seemed as if red-dyed mountain peaks d4rk{Try_r34ding_mahabharata_s0met1me}c0de lay scattered all around. And when the Sun rose in his splendour, thousands of warriors struck one another with weapons. And cries of distress were heard everywhere. The warriors fighting at a distance from one another brought one another down by sharp iron missiles, and those fighting at close quarters slew one another with blows of their fists. And the air was filled with shrieks of distress. Everywhere were heard the alarming sounds,--'cut', 'pierce', 'at them', 'hurl down', 'advance'.
#!/usr/bin/pythonfrom sympy.solvers import solvefrom sympy import Symboldefpartial_quotiens(x, y): pq = []while x !=1: pq.append(x / y) a = y b = x % y x = a y = b#print pqreturn pqdefrational(pq): i =len(pq) -1 num = pq[i] denom =1while i >0: i -=1 a = (pq[i] * num) + denom b = num num = a denom = b#print (num, denom)return (num, denom)defconvergents(pq): c = []for i inrange(1, len(pq)): c.append(rational(pq[0:i]))#print creturn cdefphiN(e, d, k):return ((e * d) -1) / k# e = 17993# n = 90581# wiener_attack(e, n) --> p = 239, q = 379e =49446678600051379228760906286031155509742239832659705731559249988210578539211813543612425990507831160407165259046991194935262200565953842567148786053040450198919753834397378188932524599840027093290217612285214105791999673535556558448523448336314401414644879827127064929878383237432895170442176211946286617205n =109676931776753394141394564514720734236796584022842820507613945978304098920529412415619708851314423671483225500317195833435789174491417871864260375066278885574232653256425434296113773973874542733322600365156233965235292281146938652303374751525426102732530711430473466903656428846184387282528950095967567885381pq =partial_quotiens(e, n)c =convergents(pq)x =Symbol('x')for (k, d) in c:if k !=0: y = n -phiN(e, d, k) +1 roots =solve(x**2- y*x + n, x)iflen(roots) ==2: p = roots[0] q = roots[1]if p * q == n:print'p = ', pprint'q = ', qbreak