Ctf encryption I have done in those years
Recently, ctf has made a lot of work. By the way, I have made some notes, including several articles on encryption, implicit writing, reverse cracking, and web. After these articles are compiled, they will be published one after another. 0x01 Base64 Base64: encoding = Base64 encoding requires that three 8-bit bytes (3*8 = 24) be converted into four 6-bit bytes (4*6 = 24 ), then add two zeros before the six bits to form the 8-bit one-byte format. If the remaining characters are less than three bytes, fill them with 0 and use '=' for output characters. Therefore, one or two '=' Base32 characters may appear at the end of the encoded text: the difference between Base32 and Base64 is that 32 characters are used to represent 256 ASC characters, that is, a group of five ASC characters can generate 8 Base characters, and vice versa. Online codec: http://base64.xpcha.com/0x02 Hill password: ciphertext: 22,09, 03,01, 10, 03, 04,08, 01,17 (plaintext: wjamdbkdeibr) Problem-Solving ideas: the matrix used is 1 2 3 4 5 6 7 8 10 Baidu Encyclopedia: http://baike.baidu.com/link? Url = 0x03 fence password: divide the plaintext to be encrypted into N groups, and then connect the 1st words in each group to form an irregular line. Example of ciphertext: tn c0afsiwal kes, hwit1r g, nuclear protocol ttessfu} ua u hmqik e {m, n huiouosarwCniibecesnren. decryption program:
char s[]= "tn c0afsiwal kes,hwit1r g,npt ttessfu}ua u hmqik e {m, n huiouosarwCniibecesnren."; char t[86]= ""; int i,j,k;k=0;for (i=0;i<17;i++) { for(j=0;j<5;j++) { t[k++]= ch[j*17+i]; } } for(i=0;i<85;i++){ printf("%c",t[i]);}
0x04 Caesar password: implement encryption and decryption by moving letters to a certain number of digits. All letters in plain text are offset backward (or forward) in the alphabet by a fixed number and replaced with a ciphertext. Ciphertext example: U8Y]: 8 KdJHTXRI> XU #?! K_ecloud] kJG * brh7yjpolicysh] * = 93dVZ3 ^ S8 * $: 8 "&: 9U] RH; g = 8Y! U92' = j * $ KH] ZSj & [S #! GU # * dK9 \. Solution: after learning that it was Caesar's encryption, try to perform 127 round robin blasting: lstr = "" U8Y]: 8 KdJHTXRI> XU #?! K_ecloud] kJG * brh7yjpolicysh] * = 93dVZ3 ^ S8 * $: 8 "&: 9U] RH; g = 8Y! U92' = j * $ KH] ZSj & [S #! GU # * dK9 \."""
for p in range(127): str1 = '' for i in lstr: temp = chr((ord(i)+p)%127) if 32<ord(temp)<127 : str1 = str1 + temp feel = 1 else: feel = 0 break if feel == 1: print(str1)
0x05 Unicode ciphertext example: \ u5927 \ Users \ u597d \ Users \ u6211 \ u662f \ u0040 \ u65e0 \ u6240 \ Users \ u80fd \ u7684 \ u9b42 \ u5927 \ u4eba \ uff01 \ Users \ u7c89 \ u4e1d \ u8fc7 \ online decryption: tool.chinaz.com/Tools/Unicode.aspx 0x06 brainfuck type: ++ [++ <-]> ++.> +. ++ .. ++.> ++. <++...>. ++. ------. --------.> +.> .use bfvm.exe for direct decryption usage loadtxt 1.txt for online decryption: http://www.splitbrain.org/services/ook 0x07 example of moss password ciphertext :-----.-..... http://www.jb51.net/tools/morse.htmhttp://msjm.yinxiulei.cn/0x08 Jsfuck password () [] {}! + Online decryption: www.jsfuck.com http://patriciopalladino.com/files/hieroglyphy/0x09 The password used by Bacon is essentially a binary number. However, he uses a and B instead of 0 and 1. Encyclopedia: http://baike.baidu.com/link?url=acaeI3babB7MogPQFh98rDAVSwHfPwh-HnEFTb9cx7DZ5Nz4MkMA14H4SDjBNnOdBsJpliNYa1vnfikQGqvA7K 0x0A pigsty password, also known as the Masonic password, Baidu Encyclopedia: http://baike.baidu.com/link?url=yN39kWG2pGd9XHo3RjeUAbd7xs0QlnJ2uHzCJfxC03V-fJcQUdfcJ-WuGoAkKGFVE0AxFK4-98wa4FtzvxRA0_ 0x0B CRC32 ciphertext example: 4D1FAE0B
import zlibdef crc32(st): crc = zlib.crc32(st) if crc > 0: return "%x" % (crc) else: return "%x" % (~crc ^ 0xffffffff)