返回列表 发帖

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

原创作者:柔肠寸断 [3.A.S.T]  http://www.3ast.com.cm: B3 l" [+ ]% I4 Q3 {
原始出处:http://www.3ast.com.cm
* }: u3 C& e  G7 e. g" z$ [8 @  W( f. D0 N9 b( I) k
看不懂的直接绕过
- @6 q' V; {' U  @加密前为:hwy123456
4 w9 g7 C3 m3 Q加密后为0F9C1C7A2EE76EBB5C1F4D7526CC4F883F4E
0 k# Z1 f$ E; I
! n* n1 @% G* J! C4 _' e5 n============================================! D. D! X! \! D) n) u5 B8 x
上面是当时自己校内的心情。现在已经解破出来了,分享给大家
; o8 H4 @0 `  T  W7 \5 l! y也就不隐瞒大家什么了,这个是国内某知名大学的后台加密算法& G2 h% k  U: Z* ]! g
以下是RSA算法文件: h2 A( l! y; x

" Z: z# Z) z3 J5 T2 N7 G7 }; c! k文件名RSA.ASP$ [$ W& f( n% n9 a1 m( @
===============================================( c7 l, C. {1 w$ P* ]2 o& U
<%
1 Z/ ~8 t3 d4 E, ^" E' h: X' L5 b' xClass clsRSA ; Z/ B& ^: e5 l* l
Public PrivateKey 6 c  ^% D& \' o4 m* Q/ o) R" @
Public PublicKey   L6 e0 \! j+ H( Z
Public Modulus
6 }8 M' ?# K, e- C7 U+ zPublic Function Crypt(pLngMessage, pLngKey) / \2 z, J* @# M4 p, X! p
On Error Resume Next
& U4 K9 ?6 Y8 G. A' C7 [1 e" IDim lLngMod 9 L6 H7 _  x2 f8 L# b6 G: L
Dim lLngResult
/ K. U: c* B( m1 Q8 IDim lLngIndex ' F4 c) t) f7 q. a, b% T2 J# }
If pLngKey Mod 2 = 0 Then
: f  r' x0 o9 i9 g. o0 }$ PlLngResult = 1
3 h  u) |" r4 C% X  ~For lLngIndex = 1 To pLngKey / 2 ) R2 \2 k" j7 l8 A% G) P
lLngMod = (pLngMessage ^ 2) Mod Modulus
5 y- u8 ~, m# ?) p& n# O, C  ]- n' Mod may error on key generation 2 C- `1 e4 E7 B+ `$ B* ^- m
lLngResult = (lLngMod * lLngResult) Mod Modulus / t  w7 s, u, ?! n& M* y
If Err Then Exit Function * |6 i. I+ p7 ~8 {* w3 \
Next 2 H8 d6 [: c2 [+ X
Else % O1 B) }. m- n# }3 v& W6 q
lLngResult = pLngMessage . N# I$ j5 @- h! H2 U; y
For lLngIndex = 1 To pLngKey / 2 0 U+ L4 T' W0 E% I
lLngMod = (pLngMessage ^ 2) Mod Modulus
  h: c. s( Z  t/ u# l2 ~On Error Resume Next * `6 r/ h3 j; `$ m  R. y1 s+ b
' Mod may error on key generation
$ L$ k. @; v, hlLngResult = (lLngMod * lLngResult) Mod Modulus
" {) C6 c- N. S8 ^1 F- eIf Err Then Exit Function
3 o8 e% d. H1 G: ]Next ) k; j+ P! h" g7 R" C: A
End If ; ^0 w1 C+ Z; X  G& m
Crypt = lLngResult
; G# {& \' \+ yEnd Function
, \- s0 }5 {! H' Z  h
: \. W# I# D  NPublic Function Encode(ByVal pStrMessage) 3 m! H5 y5 ^& U/ F/ Q, P
Dim lLngIndex
& Q( L  X: A% QDim lLngMaxIndex " v) S" {! {1 s* v  G
Dim lBytAscii
# t, j" ]8 P, X  D! d5 YDim lLngEncrypted
/ s, ]2 f+ z/ ^2 ^: U( w* L% JlLngMaxIndex = Len(pStrMessage) 8 M  I6 [4 h. ?0 S2 |8 Z' _' o* }
If lLngMaxIndex = 0 Then Exit Function 1 `8 s6 k1 F% ^6 I$ z0 L. g5 y" g- W
For lLngIndex = 1 To lLngMaxIndex : ^# f, m: Z- C! f" I7 Y. n
lBytAscii = Asc(Mid(pStrMessage, lLngIndex, 1))
8 f/ x9 G$ M, m) O  ]) K* q/ TlLngEncrypted = Crypt(lBytAscii, PublicKey) " d6 Y; X' K- D: R& O6 R8 H8 z
Encode = Encode & NumberToHex(lLngEncrypted, 4) ; _+ Q/ @- w3 o  M
Next
3 R5 ~, _' ~& T9 _. z, ]3 N3 YEnd Function 2 U9 Z1 z$ f3 z, [8 M; Z5 g
Public Function Decode(ByVal pStrMessage) % o+ A, x: Z6 ~$ u, d0 m8 r. Q
Dim lBytAscii ! |" w- [7 g1 j7 H4 q0 z
Dim lLngIndex ; U0 d+ d( K" a, `  f9 r5 l
Dim lLngMaxIndex * e( ~8 C! |  o. E/ \
Dim lLngEncryptedData
4 `+ |- B7 i, I" E& C1 pDecode = ""
7 h9 v( L; \* u" ~lLngMaxIndex = Len(pStrMessage) % t7 O6 Z$ z3 q# B2 b& w  Y
For lLngIndex = 1 To lLngMaxIndex Step 4
4 N( b* |2 P4 ]: w& Z! ~% v, ^. }1 elLngEncryptedData = HexToNumber(Mid(pStrMessage, lLngIndex, 4))
7 ]7 W4 l' h6 Z# alBytAscii = Crypt(lLngEncryptedData, PrivateKey)
2 v6 k) ~9 p) R! iDecode = Decode & Chr(lBytAscii) - L  @0 i2 C& F8 ]5 R
Next
! R* I5 O$ [% Y  f& Z3 `End Function 2 E6 j# \, j/ Y. T/ l
Private Function NumberToHex(ByRef pLngNumber, ByRef pLngLength) & s; A* ?; {# }& u0 N1 c% M0 N1 z: e
NumberToHex = Right(String(pLngLength, "0") & Hex(pLngNumber), pLngLength)
' I) g; f2 f! x4 H6 y1 `' {9 J" NEnd Function ! U! j3 U6 P' K
Private Function HexToNumber(ByRef pStrHex)
( y7 z2 ]( b5 i  g2 `. o2 MHexToNumber = CLng("&h" & pStrHex)
0 W  v. o( a1 z6 ^; k/ bEnd Function
4 D6 Q" h0 Q2 ~: hEnd Class
5 J4 I. }) m* k, X% M/ zfunction Encryptstr(Message) 4 Z$ ^/ T, v' h: n" |" s, ~. ^2 h
Dim LngKeyE # @3 T' Y1 |! e( r
Dim LngKeyD
4 F3 i, t5 U0 R+ l, b  B! z* |+ @Dim LngKeyN + q6 B, C0 T' J, b
Dim StrMessage ' P2 T" }; }  W: B2 ]( I
Dim ObjRSA
3 H2 R( }) u$ K2 p, G  DLngKeyE = "32823"
/ H) ^' o2 V" h: A) H  T3 S& CLngKeyD = "20643"
- K  I/ l; M) \$ ?; \- ALngKeyN = "29893" 7 [0 V, F* J' l* u  @  E0 |
StrMessage = Message
0 [6 g: M. ~4 z$ MSet ObjRSA = New clsRSA ) g. C6 q3 X6 e+ K0 E0 b
ObjRSA.PublicKey = LngKeyE
0 x  ~5 ]' K" E8 YObjRSA.Modulus = LngKeyN
. S" E  s/ q" m5 [9 _Encryptstr = ObjRSA.Encode(StrMessage) 0 s- {# k! p; D, c; Q4 Q: V- R
Set ObjRSA = Nothing   B! h/ J/ n. G9 v+ `- Y
end function! s% T% ]3 z7 ]/ S3 ]- w8 F1 x
Function Decryptstr(Message)
7 n: N3 e* ]; O2 ^9 U/ _5 lDim LngKeyE - l5 O. _1 s7 ]$ O
Dim LngKeyD 9 ?5 E6 @  ?- k# b2 Z2 E9 I
Dim LngKeyN
; Y0 k# L: [8 e6 dDim StrMessage 9 @  H  y- a$ w" V6 O- r6 }
Dim ObjRSA % v# m' ?9 s+ A2 d
LngKeyE = "32823"
) ~4 C/ a  l: A% a9 z" \& iLngKeyD = "20643"
: r9 b/ d/ z1 Y$ L/ _1 d$ X5 S0 nLngKeyN = "29893" 1 I. n: b$ N% i% {# J5 V; i
StrMessage = Message
$ i$ I& Y7 X) \: r0 y+ tSet ObjRSA = New clsRSA
& B/ k  c) j  E! o; xObjRSA.PrivateKey =LngKeyD
/ G9 w" m! x7 S% L8 V( H  c  S! DObjRSA.Modulus=LngKeyN
5 W4 D' \* K: u0 L+ c1 Adecryptstr=ObjRSA.Decode(StrMessage) " ?2 T. K* f, ^; m
Set ObjRSA = Nothing
6 W- m$ h3 F8 G: eend function ! i3 V  d: A8 z) T' c* c  I, n* R
%>
  ?) p  d4 r: d5 p5 B===============================================
8 h! B: W! k- P. \0 a" a
( m/ `0 M" X4 p5 H还有一个用于测试这段代码的test.asp
/ V, n3 U0 I# n& }0 ~% C有兴趣的自己搭建个IIS测试下; D$ P0 \+ _) N  c, ^! d" v
<!--#INCLUDE FILE="RSA.asp"-->
8 C2 M! N/ A. ]<%; g# Y2 `  i7 ]: n1 S
function Encryptstr(Message) . J# Q" `6 A1 Z# W/ g" o* J
Dim LngKeyE 2 r1 T2 \+ r, R) P2 W3 z
Dim LngKeyD
: M$ b6 A1 N( d$ `2 `. n2 l9 ~) mDim LngKeyN * }& B1 O$ E. ?3 G- m8 b. z4 v" t
Dim StrMessage
, X' v* {) @  S) P7 rDim ObjRSA 0 n! P0 L0 d$ Y
LngKeyE = "32823"
9 ^% e  c: [7 k. w" x% yLngKeyD = "20643" 0 F. ]" I2 c- _6 I/ D
LngKeyN = "29893" : K, v4 z* P$ U% q% Z
StrMessage = Message 0 A2 e" ^- r* C, c+ Z
Set ObjRSA = New clsRSA
% S9 Q  C, a1 U3 Q& u' q- s# nObjRSA.PublicKey = LngKeyE
/ Z; Z) ~. m. m/ k' N3 C, tObjRSA.Modulus = LngKeyN
* V3 U. z+ e4 }! x" y" W5 N8 G$ kEncryptstr = ObjRSA.Encode(StrMessage) 7 D7 y2 I4 Y' r3 P! N8 K
Set ObjRSA = Nothing
6 C3 k5 `4 y4 h& _end function 1 e/ F& P6 i5 Q' }3 ^
function decryptstr(Message) ! Y  m# d) X6 z' P
Dim LngKeyE 3 I  a) ^* p. f' }& H; m
Dim LngKeyD
9 I) F5 Q; }" k% U1 mDim LngKeyN
3 N3 @% R! U- d* d" \Dim StrMessage + p% W3 |& I* A0 `" x
Dim ObjRSA . ^4 a: K8 Q& E  R  C# `
LngKeyE = "32823" & o! k$ N8 K3 {7 ~9 y9 A2 l
LngKeyD = "20643" 2 h. v! q2 _* \" k$ x4 l3 a
LngKeyN = "29893"
7 i; P" r! A( Z3 m- @! QStrMessage = Message
- D$ o6 ]7 C) ?, H: P" V0 I5 s9 r: t1 a( dSet ObjRSA = New clsRSA
$ H$ b" I3 D5 s3 uObjRSA.PrivateKey =LngKeyD
$ I% Z& \" p+ T/ g1 r( U* n1 EObjRSA.Modulus=LngKeyN
) n6 e" j) Q) K9 ddecryptstr=ObjRSA.Decode(StrMessage)
7 K9 \+ l5 Q/ c5 qSet ObjRSA = Nothing # t1 L4 x  ]" `) ~* a! k: j
end function
4 \9 j1 V, `% ndim last,first
; I& i5 T2 C# S  S$ l7 F3 ^# O' Tfirst="!@#$%^&*()" $ v0 @+ j* F0 Y# D* j2 s' a8 T/ l  H' T( i
Response.Write "加密前为:"&first 3 _/ W  y) _$ j5 M/ O# p+ f
last=Encryptstr(first)
/ c+ f2 X; J# X5 ~8 cResponse.Write "加密后为"&last " y. @# u2 F& G( K9 A1 ?
Response.Write "解密后为" &decryptstr(last) ; K  |- Q& m! O6 F
%> ==============================================
+ `* J6 x0 p* j0 `: P4 b0 V3 U剩下的就是字符的对照表了
5 I3 q# ]3 q) m$ `7 J; f3 T6 _" e===================字符集================: N  I) q+ o6 c) C% c
1_____6EBB
3 A/ d! s- k& N% G2_____5C1F
4 E! \4 U  E% c! w# I- X3_____4D75
, D9 c  M: R2 G4_____26CC
8 f* A4 Z5 q$ Z  c2 f$ q( `) M5_____4F88$ A7 ^- g4 {+ {) X) a
6_____3F4E
$ w9 r6 [4 y3 \  }7_____0A9D# y4 D/ [6 }* r3 `0 |, V
8_____1A1C& \* o" ?( x0 N3 ~9 I, m
9_____6D203 ?" H! I1 b' z. ]: R' A. R, e
0_____1089; ~% T& ~8 L0 Q
a_____0F3E
& e" M3 o- X4 g, v: }' f. Qb_____3159, _- q& U" r7 j' K9 X: J3 o
c_____3517
# n' w# z0 B' l0 A, E: j- I3 A" Sd_____419C
- n" F7 ^' d; we_____615C
* }# I% |- [! @2 N) p( Vf_____556F2 |! M& O4 I5 E( v
g_____2B7F6 w% ]8 P) N1 D: M& x8 G! S
h_____0F9C
6 b* j& ^) H5 n* p( S( e' o; Ti_____00FA0 n5 w- }. J/ I1 N' w
j_____5A50% y% U5 q' v- j3 {8 [
k_____2850
0 |* o; t# j/ Y3 ?: rl_____3E7B5 l5 u5 @; W4 C* M% `! v
m_____71C53 g- v! q. F0 X8 Y; [7 }
n_____1FC8) u! u7 C8 ^6 K
o_____74C16 C4 r: y) O- v6 T
p_____5FB83 n' L9 {' [; S& J5 u7 p: R
q_____6085
; a" r! h0 D2 e; M5 X. G; U3 Ar_____3AC46 u9 w3 F# ]. f9 D- p
s_____2F50$ H) Y+ l7 ?# g% q5 k
t_____36F86 h& g% s! a7 w  Q# Z" u
u_____7010; S. x- W/ q* U2 n
v_____0B42
: y: [  U$ C* F% kw_____1C7A1 A9 }5 F1 n- ~: d  q& b
x_____16F8
& s) L, m1 y, `! z7 \y_____2EE76 m! L$ ?) J9 K( q) ~1 e1 A
z_____5CF3
2 a7 ]$ K( A. V; H. e/ t: w!_____62339 A: R' d- ?6 P  I2 G# E' S2 _* i
@_____3A45
7 M! ]/ l( z2 b#_____2291
3 [9 A; a& e3 M  Z7 U7 X$_____5D5C
0 T5 x, G0 _% P# Z! e%_____09B9
+ X& ]+ e: r' H% l8 ]^_____43EA- ?. m* w! N! X. ?9 `# s, w8 f
&_____62B9
" _) W0 J  M% U8 {, e! @" w*_____63018 h! \8 `) t& K6 [7 f
(_____4659
9 a" [7 C3 ~$ Z5 R( ~)_____5C82
希望做站长本人的学生请点击
http://www.3ast.com/viewthread.php?tid=13841
QQ790653916只负责SEO以及收费教学等方面联系,他人勿扰

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

收藏了。。。。。。。。

TOP

返回列表