# Cryptography experiment report

The author participated in an experimental report assignment of network attack and defense innovation practice course in freshman and primary school, which is a pure entry level

## Experimental objectives

### Part I

The following ciphertext is encrypted with classical password. Please identify and write the encryption type of the following ciphertext.

1. tsrlnhiafcisiee

2. wklvlvfdvhu

3. BAABBAABBBABAAABAABAABAAABAABAAAAABAAAAAAAABAABBBAABBABABAAAAAAAAABBAB

### Part II

The following is the data in RSA encryption. Please try to identify the available attack methods, write the decryption ideas, and write the corresponding python script.

c = 11236059610940155040515420815459088108548438695111162676979740370803612682449595975315521615456835907246170497671938930521670240256368063

e = 3

n = 123814470394550598363280518848914546938137731026777975885846733672494493975703069760053867471836249473290828799962586855892685902902050630018312939010564945676699712246249820341712155938398068732866646422826619477180434858148938235662092482058999079105450136181685141895955574548671667320167741641072330259009


## Detailed steps

### Part I

Decryption tool website: http://ctf.ssleye.com/

Website 2: http://www.metools.info/code/

#### 1. Fence password basic type

• The third bacon password is decrypted to have this is, and then blindly guesses that there is this is in it. After removing this is, there is still rlniafcee

• Then I found that thisis was placed in various places of this string of characters, so I guess it is the fence password. Then, because t and h are the first and sixth respectively, with a difference of 5, I guess it is 5 columns, so the five are divided into a group:

tsrln
hiafc
isiee

• Then the decryption result is:

thisisrailfence


#### 2. Caesar code

• First do the third bacon password, decrypted out this is

• Then blindly guess that there is this is in it, and then see the same as lvlv. It must be th isis. Maybe this is the password of displacement. i to l move two digits back, and so is s to v

• That's it. Move two people to get the answer:

thisiscaser


According to the characteristics that they are all A and B, it can be judged that they are bacon passwords. According to the rule table, the decryption result is:

thisisbaconian


### Part II

Introduction to RSA encryption: https://www.jianshu.com/p/9f7905f2c2a3

#### 1. Search tutorial

First, I searched many tutorials without thinking, and then I was very happy to see a similar topic. I wanted to paste the code directly 👻…

But this place has been reporting errors:

But I can't find the reason for the error report on the Internet, and I saw more tutorials written like this. I asked the senior students to know that it was the code in sage environment

#### 2. Concrete realization

👉Popular explanation link of station B (I think it's very good ✌️)

$m^e\quad mod\quad n\quad=\quad c$

raw data m m m. Beg e e e power, e e e can be regarded as the key for encryption m e m^e me divided by n n n and take the remainder to get the ciphertext c c c. Forward calculation c c c is easy, but reverse push m m m difficult

d represents another key for decryption

• e is very small, so it can be attacked with low encryption index

• The principle is to know $m^e\quad =\quad kn+ c$, enumerate k in a limited time, and then open (kn + c) to the power of E. if you get an integer, it is likely to be m

import gmpy2

c = 11236059610940155040515420815459088108548438695111162676979740370803612682449595975315521615456835907246170497671938930521670240256368063

e = 3

n = 123814470394550598363280518848914546938137731026777975885846733672494493975703069760053867471836249473290828799962586855892685902902050630018312939010564945676699712246249820341712155938398068732866646422826619477180434858148938235662092482058999079105450136181685141895955574548671667320167741641072330259009

for i in range(0,1000):
# Returns a tuple. The value of m[1] indicates whether the square result is an integer
m = gmpy2.iroot(c+i*n,3)
if(m[1]==1):
print(m[0])


2239776471831658234108454124349621200139611967