IK&N Internal Cryptography Exercises (1)

foreword

The 100th article will be out of water, please write it carefully

But the bull still has to blow:

CSDN内容合伙人、2023年新星计划web安全方向导师、
华为MindSpore截至目前最年轻的优秀开发者、IK&N战队队长、
阿里云专家博主、华为网络安全云享专家、腾讯云自媒体分享计划博主

Question 1: I love pomegranates

The original title comes from ctfshow

It's so kind, he told us the encryption method directly through homophonic.

He really, I cry to death

pomegranate==16

Just convert the hexadecimal to a string directly

Hexadecimal conversion, hexadecimal conversion text string, online hexadecimal conversion | Online tool

 But this question is not prompted on ctfshow. How should we think about this question?

Here are the characteristics of hexadecimal :

  • Base: The base of the hexadecimal number is 16, that is, any number between 0 and 15 can be placed in each position.

  • Number representation: Hexadecimal numbers use a total of 16 characters from 0 to 9 and A to F (or a to f) to represent numbers, where A to F (or a to f) represent 10 to 15. For example, B6C3 in hexadecimal is equivalent to 46723 in decimal.

Question 2: Is it true that Hongzhong eats bacon every day6

topic

4142414141414241424142414241414142424142424142424142414141414241424141414141414141424241424142424142414241414141424241414141424141414242414241424142424142414141424241414241414242424142414141

It's true at a glance, Bacon password, and the title is also prompted

Take the tool directly to decrypt it

 Can't figure it out, what's the difference after thinking about it.

The Bacon cipher algorithm is as follows:

  1. Plaintext processing: convert letters in plaintext strings to uppercase letters, and remove non-alphabetic characters such as spaces and punctuation marks.

  2. Binary encoding: convert each letter into a 5-digit binary number, where A represents 00000, B represents 00001, C represents 00010, and so on, until Z represents 11010. For example, the binary code for the letter A is 00000 and the binary code for the letter B is 00001.

  3. Ciphertext generation: the binary code of each letter is represented by A and B, where 0 represents A and 1 represents B. For example, the binary code 00000 of the letter A can be represented as AAAAA, and the binary code 00001 of the letter B can be represented as AAAAB.

  4. Ciphertext output: output the ciphertext string, in which every five letters correspond to the binary code of a plaintext letter.

If it is bacon, it should be in the form of AB, then this is the form of bacon that needs to be decrypted again

think about topic hints

is true 6

is 6

16

hey hey

 then run straight to the bacon

ikun{woquannimenlizhi}

Question 3: Little Heizi hits the website

topic

oq%2526t%257h%25k5%25h0%258l%25k9%25hh%2591%25k5%25gj%2590%25k6%25g0%2591%25k6%259k%259j666%257j

One thimble, two URLs + Caesar, the key is 6

import urllib.parse

# 经过两次URL编码的密文字符串
encoded_str = "oq%2526t%257h%25k5%25h0%258l%25k9%25hh%2591%25k5\
               %25gj%2590%25k6%25g0%2591%25k6%259k%259j666%257j"

# 两次URL解码得到原始密文
ciphertext = urllib.parse.unquote(urllib.parse.unquote(encoded_str))

# 密钥
key = 6

# 解密过程:将每个字符向左(或向右)移动6个位置
plaintext = ''
for c in ciphertext:
    if c.isalpha():
        new_c = ord(c) - key
        if c.isupper() and new_c < ord('A'):
            new_c += 26
        elif c.islower() and new_c < ord('a'):
            new_c += 26
        plaintext += chr(new_c)
    else:
        plaintext += c

# 去除明文字符串中的噪音字符
plaintext = plaintext.replace('_and_', ' ').replace('_', '')

# 在明文字符串中添加大括号{}
plaintext = 'ik&n{' + plaintext + '666}'

print(plaintext)

Guess you like

Origin blog.csdn.net/m0_55400802/article/details/129991500