首页
社区
课程
招聘
[原创]个人整理密码学相关的知识大全
发表于: 2020-9-16 00:15 5201

[原创]个人整理密码学相关的知识大全

2020-9-16 00:15
5201

密码学

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
## 对称密码DES加密 ##
    密文格式:3180E0975493D24031FCEB93F677FFE0015EAADC53B7DE6CF33911307E29C540
    加密解密:E:\CTF\CTFTOOLS\1、密码、编解码相关\各种密码工具\DES
## ASCII: ##
    84 104 101 32 113 117 105 99 107 32 98 114 111 119 110 32 102 111 120 32 106 117 109 112 115 32 111 118 101 114 32 116 104 101 32 108 97 122 121 32 100 111 103
## Base64/32/16编码 ##
    明文:flag{dsdasdasdsad11321321}
    base64密文:ZmxhZ3tkc2Rhc2Rhc2RzYWQxMTMyMTMyMX0=
    base32密文:MZWGCZ33MRZWIYLTMRQXGZDTMFSDCMJTGIYTGMRRPU======
## URL编码 ##
    源文本: The quick brown fox jumps over the lazy dog
    密文:%54%68%65%20%71%75%69%63%6b%20%62%72%6f%77%6e%20%66%6f%78%20%6a%75%6d%70%73%20%6f%76%65%72%20%74%68%65%20%6c%61%7a%79%20%64%6f%67
## Unicode编码 ##
    Unicode编码有以下四种编码方式:
    源文本: The
    &#x [Hex]: The
    &# [Decimal]: The
    \U [Hex]: \U0054\U0068\U0065
    \U+ [Hex]: \U+0054\U+0068\U+0065
## HTML实体编码 ##
    结果        实体名称        实体编号
     "       "         "
     '        '         '
     &         &         &
     <         &lt;         &#60;
     >      &gt;        &#62;
## 莫尔斯电码(Morse Code) ##
    摩尔斯电码主要由以下5种它的代码组成:
        点(.)
        划(-
        每个字符间短的停顿(通常用空格表示停顿)
        每个词之间中等的停顿(通常用 / 划分)
    以及句子之间长的停顿
    摩尔斯电码字母和数字对应表:
    A  .-    -.    .  .-.-.-  +  .-.-.    1  .----
    -...  O  ---   --..--  _  ..--.-   2  ..---
    -.-.  P  .--.  :  ---...  $  ...-..-  3  ...--
    -..   Q  --.-  "  .-..-.  &  .-...    4  ....-
    E  .     R  .-.   '  .----/  -..-.    5  .....
    F  ..-.  S  ...   !  -.-.--              6  -....
    --.   T  -     ?  ..--..              7  --...
    H  ....  U  ..-   @  .--.-.              8  ---..
    I  ..    V  ...-  -  -....-              9  ----.
    J  .---  W  .--   -.-.-.              0  -----
    -.-   -..-  -.--.          
    L  .-..  Y  -.--  -.--.-         
    --    --..  =  -...-
    源文本: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
    编码后:- .... . / --.- ..- .. -.-. -.- / -... .-. --- .-- -. / ..-. --- -..- / .--- ..- -- .--. ... / --- ...- . .-. / - .... . / .-.. .- --.. -.-- / -.. --- --.
## 栅栏密码(Rail-fence Cipher)--换位密码 ##
    明文: The quick brown fox jumps over the lazy dog
    去空格: Thequickbrownfoxjumpsoverthelazydog
    分组: Th eq ui ck br ow nf ox ju mp so ve rt he la zy do g
    第一组: Teucbonojmsvrhlzdg
    第二组: hqikrwfxupoeteayo
    密文: Teucbonojmsvrhlzdghqikrwfxupoeteayo
## 曲路密码(Curve Cipher)--换位密码 ##
    明文: The quick brown fox jumps over the lazy dog
    密文: gesfc inpho dtmwu qoury zejre hbxva lookT
## 列移位密码(Columnar Transposition Cipher)--换位密码 ##
    列移位密码(Columnar Transposition Cipher)是一种比较简单,易于实现的换位密码,通过一个简单的规则将明文打乱混合成密文。下面我们以明文 The quick brown fox jumps over the lazy dog,密钥 how are u为例:
        填入57列表(事先约定填充的行列数,如果明文不能填充完表格可以约定使用某个字母进行填充)
    密钥: how are u
        按how are u在字母表中的出现的先后顺序进行编号,我们就有a为1,e为2,h为3,o为4,r为5,u为6,w为7,所以先写出a列,其次e列,以此类推写出的结果便是密文:
    密文: qoury inpho Tkool hbxva uwmtd cfseg erjez
        这里提供一个行列数相等的填充规则列移位密码加解密 链接
    另外由列移位密码变化来的密码也有其他的,比如 Amsco密码 (Amsco Cipher)和 Cadenus密码 (Cadenus Cipher)。
## 埃特巴什码(Atbash Cipher)--替换加密 ##
    明文: the quick brown fox jumps over the lazy dog
    密文: gsv jfrxp yildm ulc qfnkh levi gsv ozab wlt
## 凯撒密码(Caesar Cipher或称恺撒加密、恺撒变换、变换加密、位移加密)--替换加密 ##
    工具:E:\CTF\CTFTOOLS\1、密码、编解码相关\栅栏、凯撒、维吉尼亚、摩斯、MD5、置换、替代\
    明文: The quick brown fox jumps over the lazy dog
    偏移量:1
    密文: Uif rvjdl cspxo gpy kvnqt pwfs uif mbaz eph
## ROT5/13/18/47--替换加密 ##
    ROT5/13/18/47是一种简单的码元位置顺序替换暗码。此类编码具有可逆性,可以自我解密,主要用于应对快速浏览,或者是机器的读取。
    明文: the quick brown fox jumps over the lazy dog
    密文: gur dhvpx oebja sbk whzcf bire gur ynml qbt
## 简单替换密码(Simple Substitution Cipher)--替换加密 ##
    简单换位密码(Simple Substitution Cipher)加密方式是以每个明文字母被与之唯一对应且不同的字母替换的方式实现的,它不同于恺撒密码,因为密码字母表的字母不是简单的移位,而是完全是混乱的
    明文: the quick brown fox jumps over the lazy dog
    密文: cei jvaql hkdtf udz yvoxr dsik cei npbw gdm
## 猪圈密码(Pigpen Cipher或称九宫格密码、朱高密码、共济会密码或共济会员密码) ##
    是一种以格子为基础的简单替代式密码。
    具体的字典表在桌面
## 波利比奥斯方阵密码(Polybius Square Cipher或称波利比奥斯棋盘) ##
    波利比奥斯方阵密码(Polybius Square Cipher或称波利比奥斯棋盘)是棋盘密码的一种,是利用波利比奥斯方阵进行加密的密码方式,简单的来说就是把字母排列好,用坐标(行列)的形式表现出来。字母是密文,明文便是字母的坐标。
    加密实例:
    明文: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
    密文: 442315 4145241325 1242345233 213453 2445323543 442315 31115554 143422
## 希尔密码(Hill Cipher)--替换加密 ##
    密文: 22,09,00,12,03,01,10,03,04,08,01,17 (wjamdbkdeibr)
    使用的矩阵是 1 2 3 4 5 6 7 8 10
    请对密文解密.
    一个希尔密码 老老实实写个Python解密
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    __Url__ = '3a0d9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4N6%4N6#2)9J5k6i4m8#2M7Y4m8D9k6i4u0G2j5#2)9J5k6h3y4G2L8g2)9J5y4H3`.`.
    __author__ = 'Tracy_梓朋'
    from numpy import *
    Dic = {chr(i+97):i for i in range(26)}
    def decode(pwd, org):
        temp = []
        result = []
        while True:
            if len(pwd) % 3 != 0:
                pwd.append(pwd[-1])
            else:
                break
        for i in pwd:
            temp.append(Dic.get(i))
        temp = array(temp)
        temp = temp.reshape(len(pwd)/3, 3)
        #print temp
        #print org
        xx = matrix(temp)*org
        for j in range(len(pwd)/3):
            for i in range(3):
                if (int(xx[j, i]) >= 26):
                    result.append(chr(xx[j, i] % 26 + 97))
                    #print xx[j, i] % 26
                else:
                    #print xx[j, i]
                    result.append(chr(xx[j, i] + 97))
        return result
    def get_vmatrix(org):
        org_adjoin = org.I*linalg.det(org)
        print org_adjoin
        org_det = int(str(abs(linalg.det(org))).split('.')[0])
        print org_det
        for i in range(1, 26):
            if i * org_det % 26 == 1:
                break
        org_mod = -org_adjoin * i % 26
        org_mod = matrix(org_mod)
        temp = []
        for i in range(org_mod.shape[0]):
            for j in range(org_mod.shape[1]):
                temp.append(int(str(org_mod[i, j]).split('.')[0]))
        org_final = matrix(temp).reshape(org_mod.shape[0], org_mod.shape[1])
        #print org_final
        return org_final
    if __name__ == '__main__':
        ''' for test
        pwd = list("act")
        org = matrix(array([[6, 24, 1], [13 , 16, 10], [20, 17, 15]]))
        result = decode(pwd, org)
        print "".join(result)
        deorg = matrix(array([[8, 5, 10], [21 , 8, 21], [21, 12, 8]]))
        result = decode(result, deorg)
        print "".join(result)
        '''
        pwd = "wjamdbkdeibr"
        pwd = list(pwd)
        org = matrix(array([[1,2,3],[4,5,6],[7,8,10]]))
        org_vm = get_vmatrix(org)
        print org_vm
        print "Your flag is :" + "".join(decode(pwd, org_vm))
## 敲击码(Tap code) ##
    1  2  3  4  5
    1 A  B C/K D  E
    2 F  G  H  I  J
    3 L  M  N  O  P
    4 Q  R  S  T  U
    5 V  W  X  Y  Z
## Escape/Unescape编码 ##
     源文本: The
    编码后: %u0054%u0068%u0065
## shellcode编码: ##
    首先切换python版本到2.7
    输入命令:python shellcode_encdec.py 
    输入命令:decode  进行解码
    源文本: The quick brown fox jumps over the lazy dog
    编码:
    \x54\x68\x65\x7f\x71\x75\x69\x63\x6b\x7f\x62\x72\x6f\x77\x6e\x7f\x66\x6f\x78\x7f\x6a\x75\x6d\x70\x73\x7f\x6f\x76\x65\x72\x7f\x74\x68\x65\x7f\x6c\x61\x7a\x79\x7f\x64\x6f\x67
    切换回3
    activate base
    切换到2.7
    activate python27
    查看环境
    conda -info -e
## Quoted-printable 编码 ##
    多用途互联网邮件扩展(MIME) 一种实现方式
    源文本: 敏捷的棕色狐狸跳过了懒惰的狗
    编码后:
    =E6=95=8F=E6=8D=B7=E7=9A=84=E6=A3=95=E8=89=B2=E7=8B=90=E7=8B=B8=E8=B7=B3=E8
    =BF=87=E4=BA=86=E6=87=92=E6=83=B0=E7=9A=84=E7=8B=97
## XXencode编码 ##
    源文本: The quick brown fox jumps over the lazy dog
    编码后: hJ4VZ653pOKBf647mPrRi64NjS0-eRKpkQm-jRaJm65FcNG-gMLdt64FjNkc+
## UUencode编码 ##
    源文本: The quick brown fox jumps over the lazy dog
    编码后: M5&AE('%U:6-K(&)R;W=N(&9O>"!J=6UP<R!O=F5R('1H92!L87IY(&1O9PH*

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 2
支持
分享
最新回复 (1)
雪    币: 4
活跃值: (504)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
我自己顶吧
2020-9-16 20:56
0
游客
登录 | 注册 方可回帖
返回