Switch Editions?
Cancel
Sharing:
Title:
URL:
Channel: CodeSection,代码区,网络安全 - CodeSec
Viewing all articles

# 单表代换加密

0
0

JPK，可解带密钥与不带密钥 http://planetcalc.com/1434/ http://www.qqxiuzi.cn/bianma/ROT5-13-18-47.php 移位密码

Atbash Cipher 原理

a 对应 p，d 对应 h，以此类推。

$x$ 表示明文按照某种编码得到的数字 $a$ 和 $m$ 互质 $m$ 是编码系统中字母的数目。

$$\phi(26)=\phi(2) \times \phi(13) = 12$$

$$12 \times 26 = 312$$

$$y_1=(ax_1+b)\pmod{26} \\ y_2=(ax_2+b)\pmod{26}$$

$$y_1-y_2=a(x_1-x_2)\pmod{26}$$

import sys key = '****CENSORED***************' flag = 'TWCTF{*******CENSORED********}' if len(key) % 2 == 1: print("Key Length Error") sys.exit(1) n = len(key) / 2 encrypted = '' for c in flag: c = ord(c) for a, b in zip(key[0:n], key[n:2*n]): c = (ord(a) * c + ord(b)) % 251 encrypted += '%02x' % c print encrypted

\begin{align*} c_1&=a_1c+b_1 \\ c_2&=a_2c_1+b_2 \\ &=a_1a_2c+a_2b_1+b_2 \\ &=kc+d \end{align*}

import gmpy key = '****CENSORED****************' flag = 'TWCTF{*******CENSORED********}' f = open('encrypted', 'r') data = f.read().strip('\n') encrypted = [int(data[i:i + 2], 16) for i in range(0, len(data), 2)] plaindelta = ord(flag[1]) - ord(flag[0]) cipherdalte = encrypted[1] - encrypted[0] a = gmpy.invert(plaindelta, 251) * cipherdalte % 251 b = (encrypted[0] - a * ord(flag[0])) % 251 a_inv = gmpy.invert(a, 251) result = "" for c in encrypted: result += chr((c - b) * a_inv % 251) print result

TWCTF2016-super_express git:(master) python exploit.py TWCTF{Faster_Than_Shinkansen!}

Viewing all articles

### 关于整容的泰语表达，学习一下吧~

More Pages to Explore .....