返回列表 发帖

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

原创作者:柔肠寸断 [3.A.S.T]  http://www.3ast.com.cm6 _: ]) K  U$ R0 q
原始出处:http://www.3ast.com.cm; Z) O6 p& r+ _0 u1 `0 y

! |0 ], Y% `0 ^看不懂的直接绕过
/ X' X6 m* d7 a) F$ C! U3 S加密前为:hwy1234568 q' I' w- r. A
加密后为0F9C1C7A2EE76EBB5C1F4D7526CC4F883F4E
! \% K/ Z! W6 Y7 ^4 Q3 P/ U2 b# c' r
============================================
8 V  `2 d* n! H" j, }9 R上面是当时自己校内的心情。现在已经解破出来了,分享给大家
" S1 i; b; I  l1 ^1 y也就不隐瞒大家什么了,这个是国内某知名大学的后台加密算法
$ o7 b# j3 y6 _' ~7 T" n4 q以下是RSA算法文件5 d$ _6 p" x0 N6 ]( G: K

4 b% B. e( f: _# ?文件名RSA.ASP
- ^; e% {  X, v7 R===============================================
, e9 H) {  v9 k9 |/ T. [) k<% 1 w( q4 W  ]3 O9 W' q2 e% a& t
Class clsRSA 3 F4 K9 h# B- J( ]) y
Public PrivateKey ( c2 j& c. j# @- Y7 \5 H2 Y3 G4 n
Public PublicKey
1 m5 ^0 O: M. B# a6 x; [. D4 C/ _7 U- nPublic Modulus
8 W2 C3 g9 S! k7 Y: ?Public Function Crypt(pLngMessage, pLngKey) 0 G$ L, }% g0 M, b; z1 o
On Error Resume Next
  |, X2 u- D" M& ^! R& m0 s! WDim lLngMod
: V5 C" i; J# c6 h5 kDim lLngResult / G! @7 x7 E3 l; z, f) {8 P
Dim lLngIndex
: w; L( l, ~' v" }/ d6 FIf pLngKey Mod 2 = 0 Then 5 _( }2 O' K% f: Y; {- ]
lLngResult = 1
) U0 b4 K* c4 e8 Y' |" R! jFor lLngIndex = 1 To pLngKey / 2 : ]) f0 K! }$ V( Z* |, L9 \" b& d
lLngMod = (pLngMessage ^ 2) Mod Modulus 3 f8 w/ `8 [& D0 F
' Mod may error on key generation
6 u" |. A  h! v& r9 {; }) t0 ZlLngResult = (lLngMod * lLngResult) Mod Modulus
/ J: s5 A' A4 J. GIf Err Then Exit Function
# C, G9 ]5 p& i$ w. c( bNext
3 v3 E, j- l7 `. h" E- |Else   U" F" f1 i# ]; B' F3 L
lLngResult = pLngMessage ' v! i7 P5 b4 b- G
For lLngIndex = 1 To pLngKey / 2 1 o4 h$ z- J( G
lLngMod = (pLngMessage ^ 2) Mod Modulus 7 ]. g* G8 ^8 ~) t
On Error Resume Next ( t; `1 t& U) |" @
' Mod may error on key generation ' l/ g3 O! F, r! a6 c. _; G8 I
lLngResult = (lLngMod * lLngResult) Mod Modulus
9 z! D4 z9 i; gIf Err Then Exit Function ; a0 V  E- h6 R
Next
+ {) S& i4 J3 F' AEnd If
6 g  G& s0 }, D2 MCrypt = lLngResult 1 V# w- [4 \+ A" M' `
End Function
) C" A$ _8 Y. N) ^  r% Q
) q* y! m' ^5 f7 IPublic Function Encode(ByVal pStrMessage) ( I& d- h# W% D  G( f
Dim lLngIndex 3 F# @" s2 ~* W5 u+ F% a! u$ W+ h
Dim lLngMaxIndex
, w" N! }2 U( P0 H7 FDim lBytAscii
+ a, l/ q, n$ p. A; c+ B9 K+ [Dim lLngEncrypted # {+ x1 H  ?8 l  y
lLngMaxIndex = Len(pStrMessage)
9 Q8 A7 s9 y4 r' W% z# U: [If lLngMaxIndex = 0 Then Exit Function , H4 S& r* ]$ J/ G2 D
For lLngIndex = 1 To lLngMaxIndex
" Q3 Y* \) k4 a1 f! c2 GlBytAscii = Asc(Mid(pStrMessage, lLngIndex, 1)) * l7 S( k' b: o& i' [/ o
lLngEncrypted = Crypt(lBytAscii, PublicKey)
. o# j& f. q" g- ^& gEncode = Encode & NumberToHex(lLngEncrypted, 4)
$ _3 y/ a' D/ B, D, ]2 U1 ZNext
& r- D2 ]$ M. D: v& O6 REnd Function
* o1 Y3 M2 S3 N. g, @% w: J. u6 @Public Function Decode(ByVal pStrMessage) / N7 S, S& H8 s! ~, k6 `6 n3 d9 Q
Dim lBytAscii   X* y; P  Z7 z9 X; w# Q% O. e
Dim lLngIndex
( A  v7 `, O/ T5 LDim lLngMaxIndex
  A4 Y) ~1 p6 t1 K( dDim lLngEncryptedData 1 \+ J, C# f/ H$ j% C
Decode = ""
- Q/ s9 I6 G4 u+ }$ VlLngMaxIndex = Len(pStrMessage)
5 ~7 u/ |# }: e! n" @4 sFor lLngIndex = 1 To lLngMaxIndex Step 4 % i* g& W! M7 K0 S3 z0 C3 J4 m
lLngEncryptedData = HexToNumber(Mid(pStrMessage, lLngIndex, 4))
: U& Y) D% _1 klBytAscii = Crypt(lLngEncryptedData, PrivateKey) 7 N; v- t" W  |& R
Decode = Decode & Chr(lBytAscii) 9 q' d  E) j, e, O
Next
' K/ }9 B2 P; j5 aEnd Function
+ ^/ X: l; y4 _Private Function NumberToHex(ByRef pLngNumber, ByRef pLngLength)
' r9 k6 d" j% h# L: n, j4 t. tNumberToHex = Right(String(pLngLength, "0") & Hex(pLngNumber), pLngLength) 2 ^  C8 F2 r3 V/ Z
End Function
) D  p8 B7 W. d% HPrivate Function HexToNumber(ByRef pStrHex)
7 Y. z4 Q8 k$ X6 u8 W- sHexToNumber = CLng("&h" & pStrHex) 9 B# }5 [5 p2 M( D+ t- f
End Function
' |$ C/ E: ^; uEnd Class
& D5 V7 s/ ~) v$ H; ofunction Encryptstr(Message)
4 R  b& b" `" V- J$ P9 uDim LngKeyE : d" R5 r, S- H3 X
Dim LngKeyD / \) U" @# @4 e; ]# @7 m  o
Dim LngKeyN
7 N8 w0 |1 x5 Z; R- _8 y- ~Dim StrMessage ' P  ~8 g& y8 a3 F
Dim ObjRSA
. i8 I9 [  D+ b: G& l5 SLngKeyE = "32823"
- N- e! X% \) e5 `" Y& _LngKeyD = "20643" - y$ P1 k9 v6 D: ]
LngKeyN = "29893"
, t1 @: q: B+ ]; M5 K6 [StrMessage = Message
! z' M/ V& |2 u  ?1 o5 m# G0 u# P2 K9 VSet ObjRSA = New clsRSA
' o8 n3 F0 G- d8 TObjRSA.PublicKey = LngKeyE
" I. m3 M6 j0 I" y) w! vObjRSA.Modulus = LngKeyN / H& @: E  |% z3 O
Encryptstr = ObjRSA.Encode(StrMessage)
/ U$ Y  m5 |( a0 @! }Set ObjRSA = Nothing
1 C% r1 D7 D0 g- X" d' I6 F7 x9 \/ Hend function+ I$ h" S8 Y0 y
Function Decryptstr(Message)
; G  P9 c, v. _* j& l$ v. `  D: ODim LngKeyE
. m, G" P0 S! g. E) |0 N) CDim LngKeyD   V1 B) Z. S" Z8 M) z
Dim LngKeyN
. n7 ]+ C) I: k; cDim StrMessage & O4 F4 T5 K: r  v
Dim ObjRSA
# M+ V$ q' l& z7 gLngKeyE = "32823" 0 _. R5 c# C' q3 O5 P: A
LngKeyD = "20643" / @' X) f9 R$ x  r  g" x; i
LngKeyN = "29893" , n, c( a' Z" R- X+ d2 q! R& E
StrMessage = Message
3 \. T# z4 A( QSet ObjRSA = New clsRSA
0 K5 l* M, h/ q3 F  K6 y3 l' iObjRSA.PrivateKey =LngKeyD
) B0 S1 U1 K1 `, g# Q0 i( e+ u! |ObjRSA.Modulus=LngKeyN
8 m& S1 B/ ~/ r2 Rdecryptstr=ObjRSA.Decode(StrMessage)
+ f  Y* M; [, J" ZSet ObjRSA = Nothing
) \+ N" u& @* u0 L) E. fend function
0 S5 d6 l2 e2 }$ f  P7 ^8 X%>" n8 S2 R& [* @1 j9 P
===============================================
8 j9 L+ |3 B' r" |- m9 g6 {4 _' `& P, Y1 I
还有一个用于测试这段代码的test.asp% {0 t, J- {! B1 a
有兴趣的自己搭建个IIS测试下/ U. w: C- L( B) ^
<!--#INCLUDE FILE="RSA.asp"-->
# j$ H8 s6 j5 K) \6 D* h<%
7 e) n, e5 {) U! ]: o( M$ w$ ~9 \function Encryptstr(Message) 5 n! m! P' C! e  c% K' c& z
Dim LngKeyE
) _) M$ f/ d4 w6 C+ m1 w) @Dim LngKeyD 6 i6 B* c3 R7 S2 r1 r( r6 b. l' C
Dim LngKeyN # G5 a: Y4 p! w8 Z9 X$ T! e
Dim StrMessage - y( n( N$ Q: U8 u; s- c
Dim ObjRSA
/ Y/ H3 P1 }6 S0 kLngKeyE = "32823"
, p# V& j5 F9 q. g( d7 \  v, C6 {5 ]2 BLngKeyD = "20643"
- }  Y/ _, g# A; z1 M( l" lLngKeyN = "29893"
, L( r" K8 }, N6 R6 ]7 OStrMessage = Message
- ]% W* G5 b. u" }Set ObjRSA = New clsRSA 4 A) F/ B) b; ]1 M1 A* h" N
ObjRSA.PublicKey = LngKeyE * n9 F; J+ o" i% _2 ?
ObjRSA.Modulus = LngKeyN & W2 T$ }  e. D8 v9 {
Encryptstr = ObjRSA.Encode(StrMessage)
1 |( _* ~" b) C. }' {  ZSet ObjRSA = Nothing
3 K$ {! R8 s- {, i* w! Aend function
/ ?& @! \4 m. f7 v! j1 Kfunction decryptstr(Message) - c9 D- t( Q, ~( ]0 V& v4 N' Z
Dim LngKeyE
* J! U* ]  x8 U/ }) SDim LngKeyD
- G. Z8 G3 x# X& N: k% Y8 F& j% k3 RDim LngKeyN . O  M% y: U( x6 b9 |
Dim StrMessage # r1 G) i8 Y7 s. E, W$ C3 R
Dim ObjRSA   `) I7 C' s6 a. @7 t( N
LngKeyE = "32823"
! N; P  r& S9 a- |: hLngKeyD = "20643" ' |! J; C3 q( a' u; Y* o, v' A
LngKeyN = "29893" % R- E! n; \4 G$ b3 x, u( R0 X
StrMessage = Message
' d( N; }# }" o! E1 PSet ObjRSA = New clsRSA   P. m5 N/ Q- Z
ObjRSA.PrivateKey =LngKeyD
7 ]7 \  B  D7 k7 s' I2 x8 C* i1 L; N7 uObjRSA.Modulus=LngKeyN
& R3 \* m4 i: |* a/ y' b; F# udecryptstr=ObjRSA.Decode(StrMessage)
* g' p& ]" `7 XSet ObjRSA = Nothing
) V2 Z9 e% S. r0 h) _end function 8 |! b. ]2 s0 y
dim last,first
; F. a' n/ x9 M5 }7 Vfirst="!@#$%^&*()"
: `: k) X' c; h+ R$ J! m' Z7 [6 [& |Response.Write "加密前为:"&first
' ?& U. K4 ^% h; M2 ?7 F, rlast=Encryptstr(first)
  U7 R# b' o- U7 p1 P4 J: `Response.Write "加密后为"&last
+ k8 n! ]% R" [; z% h# HResponse.Write "解密后为" &decryptstr(last)
( D5 b- v2 w$ Q- I% v/ u4 ^%> ==============================================
8 _5 m0 f7 v, n' k4 t* c剩下的就是字符的对照表了* n( Z7 q7 a# d
===================字符集================
4 @* a' o# y% e% W% Q1_____6EBB$ j5 i; J& L6 D5 f. @
2_____5C1F+ G- [8 t1 l5 @) |3 N
3_____4D75
: q3 f! B* c/ H. L( c' x: Y0 s  {% e1 _4_____26CC
! I/ A: ^$ [+ Y4 l6 o5_____4F88
% i- k1 W1 n; @$ E6_____3F4E1 n) d6 A0 P7 ^, m$ m/ e
7_____0A9D
" f+ q$ G3 I8 Y8_____1A1C
$ ~' Y& }" ]) }/ R, q9_____6D20
8 o8 Y; Z* {5 k+ ~6 }0_____1089
, G  g9 v; O' q7 t& r) ~a_____0F3E; {$ I/ L( K6 b
b_____3159
& _' I0 q$ W$ F7 {$ `3 ^c_____3517
4 s; A; i/ i1 E7 h9 G7 Td_____419C; T+ ?2 w& U- |& ~3 _
e_____615C
# q$ ]* Z2 z( p2 P* pf_____556F. |3 j; y' K# L$ y
g_____2B7F+ W4 L- A9 e1 \
h_____0F9C6 Y% G5 q% D$ `! r, \
i_____00FA% Y& V7 f% Q" O& I9 b/ C' c
j_____5A50
4 U: u$ @! J6 y& j4 Sk_____2850
7 Z1 B8 ]9 ]+ R8 [3 Q* c# Bl_____3E7B5 F0 ~) f3 {& K' V# l6 J4 C
m_____71C5
9 ]5 J3 n7 y. k/ an_____1FC8
, x% m! r  S" h( W2 H- w% }9 so_____74C1
. ?3 A( P- j+ Jp_____5FB8
7 f" d6 m9 H2 \: q& J, A  R. |# L% A5 Gq_____6085  {8 C$ n4 d1 \+ u3 ?- @) _/ R
r_____3AC4
  X. @8 E( c; @s_____2F50
- m9 Z  K/ e7 p" t# k" D. R6 St_____36F8$ x; D( ^0 e. l6 ]
u_____7010
0 s0 A9 u- k" h$ {% D" B9 {! ^v_____0B42
" p' }4 s) l# l' J. h! Zw_____1C7A- R/ e& ^# O. D; N1 f' U
x_____16F85 q% p' k! f8 A- T4 n
y_____2EE71 {" o7 {- R. M+ @2 j/ W
z_____5CF3, t2 e/ T; M6 P0 Z/ h
!_____6233
- R8 |4 ?( ?" w# \@_____3A45$ B, K; g9 |% \( w, ?6 W
#_____2291
: `0 E4 V1 N2 S2 F: S( F& N$_____5D5C
5 v& ]* X; @8 i. d, \0 n% r* u# _%_____09B9
0 R9 c" S( I% g6 p^_____43EA
6 M/ m: K: |* w  A/ q! P+ n&_____62B9
- z( p/ ^4 E! |4 T; q# w  C* A1 d0 t*_____6301; M3 `9 I5 i+ `" n. D. ~
(_____4659
! x9 a! D/ q- M: i)_____5C82
希望做站长本人的学生请点击
http://www.3ast.com/viewthread.php?tid=13841
QQ790653916只负责SEO以及收费教学等方面联系,他人勿扰

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

收藏了。。。。。。。。

TOP

返回列表