@staticmethod defLetterCase(strings): res = [] for i inrange(1 > j) & 1else s.upper() j += 1 res.append(word) return res
@staticmethod defWordCombination(word): res = [] for i inrange(1 > j) & 1else s j += 1 res.append(word) return res
# Name name = raw_input().split(' ') _name = list() _name.append(name[0]) _name.append(''.join(name[1:])) _name += Permutations.WordCombination(name) name = list() for n in _name: name += Permutations.LetterCase(n)
print'[*]Generating cache...' if length == 7: ranges1 = 0x3fffffff ranges2 = 0x10000000 elif length == 6: ranges1 = 0x3ffffff ranges2 = 0x1000000 elif length == 5: ranges1 = 0x3fffff ranges2 = 0x100000 elif length == 4: ranges1 = 0x3ffff ranges2 = 0x10000 elif length == 3: ranges1 = 0x3fff ranges2 = 0x1000 elif length == 2: ranges1 = 0x3ff ranges2 = 0x100 for i in xrange(ranges1): # for i in xrange(0xfffff): # for i in xrange(0x4fffff): # 700MB + RAM # for i in xrange(0x3fffff): # 480MB + RAM s = a % i sub_hash = md5(s).hexdigest()[ran1:ran2] cache_dict[sub_hash] = s print'[*]Done.'
print'[*]Writing to disk...' withopen(filename, 'wb') as f: miss = '*' * (length + 1) miss = '%s ' + miss + 'n' for i in xrange(ranges2): k = b % i if cache_dict.has_key(k): f.write('%s %sn' % (k, cache_dict[k])) else: f.write(miss % k) print'[*]Done.' print'[*]Saved as '%s' at current directory.' % filename del cache_dict
result = '' i = 0 while i < len(dic): payload = payload1 % (result + dic[i]) print payload ret = requests.get(url+payload) if'When'in ret.content: result += dic[i] print'[+] ' + result i = 0 else: i += 1
这次是被用摩斯电码加密了,也是直接解密即可,注意 flag 中所有的字符都是大写(莫斯电码不区分大小写)
flag{BABYMORSECODE}
RSA (150)
1 2 3 4 5 6 7
RSA is based on a simple formula, let's do a math problem. c = 150815 d = 1941 N = 435979 what is the decrypted number?
Hint: flag's format is flag{decrypted number}
这个题只是考察了 RSA 的解密公式decrypted = c ^ d mod N。另外在 RSA 体系中,m、c、d、e、n 这些的含义大都是固定的,随便找几篇文章就能懂。最后结果为 133337
flag{133337}
RSA2 (250)
1 2 3 4 5 6
This puzzle are different from the previous puzzle, what's the "dq" and "dp"? Can you decrypt the ciphertext? c: 95272795986475189505518980251137003509292621140166383887854853863720692420204142448424074834657149326853553097626486371206617513769930277580823116437975487148956107509247564965652417450550680181691869432067892028368985007229633943149091684419834136214793476910417359537696632874045272326665036717324623992885 p: 11387480584909854985125335848240384226653929942757756384489381242206157197986555243995335158328781970310603060671486688856263776452654268043936036556215243 q: 12972222875218086547425818961477257915105515705982283726851833508079600460542479267972050216838604649742870515200462359007315431848784163790312424462439629 dp: 8191957726161111880866028229950166742224147653136894248088678244548815086744810656765529876284622829884409590596114090872889522887052772791407131880103961 dq: 3570695757580148093370242608506191464756425954703930236924583065811730548932270595568088372441809535917032142349986828862994856575730078580414026791444659
和上一道题相比没有了 d 以及 n,多了 dp 和 dq,题目描述中也问了什么是 dp 以及 dq,它们与中国剩余定理算法相关
p 和 q 是素数
dp = d mod (p - 1)
dq = d mod (q - 1)
qInv = (1/q) mod p (1/q 为 q 的乘法逆元)
m1 = c^dp mod p
m2 = c^dq mod q
h = qInv * (m1 - m2) mod p
m = m2 + h * q
现在直接按照上述步骤计算即可,p、q、dp、dq 与 c 均已知,最后就能直接算出明文 m,另外上述步骤中的 qInv 是模逆的
defegcd(a, b): if a == 0: return (b, 0, 1) else: g, y, x = egcd(b % a, a) return (g, x - (b // a) * y, y)
defmodinv(a, m): g, x, y = egcd(a, m) if g != 1: raise Exception('modular inverse does not exist') else: return x % m
c = 95272795986475189505518980251137003509292621140166383887854853863720692420204142448424074834657149326853553097626486371206617513769930277580823116437975487148956107509247564965652417450550680181691869432067892028368985007229633943149091684419834136214793476910417359537696632874045272326665036717324623992885 p = 11387480584909854985125335848240384226653929942757756384489381242206157197986555243995335158328781970310603060671486688856263776452654268043936036556215243 q = 12972222875218086547425818961477257915105515705982283726851833508079600460542479267972050216838604649742870515200462359007315431848784163790312424462439629 dp = 8191957726161111880866028229950166742224147653136894248088678244548815086744810656765529876284622829884409590596114090872889522887052772791407131880103961 dq = 3570695757580148093370242608506191464756425954703930236924583065811730548932270595568088372441809535917032142349986828862994856575730078580414026791444659
qinv = modinv(q, p) m1 = pow(c, dp, p) m2 = pow(c, dq, q) h = (qinv * (m1 - m2)) % p m = m2 + h * q m_hex = str(hex(m))[2:-1] print''.join([chr(int(''.join(c), 16)) for c inzip(m_hex[0::2], m_hex[1::2])])
最后结果为Theres_more_than_one_way_to_RSA
flag{Theres_more_than_one_way_to_RSA}
RSA3
1 2 3 4 5 6 7 8 9
Normally, you pick e and generate d from that. What appears to have happened in this case? What is likely about the size of d?
Update: Fixed bug of flag.
Notice: Please DO NOT use any RSA tools, solve this challenge by yourself.
e = 165528674684553774754161107952508373110624366523537426971950721796143115780129435315899759675151336726943047090419484833345443949104434072639959175019000332954933802344468968633829926100061874628202284567388558408274913523076548466524630414081156553457145524778651651092522168245814433643807177041677885126141 n = 380654536359671023755976891498668045392440824270475526144618987828344270045182740160077144588766610702530210398859909208327353118643014342338185873507801667054475298636689473117890228196755174002229463306397132008619636921625801645435089242900101841738546712222819150058222758938346094596787521134065656721069 c = 169391604307213974710597693248166863262635321820709182280694059296079676696460036420655604420049971304712550027666676719989641872790226627271230072009450546099425697330508459430999175828530558172413805218170859212369467798719828240031394421896121823803700024559680572528969880625457942316782819682826344683732
如果硬刚这到题的话,尝试直接分解 n,可以发现 n 是非常难分解的,但是题目描述中重点强调了 d 的大小,那么可能和 Wiener’s Attack 有关
当 *d < 1/3 * N ^ (1/4)* 时,可以用 Wiener’s Attack 获取私钥 d
在生成私钥的时候,d 是根据 e 而获得的,当 e 过大或者过小的话,可以利用低解密指数攻击快速分解 n,获得 d 和 m。具体算法以及证明过程见 低解密指数攻击
flag{Are_any_RSA_vals_good_87768438250}
REVERSE
what is IDA? (150)
1 2 3
我有一个 exe,你能找到 flag 吗?
提示: IDA pro 6.8 以上版本
下载一个 IDA pro,用 IDA(64 位)载入该程序。反汇编 main 函数,只有个 Ha Ha Ha