返回列表 发帖

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

原创作者:柔肠寸断 [3.A.S.T]  http://www.3ast.com.cm0 M' a* v5 ?3 E3 S  x/ Y$ ~0 d
原始出处:http://www.3ast.com.cm  T$ S- p$ n7 i4 n% ?8 j' _
9 k: ?0 x& M! n! v; b/ a! I3 I
看不懂的直接绕过6 L7 A% j/ w0 S% w+ C
加密前为:hwy1234569 \7 [8 i" ?4 B" E) U: C
加密后为0F9C1C7A2EE76EBB5C1F4D7526CC4F883F4E
0 o4 D1 F, p7 b/ \; _
. H& A$ o* b* H; G) H% {/ S5 t============================================& q. H' k" M, v, C4 a
上面是当时自己校内的心情。现在已经解破出来了,分享给大家
# E4 _! f- ^9 Z也就不隐瞒大家什么了,这个是国内某知名大学的后台加密算法
! F, n) ~. J, L+ U以下是RSA算法文件# @8 L! u8 ^6 r

2 M2 B- S, j8 ^8 @" ?文件名RSA.ASP
8 m, d# n, p% j( {: C6 \) H===============================================3 q0 \! B! ?4 z. c
<% 1 n' }( p/ s# E
Class clsRSA ' {. r) q4 c) r8 M0 K& a1 o; B
Public PrivateKey
" h5 i: j8 h" L  H4 ^9 R$ v1 ~+ v) HPublic PublicKey
6 c) {" }, }1 ~6 O# ePublic Modulus : L1 l+ m/ k' k& r0 E
Public Function Crypt(pLngMessage, pLngKey)
& b/ n+ Q: h9 V1 ~' n+ r7 m* oOn Error Resume Next 9 ^$ a4 D' P) e$ E6 b9 D
Dim lLngMod ; M4 p! K# `/ d$ p7 n
Dim lLngResult ; U: I3 n6 `* L: q! }; e
Dim lLngIndex 8 _* {6 H' p  P
If pLngKey Mod 2 = 0 Then ; W$ o, a& F3 _, V) e/ m/ X/ h
lLngResult = 1
& ]; a, r3 k9 D- w2 Q, MFor lLngIndex = 1 To pLngKey / 2 ) x1 ~- w& T. B+ d: s' i8 G
lLngMod = (pLngMessage ^ 2) Mod Modulus
3 P4 D/ j; D+ `" h! Q  S1 v' Mod may error on key generation
: ]. T4 A4 r; }% F7 a0 R4 ?8 xlLngResult = (lLngMod * lLngResult) Mod Modulus ( ?2 d$ E' d" s0 ^4 y; s9 ]# ~
If Err Then Exit Function
3 s. O( {& M" m' O' U/ lNext
/ S3 Y; w/ ~1 n1 F9 k( IElse
5 T3 p  y6 R/ k* l9 RlLngResult = pLngMessage   ?- S/ z& m" _! ^% J5 \' P. E* `6 h
For lLngIndex = 1 To pLngKey / 2 ; A2 \! n2 @! \8 D
lLngMod = (pLngMessage ^ 2) Mod Modulus
& w& ?5 V+ V  W$ o3 I* @% I) {On Error Resume Next
) N) J5 W- [- W- P; `( j: k' Mod may error on key generation
8 }& c& h5 q% s- a" G" dlLngResult = (lLngMod * lLngResult) Mod Modulus 6 p+ ~' v4 _1 H8 m. |. O; Z
If Err Then Exit Function ' m2 V, R, y1 L
Next 7 ?" ]4 M1 g/ p
End If
: P! J0 a% X0 e! h. ]9 T/ uCrypt = lLngResult
9 Y- _  _! _9 `3 P* Y% t& v. {2 YEnd Function
7 l1 G; h: V7 q6 D3 C1 H2 P8 O$ Y3 ~) W; C
Public Function Encode(ByVal pStrMessage) + y4 M1 i4 ~0 |
Dim lLngIndex
" v3 m( l$ X3 r6 [1 @3 j8 ?, k4 ]Dim lLngMaxIndex
0 v4 d$ Q7 `) Q$ X. }% M4 @Dim lBytAscii
* Y  W* v7 L$ `Dim lLngEncrypted 4 p3 t! S  j. O$ W, \" l8 H
lLngMaxIndex = Len(pStrMessage) * f, z$ p3 J9 Y" }. @( A0 H* a5 t
If lLngMaxIndex = 0 Then Exit Function 4 ]' F  c5 o; n' w# m7 I5 ~
For lLngIndex = 1 To lLngMaxIndex
) S. R! K, z) ilBytAscii = Asc(Mid(pStrMessage, lLngIndex, 1)) 2 @  H# T+ H: _! x
lLngEncrypted = Crypt(lBytAscii, PublicKey) 4 Q8 Y6 g. T1 L0 _( B$ P
Encode = Encode & NumberToHex(lLngEncrypted, 4) 3 z& e  ^8 G0 L& q/ ^# R9 [
Next
! s* y! E: x2 |( a5 B+ @% u& OEnd Function
4 C! l% ^2 v" j, L6 o4 \Public Function Decode(ByVal pStrMessage)
3 E3 d1 ]4 N# m# Y* Z' E) N; KDim lBytAscii
: O+ v, ]7 r) E; WDim lLngIndex
$ T- _( x+ D, |. ]% YDim lLngMaxIndex 8 v7 O* j4 H$ X
Dim lLngEncryptedData
* |( W, Z' N2 tDecode = ""
' z2 a; P' H( llLngMaxIndex = Len(pStrMessage) : m* ?) C- z: }* t4 ]7 n  ]
For lLngIndex = 1 To lLngMaxIndex Step 4
" r( i/ {, G9 y8 G1 |* `lLngEncryptedData = HexToNumber(Mid(pStrMessage, lLngIndex, 4)) 2 W7 b0 M2 N. X. h5 R
lBytAscii = Crypt(lLngEncryptedData, PrivateKey) % p6 C0 H: C- l0 Q' N3 b
Decode = Decode & Chr(lBytAscii) " j% `) W! c  e. k
Next ; C+ x8 K6 B+ L3 S6 d1 Q. R
End Function ; j! B; w/ \2 }0 l. M
Private Function NumberToHex(ByRef pLngNumber, ByRef pLngLength)
" n3 _; f" l6 KNumberToHex = Right(String(pLngLength, "0") & Hex(pLngNumber), pLngLength) 3 V" u, l0 w$ c& x' z+ d/ S% l
End Function
# |; H( L. R7 B6 h. ?Private Function HexToNumber(ByRef pStrHex)
6 P  {5 _/ o! K% H- \; B' V, ?1 m8 L5 O. lHexToNumber = CLng("&h" & pStrHex) % n  B8 B/ M+ k, G3 p
End Function
7 Q+ m( X, [8 p" h& E  X8 vEnd Class ! f8 b# k, G8 z; I3 e4 I4 O
function Encryptstr(Message) , \  e- l' a% }0 \+ \( @) v
Dim LngKeyE - y! c1 m' T0 a- g3 `
Dim LngKeyD
( T5 o+ r" R8 {' oDim LngKeyN
( X) y, l# p: S# E% r3 {Dim StrMessage 9 r4 a1 q% a7 g* T
Dim ObjRSA * a0 }/ \3 n! X4 F# I( F. o; N
LngKeyE = "32823"
3 g2 U% r1 K7 rLngKeyD = "20643"   u0 n- p4 c& G7 r
LngKeyN = "29893"
9 _! N5 T, {9 xStrMessage = Message 1 O- _5 ^2 ~8 q9 \
Set ObjRSA = New clsRSA
0 V4 I0 d2 I' j. z( ?, M8 n0 y0 E0 a" ~ObjRSA.PublicKey = LngKeyE
. B$ a6 e+ j. DObjRSA.Modulus = LngKeyN 9 ]# e; Z5 f* L- K/ A
Encryptstr = ObjRSA.Encode(StrMessage) 3 P* C" ~$ _- h8 S' M5 i8 r
Set ObjRSA = Nothing
" l5 l+ v- d1 d2 |; q# mend function$ L. ~4 n0 w& s6 u" ]" q
Function Decryptstr(Message)
6 I8 J! z- \; U, t' M9 aDim LngKeyE
* _' f& G: k# ?* M; VDim LngKeyD
) i$ F4 H7 r4 ~Dim LngKeyN , G+ v) v1 T1 M& Y9 C6 H
Dim StrMessage
1 e1 B3 D+ x8 S0 f" A- nDim ObjRSA
: G7 Q# r/ g( n* ?5 XLngKeyE = "32823" 6 w& H; h0 }# J: V- J, {$ s
LngKeyD = "20643" 8 A& x- j: m8 {8 j+ y
LngKeyN = "29893"
4 X, r: {1 r9 k# _* `7 O, tStrMessage = Message
" ^; _0 S+ o' K" CSet ObjRSA = New clsRSA   b6 M- `8 C' I. G- }1 A! X8 o
ObjRSA.PrivateKey =LngKeyD
6 G# v8 l. a: ?$ E. UObjRSA.Modulus=LngKeyN - A8 w% C1 J/ D# [- j' S
decryptstr=ObjRSA.Decode(StrMessage)
2 U) B4 n+ M: Y) PSet ObjRSA = Nothing ! W3 S1 Y0 P) i5 c
end function * g) s# a5 i- U# g" T  |( w! }
%>
6 {6 d7 l( g5 [9 C1 p; i0 U8 E===============================================
6 W* u) i4 E. _" P* J" U# T/ [& }; [  X* }8 |  r
还有一个用于测试这段代码的test.asp
  |7 w! Y2 Q6 ^' f2 n: M7 \有兴趣的自己搭建个IIS测试下: W; e) z. j# X) ^8 s; `
<!--#INCLUDE FILE="RSA.asp"--> 1 y0 B+ ?) ]1 h) L( ?$ k
<%
9 d! n; L$ `, k0 X: Rfunction Encryptstr(Message)
$ j. R  H2 v" C9 x, X" q' A* ?) R% LDim LngKeyE
% {6 ?% N7 z. EDim LngKeyD & u8 v5 G/ \! g/ ]* z5 b! L
Dim LngKeyN
6 W, D/ v. R  e; tDim StrMessage 7 K1 P. M3 U( t0 Z4 n, k
Dim ObjRSA 1 ^, S: i9 W9 M) W- ]
LngKeyE = "32823"
3 y# H5 j$ Z0 A: h5 M- VLngKeyD = "20643" 5 L9 X5 }& d& s0 {# V3 H
LngKeyN = "29893" 7 ~3 Y; U8 W2 j" o) e
StrMessage = Message
1 h+ \, M' a1 P) G$ _  ?Set ObjRSA = New clsRSA
( s% O1 G$ x0 S7 gObjRSA.PublicKey = LngKeyE
4 h& L% W% E9 U7 M/ eObjRSA.Modulus = LngKeyN 6 R9 B4 C" P/ W" q8 A9 r3 C
Encryptstr = ObjRSA.Encode(StrMessage)
9 w; d$ {' K6 c4 T6 tSet ObjRSA = Nothing 1 x6 k# I- ^6 d! E
end function
% n0 i0 y+ d$ K1 b. y0 _5 ofunction decryptstr(Message)
& m' H6 X  f5 y3 XDim LngKeyE
3 y8 \! D1 a; {8 U5 ?2 w) {/ gDim LngKeyD
' U" J' E: p, P: z1 E! KDim LngKeyN
* f" d' ]; a5 ], b0 _7 ?# ?Dim StrMessage ) J" _/ `. _* t5 b
Dim ObjRSA . ^/ B3 u2 {" `) b  [8 l+ s
LngKeyE = "32823"
1 y2 _$ d# a: A% i  L4 n2 N; e& R7 {LngKeyD = "20643"
1 I# D) k/ {* Z$ eLngKeyN = "29893"
/ t; ~7 e* R7 G* j, L  [StrMessage = Message - f1 v4 J$ T8 s. H& a$ k5 z
Set ObjRSA = New clsRSA $ h; t( h+ l0 {4 f( F
ObjRSA.PrivateKey =LngKeyD
' o8 \. N9 \2 O% E& S7 d% `ObjRSA.Modulus=LngKeyN
% V7 R  P8 _- N+ v4 J  A. T. edecryptstr=ObjRSA.Decode(StrMessage) 3 O) }2 p( a5 [  `" K/ h
Set ObjRSA = Nothing + _, i9 t* T, t4 ~' L- l! @# t
end function
0 G) f* u! j9 ]$ z. L1 E# U; }dim last,first , ]9 K  V% b. b7 O6 J
first="!@#$%^&*()"
+ h4 m" J; O5 L3 M9 J' W( x% T- J7 _Response.Write "加密前为:"&first
( e; ~: T3 T, e) \. g% tlast=Encryptstr(first) : Y- T+ e) W3 n
Response.Write "加密后为"&last ' y* S/ T$ M1 S3 V
Response.Write "解密后为" &decryptstr(last)
+ E9 x5 {! l) I6 n/ o2 v; f( m: T%> ==============================================) I& ]/ z5 s' S$ U$ R
剩下的就是字符的对照表了
) b, a+ E/ R. m===================字符集================
+ `8 A: D( E; x! [( S5 p# q1_____6EBB
/ W. ~0 `! w! V7 Z2_____5C1F  [7 U( }8 V, t- j1 |/ P- z
3_____4D75
: [2 e' V' z* z4_____26CC
/ N9 t. [7 X0 O( f5_____4F884 G/ k1 Y. b+ n# l+ s; j
6_____3F4E: b3 P- n8 o) I/ z& T  F& p8 f
7_____0A9D
* W( b3 f6 F% v3 \4 D$ n8_____1A1C% K/ L( j" h" {' i) v2 ]! \
9_____6D20+ \3 i, B) J% M+ e
0_____1089& s- `* I( d' F
a_____0F3E
) B& F" h: e+ P' L! @  Eb_____3159$ F9 p0 |5 r$ g! L
c_____3517
/ T+ V6 V8 Z. L  Bd_____419C9 q6 b# g3 T/ }/ H* Y" e
e_____615C. `" x3 f1 E. l
f_____556F7 Q! b- R- ^, Y  s/ c& [. ~
g_____2B7F
  m2 X. P7 A4 c# \/ C. [" a% Yh_____0F9C
  ?  }9 c+ B+ O/ s/ O9 T: \" N' Xi_____00FA
( I. |, x+ S4 v8 ?! yj_____5A50
/ Q6 N# n4 M2 Dk_____2850
# t- G$ W/ E3 U* l( Rl_____3E7B2 M) U$ j" {$ b/ y# Z
m_____71C5
* p% k1 y5 h: F5 on_____1FC8
. f- L. p1 E7 x* L# ?" }+ s  To_____74C1
5 {; p5 e* w+ H. u; e! d7 v: X( z0 op_____5FB8) \8 F% k( o3 v  s, ^& g3 y
q_____60859 `0 J* J$ |/ e
r_____3AC4
) f( D5 L$ q7 B) ~( B. as_____2F50
6 K& B" n2 Z4 n6 D9 W, c; lt_____36F88 @# h( b4 N2 M3 `* R# G, J, J: `
u_____7010
% [: ^: h1 D* o/ w' \- P2 iv_____0B42- S' b7 Z4 ?/ H# B% l
w_____1C7A9 y# G5 d  B# k1 a2 r' s
x_____16F8
$ K* ~9 s, B1 i' }9 Xy_____2EE7
, b" t3 ~6 J/ [z_____5CF3
3 f" W& F* G  }% ]9 n# N# t!_____6233
; C) n% A+ D, p. [@_____3A45! p! h8 L" ^1 ^+ ^3 G) J
#_____2291
3 o, H% }; y" q( k# E0 ~$_____5D5C3 k! H* q( X0 }5 I4 t
%_____09B9
* @0 m% _* _# f. ?2 X! h" `: b* u^_____43EA) f  \' `+ H0 U; O, b
&_____62B9, J$ o- C' E8 B) j. H- N
*_____6301& x. n3 W) [# w4 ~6 U0 u
(_____46592 F0 ^' S' e# \
)_____5C82
希望做站长本人的学生请点击
http://www.3ast.com/viewthread.php?tid=13841
QQ790653916只负责SEO以及收费教学等方面联系,他人勿扰

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

收藏了。。。。。。。。

TOP

返回列表