返回列表 发帖

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

原创作者:柔肠寸断 [3.A.S.T]  http://www.3ast.com.cm
. k9 i$ x$ e6 ]5 N原始出处:http://www.3ast.com.cm/ q( C6 i# n! j) P3 P  q
! f' Q8 F6 \6 M9 Y/ F% j* l" h7 J, G
看不懂的直接绕过2 Y& I  P6 J9 X9 X/ D
加密前为:hwy123456/ b4 W# s; l! S# _
加密后为0F9C1C7A2EE76EBB5C1F4D7526CC4F883F4E/ K8 G' o- f; U6 ^

- ]- L& t; D2 E# o6 A' G============================================: H; f( T2 B; T" [8 ^
上面是当时自己校内的心情。现在已经解破出来了,分享给大家( y5 A4 y4 g! \8 s1 V
也就不隐瞒大家什么了,这个是国内某知名大学的后台加密算法* F* h& T( o' c* g
以下是RSA算法文件7 n$ O2 T9 j8 I( _5 j

3 |, q3 S7 h  w( f' }( u0 {) K文件名RSA.ASP
) B2 f3 v3 a/ E! _2 ?" X2 w3 F" E===============================================- z( U, i: W5 s, O, m4 [- Q
<%
1 _! f6 L8 O# ~. [) ?Class clsRSA
+ [* c+ @" M$ \2 l' A/ hPublic PrivateKey
9 S% F( R+ @! ]! ]* x" m) A- f( y9 l/ mPublic PublicKey : s" i# {3 C( t8 g
Public Modulus
+ o. A; k# P  H' GPublic Function Crypt(pLngMessage, pLngKey) # v/ T6 }5 a, W( }3 A
On Error Resume Next
- A6 N. V4 p8 l8 R# ?0 hDim lLngMod ( f% S& P/ X# @, P- R/ H7 Z4 R
Dim lLngResult
0 n; k# w' _3 W! t; s7 DDim lLngIndex 5 A8 U8 ?$ J/ C
If pLngKey Mod 2 = 0 Then
" e6 X7 Z/ J& L3 H2 N5 p0 [lLngResult = 1
) l/ ?% Z  s( o5 n4 }For lLngIndex = 1 To pLngKey / 2 4 {+ T) b" \) Q
lLngMod = (pLngMessage ^ 2) Mod Modulus $ L/ z; D, m4 e4 p& W
' Mod may error on key generation . K- m1 J, X8 p2 g0 _: P! B
lLngResult = (lLngMod * lLngResult) Mod Modulus
8 }) E- a2 K. y' A. OIf Err Then Exit Function
6 W! q8 f# M" {$ `$ ONext
% ?) h, J# y: lElse ( c) n- d* a4 g0 L' ~# L
lLngResult = pLngMessage ! m* N) s7 U: G9 }! s2 y; F. p
For lLngIndex = 1 To pLngKey / 2 4 _; \- g8 _0 x# N- Z, i, w
lLngMod = (pLngMessage ^ 2) Mod Modulus
$ C+ n5 D  ~- O* HOn Error Resume Next
7 e' q9 f. }" y( a# o' Mod may error on key generation
* O4 S5 ]$ a- {2 Z2 e) W0 C/ U2 R5 clLngResult = (lLngMod * lLngResult) Mod Modulus
, |' z2 g4 w0 S/ NIf Err Then Exit Function
( P2 f2 h- _' d, bNext 0 d$ m5 ~# s7 T9 q
End If 2 y- c$ B: I! e. k" G+ V
Crypt = lLngResult
7 I( n& r+ k- z) ~! TEnd Function
; r. b9 Z3 c: L7 A
2 [0 h& ?! y- j0 P! Y; U. ]Public Function Encode(ByVal pStrMessage)
1 Y8 E6 y, ~1 B6 G( MDim lLngIndex / U5 o% j4 L3 F
Dim lLngMaxIndex $ x- B* E# F' N7 @9 g
Dim lBytAscii 1 m& Q) m9 [  N7 G8 {: P* `9 [1 n. v
Dim lLngEncrypted 0 i2 U, G3 O9 K. R1 L
lLngMaxIndex = Len(pStrMessage)
" A( }$ W7 }  e  \If lLngMaxIndex = 0 Then Exit Function
9 c. j  o( s/ DFor lLngIndex = 1 To lLngMaxIndex 6 {  n2 S, g# i# G7 m" ]
lBytAscii = Asc(Mid(pStrMessage, lLngIndex, 1)) 5 \- A+ Y% P. u3 V6 p& B
lLngEncrypted = Crypt(lBytAscii, PublicKey)
7 `3 V* K7 i9 G& zEncode = Encode & NumberToHex(lLngEncrypted, 4)   j' e$ Q7 i5 z2 J& @
Next 4 z! F6 {, f1 h6 k/ h: g, H' d
End Function : \1 _" M. A/ J% f4 U
Public Function Decode(ByVal pStrMessage)
8 R6 `3 p5 _. b! _Dim lBytAscii . F7 i+ c  h$ k* V! F; z3 M
Dim lLngIndex
8 g/ T6 M: N+ G  }8 J# s! fDim lLngMaxIndex % b" y" ?3 @5 H" n7 [) m5 H# z& G
Dim lLngEncryptedData
! }% [8 O1 w2 j% s& L' f: MDecode = ""
; |. V8 o! e* b8 D) V/ r3 o, }lLngMaxIndex = Len(pStrMessage)
" l0 n) X7 P+ c9 d. [For lLngIndex = 1 To lLngMaxIndex Step 4 1 q$ E8 u4 [! i6 }( G: O: l
lLngEncryptedData = HexToNumber(Mid(pStrMessage, lLngIndex, 4)) 3 |; \+ {2 z* n" z
lBytAscii = Crypt(lLngEncryptedData, PrivateKey) 3 O2 G% ]# o# C; U  t; P6 I( Z7 B6 J+ d
Decode = Decode & Chr(lBytAscii) ! L% l+ E* ?0 j/ l
Next - z/ l+ c; g( C. g% p( i0 b& H
End Function
( Z! n% }, w, w) |9 xPrivate Function NumberToHex(ByRef pLngNumber, ByRef pLngLength)
! Y1 @1 r5 [% a- |0 B7 cNumberToHex = Right(String(pLngLength, "0") & Hex(pLngNumber), pLngLength)
* h! o* F6 P0 ZEnd Function
, \; |4 S/ k) vPrivate Function HexToNumber(ByRef pStrHex) ) i& N+ N' k9 E3 c: d
HexToNumber = CLng("&h" & pStrHex) ! l" S- G# q8 x7 e7 R
End Function / ^, x; T  ?+ s. [( ~' e) i
End Class
* g7 W$ e; I! @* y0 Lfunction Encryptstr(Message) . _4 L. A; c& p* M
Dim LngKeyE 8 D: N' C  H) D6 L& v/ q
Dim LngKeyD 3 [3 h  Q# {# [
Dim LngKeyN . L2 F" ^5 X4 s: @& M
Dim StrMessage
# {' v% a- r. X, gDim ObjRSA 5 ~( }+ l% Z' I( n
LngKeyE = "32823" 1 s* g  u/ Z, }' J7 D& q: l
LngKeyD = "20643"
/ l7 g9 o1 C: F. v8 ?' o. |1 hLngKeyN = "29893"
4 Q. ?! ^1 V9 N$ ~( N5 l  EStrMessage = Message
! J/ `7 {$ H+ O1 T8 {, h8 @Set ObjRSA = New clsRSA , s  y  U' I  S( u) Z$ R! ?
ObjRSA.PublicKey = LngKeyE
5 p& d* G7 W/ }2 [  q4 zObjRSA.Modulus = LngKeyN 0 m/ c' Z7 C# a- c6 H
Encryptstr = ObjRSA.Encode(StrMessage) 9 B& a7 n, I7 I9 {
Set ObjRSA = Nothing
3 @: Z3 u+ W1 p- Eend function% C& c0 B5 Y) M6 s
Function Decryptstr(Message) 7 t: w; {& C' I9 K9 i7 X2 u. P
Dim LngKeyE , b5 a6 W# @* p/ w5 r
Dim LngKeyD
5 E1 `4 V, o3 B: v: s' ~Dim LngKeyN % T% h% x& l3 C
Dim StrMessage
, g+ Q" I/ C( o/ U6 V+ ^* FDim ObjRSA
( X7 a/ Y! F" Z! B; F% @7 u$ FLngKeyE = "32823"
$ c, t& _, O' MLngKeyD = "20643"
3 i6 X* i! P) q2 i+ ^" ^; xLngKeyN = "29893"
1 g9 K8 o% N: V2 a7 EStrMessage = Message ; r- H# F( G1 D8 a2 J  E) F' D  @# D) N
Set ObjRSA = New clsRSA
1 |3 o/ s4 N3 v, ^ObjRSA.PrivateKey =LngKeyD
' U' `  E' h  M; G* `9 C3 \ObjRSA.Modulus=LngKeyN 6 V, ^$ f9 S- u
decryptstr=ObjRSA.Decode(StrMessage) $ G0 O4 V( a$ c& y' [7 N
Set ObjRSA = Nothing
) [; ^( m3 `/ E! K! d1 e2 \4 Yend function % d0 l& Y5 H/ ?
%>$ f; d, j/ z. z5 C7 [
===============================================
3 M. }9 k+ X* _! v  u6 N0 \& `  A! H# p% ]: i1 H& U
还有一个用于测试这段代码的test.asp! R; [. `8 Y5 W; j( X
有兴趣的自己搭建个IIS测试下. O- P/ Q) V( z- `- A
<!--#INCLUDE FILE="RSA.asp"--> ; c) N* d6 T: _6 F
<%
6 a! k2 q; _7 k$ I% a& O! Xfunction Encryptstr(Message) ( t; J# ]7 F, w6 Q7 Q* J
Dim LngKeyE   i0 s/ P7 y( H0 o, a
Dim LngKeyD
0 C, `# T* \- Z6 P* W6 h1 hDim LngKeyN
4 d/ O" ?) s, d: b! dDim StrMessage , m. O4 D) A. i
Dim ObjRSA 7 T2 }2 D3 u  g. ?4 t5 `% A
LngKeyE = "32823"
( d: M0 C6 ~, M8 }LngKeyD = "20643" ( }* p$ |% R; X* k1 u
LngKeyN = "29893" # h' l1 r8 n; L# @/ m4 q: z
StrMessage = Message ; q3 E4 n- ^1 m& t* o' c* _$ M+ I7 N+ B
Set ObjRSA = New clsRSA
, M: v$ m/ C8 C. Y1 t3 n) BObjRSA.PublicKey = LngKeyE
0 ^  C( H/ K( u, rObjRSA.Modulus = LngKeyN
' [. j1 N" j- \Encryptstr = ObjRSA.Encode(StrMessage)
4 Y6 f/ H0 k4 vSet ObjRSA = Nothing 1 z" K  n9 q% M& x
end function 2 o1 r' W( Z" L
function decryptstr(Message)
* A9 `" z, Y; nDim LngKeyE 3 ]( p* s* \% o
Dim LngKeyD 0 m& D; M5 `* f' i9 q- y1 p' L8 r
Dim LngKeyN
: R' N+ K4 {) MDim StrMessage
7 ~( I, H) F( g4 M7 W& pDim ObjRSA
  R9 ^. ^  u% ALngKeyE = "32823" 3 w% {2 G8 g% X. Z  A" b
LngKeyD = "20643"
7 D) J" e# h* {' ~9 I& qLngKeyN = "29893"
( N. T& ^) n9 _8 b. VStrMessage = Message
4 m, b  _9 E, K, r: M! |Set ObjRSA = New clsRSA
4 \6 E6 Y4 _3 B+ Q' s  sObjRSA.PrivateKey =LngKeyD & f# x0 I1 j0 K, K: W
ObjRSA.Modulus=LngKeyN
8 R: v) @. u! D$ h, ~5 |: @/ o3 ldecryptstr=ObjRSA.Decode(StrMessage)
3 G! U, ~* Z6 O% z- nSet ObjRSA = Nothing
5 @0 u! i2 [( F; B" }- F  ?end function ) w1 b0 W' n2 V5 |$ Y
dim last,first ! q( k$ V: u( F( u8 V4 f
first="!@#$%^&*()" " J, p2 E" l& i) e5 Q
Response.Write "加密前为:"&first
( R# Q1 r& M0 E) W& {0 Llast=Encryptstr(first) 4 r) ~. X! w; w( `5 {( ]4 T
Response.Write "加密后为"&last
+ h; _, z$ Z$ K. hResponse.Write "解密后为" &decryptstr(last) ( X+ u0 o/ ?* I. H7 @8 i+ g2 k
%> ==============================================
" J8 u' D. t( B$ o: F剩下的就是字符的对照表了6 O- F1 O. Q3 W, I8 j2 _9 h/ o2 G
===================字符集================
  g/ k8 y0 B$ W' O1_____6EBB
5 f4 y0 T6 {( O& q2_____5C1F
6 i4 Q: l0 n5 Q! |2 \& R3_____4D75
3 d1 m! [' [1 h' Q4_____26CC5 m& l& d+ s, V
5_____4F88+ C! |, r5 X; e# k1 ^4 }& H" `: ?( E
6_____3F4E% x! u0 l- N5 ]
7_____0A9D1 M+ @* b" x! J7 D: R( r/ A
8_____1A1C/ ?1 a, y) i+ Y7 q
9_____6D20% r# X+ y8 `1 u
0_____1089
. S! S  g2 o3 N' ba_____0F3E
" k) Y8 z3 B. F' u. H7 u6 Nb_____31594 f# k/ P; j$ v" d9 N$ t
c_____3517
! [1 l( L' I2 S, [7 @d_____419C
' a& G( G- R/ T% q: Y. ce_____615C
* M" w2 S2 U9 A8 w9 ff_____556F$ K+ G0 {; y. `4 W. V2 c3 n. w
g_____2B7F( }3 J* Y. a; f' D" M3 s
h_____0F9C( S! [; J8 l6 Y
i_____00FA0 ^- P+ ~6 `4 p: a9 \2 ?  e
j_____5A50
- n- y7 z/ V8 I! p  o& r! y8 O8 Kk_____2850
$ I! f  k: i. \3 S4 C3 A- b; xl_____3E7B$ h: ~7 ]8 x2 q+ {1 {
m_____71C5
; Q9 x' x- Q# gn_____1FC8( Y) c! @6 P- |. |4 U1 j; V3 e
o_____74C1* {6 g/ [+ G- S. d; Q# Q1 T
p_____5FB83 c: x" [1 N, ^' h: y" R' y  d; p
q_____6085
% ~, k3 k! P8 b9 Z6 c( Gr_____3AC4% _" U* [" z6 z8 R5 F) t& ^  }
s_____2F50
  J3 _2 s) K" b5 i- i8 U# Ct_____36F8
3 o9 s/ V2 S9 y) z/ v, ~/ au_____7010" d+ k% m# W2 j/ [  ^
v_____0B42( {4 g) K, P( e6 l/ {" [! ?
w_____1C7A. V) g' B6 \2 m- n3 {
x_____16F8) g, ^" T1 O: U3 v  b* B
y_____2EE7
, F* X: e' D  B  u0 @4 cz_____5CF3
+ T6 w2 t0 f$ I  [5 f!_____6233- b! l$ ~$ z7 e6 n8 e
@_____3A45
3 D& }; i- S& f& t' {3 c/ M#_____2291
7 b( j  A" T9 |+ D  n3 |$_____5D5C' w+ i, h( ^7 r
%_____09B9
& U# l7 v6 ~& _4 B: d9 i& P) J* P^_____43EA' w4 P; S: i9 Z, C3 M, U/ n  \  W
&_____62B90 g' g6 _1 Z' K/ g9 X
*_____63010 p6 {0 _2 f" g6 o
(_____4659' g1 @& }6 Z3 z8 T2 [1 i- m
)_____5C82
希望做站长本人的学生请点击
http://www.3ast.com/viewthread.php?tid=13841
QQ790653916只负责SEO以及收费教学等方面联系,他人勿扰

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

收藏了。。。。。。。。

TOP

返回列表