返回列表 发帖

[原创文章] 关于国内某知名大学网站加密算法的研究

原创作者:柔肠寸断 [3.A.S.T]  http://www.3ast.com.cm' |+ n( X0 p6 \$ o* l
原始出处:http://www.3ast.com.cm
/ L' C& e. F8 m7 t* K# R; v8 N" s5 T- Z' ]/ O9 U
看不懂的直接绕过3 e% M! n3 |) U' u6 I
加密前为:hwy123456
0 Y% J1 ~3 k: O7 d7 a加密后为0F9C1C7A2EE76EBB5C1F4D7526CC4F883F4E
( k6 X4 v- I) w' `0 V& |0 L1 k' @6 C# W- w; N1 ^: j7 F2 \% {% r
============================================
/ X9 F* c5 g- u1 n% E上面是当时自己校内的心情。现在已经解破出来了,分享给大家: w7 _9 J9 K$ N3 Q# @
也就不隐瞒大家什么了,这个是国内某知名大学的后台加密算法
2 C0 M5 R1 t3 T; d, X/ S6 y以下是RSA算法文件. c  _/ G( N. L$ U: P

7 H6 e* [; c. q* c( r% a文件名RSA.ASP
4 g- }7 q' u& {1 M===============================================
! m/ i$ {3 Q2 q4 B: @5 s<%
3 C" n8 W/ D1 nClass clsRSA
: ~1 }2 S! o0 `7 i6 F' b& J$ b8 VPublic PrivateKey . W$ w% R. L* K0 `
Public PublicKey " ], V6 |  p6 \7 ^
Public Modulus % s( {5 `  Z# l: p( ]$ i: J5 }& g
Public Function Crypt(pLngMessage, pLngKey)
( g8 ?  P' |7 z1 Y: U$ T5 i' i! KOn Error Resume Next 8 W& }2 M. s  _2 J% E' c. g
Dim lLngMod ) R- f) x6 [/ \# r/ ]! w
Dim lLngResult 1 o( |9 O' z* ]& N/ d4 v2 T+ p
Dim lLngIndex 3 m9 @! f# |+ U$ ?8 w) z, I" A
If pLngKey Mod 2 = 0 Then 3 i3 t5 `) o9 |. T' M' P
lLngResult = 1 2 \& T  K1 E, h0 b# q
For lLngIndex = 1 To pLngKey / 2 " W/ y4 Y0 m% r( H" \
lLngMod = (pLngMessage ^ 2) Mod Modulus
- n2 T1 w' N* ~. H8 y2 o' Mod may error on key generation
$ [5 N, {$ i, q  J4 ^% t0 ClLngResult = (lLngMod * lLngResult) Mod Modulus " E9 W4 v: S3 t9 v( `4 P1 K2 l
If Err Then Exit Function
% Y" e1 f3 ]' `) |1 i) U" G4 XNext
5 v2 s( t4 Y$ J2 |8 i# IElse 8 A' S) h# k. Y% k  V& ]! y7 m
lLngResult = pLngMessage : F, q# c7 n1 i! z! G4 R1 _
For lLngIndex = 1 To pLngKey / 2 " q2 w5 r% \- s6 S2 S  |6 N
lLngMod = (pLngMessage ^ 2) Mod Modulus   S4 f3 X! i  B
On Error Resume Next ! e: |+ n6 T$ t' ]6 V
' Mod may error on key generation / y7 M  F8 G/ Z( X/ {; t
lLngResult = (lLngMod * lLngResult) Mod Modulus   B1 B' h: L$ K& |) Q, G1 p/ h
If Err Then Exit Function : B$ S7 ^/ Q2 ~/ K- n
Next
! T& }$ c" p$ H6 ^' c3 v* P; N: xEnd If
  N1 B. O7 v1 x/ ~/ lCrypt = lLngResult % o; f: ]1 J7 B2 \2 s
End Function
/ D7 V0 x- z+ |9 q. l4 q' _- K
3 {3 W  h/ G7 M! ^7 _Public Function Encode(ByVal pStrMessage)
% l* P) O1 V% ?; z/ R9 n3 Z8 ODim lLngIndex
0 i; j9 W1 e. kDim lLngMaxIndex
/ f+ c0 k6 N& B* y( x: y8 u$ `Dim lBytAscii 3 \! |5 |5 k/ o# M, l2 v5 X
Dim lLngEncrypted / l, |) F2 U. A" R
lLngMaxIndex = Len(pStrMessage)
& c. E5 R+ T( f5 g# E* g- dIf lLngMaxIndex = 0 Then Exit Function
) o( Q) I& u0 B+ i+ r9 E% rFor lLngIndex = 1 To lLngMaxIndex 0 e% a$ ]4 W; V: v9 k
lBytAscii = Asc(Mid(pStrMessage, lLngIndex, 1)) % A7 J" g9 v& c7 d; K
lLngEncrypted = Crypt(lBytAscii, PublicKey) 6 x. V) i/ z$ [8 r, S9 \
Encode = Encode & NumberToHex(lLngEncrypted, 4) $ q$ }, O  v6 ?$ k. C0 [0 b
Next ; R( q9 R6 N2 m+ w7 R
End Function ( E, l& H3 a$ u# c  u% B
Public Function Decode(ByVal pStrMessage)
7 H) k8 J% h4 ^' I) }4 v( YDim lBytAscii
* R* ?# Q& l- ?. T, G7 A/ A- JDim lLngIndex 3 g2 k' k' z! g$ a9 R
Dim lLngMaxIndex
  z/ H: [6 y+ u- O' pDim lLngEncryptedData 5 n5 O4 F  {+ C- R3 B9 v
Decode = ""
# R. `2 b: @6 {6 MlLngMaxIndex = Len(pStrMessage)
" G* l: ]8 ^4 R: ?5 d: ]" S& `For lLngIndex = 1 To lLngMaxIndex Step 4 8 z& b1 |5 U2 S$ S& o2 q
lLngEncryptedData = HexToNumber(Mid(pStrMessage, lLngIndex, 4)) 5 u8 C% _8 Z( z* `2 `9 v
lBytAscii = Crypt(lLngEncryptedData, PrivateKey)
$ ^- V+ ~. P1 ~# n2 WDecode = Decode & Chr(lBytAscii)
" C* j% O4 F4 @% Q, i; g6 f- J) H8 `2 lNext
2 ?5 T% H/ h3 j8 n* ^End Function ; s5 `$ D9 \" i5 c
Private Function NumberToHex(ByRef pLngNumber, ByRef pLngLength)
: m3 A# V9 \4 b  \NumberToHex = Right(String(pLngLength, "0") & Hex(pLngNumber), pLngLength) 3 e4 Z( K  w* A( g5 G$ B
End Function 2 [+ B( d' d5 F4 Y% ~- U! o
Private Function HexToNumber(ByRef pStrHex)
. b$ a! t# B1 L! GHexToNumber = CLng("&h" & pStrHex)
; u8 z% ^9 _9 [) R8 QEnd Function : D4 e0 L  m2 m+ O2 h- A# ]
End Class . D; t( g+ }& `
function Encryptstr(Message)
) Y/ B( D, G# G" H0 B5 f8 o( hDim LngKeyE
; j+ M- T5 N$ E5 j& |8 aDim LngKeyD
8 ^! N) N/ D5 U+ M" Z8 g1 N" u" xDim LngKeyN
7 L6 }0 G; E* f7 y: ]! ]Dim StrMessage
, o8 \% X! o/ K9 w( D4 I* ^- HDim ObjRSA
- \5 s2 R+ o  Y+ a9 e' M& |LngKeyE = "32823" , q; m4 R$ k$ V+ d
LngKeyD = "20643" # r4 L9 g- J' `  Q( D+ |* O5 l
LngKeyN = "29893"
7 J# O! N$ F# g8 mStrMessage = Message 8 X9 F6 Y. X0 z/ {  ^: T5 I
Set ObjRSA = New clsRSA
/ `/ u$ {' J8 J& S9 U& Y: hObjRSA.PublicKey = LngKeyE
) I" C5 C8 d& _2 a& G. w+ [" JObjRSA.Modulus = LngKeyN
( F  B/ i6 C5 HEncryptstr = ObjRSA.Encode(StrMessage) , S) F. h4 Q' |, z- J' Q9 d7 z6 z3 r
Set ObjRSA = Nothing : ^6 D; q" t' X& p4 l9 x
end function( [: G. D' i4 ]8 |5 ^! _8 e
Function Decryptstr(Message)
% N# k( B2 f: \/ cDim LngKeyE : v6 R6 d; d/ l; }, k4 v3 I& E
Dim LngKeyD
( K" o( V3 n& y6 ^! @+ u. [Dim LngKeyN
$ s7 Y8 p' Y" y! y8 NDim StrMessage
3 {" s5 o6 ^! @7 M" [Dim ObjRSA
) H) ]" y6 J) \$ G, ULngKeyE = "32823" " w" ]* g+ v- S& L& n* X% A
LngKeyD = "20643"
, y7 R$ k# s& w6 u" v& m  f* BLngKeyN = "29893" 9 q+ P9 x3 S5 C7 {" `$ I4 i
StrMessage = Message
5 G/ {4 E" g4 y5 Q4 i- mSet ObjRSA = New clsRSA
+ B, i% K: L8 `0 d7 ?ObjRSA.PrivateKey =LngKeyD 7 g) }' b9 l, M6 D$ ]
ObjRSA.Modulus=LngKeyN
' C5 U" G) ~+ E1 J  @: g3 [6 ]decryptstr=ObjRSA.Decode(StrMessage)
) L- A0 ]- h( oSet ObjRSA = Nothing
) V( C! U& a5 G' L& Gend function   P7 G) C# T+ {$ c* k' e: w
%>* E5 ]# _+ B: ~, N
===============================================
7 ^& k6 u4 p4 w2 U+ \$ F# Y/ y/ a! W+ r# R) s/ W+ D% ~6 t6 _1 |
还有一个用于测试这段代码的test.asp
, v: t4 f; q% K$ c有兴趣的自己搭建个IIS测试下
; ~* f- T7 L) b( H+ u; ~, T<!--#INCLUDE FILE="RSA.asp"-->
$ z- `. Q3 O" j<%  `8 V! x  \, l; Z! F
function Encryptstr(Message) 3 _( y7 E3 N7 i8 V+ E1 v+ O( h
Dim LngKeyE ; `6 S! B0 r6 l$ v! m
Dim LngKeyD
& s+ `/ z8 z5 h  i3 M0 EDim LngKeyN
1 z/ h0 x8 Z! h1 ?8 O; CDim StrMessage 5 I1 L* ?! `/ r! }; X( a
Dim ObjRSA
! A. d; O& p8 U. a& n1 D+ {LngKeyE = "32823"
" Z6 }) F, }4 m3 DLngKeyD = "20643" - L0 {& q& p9 i3 T% j
LngKeyN = "29893" " M0 Z3 z. a) V3 ]
StrMessage = Message
2 y* e; h' f0 m% Y3 [$ \Set ObjRSA = New clsRSA
) C8 Z2 G9 M8 {6 {0 m9 ]& SObjRSA.PublicKey = LngKeyE & C( {: c$ b/ |* s- y5 w. S
ObjRSA.Modulus = LngKeyN
6 C4 Z" e- Y# G3 O4 LEncryptstr = ObjRSA.Encode(StrMessage) 0 }* I2 a5 A- P* }5 d
Set ObjRSA = Nothing
" H! h# D0 L: c* q. bend function ( s7 H6 f$ U" O8 Q
function decryptstr(Message)
9 V. Z0 |4 C# Y5 [; ?7 oDim LngKeyE
; [/ N/ X* U2 A& K, VDim LngKeyD 3 I- h" K3 f3 T4 r6 D9 V
Dim LngKeyN 2 z: q( \+ [" A% i
Dim StrMessage ! A/ T+ o9 Q/ \1 d6 t' J
Dim ObjRSA
9 Y( v/ B% c/ v6 `5 o$ TLngKeyE = "32823"
4 s1 S% R# W$ A% Q/ _9 n3 A, CLngKeyD = "20643"
, M" ^  ^, f  w0 \: P  u- H$ ~LngKeyN = "29893"
; y8 y2 V, V/ d+ f% {StrMessage = Message $ K5 u5 T- g  q. C8 O9 X: f1 f
Set ObjRSA = New clsRSA
- @% m* H5 X' k' b8 Z$ nObjRSA.PrivateKey =LngKeyD : K( i" Y* R; U" o/ w3 g
ObjRSA.Modulus=LngKeyN
8 E( F+ {1 R# a/ W$ j/ H6 Rdecryptstr=ObjRSA.Decode(StrMessage) , B1 ?; Y  i  j& z4 G
Set ObjRSA = Nothing " u9 v+ }. U# J9 a7 G* F) h
end function
4 a( N% ]) L0 V8 |; odim last,first
" K8 c: ]8 X7 c& S9 p' A* \0 efirst="!@#$%^&*()"
$ P/ Q$ ]$ e% ~7 m7 h3 z& ~Response.Write "加密前为:"&first # b, _9 L, E5 a# `  U$ s, X
last=Encryptstr(first) ) L1 y! k5 ]" e  m
Response.Write "加密后为"&last
( [& o8 R; ^) P) I, h& N6 ?Response.Write "解密后为" &decryptstr(last) ' b5 e5 ]' l0 s/ k/ I" f) M- w: J9 L
%> ==============================================: {3 M) h6 |3 J) D( U
剩下的就是字符的对照表了, i# S1 ]! G, t* c. o
===================字符集================
( k# F% W; ~: f7 |& B/ w' S1_____6EBB% d# u  J8 J+ q9 f
2_____5C1F
% W' a# ]$ g  \8 _2 }! d3_____4D75! a6 H# G! W, {. X% s5 ?) c* ], W
4_____26CC
9 o" d% V8 S% y. \. C5 H9 V5_____4F88
2 M- w4 W& @( ~& e6_____3F4E
2 H- ~4 ^# k* s4 f7_____0A9D4 J1 k' [: M( B  F$ @# P: N
8_____1A1C
4 K- G& |% J9 d, c9_____6D20
  r4 }! m$ C* m$ o0 d) m0_____1089
6 K; O3 F4 U* T7 F- G3 b2 M9 Da_____0F3E& y4 Z7 D- t) a1 t8 e6 a3 J3 L
b_____3159( ?$ [" @" D  F/ `' C2 e6 t
c_____3517$ b" F5 }2 A6 U% V- ~
d_____419C7 h3 N& [  ^9 Y- L
e_____615C8 }' N( i9 p; @, a% P! u' K
f_____556F
. {9 c  |3 w; X7 |g_____2B7F
/ X" W% v! M- bh_____0F9C
+ |  u. R' B3 {, ni_____00FA" |, u+ D/ q' w0 _; n& o
j_____5A50
* z, v9 O# X* A1 Q8 Xk_____2850
* ?" A- }; E: q- R- O- g, F# b6 o1 Tl_____3E7B
; {# o0 {; Z; M" j' m7 Q8 m* F+ nm_____71C5+ u* K, E2 [: M# g' F# d: D6 V& A- N
n_____1FC8: x. V% n, T" u6 F- B& _
o_____74C1
8 R+ T) o+ N% sp_____5FB8
7 r- F; ?. ?& |q_____6085( \+ P2 ]0 h; Z( Y* O( S2 S
r_____3AC41 n3 b% b# f7 [! B' V2 v( U5 q/ }3 a
s_____2F500 Z3 `1 V  K7 o9 @' f9 O1 h
t_____36F8
1 W+ I+ u' k  wu_____7010( n) u8 u$ Q2 [& Z( {4 J
v_____0B42
: M/ f6 m; J" R* a) c. ?: j/ Bw_____1C7A- J3 h# j9 A# [: V; D
x_____16F81 L: Z, N8 B  A
y_____2EE73 T4 v% P* H3 |
z_____5CF3
/ J9 g/ R9 ~/ c$ N!_____6233
7 G' k6 U: I- Z0 X" A$ G- h@_____3A45
/ R/ _+ T& q# r9 ~8 i! @& x#_____2291/ N8 z' e# H; q! h& M
$_____5D5C
( G5 `) ]: y$ B6 r$ V%_____09B9
  F# d+ X4 n* \' O- u^_____43EA
; i! {- |1 L5 [5 w4 w: n&_____62B9
8 R# _' f1 C$ X  T, i*_____6301
8 P) n4 c5 t% C$ I+ C/ b' ]" j& f(_____46593 l$ D9 V+ U# t1 a- F
)_____5C82
希望做站长本人的学生请点击
http://www.3ast.com/viewthread.php?tid=13841
QQ790653916只负责SEO以及收费教学等方面联系,他人勿扰

于智者同行,你会不同凡响;与高人为伍,你会登上巅峰

收藏了。。。。。。。。

TOP

返回列表