& u b: @) W6 J
对了 哈哈哈。谢谢大佬,另外贴出相应解密python代码3 f( m& E- N3 {
/ i# F, e6 d2 ?#!/usr/bin/env python3. T/ c6 S, ?7 m3 Z. C! B( `
, H# I2 j! m, R. o. T& Q
8 i5 M# M, {! ?& l
; l. Z# j$ e7 c. F# w' ], ]% yimport sys
: g: p: R! A8 ?7 W' ? u bimport zlib+ ?+ Q2 B' h2 g( q/ Z' S
import struct( Y7 `# h0 |. y: w4 Z0 D+ N7 ^
import base64
$ \4 L6 M3 @$ E( Fimport binascii
+ r1 O, X8 ]5 y$ @* V. m$ fimport datetime
: Q3 i% m$ ?( |1 W8 lfrom Crypto.Cipher import AES
, T6 [' F: a8 m( Y5 x* S w6 q9 t
1 t% |8 S; g* V5 r, Z
/ Z- K- B ] P' c+ Gclass RouterCrypto:5 |# R4 p+ U& {# h
' m% s' H% g. l, G1 g# ^6 S
def __init__(self):
+ z* T4 e7 [" g" T7 n# B key = '3D A3 73 D7 DC 82 2E 2A 47 0D EC 37 89 6E 80 D7 2C 49 B3 16 29 DD C9 97 35 4B 84 03 91 77 9E A4'
. O+ [3 x$ ?9 s$ |# w iv = 'D0 E6 DC CD A7 4A 00 DF 76 0F C0 85 11 CB 05 EA'* }# R, y8 A9 \
self.cipher = AES.new(bytes(bytearray.fromhex(key)), AES.MODE_CBC, bytes(bytearray.fromhex(iv)))$ F5 T6 ~: u7 l' F6 o) ~, `* ^9 g
8 q6 t8 t/ B- A; f& n4 _2 `* M6 ~% @4 O4 K
# create AES-128-CBC cipher, g) e" A& o& B4 A" y) P
4 b6 |2 s2 j; Q2 J4 u/ a: _
def decrypt(self, data):. C* k8 E- a7 R+ R8 r3 Y
output = self.cipher.decrypt(data)
% {/ ^8 W- L% R8 X# v/ e6 o( U return output[:-ord(output[-1:])]( K) G: G* m( h% n; k: C) W
$ E( d) x, i1 [- l, C
def encrypt(self, data):/ s* ~0 u5 v+ V
pad_num = (16 - (len(data) % 16))& `7 ^0 K) q4 l# z3 x) r
data += chr(pad_num).encode() * pad_num% y2 Q$ e# d( n, s" P
return self.cipher.encrypt(data)
- ~) t4 o4 F- ~2 M; b3 t7 K8 x+ h$ K& Q* [# v) q5 @) V0 P9 t* H
( t2 _/ Y0 J7 ]/ V3 s2 b
if __name__ == '__main__':
/ P6 O t- t2 c# h decrypt_mode = sys.argv[1] == '-d'
$ t1 Z( u4 M* }- R4 K2 F6 {$ t if decrypt_mode:
0 P2 G- f5 w5 ?+ \* W; N" R1 _( W. i print('\ndecrypted: ' + RouterCrypto().decrypt(base64.b64decode(sys.argv[2])).decode('UTF-8') + '\n')
. Z m* L8 L6 S' L0 w, i" c, K# V9 y7 A
else:9 y- u& h/ V- q7 h
$ U& H; V7 E: w; o5 f4 r# ]4 t/ H) S print('\nencrypted: ' +base64.b64encode(RouterCrypto().encrypt(sys.argv[2].encode())).decode('UTF-8') + '\n')$ u" m) e5 A9 `- h; f+ f( b
|