返回列表 发帖

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

原创作者:柔肠寸断 [3.A.S.T]  http://www.3ast.com.cm7 ?, U- w+ V  P( F% Z
原始出处:http://www.3ast.com.cm3 k+ m! B# K5 B+ E4 J1 G% x) n9 J- ?

( |1 W7 n8 u( {, o看不懂的直接绕过
+ l9 D6 F1 K+ C; }2 g, ?加密前为:hwy1234564 v. ]! C& ?/ r4 m8 ?) {+ E
加密后为0F9C1C7A2EE76EBB5C1F4D7526CC4F883F4E' E( v0 w5 w6 W4 r% w. t

9 m8 P, @3 [% k4 o% S9 L: Q============================================
  _6 n% V$ V* t* g; s5 X; D上面是当时自己校内的心情。现在已经解破出来了,分享给大家
: ]; f& ]! d, a也就不隐瞒大家什么了,这个是国内某知名大学的后台加密算法: \+ H4 j. y! y1 ~, j( ?0 I
以下是RSA算法文件' t, ~* }0 L; ~1 N$ h  B3 q

& R2 M5 X6 h$ w/ X3 N* X文件名RSA.ASP
# t' S" z% Z9 s8 J: q===============================================! {( B& R9 s+ F" t+ B9 c3 J: B
<%
8 y" @: H: r4 sClass clsRSA
" f8 x) c# Z( kPublic PrivateKey 2 {2 @, T9 a. `" i. M: j
Public PublicKey / I7 F6 d8 y" Y
Public Modulus # {- |. r* s. Y$ t; l
Public Function Crypt(pLngMessage, pLngKey)
9 q5 ~: j2 C! \4 H* hOn Error Resume Next
  d7 J8 V( R4 ~1 z5 d+ H  vDim lLngMod ( F- l3 f# T# X7 z9 {# w" f
Dim lLngResult 2 [' _9 x" I/ z( i! a5 X5 y
Dim lLngIndex " N: s. u* f; t! w4 T3 H  `9 X
If pLngKey Mod 2 = 0 Then
' y) W; E: O* v# FlLngResult = 1
; f+ u( I5 T" M5 I6 ^* Y2 U- TFor lLngIndex = 1 To pLngKey / 2
! I) h: F) i4 t( _8 ]0 flLngMod = (pLngMessage ^ 2) Mod Modulus
5 T7 r/ b( I8 o! X+ A) m/ [' Mod may error on key generation 5 M  i2 ^9 O! u; p+ Q4 u& G
lLngResult = (lLngMod * lLngResult) Mod Modulus
; o% I; x& A8 f" DIf Err Then Exit Function
* v5 b3 ^9 I; R! C7 z6 uNext - p5 H# Q8 }" }5 I
Else
, G$ v! r. i. B7 |lLngResult = pLngMessage
2 S; H8 g; ?# i" D( nFor lLngIndex = 1 To pLngKey / 2 " x6 c# u' u/ c" M* o& f
lLngMod = (pLngMessage ^ 2) Mod Modulus & J4 b1 w5 ?9 g. ^) S  q2 b/ N" S
On Error Resume Next 7 X6 }% q+ D. w0 b: A( z: j
' Mod may error on key generation
, N  \) N* q5 vlLngResult = (lLngMod * lLngResult) Mod Modulus / H% C/ P$ K) s. H
If Err Then Exit Function # g3 L+ c0 Y5 D+ r" p7 l. Q
Next
! h1 W+ k* q8 W* ZEnd If
. v; J) A, p! T/ t; FCrypt = lLngResult 9 z  j4 H5 C' C/ F: e/ n# J: h. j, J
End Function
. S' S3 J) M( {2 \+ d8 @, v% v
2 N0 a  b8 i* G" C, UPublic Function Encode(ByVal pStrMessage) 2 R+ {! h, X/ o# j' I1 Q. t
Dim lLngIndex
/ A0 D6 x7 `( VDim lLngMaxIndex + h, R1 y+ U. l$ y5 W7 K/ b. `5 I
Dim lBytAscii , J# O3 a/ h% e1 a# d; {( G
Dim lLngEncrypted
/ u  U" {4 [4 FlLngMaxIndex = Len(pStrMessage) 1 c9 q; d1 C9 ]: J9 h$ |
If lLngMaxIndex = 0 Then Exit Function
' x5 Y& f3 h: z0 p, N5 _8 c6 XFor lLngIndex = 1 To lLngMaxIndex 5 F) j  ~% e: g" T1 U
lBytAscii = Asc(Mid(pStrMessage, lLngIndex, 1))
0 G) U/ x- V' C8 x* j8 S: VlLngEncrypted = Crypt(lBytAscii, PublicKey) 6 ^3 ?2 M, D6 H% m) Z
Encode = Encode & NumberToHex(lLngEncrypted, 4) 5 ]$ o. t+ ~2 Y6 r7 b
Next 8 Y9 W. I* d+ [$ s% E
End Function " J: ?/ l2 P' C# e! c
Public Function Decode(ByVal pStrMessage)
3 k$ \9 Q& _; YDim lBytAscii
" q) s( l# ~6 U. _) c8 c/ T$ hDim lLngIndex   V* g' U: R* k
Dim lLngMaxIndex 9 s# L' ]; v2 T6 S, n# k' a" i
Dim lLngEncryptedData 7 b2 z8 M( V* F8 D1 Q
Decode = ""
1 i' w( z9 G0 T- ~- V7 tlLngMaxIndex = Len(pStrMessage) 8 y3 e1 }$ `- k+ x; v* @
For lLngIndex = 1 To lLngMaxIndex Step 4
- |, P7 x) s0 V1 L* F, C" VlLngEncryptedData = HexToNumber(Mid(pStrMessage, lLngIndex, 4))
4 a! z: l  p0 {+ AlBytAscii = Crypt(lLngEncryptedData, PrivateKey)
' P: ?* W. b9 ~% Y7 xDecode = Decode & Chr(lBytAscii)
( Y2 ~' s  Q* X0 U0 T' E8 xNext % }/ g$ I" \  ~  Q
End Function
! ^  B  S3 B! e1 f, GPrivate Function NumberToHex(ByRef pLngNumber, ByRef pLngLength)
. W; z- M! F' y' NNumberToHex = Right(String(pLngLength, "0") & Hex(pLngNumber), pLngLength)
) K# u* P- T% x0 i( _End Function
/ M0 r; [6 o0 J8 i' Y) lPrivate Function HexToNumber(ByRef pStrHex)
( \; R- [# f) Y. j# p# lHexToNumber = CLng("&h" & pStrHex) " N8 @! I- J6 T' K5 K
End Function
( b3 |! h% \/ ^7 l  I: q* ?+ \# KEnd Class 9 Y0 f! k3 O* f3 h$ d+ y, r) Z' y
function Encryptstr(Message)
$ c/ U+ w& o8 \2 E: v! E7 ADim LngKeyE 8 c! p% F4 J& l' K" D3 a
Dim LngKeyD
: c, o$ j0 G. ^+ @! U! PDim LngKeyN & L; E) v0 R1 o6 F' B
Dim StrMessage
1 d- m$ G, m5 _. O8 @/ ?Dim ObjRSA
) k8 |, y1 p( I- yLngKeyE = "32823" 0 U6 [0 F4 K4 s
LngKeyD = "20643" 6 g3 W* `5 l8 f; X4 I' c$ S
LngKeyN = "29893"
5 l+ S# L4 {5 F( l; O# G& n3 wStrMessage = Message # b, z  K6 Q/ }. d- j" l
Set ObjRSA = New clsRSA
2 Z8 n0 |6 C: @2 t3 bObjRSA.PublicKey = LngKeyE
- L* d& d- B% E8 vObjRSA.Modulus = LngKeyN * a/ x" W) n% h, K: a2 J* C" d
Encryptstr = ObjRSA.Encode(StrMessage)
$ [. r, R7 F! y3 MSet ObjRSA = Nothing 4 n( x7 ~5 W  e! q- m
end function
4 x$ V  Q3 S7 _Function Decryptstr(Message) 4 A' y  P  a; ?% S
Dim LngKeyE ( X2 P; i8 k7 N3 S) Z
Dim LngKeyD
9 [7 x$ f) R: j' B7 a' aDim LngKeyN . V$ a! e3 ]& f3 H6 d- h
Dim StrMessage
6 w8 B6 G* B" r. I$ xDim ObjRSA . a; _  I6 _- |
LngKeyE = "32823" ' p+ i7 G2 P! e& n+ X1 H$ p% [
LngKeyD = "20643" 3 o6 a1 g3 @  a0 \0 l# ~; o' [8 W
LngKeyN = "29893" 2 C7 ^" X+ }$ ~! H  x, Z- e( G
StrMessage = Message
# D, G2 N, u4 L# s7 q0 E* wSet ObjRSA = New clsRSA 9 z- ^$ Q& X  J4 J" O; |$ ^( B) H
ObjRSA.PrivateKey =LngKeyD
$ h$ T) }9 M0 a$ V4 j9 fObjRSA.Modulus=LngKeyN
4 z+ H# y; P' Rdecryptstr=ObjRSA.Decode(StrMessage) 4 Z& p- g1 A  Y/ c& Q
Set ObjRSA = Nothing # b  M# {+ [( C, G' I/ w9 O
end function
( h* l0 b( m6 k& b. ]- R: T7 _) V0 o%>
# ~4 [. O' ]# ?1 W# l' C===============================================
' _+ Q2 Q& S# _/ `: J6 N2 c) V% w+ L5 P9 H, U! F* z5 Q& E
还有一个用于测试这段代码的test.asp* \. m7 g3 ~, a& [6 r+ K
有兴趣的自己搭建个IIS测试下' F7 r$ b8 h5 g$ ^: v8 \* ]+ x1 m
<!--#INCLUDE FILE="RSA.asp"--> ) b5 q& j: j' W- A1 U; U' k! E
<%# Q* l4 u* z. s  P9 t
function Encryptstr(Message)
* n. J: R# v- B. b- iDim LngKeyE 1 I& K0 `* C, u' i$ m! e8 R  N! I
Dim LngKeyD
( o9 Q  X6 b0 A6 f) H4 e' e% e' Q0 ADim LngKeyN 8 Y' l/ `) d" N3 Z7 C6 N( R
Dim StrMessage ! O6 Z& \' D% j2 B
Dim ObjRSA
# G: b( ?+ h1 j  E/ f: j! TLngKeyE = "32823" ) k4 O4 @/ y9 L. Y
LngKeyD = "20643"
, }7 h5 N4 X+ M4 h: |* v: M3 t$ f. p) NLngKeyN = "29893"
; a4 u6 \' E$ m  [StrMessage = Message 9 K1 a; R, K, _7 B
Set ObjRSA = New clsRSA   L$ z6 ]: B: ]( k
ObjRSA.PublicKey = LngKeyE
: @7 d  |1 q& eObjRSA.Modulus = LngKeyN , }4 V; _. o. C# i! D; f
Encryptstr = ObjRSA.Encode(StrMessage)
1 ?4 V0 U3 \2 ~Set ObjRSA = Nothing - E: Q- K, v2 G1 H5 }' x* g' K/ i. A
end function
! M3 G0 z0 {. j- v" p0 R8 _function decryptstr(Message)
3 X8 i* p! y! hDim LngKeyE
0 V/ Y! G6 v) L( F! iDim LngKeyD
( O4 D8 Q  D* |0 m( TDim LngKeyN
8 D; ^- X, u, uDim StrMessage 6 Y9 y, s! r8 O8 o  T" g. b, Y" X
Dim ObjRSA
5 Y1 y( w1 ^- c. Y, W3 ^LngKeyE = "32823"
6 d- Q, K3 o: C' A$ l; FLngKeyD = "20643"
' Q$ W. o. n7 H* Z/ f( r( fLngKeyN = "29893" , I* G- q! S8 l6 K0 J
StrMessage = Message
) J. m$ x* ~, D* X! G6 dSet ObjRSA = New clsRSA
$ E& c% p  z4 D/ g; d+ H1 NObjRSA.PrivateKey =LngKeyD
3 z0 |8 X9 `/ I8 s9 N7 c3 LObjRSA.Modulus=LngKeyN
% W+ E. b1 ]1 d& N6 V9 E& J' adecryptstr=ObjRSA.Decode(StrMessage)
% E; t' ^* w7 a0 g, W. ^Set ObjRSA = Nothing + W8 C( j3 r; W' ]6 J; O. i
end function
, j+ I2 T  a8 Q1 z2 d9 Q0 D* e4 {dim last,first , ?' T: L* N: q  P/ a
first="!@#$%^&*()"
0 d- c2 j+ E$ M& K" m2 MResponse.Write "加密前为:"&first % ]. Q- m6 D/ i( ^
last=Encryptstr(first)
9 w/ ^: ~1 |  O9 _% N5 i/ U: g% pResponse.Write "加密后为"&last 8 `$ I3 A! o2 z" X" W2 H* ]
Response.Write "解密后为" &decryptstr(last)
9 k# \& G+ B0 @%> ==============================================
! g3 t; k1 y6 B' w% H$ B5 Y4 C剩下的就是字符的对照表了# F: b. L$ J9 U% l) l
===================字符集================
& d0 g5 D2 e, r  C" u1 ?1_____6EBB2 n2 b  o4 P7 U2 h5 t
2_____5C1F$ i9 b2 X7 @  T! e5 @7 K: m
3_____4D75+ z3 g7 W3 L: P$ B; }; ?/ ^
4_____26CC% i& v# z0 M3 {: Q' J
5_____4F88
8 v. }) \2 {7 k7 ]/ F6_____3F4E: Z7 a& u6 b2 [& E
7_____0A9D
1 p) x' e% [- g9 _: Q9 i  [8_____1A1C
1 _0 N! q' I+ X/ I0 l& B  `  m4 U9_____6D20
# t8 u9 C8 w3 ~8 ]0_____1089
' `% [5 }% d3 ]4 D2 Ja_____0F3E
: l& Z; m! ], vb_____3159! p; ?6 E4 F1 w* _' D
c_____3517
+ l4 M) V( k, a7 F5 Vd_____419C3 _0 K, h! Q0 E! L9 n3 v
e_____615C: A+ }  n& b. E. g
f_____556F
/ R* G; u) Z2 a# Mg_____2B7F
) Q! `2 Y- P$ J. i; V7 t# F) wh_____0F9C
: T3 f+ q& \7 ]i_____00FA$ J+ X$ k; u5 G  }  j
j_____5A50
3 H1 ^- Q2 b& Q6 y/ P$ sk_____2850
; j9 J! \4 F1 f( ~5 ~l_____3E7B
- T. r/ x6 M9 ^* L5 fm_____71C5
& E( I$ i& a/ ?9 `! rn_____1FC8+ C/ {% k8 M# W( J
o_____74C1
8 M7 C0 o# u3 |( \7 y# g( @3 l6 @p_____5FB81 {3 l+ ^6 r( T0 ^1 u  Q9 _( Q
q_____6085
& `- J' n: Q$ J5 ~1 pr_____3AC4
# p+ h# T. I$ Q5 V8 Q' s. \" M5 Ms_____2F503 D1 n. |4 q4 W
t_____36F8! L4 f6 q* \! ^! _# r: j0 ]
u_____7010
. F1 M+ I1 n. w7 e4 {% g9 p# Wv_____0B42$ C( d6 B, R+ F2 V+ ?+ G
w_____1C7A: u" X4 U2 i' Y) Q. d( g1 F
x_____16F81 J+ }% Q/ J* `5 `# ?
y_____2EE70 Y$ _$ X, Y) L; G/ f
z_____5CF3, n" U& q, ~$ A
!_____6233
& c( y  ]4 i. n% c& a' C& R2 Q- o$ Q@_____3A451 {) t' h5 P: j# x+ j
#_____2291
$ h7 D& o- p7 f. p7 ^: J$_____5D5C
6 L% f) B3 a1 w%_____09B9( S& c; v# N) M  {) s
^_____43EA4 }* g  \0 C. [% s- G  M; i  L# e* R
&_____62B9" A. w1 |+ l0 W# o
*_____6301
5 W4 R: w& `% _' Q3 {; Q- }0 K' E(_____46596 c3 i5 F( a( r. G- f5 ]
)_____5C82
希望做站长本人的学生请点击
http://www.3ast.com/viewthread.php?tid=13841
QQ790653916只负责SEO以及收费教学等方面联系,他人勿扰

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

收藏了。。。。。。。。

TOP

返回列表