返回列表 发帖

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

原创作者:柔肠寸断 [3.A.S.T]  http://www.3ast.com.cm0 }- M( u3 N5 j$ i6 W
原始出处:http://www.3ast.com.cm
0 y0 m& {5 w+ D4 j& i9 k) t% m) [& B
5 }+ j" k! z( `- ^1 m4 M看不懂的直接绕过& T1 J- Y( U! Q8 E3 w) G& h
加密前为:hwy123456
7 g* s+ m4 u3 i! {: l加密后为0F9C1C7A2EE76EBB5C1F4D7526CC4F883F4E
, |. i. ^$ R' q8 C# Z& u$ n2 [. ^( U- v/ _' X) h
============================================7 a3 M& |5 v, `8 m/ K/ Q
上面是当时自己校内的心情。现在已经解破出来了,分享给大家, Y" Y) \' m, ]% R$ T7 N" ]
也就不隐瞒大家什么了,这个是国内某知名大学的后台加密算法
4 Q1 z$ L: A% S0 H% o以下是RSA算法文件: O- @7 {/ a% f4 d8 i. I
8 B) l2 O; C. L& g, }! \6 @
文件名RSA.ASP
6 H- Z8 u9 n( u  S' v===============================================
. f0 r# p$ U/ z" S1 Y<%
" p- G( x7 s  I" x7 H% S0 LClass clsRSA ! \5 _* l( x+ @! s! n; P
Public PrivateKey
, ~  l# c6 Z- C" xPublic PublicKey 6 Q: w5 n4 \( C. m7 F- n
Public Modulus 0 `$ D# [4 f# T. z
Public Function Crypt(pLngMessage, pLngKey) ! e8 o9 t. p* c$ v
On Error Resume Next 2 S& r2 }- u: `2 P# F* H5 ~# r; r
Dim lLngMod : i: N# g/ Q; }5 G8 R( t* E8 ]
Dim lLngResult
4 m8 v* B  w: z) z% |! D1 m3 V! mDim lLngIndex ! f( l7 T9 q' u; q) z
If pLngKey Mod 2 = 0 Then ' p: n* E& e" I
lLngResult = 1
: X% s+ c" T7 q5 E7 ~9 V* @For lLngIndex = 1 To pLngKey / 2
; Q  s! n/ T$ r& T$ ^lLngMod = (pLngMessage ^ 2) Mod Modulus
9 f! v- E6 O- ~7 L8 Z9 t  h) A' Mod may error on key generation , O" W& }# k: |- z3 Q' q& i7 H
lLngResult = (lLngMod * lLngResult) Mod Modulus
( f" u& N% A$ ^! Y" k* ]8 sIf Err Then Exit Function
& H( ^3 F6 H% U2 K: W" tNext
. f( a9 _+ b' d% ^  h6 l) e& fElse 1 L: c6 g7 b# c) J. z- R' q
lLngResult = pLngMessage ) N: K$ R6 B6 |: x0 u
For lLngIndex = 1 To pLngKey / 2
" H& H4 }8 U8 y3 A: llLngMod = (pLngMessage ^ 2) Mod Modulus # L* w3 B* z  V; G" c1 \# ]
On Error Resume Next
* O5 l5 c. e  J' Mod may error on key generation
- u5 |) m$ r) U5 R& UlLngResult = (lLngMod * lLngResult) Mod Modulus
! A7 \; v6 l. E4 s% VIf Err Then Exit Function
; b5 s. t6 u, nNext 2 F7 q2 N# m$ G: L  l1 j1 r$ L
End If " R' e# u+ s) O- |' s7 ]) @
Crypt = lLngResult
* [1 Y( D8 ~3 R2 t6 [End Function/ G1 Z% K9 }& |1 S" v
9 \5 d, ?6 T+ X
Public Function Encode(ByVal pStrMessage)
1 O9 a5 g" t  |+ P3 zDim lLngIndex
# v9 W* h, n$ S. Z! n4 s% K3 bDim lLngMaxIndex
# p4 X3 n# I8 ODim lBytAscii # a% h/ a- a( F/ ~1 ], _
Dim lLngEncrypted
% V) E  X% N* c2 w3 xlLngMaxIndex = Len(pStrMessage)
; b2 l, ^8 d; Q" g5 V- YIf lLngMaxIndex = 0 Then Exit Function % ?/ w, Z, J5 B6 n+ c
For lLngIndex = 1 To lLngMaxIndex 8 |( V/ U$ C5 j" v/ Q4 F: y* T' t
lBytAscii = Asc(Mid(pStrMessage, lLngIndex, 1)) . t$ z: J# o1 N* J0 r7 E& f
lLngEncrypted = Crypt(lBytAscii, PublicKey)
4 M4 N4 `* |) ]) Z- a& ~) }( |$ oEncode = Encode & NumberToHex(lLngEncrypted, 4)
4 x, E. }% h; {( O& JNext
6 t- ~+ \% `) e3 c1 ]$ o: e( lEnd Function
8 t! D& j6 ^+ b. g9 I8 vPublic Function Decode(ByVal pStrMessage)
( _; z6 G+ D8 Q+ l4 qDim lBytAscii
. L: e0 i: ]* O2 [* sDim lLngIndex / @9 b' s# E3 }; v
Dim lLngMaxIndex " U: \) Y- x& M; Z
Dim lLngEncryptedData
9 x0 x& t8 C. D$ @1 h+ s8 gDecode = ""
( O& j; Y8 ?' s4 H% MlLngMaxIndex = Len(pStrMessage) ( K4 X+ r; O* d9 F
For lLngIndex = 1 To lLngMaxIndex Step 4 5 g2 n5 j2 @" y: l1 H
lLngEncryptedData = HexToNumber(Mid(pStrMessage, lLngIndex, 4))
3 Q' }. s) l; X" m+ P# p0 a2 clBytAscii = Crypt(lLngEncryptedData, PrivateKey) + a9 b3 j0 v; P* I2 S( I7 j3 M
Decode = Decode & Chr(lBytAscii) 3 E' y% x4 y8 M, \0 b! L
Next & C8 c) p/ ?# D/ A5 |
End Function
1 J" [3 `! f& M- }- FPrivate Function NumberToHex(ByRef pLngNumber, ByRef pLngLength) 3 E7 A( S0 y9 @3 E& Y
NumberToHex = Right(String(pLngLength, "0") & Hex(pLngNumber), pLngLength)
6 ^3 {9 y' F% _End Function
* {! P, [2 X0 R3 ?& u( FPrivate Function HexToNumber(ByRef pStrHex)
5 L7 ]0 }" C$ R0 [& }HexToNumber = CLng("&h" & pStrHex) * ]4 F! e0 m3 _5 M5 m) o8 s
End Function * c% z6 i% A6 I! I2 @; f# w( A2 J
End Class . v5 ^+ T, m5 k! h% k2 @
function Encryptstr(Message) 9 z# F) v$ H0 B! I0 X+ i
Dim LngKeyE
% J& Z+ k, B8 x* o. u1 o: _Dim LngKeyD
9 `8 _' @3 S8 l. _6 D, DDim LngKeyN
1 r1 f: Q* N( `% G  w1 kDim StrMessage 1 u+ D7 X% B9 H/ _& n
Dim ObjRSA
* A; P6 R2 ?' [: `$ y; ]LngKeyE = "32823"
9 y( ?# l1 p/ i# s4 n0 a0 FLngKeyD = "20643" . P6 H' ]9 f) T2 V9 B6 J
LngKeyN = "29893" 7 B7 n# d% w* J0 J+ l$ W+ G
StrMessage = Message ( ?+ i/ `( P+ Y3 W) O
Set ObjRSA = New clsRSA ( Q6 I% y5 F0 l: s
ObjRSA.PublicKey = LngKeyE
. j; u- F) p* q/ D% @) z' l; P; |ObjRSA.Modulus = LngKeyN 9 [' D6 B' ~+ J1 H9 i* K2 ~3 k1 P
Encryptstr = ObjRSA.Encode(StrMessage) 1 H$ y( L0 @6 \2 @2 n
Set ObjRSA = Nothing
6 h) r+ i4 Y5 `9 iend function
2 S% i& }( b4 K  g# MFunction Decryptstr(Message) $ T' O2 k0 r0 E% W0 D
Dim LngKeyE
5 o8 ]) M- x: z9 RDim LngKeyD
" V# j  g5 {1 ]; nDim LngKeyN
: B* W$ E' T# l% @' x9 RDim StrMessage
1 X/ M, q5 \3 r. LDim ObjRSA   X3 ^' d. K& ^2 Q
LngKeyE = "32823" $ ~4 d4 A& T- U5 a' H" R
LngKeyD = "20643"
) F0 F' N4 X' I: H5 d1 t8 L+ G" aLngKeyN = "29893" 9 w6 ?) b$ |# D" D: G# Z
StrMessage = Message 6 z3 {* S! p' L2 s9 Z6 E9 j# h
Set ObjRSA = New clsRSA 3 H) ^4 H# x2 t; f& w3 X7 P1 }
ObjRSA.PrivateKey =LngKeyD
& X7 {: e# r" UObjRSA.Modulus=LngKeyN
4 c6 A' ?! z; {" q( r8 Sdecryptstr=ObjRSA.Decode(StrMessage)   c! V5 Z1 a1 K  }
Set ObjRSA = Nothing
; T4 ], L4 T* H! @7 iend function - v, x4 N% q6 d. \" p. G" x
%>0 n0 Q- j* c7 b+ I+ w
===============================================; i% }8 U1 Y( I1 }/ p! w

' P" [( i. t# `/ ?还有一个用于测试这段代码的test.asp
" K8 b7 a: B, k5 p有兴趣的自己搭建个IIS测试下6 T5 C% v- r- G% v
<!--#INCLUDE FILE="RSA.asp"-->
" j. N3 x. o) E0 E# u7 A<%
3 b# t8 t" R/ a. m' _2 mfunction Encryptstr(Message) # M  i% e0 S, }0 N
Dim LngKeyE
/ O" [- i8 I" h! j6 Z4 Y# tDim LngKeyD
; p' g. x( B1 G" QDim LngKeyN 9 `4 C7 v7 o3 _4 z9 R
Dim StrMessage , w4 S  i# |2 a* M
Dim ObjRSA
9 h# x# _- c+ w$ FLngKeyE = "32823"
# x. F* t" Z! _6 v/ g3 zLngKeyD = "20643"
0 ^) p0 R/ A1 q0 \LngKeyN = "29893"
  \3 J: z( x) ^StrMessage = Message
) S6 \/ W$ o3 q+ Q6 T9 jSet ObjRSA = New clsRSA
+ h' b+ K. [( C" h0 Y: t% ]ObjRSA.PublicKey = LngKeyE - m8 d# P; H9 C* Y9 |4 a3 O6 x
ObjRSA.Modulus = LngKeyN 4 X  C) l9 x9 B# P+ D5 q5 r
Encryptstr = ObjRSA.Encode(StrMessage)
; N; [5 r& C8 d6 C3 h4 M$ MSet ObjRSA = Nothing
# p- Z! G; X! j+ A! `; aend function 2 x6 x6 y+ a" R/ m: a
function decryptstr(Message)
9 _# S9 C) C) W! ~+ P5 `Dim LngKeyE - m, z+ F5 D2 |3 ^; k+ t; \4 l8 `
Dim LngKeyD
# ]& b& j; x" T5 pDim LngKeyN & K  \" Y- p/ L* x# L) |9 u6 g* V
Dim StrMessage ! K# d' O0 Z1 h* R' O+ m
Dim ObjRSA ' X  K: B: K- a
LngKeyE = "32823"
8 O, a  I3 _0 g8 ]! hLngKeyD = "20643"
& y; k" S8 `/ Q& C" M& TLngKeyN = "29893"
  P. B& P4 K/ e, e# P/ N) m+ lStrMessage = Message 4 _! U! }, c: T2 H$ ], }
Set ObjRSA = New clsRSA   Q& ^2 c, p! b4 |5 V
ObjRSA.PrivateKey =LngKeyD
0 U$ E3 e' I8 x; U/ HObjRSA.Modulus=LngKeyN
$ x$ ~( t  n  J/ ]# Mdecryptstr=ObjRSA.Decode(StrMessage)
. f1 J3 t: c( x; D6 b) z, S$ XSet ObjRSA = Nothing - m$ r% ~5 \# J! l
end function + x5 K# g+ H! @4 H3 P
dim last,first ) ~$ _5 }4 o+ H+ G& b2 u8 O2 d
first="!@#$%^&*()" : K, t* w6 N: Z2 z
Response.Write "加密前为:"&first . i7 R+ @4 \7 {! P$ J
last=Encryptstr(first)
- r, k' q) P0 Q8 _7 {6 f, J- }' H% x3 AResponse.Write "加密后为"&last 5 P& C8 |" e! @
Response.Write "解密后为" &decryptstr(last) % p; {( ~2 C# ~# A  a# A9 L
%> ==============================================  c  P- h. s5 F4 A
剩下的就是字符的对照表了
; r- z+ y# h+ c& i: R===================字符集================( p3 i! p7 S) p9 q
1_____6EBB
$ N$ u. F2 b/ X6 Y! K7 V$ E3 j2_____5C1F
+ F. c5 ^0 I+ F7 Q7 A3_____4D75; f: F$ U; b- M- \& e7 O; X% p
4_____26CC: ^' d  j  h' [9 p
5_____4F88
1 g( Z+ V! Y/ x1 }4 Z4 t+ a8 \) C5 Z2 Q6_____3F4E
: L, T/ |8 j/ Q, R7_____0A9D
+ T6 u0 [; c, h* o8_____1A1C
" y# R/ R( W/ z) O0 t9_____6D20
( O% _$ ^' \1 H) [6 R0_____1089* Y9 R7 L+ C( _9 v
a_____0F3E$ m2 c& ?/ |* H
b_____3159
1 B5 _3 e( g1 }2 f. Q9 }* g9 `c_____3517
! l" ]9 V* a1 U9 k1 O* Bd_____419C
# {2 ?9 C" b- W: Me_____615C
4 R; |" P8 r, n4 [) ef_____556F+ R2 X+ ]: Y: v) G! e8 m/ B1 j
g_____2B7F
- T' d( w# J$ ?1 N/ h4 d  ~h_____0F9C
! t9 M, b3 m  E: j6 ]2 V8 j2 h1 a& U9 J( Wi_____00FA; U; e7 P6 i# j
j_____5A50
% v# |& ?4 ^, \( {k_____28508 Z/ r3 w) i7 R/ x1 o0 N
l_____3E7B
. {( y; s  f, Z9 g, z- Dm_____71C5
1 t2 U0 k9 S3 T$ S& P; z* yn_____1FC8
/ o; }6 i8 l- W) t8 v; n3 j9 @o_____74C12 n) T! T% j0 e! J* T7 y# d+ X1 ^
p_____5FB8/ U* X) Q/ w; T
q_____6085. K9 I+ d! h" q) }4 ^' G. d
r_____3AC4
6 K# C$ x  C' L$ s7 c' Ks_____2F50! ]/ S' h3 [; ~" w. {' H; U& s9 d
t_____36F81 N$ R: T% y6 E! b
u_____7010- [  ^2 S1 j5 V0 Y5 s) d
v_____0B42
$ x: u4 Y0 r& B8 Bw_____1C7A  q, g( s# T, p+ b7 q3 M  }, ~
x_____16F8
8 A8 H9 C3 ]- py_____2EE76 C8 o$ H0 w( N! N' }, n
z_____5CF36 i8 p! w# _2 s- A
!_____6233# P+ c) p- R8 `4 E
@_____3A45, y7 z8 y% j$ r
#_____22911 A3 J7 x8 x6 @  U* u: h2 E
$_____5D5C: R$ ~$ u% y; S6 W
%_____09B91 W2 \5 t. j+ g2 j5 @! l
^_____43EA$ a3 G) K* d1 a* v: A" g, o9 [: T9 r
&_____62B98 i' K. t. y  ~% S% z
*_____6301# A- L6 ^1 O$ @2 R5 v& [
(_____4659
- Z3 s, h0 I1 Z" @)_____5C82
希望做站长本人的学生请点击
http://www.3ast.com/viewthread.php?tid=13841
QQ790653916只负责SEO以及收费教学等方面联系,他人勿扰

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

收藏了。。。。。。。。

TOP

返回列表