返回列表 发帖

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

原创作者:柔肠寸断 [3.A.S.T]  http://www.3ast.com.cm# L* N/ `$ g+ G; }0 J
原始出处:http://www.3ast.com.cm
$ n- s1 e+ b. U) d, G
( A  D) k6 j. I看不懂的直接绕过! [! b* y5 \& n! p( u3 z4 F
加密前为:hwy1234564 E% }0 U4 T% J# ^. i. f% N" c
加密后为0F9C1C7A2EE76EBB5C1F4D7526CC4F883F4E% Y% b* I' q  S7 [

& {2 Q" K7 Z, D5 ]" z============================================
9 U9 b/ Q* Y2 N上面是当时自己校内的心情。现在已经解破出来了,分享给大家# I( J% v8 E/ s7 j! H0 v
也就不隐瞒大家什么了,这个是国内某知名大学的后台加密算法
5 h% \: @+ N! K4 M8 P. H以下是RSA算法文件) ]7 P/ t. d+ |7 U

# @: C, Z( Y0 E5 f  X/ v$ a% j文件名RSA.ASP7 K1 Q" ~9 M4 @; G
===============================================! }3 B: V" H0 V; w1 V& V
<% 6 l# P: {4 d9 }1 x
Class clsRSA
) g- [) p6 H5 h* L' V) Y" ^9 cPublic PrivateKey - Y9 ?8 s  o* d. D  ?
Public PublicKey 4 ?  [' G2 v' c/ g  X
Public Modulus
- O, j" g' g* A" l+ p1 v3 I$ @Public Function Crypt(pLngMessage, pLngKey)
# B8 H5 I5 d9 K* d9 V% R/ POn Error Resume Next
6 k3 l+ d) J6 Z$ h3 x; \Dim lLngMod $ }+ I5 l! v- t, I: k: k
Dim lLngResult 9 i) e; x. a; A. R/ J: U
Dim lLngIndex & {5 B! K8 k( y6 p
If pLngKey Mod 2 = 0 Then
, V2 E9 F1 k$ {; N9 _& alLngResult = 1 : |! I6 d5 N  G8 |4 ~
For lLngIndex = 1 To pLngKey / 2
, f% K/ ]) Z5 PlLngMod = (pLngMessage ^ 2) Mod Modulus
: ~$ [0 u: c: m, n  Z0 G+ T3 T' Mod may error on key generation
& I- P1 y" E3 i. v5 L2 tlLngResult = (lLngMod * lLngResult) Mod Modulus
7 ]3 b2 U4 n. u# IIf Err Then Exit Function
* e% X. o  S3 N$ lNext ! l' r" j" }4 t7 I+ B
Else 6 f+ [6 h0 {0 r: ~! L8 U  L
lLngResult = pLngMessage
6 W  q+ u% _& a4 h9 k9 i6 S/ M# K1 rFor lLngIndex = 1 To pLngKey / 2
- Z( Z! ~3 `+ \5 \# I6 s( nlLngMod = (pLngMessage ^ 2) Mod Modulus
, G8 N2 Z2 R: y1 i1 L( HOn Error Resume Next * J$ D3 W+ f5 ]+ ^
' Mod may error on key generation
3 c  P' M( D+ n- BlLngResult = (lLngMod * lLngResult) Mod Modulus
* U/ Q/ V+ e: @& ^% e8 A+ ^If Err Then Exit Function ' G8 k- e7 _) h  U
Next 3 A/ d; |4 h$ R
End If
( A4 x5 }4 I- RCrypt = lLngResult
" [  N, N: C3 f  g- kEnd Function
$ F  L& }4 Y1 y0 E) Q/ d
3 O% x: Q# o- V4 x8 L: qPublic Function Encode(ByVal pStrMessage) 3 ~! ^# z' K% `5 |: |5 `
Dim lLngIndex + b& ?4 H* ^$ n, l8 H
Dim lLngMaxIndex
+ B# x( i7 z, V4 [Dim lBytAscii
1 P. R) ~' v) h4 C- xDim lLngEncrypted
5 G9 ]5 T+ R9 [! ]& YlLngMaxIndex = Len(pStrMessage) $ I) n3 u$ l4 Z  O( p
If lLngMaxIndex = 0 Then Exit Function
6 b' A5 b' x7 m& j0 wFor lLngIndex = 1 To lLngMaxIndex
# D1 q+ R* F; w) B! [8 [. N9 {lBytAscii = Asc(Mid(pStrMessage, lLngIndex, 1))
! H! N8 S$ f* `6 [4 clLngEncrypted = Crypt(lBytAscii, PublicKey)
" p% @  \7 n. n% ~( W7 G- kEncode = Encode & NumberToHex(lLngEncrypted, 4)
* M- z3 U" r  G" P' \Next + N* |1 j6 w. F  m5 J- E! k
End Function . K) p: d/ M* P7 x9 t: f$ S
Public Function Decode(ByVal pStrMessage) % z# i4 E8 s/ N. Y
Dim lBytAscii
3 \) t4 N' ~' M* u4 T/ g$ tDim lLngIndex
& i  D8 e  D3 i& m: A! GDim lLngMaxIndex
! A: P# X# \$ V9 cDim lLngEncryptedData 0 I9 }) B# \$ w- @6 l6 ~  w
Decode = "" . e7 H8 z0 k. q. w( r) I8 E
lLngMaxIndex = Len(pStrMessage) # P; P. |+ H  M# [2 u8 {3 s
For lLngIndex = 1 To lLngMaxIndex Step 4
' S5 a( q1 e+ DlLngEncryptedData = HexToNumber(Mid(pStrMessage, lLngIndex, 4)) ) l) y- p  u. n( t2 A+ O! w
lBytAscii = Crypt(lLngEncryptedData, PrivateKey) 4 i' ], R1 o& B! p
Decode = Decode & Chr(lBytAscii) 3 x: q5 E4 }8 R& G# b- @7 E( H3 f
Next ; y5 d- f- p. S( P$ @
End Function ( t- n. x6 O9 W8 w
Private Function NumberToHex(ByRef pLngNumber, ByRef pLngLength) 6 @) x! y: u! H/ Y
NumberToHex = Right(String(pLngLength, "0") & Hex(pLngNumber), pLngLength)
; D5 J! _# _7 m. `4 y2 R& OEnd Function " T2 i# z5 U: P" c: p
Private Function HexToNumber(ByRef pStrHex) 6 D4 a# x5 R1 y0 C* E
HexToNumber = CLng("&h" & pStrHex)
: c! m, f6 U' E& z" y4 DEnd Function 8 Q/ Y& f$ R  y; p0 C% H0 R
End Class % l7 m& \6 p; T, H  B7 b+ U
function Encryptstr(Message)
- `: c; I. m) ?; l. \+ V) q5 oDim LngKeyE
. c4 Y' M: y% N4 JDim LngKeyD % H. o5 T" o) B
Dim LngKeyN ( X! R3 _0 }6 y' }' H
Dim StrMessage
9 [0 v4 e( u  W# `Dim ObjRSA 2 r6 n9 Q& Z1 C8 I1 P
LngKeyE = "32823"
5 v* Y  T! A9 M5 f0 MLngKeyD = "20643" ; r. E; ?* y' r$ m: C0 L+ o
LngKeyN = "29893" 1 v" F! G* ?  d7 c
StrMessage = Message : u! l0 Z* {- M5 _4 y' a
Set ObjRSA = New clsRSA
+ }0 C, X( Y1 }2 z+ A- XObjRSA.PublicKey = LngKeyE ' k2 {3 a$ x1 d2 K& |- \# Q8 R
ObjRSA.Modulus = LngKeyN 2 @" l5 W+ z5 s& g$ K* U: T9 k/ g
Encryptstr = ObjRSA.Encode(StrMessage) 7 x( {' u2 i6 E. V, |$ E- H
Set ObjRSA = Nothing
4 e3 I' \5 b$ o5 N, I. ]8 {& dend function' Z8 B0 Q$ w# }9 r9 X% f2 N# N3 K, U
Function Decryptstr(Message) 2 i+ l. Q8 l* I. p' q. y( d8 `: e
Dim LngKeyE
% R6 v! H1 `8 d* R0 _& j9 TDim LngKeyD : D/ F8 P1 v7 w. A0 `# H
Dim LngKeyN 0 t' h  V, k1 I% {) U0 m
Dim StrMessage
$ A  t! {7 O' P2 V' j& s: M6 XDim ObjRSA
3 y! N% ]9 m  E) g+ bLngKeyE = "32823"
- v' N* D4 g2 k- W# `7 {2 oLngKeyD = "20643" ' A, g3 [% r/ K' e- v
LngKeyN = "29893" ' f0 O# w. i$ a" B
StrMessage = Message " l" b! J* y5 `
Set ObjRSA = New clsRSA / T% |4 K% c* U6 Q6 r$ z
ObjRSA.PrivateKey =LngKeyD " }1 m- s( y! v
ObjRSA.Modulus=LngKeyN 3 A. V8 S1 L% J
decryptstr=ObjRSA.Decode(StrMessage)
: Q7 _9 S7 g( J( {$ k1 uSet ObjRSA = Nothing
' ?6 I( B" r! s3 [( ~- ^& F  C  Cend function
. x& ^% K; t# t6 B%>0 B# [" E7 `$ R, t* s
===============================================
0 t) F  v$ t8 i
4 h% T. J; a" @4 E, }1 y还有一个用于测试这段代码的test.asp1 m" o7 W. r- A% ~
有兴趣的自己搭建个IIS测试下* ~- h0 V8 s- }3 p1 X2 Q
<!--#INCLUDE FILE="RSA.asp"-->
" |) O! j' m3 r# J  b: R% I3 d1 \<%. e  o8 w6 M  I- Y: h1 |9 H
function Encryptstr(Message)
" u* U2 P, ^! v3 A5 F9 a( w  WDim LngKeyE 4 C2 I+ M$ g$ [, V5 [. o
Dim LngKeyD
) D0 Y: ~6 l* N1 Q( HDim LngKeyN   x1 F! Y+ D# H- o% [
Dim StrMessage
& `0 E, x& A+ g2 j8 c: q% vDim ObjRSA
; P; t- ]5 @& H; H- c1 x0 d# SLngKeyE = "32823"
! a+ h7 \$ @3 }LngKeyD = "20643" . G3 h; l% o4 K/ [; W4 M6 K
LngKeyN = "29893"
" Z7 G+ d  Y; J8 d4 p* tStrMessage = Message 1 W% M1 Z+ s* V1 K4 e8 n  s# c
Set ObjRSA = New clsRSA
3 h; V: s$ W" f+ L$ |; g: pObjRSA.PublicKey = LngKeyE " p, R4 d+ b5 m' j) f$ `
ObjRSA.Modulus = LngKeyN
5 s+ V: p8 U/ Z% D8 z0 w( JEncryptstr = ObjRSA.Encode(StrMessage)
- V& Y+ P0 N& w& E. _+ \* aSet ObjRSA = Nothing 8 U  b% j. j# b4 o4 v+ I9 d
end function
5 G+ a$ [! _% j) V6 R- E" P* hfunction decryptstr(Message)
5 B0 H( M- H& o# n1 IDim LngKeyE 9 m& g7 X1 x8 e! q* U- s
Dim LngKeyD
3 ^3 t# r; I$ C( x* g' O$ @Dim LngKeyN
: V& k' ?" G9 |( ]( k: u5 ADim StrMessage , E$ t5 O& J" R0 U
Dim ObjRSA 3 h9 {) |, `6 R( P0 f
LngKeyE = "32823"
' t1 K, o& U( O1 {* @7 v7 ELngKeyD = "20643"
/ E9 I, g% R0 e! c/ LLngKeyN = "29893"
$ @) L( \; c% q0 J" SStrMessage = Message
2 d7 h: X: {/ CSet ObjRSA = New clsRSA
# a; K; B" ~$ EObjRSA.PrivateKey =LngKeyD
' N1 Q, N; \  D4 w) V' PObjRSA.Modulus=LngKeyN / ~6 T+ D2 u! g$ d: }
decryptstr=ObjRSA.Decode(StrMessage) ! o2 W( n2 ^/ G7 J9 c$ L, f* a7 o2 n
Set ObjRSA = Nothing ) H4 `2 I. [! {+ _/ m# W$ S2 @
end function
& u" _8 H" m4 b  X* {9 Gdim last,first ( u) P' C5 s. V+ u
first="!@#$%^&*()"
+ `- T" c6 N1 k  m: w, O9 ?- iResponse.Write "加密前为:"&first 0 e4 D" ]. ^( N7 l( A- {' G
last=Encryptstr(first) 7 z9 F2 f1 E6 M3 K5 [% b6 Z# M8 G
Response.Write "加密后为"&last , M% M" }" x! _( `1 t
Response.Write "解密后为" &decryptstr(last) ( N4 x) d/ l# T* u, ^$ ~* p
%> ==============================================) c* f+ u9 m# f$ I0 ~$ x& q+ F: |
剩下的就是字符的对照表了
5 X7 s2 X" y, d===================字符集================5 m* N5 r5 p$ W0 B
1_____6EBB! |# A. [+ O# Q' h
2_____5C1F# ~  T4 y) J6 _4 }
3_____4D75
- z0 v. c6 g* @" u4 b* X4_____26CC: H9 v+ n( }% |" U, Y
5_____4F881 y' n" B! L8 H4 d3 M2 q
6_____3F4E
' Z8 h. M7 G  h( p9 w1 W* \! N  S( z6 d7_____0A9D
' E) ?( s0 Q  X; P5 ?' c8_____1A1C
* q8 M" {5 k& |& B9_____6D20- O  u2 ]) q# g4 A0 d
0_____1089. ]  i3 D3 t) J3 j/ A2 G
a_____0F3E2 _0 z+ U- P( [" z  j# W
b_____3159
8 x2 a, D1 s: qc_____3517
3 e# x! n& `" u* }1 \* l0 f, ed_____419C, ^7 O- `, X+ d1 {" @1 u& c- C
e_____615C
- w; Z& [7 y9 A5 W" Jf_____556F4 I" Q5 O6 e% I6 n
g_____2B7F
; t; c; S7 X% f, Y6 rh_____0F9C
" Y4 h6 v% T: S' u' ti_____00FA
0 G( N1 d" d' wj_____5A506 a! J/ |8 x8 s+ B6 N
k_____2850/ ~& Z8 B  Q& W  s! d4 h
l_____3E7B
- Y. x1 v- L/ Q4 J! `* a. dm_____71C5. c% x8 K* Y2 M& M0 j
n_____1FC8
: {1 C/ I. ~0 Q  x$ co_____74C1% k* [- y0 e5 B, o+ d" u" z
p_____5FB8. Y3 e+ J5 R' L1 c
q_____6085( X, ^4 X& W% O: t- u8 K
r_____3AC4/ r6 G. Z" w# L6 [- [0 o
s_____2F503 y, N- p( d) x) }5 `4 i1 O
t_____36F8) ~* Q* p( I" ?$ x% U6 \
u_____7010; [2 I- I5 {3 D7 F2 l4 y* M
v_____0B42. p+ Q; A; @" P8 G
w_____1C7A3 t3 i: S. v( L2 Z( n
x_____16F88 B* |" t/ E0 M
y_____2EE7
: _0 e1 L6 L% f" x% @z_____5CF3) c& w( u. \3 W4 Z2 R
!_____6233
# M( z0 v( X* {3 S$ m" u, i@_____3A45( t0 J! K$ f! F
#_____2291
" Y# |5 S& m* ?: w$_____5D5C
$ [6 a, i' s1 g/ N/ h%_____09B9
% M7 Y: I) k- d9 Q^_____43EA
$ H. d' M$ O+ G! c/ ^1 x&_____62B9. A. A7 s. @' ]2 K; X$ ~) q1 `# {
*_____63019 E4 j. Q/ ?7 U3 n& l
(_____4659* `8 `" Y% r8 I6 b
)_____5C82
希望做站长本人的学生请点击
http://www.3ast.com/viewthread.php?tid=13841
QQ790653916只负责SEO以及收费教学等方面联系,他人勿扰

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

收藏了。。。。。。。。

TOP

返回列表