【密码学】基于 CAP 分析破解 Hill 密码并获取密钥矩阵(Hill密码+多表密码分析+已知明文攻击)

【密码学】基于 CAP 分析破解 Hill 密码并获取密钥矩阵(Hill密码+多表密码分析+已知明文攻击)

原理

Hill密码

Hill密码是一种基于线性代数的多字母替换密码。它使用矩阵乘法对明文进行加密。

破解步骤

  1. 获取一段密文和对应的已知明文。
  2. 将明文和密文分成与密钥矩阵大小相同的块,并转换为向量。
  3. 使用明文向量和密文向量构建矩阵。
  4. 计算明文矩阵的逆矩阵。
  5. 使用密文矩阵乘以明文矩阵的逆矩阵,得到密钥矩阵。
  6. 使用计算得到的密钥矩阵对明文进行加密,验证是否能得到原密文。

步骤

  1. 打开CAP,将密文放到Ciphertext区域

       28    0
       27   82
      192   97
       45   94
      237  206
       91  248
       52  253
       48  256
      188   15
      167   62
      254   28
       33   27
       38   21
       49  107
       88   73
      211   73
      197    0
        3   82
       76  230
      122   12
       92  230
       83   12
      244   85
       64  215
      152  197
       10    3
      162  144
      131    3
      232  132
       80  223
      142  231
      245  250
       28   88
       27  106
       89  117
       87  138
      217  198
       47  241
       41  184
       98   38
      115  205
       70   10
      120   55
      239  202
       71   36
       58   34
        7   12
        2   66
      109  176
      236  235
       34  180
       72    8
      187  151
       34  128
      185  232
       19   80
       76  187
      227  238
       33  163
       38  112
      180  187
        8  238
       10  141
       51    7
      106  189
      135   49
       23  220
       69   96
      188    4
       15    6
       22  188
       35   15
      188  120
      167  239
       89   68
       87  220
      156   76
       40  122
       23   52
      122  101
        7  164
       55  251
      196  221
       75   24
      246   63
       26   51
       17  185
       24   19
       25   93
       31  117
       96   90
      218  121
       49  195
       52  140
       84  220
       76   43
      131  176
      242   31
      253   16
      256   96
      228  196
       50   75
       76    1
      227   63
      222  222
       58    5
      202   76
       67  227
      206   34
      248  125
        0  152
       82   10
      253   33
      256   38
      231  240
      250   87
      241  165
       15  232
      121   39
      115   30
       12  254
       13   33
      220   60
       96   55
       52  153
       48  248
       30   61
       42   36
      235  164
       23  251
      100   27
       90   99
       77  108
      103   97
       95   87
       79  230
       41   17
       45   24
      220  165
       96  232
       83   89
       42   87
      226   77
       88  103
       76  254
      227   86
       23  200
       69   52
      108   44
       97   41
      164  178
      251  145
       56   68
       78  220
       60    6
       55   21
       97   12
       94   13
      153  224
      248   73
       79  208
      118   59
       71  163
      216  112
       23  180
       69    8
      183   16
      156   43
       44  233
       41   61
       85  189
      110   49
       60   71
      108   58
       85  251
      110   37
      211   68
        2  220
      196  108
       22   97
      187  228
      238   50
      243   60
       83  213
      132   82
      223  114
       96   12
      218  119
        0  104
       82  225
       21    5
       54   40
      187  214
      238   51
      213   93
       70   64
      100  180
       90    8
      181  188
      141   15
        0  176
       82   31
      230   82
       12   61
      131  176
      242   31
      245  164
       45  251
      108  243
      255   83
       40   49
      117   52
      240   23
       34   69
      110  241
      217   68
       40   67
       64  134
      132  195
      223  245
      248  196
       94   75
       35  187
      106   34
      242  152
      253   10
      181  221
      246   24
      152  118
       10  119
      153    0
      248   82
       76  230
      122   12
      235  230
       76   12
      154   15
      124  115
    
    
  2. 选择Analysis Tools - Polyalphabeti tools - Hill Attack

  3. 在Possible Plaintext中输入明文内容,Matrix Size设为2

    theresnodoubtthatmymothergivesallherlov
    etomeidobelievesheisagreatpersonwhomakes
    mylifebeautifulandmeaningfulsheisaneasyg
    oingandkindwomanwithbrighteyesandalovely
    smilealthoughsheisoftenbusyistillfeeltha
    tiamtakengoodcareofbyheritsagreatpleasur
    etochatwithherwhenigetintotroublesshealw
    aysencouragesmenottogiveupandtriestochee
    rmeupbycomingupwithgoodsolutionsinadditi
    oniamfascinatedbyhercookingandwritingwit
    hherloveifeellikeafishswimminghappilyina
    beautifulseaillcherishherloveforeverx
    
  4. 点击Run,得到分析结果。结果中给出几组可能的密码矩阵的逆矩阵,可以通过样例明文来判断是否为密码矩阵的逆矩阵

     -------------- 
    
     {Possible Inverse Key 
      165    252  
      223     39  
     
     Sample plaintext: 
    theresno
     -------------- 
    
     {Possible Inverse Key 
      203    136  
      185    136  
     
     Sample plaintext: 
    herey---
     -------------- 
    
     {Possible Inverse Key 
      223     39  
      149    249  
     
     Sample plaintext: 
    eresno--
     -------------- 
    
     {Possible Inverse Key 
      185    136  
      134    227  
     
     Sample plaintext: 
    resn----
     -------------- 
    
     {Possible Inverse Key 
      149    249  
       69    180  
     
     Sample plaintext: 
    esno----
     -------------- 
    
     {Possible Inverse Key 
      134    227  
      213    183  
     
     Sample plaintext: 
    snod----
     -------------- 
    
     {Possible Inverse Key 
       69    180  
       87    180  
     
     Sample plaintext: 
    nodo----
     -------------- 
    
     {Possible Inverse Key 
      213    183  
      240    155  
     
     Sample plaintext: 
    odou--q-
     -------------- 
    
     {Possible Inverse Key 
       87    180  
      196     20  
     
     Sample plaintext: 
    doub----
     -------------- 
    
     {Possible Inverse Key 
      240    155  
       29    202  
     
     Sample plaintext: 
    oubtq---
     -------------- 
    
     {Possible Inverse Key 
      175    124  
      145    166  
     
     Sample plaintext: 
    ----ther
     -------------- 
    
     {Possible Inverse Key 
      188     34  
      170    151  
     
     Sample plaintext: 
    --c-here
     -------------- 
    
  5. 点击菜单中的Ciphers,选中Hill
    选择Hill密码

  6. 设置Matrix size为2,填入通过计算分析结果中密码矩阵的逆矩阵得到的KEY MATRIX:

    11 8
    3 7
    

    设置密钥矩阵

  7. 选择菜单中的Key,选中Set,生成逆矩阵

    165 252
    223 39
    

    生成逆矩阵

  8. 点击Decipher,在Plaintext区域得到明文
    明文

    theresnodoubtthatmymothergivesallherlov
    etomeidobelievesheisagreatpersonwhomakes
    mylifebeautifulandmeaningfulsheisaneasyg
    oingandkindwomanwithbrighteyesandalovely
    smilealthoughsheisoftenbusyistillfeeltha
    tiamtakengoodcareofbyheritsagreatpleasur
    etochatwithherwhenigetintotroublesshealw
    aysencouragesmenottogiveupandtriestochee
    rmeupbycomingupwithgoodsolutionsinadditi
    oniamfascinatedbyhercookingandwritingwit
    hherloveifeellikeafishswimminghappilyina
    beautifulseaillcherishherloveforeverx
    

声明

本博客上发布的所有关于网络攻防技术的文章,仅用于教育和研究目的。所有涉及到的实验操作都在虚拟机或者专门设计的靶机上进行,并且严格遵守了相关法律法规

博主坚决反对任何形式的非法黑客行为,包括但不限于未经授权的访问、攻击或破坏他人的计算机系统。博主强烈建议每位读者在学习网络攻防技术时,必须遵守法律法规不得用于任何非法目的。对于因使用这些技术而导致的任何后果,博主不承担任何责任

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值