返回列表 发帖

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

原创作者:柔肠寸断 [3.A.S.T]  http://www.3ast.com.cm
: V4 [0 g- A6 U" y- p' ^1 k& Z原始出处:http://www.3ast.com.cm9 C3 K& f$ |3 \' K2 G4 V6 n

( o* J; `1 W& X5 a: D) U$ c! u9 g看不懂的直接绕过* ^4 j% w( n. t+ @* R. D
加密前为:hwy123456
- a1 N% u' [, w, v% r加密后为0F9C1C7A2EE76EBB5C1F4D7526CC4F883F4E) O$ S9 `" C' g3 I

1 c( k8 y% @8 o3 J============================================2 s  g" n$ i- F3 A
上面是当时自己校内的心情。现在已经解破出来了,分享给大家/ V$ M+ q! J& ?) x, F- c
也就不隐瞒大家什么了,这个是国内某知名大学的后台加密算法
4 B3 y2 B2 _% Z( ]( y/ v1 |以下是RSA算法文件
# k7 J) ]4 E& ^% A4 _1 G9 I# Z3 V& E7 q5 _4 @5 O  X& J( ]& w5 e9 n/ H
文件名RSA.ASP% {7 ~* l/ N5 {( Y
===============================================
( {3 M+ n! y9 n! q( S( _9 k<% 4 n" L: y+ M) }: B- O; j
Class clsRSA " R3 r( _9 Z. P9 L) d
Public PrivateKey - r  T1 f) L5 J( G9 f5 Y; T# |
Public PublicKey
5 G- O( `8 `' v! `Public Modulus
% B3 M8 L) C' f6 fPublic Function Crypt(pLngMessage, pLngKey)
' U( S. w+ E0 B4 x0 e- Y# ZOn Error Resume Next
  [' U, Y. g' C0 p7 @1 ^Dim lLngMod 3 g( A- b5 t1 h4 E
Dim lLngResult % r0 e- {4 b' I4 s  Y
Dim lLngIndex , \0 Q& c/ a) `2 k: V, u$ w  d
If pLngKey Mod 2 = 0 Then
/ o; }( \0 ?7 m% i) Y) W) y+ plLngResult = 1
4 U; C* ^4 L/ `# T& @For lLngIndex = 1 To pLngKey / 2 . n- R8 ]+ j' o& B
lLngMod = (pLngMessage ^ 2) Mod Modulus 3 N4 s( b6 {7 ?+ c
' Mod may error on key generation 8 s4 f0 n4 ?% I" V' e
lLngResult = (lLngMod * lLngResult) Mod Modulus
/ T9 s! I; ~+ x7 u& [( xIf Err Then Exit Function
# c5 e" O$ j8 ?* y3 KNext ) V; a2 v: }% y( K; d8 V/ `
Else ( y+ B/ v# {9 }0 B0 }3 ]4 P
lLngResult = pLngMessage + L; K6 p0 d8 s# y8 |: {0 ]
For lLngIndex = 1 To pLngKey / 2
# x" W! g  _. p5 _" t( E5 x( OlLngMod = (pLngMessage ^ 2) Mod Modulus
* M7 C9 U3 O/ N7 u# Y4 f) TOn Error Resume Next
/ b" A/ z# G4 r' Mod may error on key generation
3 s9 d' O- }3 i, WlLngResult = (lLngMod * lLngResult) Mod Modulus
% g- c* [' K" U# @- IIf Err Then Exit Function
/ J& f8 U- T( o; G' p5 `9 pNext 4 i, I4 o! F# N; `- {* Q
End If
* m; b: c2 T3 b! pCrypt = lLngResult
. o. V+ ]; J  Y* i# ]End Function, i0 O5 }: E) e$ Y; c( J& w' z
" i1 T) @! ~  Z9 ?" y6 E
Public Function Encode(ByVal pStrMessage)
. p8 v$ T( Y6 ~0 TDim lLngIndex
# J/ H' Z3 b( z6 N2 E0 S) ZDim lLngMaxIndex ' h2 \9 I! Y) t
Dim lBytAscii
. }. A9 _6 X4 \& M  [# ?7 w/ yDim lLngEncrypted + n4 m+ f8 m, A+ u& {1 `
lLngMaxIndex = Len(pStrMessage)
1 b6 S& W6 [. F/ C/ `4 OIf lLngMaxIndex = 0 Then Exit Function
4 c  {& h, `1 sFor lLngIndex = 1 To lLngMaxIndex
" \% ~5 y& A( n, YlBytAscii = Asc(Mid(pStrMessage, lLngIndex, 1)) ) I9 b; Q( x: W- e
lLngEncrypted = Crypt(lBytAscii, PublicKey) ( i7 U  ~( C, t/ m9 q
Encode = Encode & NumberToHex(lLngEncrypted, 4)
. F$ |) B  ]- t8 ^0 a) d) sNext
. e& _+ q6 M2 I1 m- ~End Function ! B  A+ ?! o0 E$ x
Public Function Decode(ByVal pStrMessage) . X' Z, {7 N+ C, V: F' c* e. \
Dim lBytAscii
! p  N0 U; c& @# lDim lLngIndex
/ ^0 P# |9 k6 XDim lLngMaxIndex 0 i/ |9 V8 G7 i9 y
Dim lLngEncryptedData
8 b! `* r$ R  I% @7 fDecode = ""
" [4 x. L- G* j% D. b! A5 jlLngMaxIndex = Len(pStrMessage) , _+ r1 Q0 b( g8 e: f9 L1 e
For lLngIndex = 1 To lLngMaxIndex Step 4 5 W0 \9 g' F& W/ x
lLngEncryptedData = HexToNumber(Mid(pStrMessage, lLngIndex, 4)) 9 Y7 Y2 }6 ]" i; _+ R4 c6 v9 z
lBytAscii = Crypt(lLngEncryptedData, PrivateKey) 4 G3 P4 X( G! W% a! J4 i+ N
Decode = Decode & Chr(lBytAscii) ; B( l9 d+ u2 n" L. ?( U2 C7 Y
Next
( W% }4 S! c# Y: bEnd Function ! j) h% _# V( ]5 L
Private Function NumberToHex(ByRef pLngNumber, ByRef pLngLength) / N6 [# M* R  \  u2 L; C
NumberToHex = Right(String(pLngLength, "0") & Hex(pLngNumber), pLngLength)
# D2 P9 n7 O4 n2 L. q( M! eEnd Function * J8 o( ?' R) a; x7 W, U2 h) P
Private Function HexToNumber(ByRef pStrHex) * ?0 q2 }9 \3 N
HexToNumber = CLng("&h" & pStrHex)
; h( t0 j; S( E" S$ WEnd Function
! s, Z/ ^# s& R# `9 e* n0 {End Class
! U1 a" \# p- e5 J/ r3 E" m; p% nfunction Encryptstr(Message) 5 L, c0 f0 o4 X: Z
Dim LngKeyE ( d8 e: n; s: N; Y3 U
Dim LngKeyD
3 N8 `1 {* }0 @9 B2 q9 b* x& RDim LngKeyN
/ F" @1 Q) H  i/ G. ADim StrMessage
/ z! B% c( g% I$ ^Dim ObjRSA 1 p7 p! B3 o% s2 @  O) O3 X. o/ r4 A
LngKeyE = "32823" 3 T. s, n3 \- v; H# \) H1 Q
LngKeyD = "20643"
7 J6 `5 o% K2 M7 ^0 `; N3 |6 ^LngKeyN = "29893" # O9 U: r$ h" O
StrMessage = Message 7 q* T$ l3 n# W' \& C% M
Set ObjRSA = New clsRSA $ Q  v1 K5 o/ T2 i5 d
ObjRSA.PublicKey = LngKeyE
/ S3 c5 n/ b% @4 oObjRSA.Modulus = LngKeyN % Q( j  w6 I) |9 V
Encryptstr = ObjRSA.Encode(StrMessage) + F+ g% @& F- Y9 m2 R$ P7 U. u
Set ObjRSA = Nothing / W; T1 l1 [/ N3 b# r% ~  {
end function
% b9 g- f+ ^/ P' KFunction Decryptstr(Message)
1 C4 A$ ?8 B" YDim LngKeyE " w4 U: }* `: E* e/ |0 p$ a, O$ j
Dim LngKeyD
8 ~/ B$ W6 o/ f3 x6 l7 O6 DDim LngKeyN
6 |  d0 b9 t. q3 O! }5 kDim StrMessage / u) {- |' N& I( `& D
Dim ObjRSA
! k# x: V* F5 C5 j- [( A; n% J9 MLngKeyE = "32823" 2 i8 I5 F/ z  @& K  n
LngKeyD = "20643"
7 I$ j9 e; L+ I. l6 oLngKeyN = "29893"
; h4 k' a$ a. r$ U# A6 DStrMessage = Message , o$ |- o7 _2 g# d' f# _3 N
Set ObjRSA = New clsRSA
6 g7 s8 G( u- gObjRSA.PrivateKey =LngKeyD
: a  _7 G+ D6 q, @+ TObjRSA.Modulus=LngKeyN
7 [* M* B' P9 x& l& j" {decryptstr=ObjRSA.Decode(StrMessage) $ U( p" k- k8 s& g* ~/ ?3 w& C
Set ObjRSA = Nothing
% o8 z: f5 K; X! B: Xend function : R8 l' g* G/ d( ?0 O2 {, O
%>
6 F& V$ [+ z( ]; |/ ~===============================================9 v" B: v' N2 r0 C$ Y

( r1 u; Y+ E2 ]* Y% E还有一个用于测试这段代码的test.asp' n. w* Y2 \' m
有兴趣的自己搭建个IIS测试下
* z( `) ~' |# q9 s0 N<!--#INCLUDE FILE="RSA.asp"--> - d5 V1 D' |2 E, U' W6 J
<%. w- n& ?) x1 z# z5 t) n
function Encryptstr(Message) 7 \& D* Q6 n; ]0 [( N
Dim LngKeyE 7 {( v& f: d3 c
Dim LngKeyD
9 O1 C2 `5 p3 P% eDim LngKeyN
. V! ?0 f- Z9 b7 {Dim StrMessage
+ d7 V0 q) `$ bDim ObjRSA
2 _& R3 [  [, p/ ?% T% @LngKeyE = "32823" 0 ?" ~/ C0 X  e
LngKeyD = "20643"
5 ?/ H, y2 m' \& MLngKeyN = "29893" + Y  R4 \7 }- m# H* h& S8 a
StrMessage = Message - ]: h  L( C6 k; x
Set ObjRSA = New clsRSA
: r# b& F  C: M2 DObjRSA.PublicKey = LngKeyE 9 u" i2 \2 N7 [
ObjRSA.Modulus = LngKeyN
3 U* V' d/ ?! q. FEncryptstr = ObjRSA.Encode(StrMessage) , }4 Y8 H  M- b
Set ObjRSA = Nothing " ^" D( `) b3 b, W$ Z8 A$ ^5 y$ @* b. H$ G
end function 5 a% z/ Z( o" P7 M5 U
function decryptstr(Message)
  y8 E; P* o7 }5 V9 H( V) ]7 tDim LngKeyE
/ e; x8 _; ~% u: h1 T/ R6 rDim LngKeyD 6 k, E+ C, t# C6 Q; R& O
Dim LngKeyN # _/ c# r2 d% M: d4 v/ S: j( w
Dim StrMessage
. {% ~) a0 i: a0 m( bDim ObjRSA 4 P5 [0 ^5 [4 A  O4 P! j# u
LngKeyE = "32823" 8 z7 C4 }0 {- [8 s' |
LngKeyD = "20643"
3 f4 J  r' k5 Q8 S* S0 OLngKeyN = "29893"
3 D9 T. a6 G; X/ e4 V/ B( p0 f$ j- bStrMessage = Message + \- R% @/ D& [* U. _& @
Set ObjRSA = New clsRSA
5 k1 P3 a. r; T6 b8 Y" uObjRSA.PrivateKey =LngKeyD . ~9 P! C6 E! V# u- P. L; x
ObjRSA.Modulus=LngKeyN ) n( t9 h2 {1 f
decryptstr=ObjRSA.Decode(StrMessage) + J7 r( [# S# F5 D
Set ObjRSA = Nothing . m6 U0 Q# h! K% L) h! Y
end function
5 H# L% w* v! t5 a" udim last,first ) F' x' _. |0 ?5 |' ?
first="!@#$%^&*()" ) Y/ n6 o. V8 t; D4 i4 W* M* O# G) r' ]
Response.Write "加密前为:"&first
3 v1 u# v5 F) h, M3 o! [8 elast=Encryptstr(first)
% S4 b; W, v' O3 h: g9 aResponse.Write "加密后为"&last : t0 G* W" W& N! }; X
Response.Write "解密后为" &decryptstr(last)
4 p; ^  B" d5 \4 [8 i( K%> ==============================================
# B" \4 r/ s2 L" i  u9 ~0 J1 D# q剩下的就是字符的对照表了
; ^1 {3 ^0 {- V6 S7 B1 D===================字符集================5 `1 C! l3 {: Y
1_____6EBB0 t* ]4 F3 d5 R0 d5 ]$ R8 ]9 G; v4 |
2_____5C1F
* m4 ?' ~% ~4 v1 Q3_____4D75
  Z: r& o1 V8 V4_____26CC" `8 K& c0 g0 M* `7 E) Q. T
5_____4F88
8 V# W" y. B! e2 q* X6_____3F4E! O8 N/ c; c' V/ [8 w4 w
7_____0A9D( f2 W" W% s1 u% Q" X
8_____1A1C
" [& J9 f# ~$ ~0 f3 H/ J9_____6D206 ?9 j, Y9 j3 b* [% b# G2 D( h
0_____1089% ~. a, w4 t; G
a_____0F3E$ X4 c- ^& E! k0 L9 p0 k2 {
b_____3159
& G  W3 N# R  F: @& V; {c_____3517
* w* w: X0 r+ \4 e5 g$ [+ G! Dd_____419C* v/ a/ a9 u& Y; t# k* k; J8 s
e_____615C* E0 e0 i6 a1 j0 C% |
f_____556F- Z! t/ }3 I6 f, H7 w' G! f2 t
g_____2B7F
1 `' l/ `9 @7 x  l5 X1 ?" eh_____0F9C
* r7 {" h2 j1 `i_____00FA
/ p' C$ j' B3 L/ j& O: \2 d; tj_____5A50
4 Z' z$ j$ R4 Y. L) q3 n, r8 Wk_____2850
; m2 F% u2 q# \, A) ?' Al_____3E7B
( v# j2 v2 Y* m5 q2 _m_____71C5
8 q; r* e3 F! Z1 k$ Bn_____1FC8
2 ~4 {* V8 y& l( O! fo_____74C1
6 j' y# x( K1 p4 t5 Q6 W' C  yp_____5FB8* {' |; b" D( x7 m+ o* R" K
q_____6085
# k+ h2 Z) u. i; K7 o* N% {r_____3AC4' ]. X. `8 j( p4 i
s_____2F500 Q) K' ~* j1 S. [  }! V
t_____36F8/ N1 v" X# l, E7 a: G6 |) o
u_____7010
1 c$ B) s# S8 `8 U2 H! Y5 `v_____0B42
. Q" m5 B) Y  c0 Ow_____1C7A2 k/ |; o: w- E5 K1 w+ N
x_____16F8
$ F& ~6 ?. Z8 j" W6 h+ Py_____2EE7
# }+ U. `" |0 ?0 @. @8 i# @z_____5CF3# k$ P7 i$ U' E4 o3 S+ G
!_____6233$ I  R2 s5 P+ X3 o4 G6 J
@_____3A45
+ B! q7 w5 X: o#_____2291
7 x* |$ J* y0 Z/ m; f# p$_____5D5C$ _7 u  \$ y! S. E* |
%_____09B98 ^1 ]" e* Y. n2 |
^_____43EA4 C9 ^, N( D7 o( ~
&_____62B9
2 H7 _) _2 [, R# j% T  T*_____6301
* r$ O3 R3 O9 d5 h(_____4659% K, G& g2 J  M/ ^+ o
)_____5C82
希望做站长本人的学生请点击
http://www.3ast.com/viewthread.php?tid=13841
QQ790653916只负责SEO以及收费教学等方面联系,他人勿扰

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

收藏了。。。。。。。。

TOP

返回列表