返回列表 发帖

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

原创作者:柔肠寸断 [3.A.S.T]  http://www.3ast.com.cm
+ Q2 Q) k1 Q) C& m" c原始出处:http://www.3ast.com.cm% p/ I( Z# h3 u
. R) n! j; [% i# i8 J
看不懂的直接绕过
* {+ R4 u; X" M* A3 }1 H) V加密前为:hwy1234564 p( {" V5 t+ T8 J5 F3 L
加密后为0F9C1C7A2EE76EBB5C1F4D7526CC4F883F4E
; [. ^7 U- i$ |" j, r% O  w% K7 I7 A6 {8 Y) @- ]9 {% i
============================================
. @, D! I# c5 J7 x5 H/ P上面是当时自己校内的心情。现在已经解破出来了,分享给大家. N+ i+ A8 m' g+ Q7 |+ S: v
也就不隐瞒大家什么了,这个是国内某知名大学的后台加密算法
2 A; H; B  B( w* N以下是RSA算法文件
' F6 E* Q! V+ h: p% z# S2 B& e( w1 L8 E# r3 X4 B
文件名RSA.ASP
- U. U# B' [5 J1 U===============================================
& k0 r+ l) y2 _) w/ ^<% 3 N4 E4 c; {- F) ]+ p
Class clsRSA
, }, ?6 u1 W+ V9 Y8 D  v0 ?Public PrivateKey
& o9 L, q5 Z  n: G- T; |( y0 WPublic PublicKey
. i# c: T( ^3 B' Y: C1 h; FPublic Modulus
9 [' Z" Y) a  ]( nPublic Function Crypt(pLngMessage, pLngKey) 3 R  ]; \7 H' U- P5 @' P5 E
On Error Resume Next 9 _" \+ x7 ~: K
Dim lLngMod * d" f" Q7 x0 q
Dim lLngResult
  p# W# L9 t! V" I0 MDim lLngIndex 8 k5 n; u/ _8 e5 k% a
If pLngKey Mod 2 = 0 Then
0 [6 C- S; J+ {4 b) tlLngResult = 1
' _+ q5 b/ ?: q: n6 y2 t3 X" XFor lLngIndex = 1 To pLngKey / 2
( V  H2 o, [$ dlLngMod = (pLngMessage ^ 2) Mod Modulus
5 ~& w3 i$ ]! W2 `4 \' l' Mod may error on key generation ) Z* _( m7 ?6 k; p
lLngResult = (lLngMod * lLngResult) Mod Modulus
9 ?$ J$ y7 p8 lIf Err Then Exit Function
1 I" E* z/ \9 s$ j  oNext
( W$ G$ a, A0 L; Q, tElse 9 ]  S9 Z& a' }2 `1 Q7 }
lLngResult = pLngMessage 2 A" W6 K' l  \% `- G' D4 a8 f
For lLngIndex = 1 To pLngKey / 2 3 v+ G7 g; d: j
lLngMod = (pLngMessage ^ 2) Mod Modulus
. n( B1 x* n2 H2 H9 R) xOn Error Resume Next : b. d  _! `- P& A
' Mod may error on key generation
3 D0 F4 _1 G. e! C' BlLngResult = (lLngMod * lLngResult) Mod Modulus
# Y& L$ t$ n; R/ w8 k# O4 `- tIf Err Then Exit Function 7 W! u6 M& V+ f
Next
; r" D& t# O; |/ W$ q! O0 h( e2 R+ S% ?. JEnd If 0 V( }$ h+ Q; s  N6 u/ M
Crypt = lLngResult 7 m, T' ~2 j! U  }+ u/ i1 D) W
End Function( l: w. m- v. O

/ C' M. f* ]2 gPublic Function Encode(ByVal pStrMessage)
% H1 e& @6 o: E( M1 n; i6 L( iDim lLngIndex 6 B# v. R0 j8 s1 B% T. L
Dim lLngMaxIndex , T# ^0 r8 r4 S7 A3 T+ c2 Y
Dim lBytAscii
8 v5 P  f+ e- pDim lLngEncrypted
0 X9 w: @9 u9 V" a9 X  S* V: G3 KlLngMaxIndex = Len(pStrMessage) - g) N0 C5 D# J  n, }
If lLngMaxIndex = 0 Then Exit Function : J8 a5 i0 C- f* M' A4 {
For lLngIndex = 1 To lLngMaxIndex
2 D) c+ G+ _6 F1 u1 WlBytAscii = Asc(Mid(pStrMessage, lLngIndex, 1)) & r6 Z! S4 j4 F  T2 ~$ K
lLngEncrypted = Crypt(lBytAscii, PublicKey)
% C4 N: O9 A  `# H* P# EEncode = Encode & NumberToHex(lLngEncrypted, 4)
. v) a8 p% Q! [9 _7 v2 ENext
7 e  I9 K4 f) Y3 j1 H3 F% UEnd Function
- E5 z- [8 Z( l6 {: A6 }Public Function Decode(ByVal pStrMessage) ' @$ S! D. P- ~  V
Dim lBytAscii 1 }2 W; C6 J- j. c
Dim lLngIndex 4 }+ b% ~& i( ^% P
Dim lLngMaxIndex
1 H9 s/ p7 `1 j- q1 a( P2 E$ ~5 X2 |Dim lLngEncryptedData
. S5 C3 [% ?/ z" Y9 HDecode = ""
& a( h1 k9 F7 ~- x3 O9 rlLngMaxIndex = Len(pStrMessage)
) e; E' c6 t. S9 M8 C, UFor lLngIndex = 1 To lLngMaxIndex Step 4
4 V0 F3 O& D: w  q: E" LlLngEncryptedData = HexToNumber(Mid(pStrMessage, lLngIndex, 4))
" D- c! r0 ^6 r5 p5 r) XlBytAscii = Crypt(lLngEncryptedData, PrivateKey) 9 J4 c$ B4 ^) n6 x) S0 I; ^9 z
Decode = Decode & Chr(lBytAscii)
, x2 C" b" b+ O  RNext
& _. b& h7 F8 _# M% cEnd Function , J4 W) Q% r3 p: O: g
Private Function NumberToHex(ByRef pLngNumber, ByRef pLngLength)
: u- ?) ]" ]6 a$ oNumberToHex = Right(String(pLngLength, "0") & Hex(pLngNumber), pLngLength)
/ [$ z4 v: }5 \; [$ ?. b# ^End Function + ]0 G4 X& ?, G" K2 t  D( c  H
Private Function HexToNumber(ByRef pStrHex)
. R. O3 C3 o0 w+ j0 I  h' |HexToNumber = CLng("&h" & pStrHex) $ [7 ?/ C" O0 s
End Function
" Y) d' z3 W) q" P  M4 H3 W, ^  MEnd Class 7 R% A, ?4 B8 i# q
function Encryptstr(Message)
* D" d! r" u2 g8 V' v( V2 I" \Dim LngKeyE 1 x, W! O0 A3 C  G9 E, b1 g* n
Dim LngKeyD 8 B& E+ X+ H0 R/ M0 H
Dim LngKeyN 1 |" e# n' A% ~3 O. r6 A% l/ J
Dim StrMessage 6 ]: c9 N) n! q( Y8 r
Dim ObjRSA
5 ~) H0 R1 K2 h) u: F  y7 e8 }LngKeyE = "32823" , {/ t7 B) z8 _5 t) }
LngKeyD = "20643"
: |+ k9 y" u& K+ s4 d2 ]LngKeyN = "29893"
" O+ L# L/ Q% U8 l6 u2 UStrMessage = Message 8 L+ O: [, b7 o* Y0 G4 v7 c
Set ObjRSA = New clsRSA ! A" |! S, U, o
ObjRSA.PublicKey = LngKeyE
/ P3 n% `6 w4 ~8 t4 KObjRSA.Modulus = LngKeyN 2 r: a3 K) @, ?
Encryptstr = ObjRSA.Encode(StrMessage)
- @0 W1 s* Z4 A% h& kSet ObjRSA = Nothing
  h5 a# _" J, w% _; t6 yend function
. c. D! L9 @3 m+ P0 t& C/ B, gFunction Decryptstr(Message)
6 u1 Y' G) o$ Q% Q. e1 j* R* x# [Dim LngKeyE
/ L- f0 t/ R, y% ~- J' ~Dim LngKeyD * I! G: R0 N. x/ M5 e, Y* d, D
Dim LngKeyN ! L6 J) ]. H' S# j
Dim StrMessage
6 i7 O+ j* q1 F) KDim ObjRSA
  p& R. H5 d+ Z+ u3 _$ e0 K7 oLngKeyE = "32823" ' G: F9 U/ s5 U  l4 k9 p8 V, m, Z2 I
LngKeyD = "20643"
. U; |( ?& ?  ~" L7 D5 m0 y' gLngKeyN = "29893" 5 G- K1 ?$ S" F  ]3 ?, S- d# o3 M: T
StrMessage = Message
$ `+ P0 {8 t1 ~1 h! BSet ObjRSA = New clsRSA : V# e$ m, [0 V
ObjRSA.PrivateKey =LngKeyD + R7 l4 B+ F) W
ObjRSA.Modulus=LngKeyN 9 O# ]7 F% {- X1 \
decryptstr=ObjRSA.Decode(StrMessage)
. s. k. A5 q- p/ O) ?# ~. Q4 pSet ObjRSA = Nothing 9 j1 x0 {! i$ @/ y. T6 l3 n5 d
end function
5 G% M9 [0 A% \1 r  P3 H%>
* `* W, g+ @$ m* }! S2 m===============================================/ i- {% D$ ?4 I6 k& H

" j9 q6 V/ U3 E/ e! W  J0 x还有一个用于测试这段代码的test.asp3 w% s9 d' {) J/ Y; F: b
有兴趣的自己搭建个IIS测试下, t  J5 k% |7 Y/ _
<!--#INCLUDE FILE="RSA.asp"--> - W- _7 j2 r7 Y' R( v
<%; g" g) [/ E0 V/ Q* f3 t0 L
function Encryptstr(Message)
; s: s* _( y& U! _Dim LngKeyE
5 b3 h3 t' m' I( Q; l0 {1 fDim LngKeyD
: h( H, {4 ]+ @Dim LngKeyN
5 Z8 ^# ~( I: Y! TDim StrMessage
6 |- Y0 @! v% a" `. |Dim ObjRSA
* d( Q$ D* Y1 G( ^LngKeyE = "32823" 2 l! P3 B: q  w8 c" f
LngKeyD = "20643"
* Q$ y4 p% n& \1 l9 I* u9 u5 M- n9 LLngKeyN = "29893" : _2 `$ h3 d$ F6 o
StrMessage = Message 1 A# F4 I2 a# k, n, ^! R
Set ObjRSA = New clsRSA ) J; t4 A; }" G$ M1 p
ObjRSA.PublicKey = LngKeyE - j& F8 Q7 s4 S! A4 V3 L% D4 b
ObjRSA.Modulus = LngKeyN 3 N! y  @& j/ V0 X  ]1 x
Encryptstr = ObjRSA.Encode(StrMessage) 6 d  _! G2 Y4 A4 B% u- A
Set ObjRSA = Nothing
% Y$ _2 M$ ?* f& kend function
! i# k5 E  S  pfunction decryptstr(Message)
7 u( I, @$ W( w6 B  TDim LngKeyE / y# }1 Z# T/ C# I9 d0 o
Dim LngKeyD . D$ N' V/ J# f. u: o
Dim LngKeyN " V6 L3 h. |8 m+ n2 p9 j& g
Dim StrMessage 8 y7 r, p. Y, n6 ?1 z
Dim ObjRSA
0 b" l0 \$ l) M6 p9 w" {1 k; uLngKeyE = "32823"
& v& V& g2 S' m& wLngKeyD = "20643"
% |# w3 x7 p2 w3 ~) c+ K1 dLngKeyN = "29893" ' n1 v2 d' D0 V# b) u" w
StrMessage = Message
" r4 y% S$ [3 u* nSet ObjRSA = New clsRSA
( M( W- U" m9 A1 n6 E3 Q0 M5 ]ObjRSA.PrivateKey =LngKeyD
+ J; h  z% |+ c% l7 O2 IObjRSA.Modulus=LngKeyN
, p4 }6 P% a" e# _; n7 R) U4 cdecryptstr=ObjRSA.Decode(StrMessage)
4 A& G( N2 P1 C% \Set ObjRSA = Nothing
& W+ C6 |* P7 s3 a/ |! M( @end function
9 m0 c0 i7 F: y8 f3 l2 Mdim last,first
  Q1 e3 k8 h5 y9 |' d+ dfirst="!@#$%^&*()" ' A0 J7 s* K8 S' o4 M1 x
Response.Write "加密前为:"&first * n- W# o! P3 ?2 E% u: t
last=Encryptstr(first)
$ J2 B$ e% \+ x& j' B4 @. wResponse.Write "加密后为"&last 1 l' \' [  n$ d9 E- V# X* L
Response.Write "解密后为" &decryptstr(last)
- D! ?; ?; r) W- ^9 V%> ==============================================4 H) X# T! s( j! d+ o. b" n+ J1 t4 T
剩下的就是字符的对照表了) H1 l! N  j! b" |! A; ~5 }
===================字符集================
8 o0 O$ X$ F# w: V+ W6 C1_____6EBB2 H  P" A7 d3 |8 g6 F
2_____5C1F
6 @& J9 B) S8 B( k9 X* }3_____4D75- N- H  e) b% c2 }- U
4_____26CC
, w. U4 Q2 q2 t' _" B5 |: ^2 x* Z5_____4F88
; O" B7 j  n0 A6_____3F4E8 I2 j2 }% R6 E5 v# ]  y' ~
7_____0A9D$ B1 _* _4 W" D' @. o; w' p
8_____1A1C
& O. M: o1 e2 T3 U9 w9_____6D20
4 z- S  V7 y" R* B2 b3 D0_____10898 v  h4 Q4 u0 z7 O
a_____0F3E: b! Z9 d- }8 i+ h7 W* E
b_____3159
( e  a$ g. Q- n* yc_____3517. d# a4 e6 @/ X& G% s
d_____419C3 J) C' Y1 {* W2 M* T3 s- Y. S
e_____615C
$ i, U  d- |' n( T' mf_____556F
# [: S  t* B- P8 F9 ag_____2B7F9 N) j6 D; y! |3 ?
h_____0F9C2 J; S: F% F( w
i_____00FA5 }% o. A7 Y5 l8 h; H- k
j_____5A50% m: P$ E4 d/ R9 }4 i% x  i* U) K
k_____2850
2 b9 O% C; p3 q0 A7 Z. kl_____3E7B
" q0 c% x7 k  _/ X. \m_____71C5
) w8 T% O+ q. O/ g' s, V9 ?2 L) B' Zn_____1FC8
4 [9 i5 _( g. P/ a+ d  no_____74C1/ W/ f( {. g% ^5 Q8 ~4 l
p_____5FB84 T4 P$ A- P4 U$ E
q_____6085, j8 ~9 C7 S( B3 w
r_____3AC4
$ A! q- N& v) G" A( J: Q: o& M# p1 ts_____2F50
' _* e* A; a: g7 e$ H2 k+ \t_____36F8
% |0 `4 e. `2 q* gu_____7010
+ }' D# }) x9 u/ H( S' X4 z& `: A2 Ov_____0B42( t2 C# R) {) S1 d
w_____1C7A7 E% ~- n3 d+ O7 ^: l
x_____16F8
8 |* ^# M0 W$ Oy_____2EE7. h0 {6 z3 W  {+ E
z_____5CF3& E& w) H) Z0 Z- o# ~7 ]
!_____6233
/ l6 W( g( i/ K5 h& {( v8 p0 t: L( e@_____3A45
3 f3 _/ J( K. M  z% j#_____2291/ h" @) B; A6 ?) k8 w0 v7 b2 t
$_____5D5C- A5 I5 p* L/ F. Z& E
%_____09B9% F' `4 T% P( e) V: `, i3 B) `
^_____43EA1 H. H' p8 M3 y( Q1 k% E& m
&_____62B9
8 t/ X* e& |) H4 j4 I" ]*_____63018 {8 ~& w& z( n% {
(_____4659, l- h2 C; k% o# J. \% |: I. ?
)_____5C82
希望做站长本人的学生请点击
http://www.3ast.com/viewthread.php?tid=13841
QQ790653916只负责SEO以及收费教学等方面联系,他人勿扰

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

收藏了。。。。。。。。

TOP

返回列表