Board logo

标题: [原创文章] 关于国内某知名大学网站加密算法的研究 [打印本页]

作者: 柔肠寸断    时间: 2009-4-19 21:52     标题: 关于国内某知名大学网站加密算法的研究

原创作者:柔肠寸断 [3.A.S.T]  http://www.3ast.com.cm
8 |+ G+ g- f9 n$ ~' f' K原始出处:http://www.3ast.com.cm
* s4 T+ q( V7 ?$ G. x& ?  A. D+ ^! q1 \$ i, L5 [7 ?& X" O- H
看不懂的直接绕过* u* a& g% p! u  P$ h( @
加密前为:hwy123456) V' E) [3 y' }& N
加密后为0F9C1C7A2EE76EBB5C1F4D7526CC4F883F4E
; f) p: C1 t( b( }
9 F- k5 [6 D8 V8 f1 H$ C============================================3 F& S: T# U' S: x7 i) [
上面是当时自己校内的心情。现在已经解破出来了,分享给大家
1 x; |! t+ X4 j, u( [% ?3 T也就不隐瞒大家什么了,这个是国内某知名大学的后台加密算法
0 b3 j9 l1 M# r6 g5 K& ]  W( i以下是RSA算法文件
: k6 L, b( A7 Q* V, @, Q" W
! v+ k2 u! P2 E) K$ U文件名RSA.ASP, }2 x# |" N( [! E, f
===============================================  Y. H: p; x. f3 B  T. k
<%
( U8 W: ^1 r" o3 lClass clsRSA 7 w% u. `, s* \
Public PrivateKey ; P6 w1 w4 r4 U6 }8 B* W
Public PublicKey , E3 @) l& O; E. c* {
Public Modulus
& H/ ^8 x& |8 {( \: B) dPublic Function Crypt(pLngMessage, pLngKey)
4 t- z5 N# Z! D+ l4 v/ T5 s- B% YOn Error Resume Next
- Z  j- r9 B0 j( wDim lLngMod
% T. X9 a0 J1 l, H% K* n7 n/ K0 g4 BDim lLngResult # `$ q5 R+ h! U
Dim lLngIndex
( F; E( {; [4 Q% ]( _If pLngKey Mod 2 = 0 Then / Z2 l! f. m7 T2 _
lLngResult = 1 3 v2 g9 y! r3 B* g8 I+ G; @* t
For lLngIndex = 1 To pLngKey / 2
1 t2 B( K! \: d9 q  }lLngMod = (pLngMessage ^ 2) Mod Modulus
: {9 d- C. y) I, H1 _1 i& }' Mod may error on key generation & q- ^1 P: B7 v% X! J" }9 l. P
lLngResult = (lLngMod * lLngResult) Mod Modulus + f8 u5 ]. c% Q7 p8 \' S% t
If Err Then Exit Function ' X6 M& A5 |1 m2 I% \
Next
- ~! M7 I$ x# X4 Y" F' |% KElse
; l+ O0 m# V& N5 e5 f* c. tlLngResult = pLngMessage ) a; Z( M9 i' t. h* C" Q7 c
For lLngIndex = 1 To pLngKey / 2
9 l, Y8 p  D! E9 J- i: h; ~lLngMod = (pLngMessage ^ 2) Mod Modulus ) N4 i7 e3 ~% v' c
On Error Resume Next 9 @: ]9 E1 \& _* m- I
' Mod may error on key generation 8 n# h) _. a4 ?) a
lLngResult = (lLngMod * lLngResult) Mod Modulus   W3 ?& j# V3 M* r3 A. {5 m0 ^/ L
If Err Then Exit Function 3 p) D7 d1 ?- ]) G+ C
Next 1 V# a+ a5 B. V
End If
+ e$ x" x( g  _$ d9 K2 L4 A+ t6 YCrypt = lLngResult ; q7 I+ o  Q2 O- M
End Function, z! o5 x0 o, [; R% {

2 ]4 H: }1 R' i$ I. qPublic Function Encode(ByVal pStrMessage) & I/ e9 T7 L2 ]! o' p5 {0 g6 H/ h
Dim lLngIndex . s2 l. L- Y! n' i6 b/ }
Dim lLngMaxIndex 2 |  o* s: I# {
Dim lBytAscii " ]+ g0 P7 w8 q- y6 z2 a9 i" h
Dim lLngEncrypted
5 _: H+ e& N5 Q4 d5 IlLngMaxIndex = Len(pStrMessage)
" M% m- q3 S- kIf lLngMaxIndex = 0 Then Exit Function % Q/ F# F6 k; a  _( l$ o
For lLngIndex = 1 To lLngMaxIndex # O, o* k3 K6 ^! Y, b1 ^
lBytAscii = Asc(Mid(pStrMessage, lLngIndex, 1))
0 A6 c2 E9 |, s: Y% [# f1 AlLngEncrypted = Crypt(lBytAscii, PublicKey) ) v( c; y( e- s# ]4 \+ g
Encode = Encode & NumberToHex(lLngEncrypted, 4)
/ C$ v" W4 Y0 j% A& y4 BNext - u% b, U" J# A0 m% [
End Function ) H& H" h. j; @, b
Public Function Decode(ByVal pStrMessage) 7 x' }# k! K/ H" O, b& E
Dim lBytAscii
) ?4 d6 r: [9 }) oDim lLngIndex - s  ]& m- o* y7 F  T/ q: j
Dim lLngMaxIndex
. y, Q: y* b* S1 U6 ]9 c$ iDim lLngEncryptedData 0 m* L/ z1 H0 m1 l
Decode = ""
- l+ J5 k/ Q% a. {8 A7 RlLngMaxIndex = Len(pStrMessage) ! C. R4 {  ?% c7 t9 K# `9 f4 X9 K
For lLngIndex = 1 To lLngMaxIndex Step 4
1 C* k: x. S" ~! JlLngEncryptedData = HexToNumber(Mid(pStrMessage, lLngIndex, 4))
; g! B4 g6 |9 w4 D2 H0 n$ OlBytAscii = Crypt(lLngEncryptedData, PrivateKey) 2 E4 T! I# N# F0 A% M; t. s7 \9 u& o
Decode = Decode & Chr(lBytAscii) . F6 N4 j% D: K2 ~+ ~( |
Next
. q+ I$ R" P8 G  lEnd Function
; n9 y, j3 `7 a, [, t9 |7 y, APrivate Function NumberToHex(ByRef pLngNumber, ByRef pLngLength) ) [! `4 r9 a( [0 j
NumberToHex = Right(String(pLngLength, "0") & Hex(pLngNumber), pLngLength)
: f: |' s/ j: BEnd Function
0 ^9 K' L& A9 S$ f0 Y3 I, @Private Function HexToNumber(ByRef pStrHex) " J' q; t/ w  B7 ]# X/ {8 ?, i
HexToNumber = CLng("&h" & pStrHex) 5 r6 F( F' m1 k- {& e! X
End Function 8 c! F1 F" A1 B: Y; f, @7 C
End Class + |0 L2 N3 z* t& B& T* x5 Q
function Encryptstr(Message)
5 J! R/ q: k2 yDim LngKeyE . q, J, u+ K. P, }' t7 s
Dim LngKeyD ( Z8 x6 k. F# v( r+ ^" T
Dim LngKeyN 9 w0 M3 n: d6 G" S, j- X
Dim StrMessage 6 E! y' d' n1 f0 T& l& ?% E
Dim ObjRSA
9 C+ c  z6 ?' `5 hLngKeyE = "32823" ! U( s* a! m8 `- g# v% w
LngKeyD = "20643" 2 V0 A' P3 q& w; [! C: F
LngKeyN = "29893"
/ e; L$ g. P5 F9 BStrMessage = Message
; z- P' g# Y- k7 Z. H( ]Set ObjRSA = New clsRSA
: T/ F1 M$ A$ |% U' eObjRSA.PublicKey = LngKeyE
9 R% Y  ~5 ]9 x  X, b- }+ ]) nObjRSA.Modulus = LngKeyN
" ~3 H. ^/ L' k- w4 bEncryptstr = ObjRSA.Encode(StrMessage) ( y: X" \. G3 Z" q( y- V( A6 o
Set ObjRSA = Nothing % U0 S0 Q* ~2 e7 H3 r
end function
& R+ M7 x! D/ _, \+ ]Function Decryptstr(Message)
! c8 D6 A  \* d5 a  h9 S; WDim LngKeyE 8 p/ P. n8 `7 ^7 n
Dim LngKeyD
1 L' X- |* J( ^# p9 w8 xDim LngKeyN   P! T7 W( q- Q+ g; M3 \* G& e
Dim StrMessage
- t$ f) s( c7 L" o/ xDim ObjRSA
3 }9 o* @  O' n( Y' r" t% K; ELngKeyE = "32823" , ~. N' x) m; [; i
LngKeyD = "20643"
) e+ g( F& R) e3 p' X; QLngKeyN = "29893"
, Z2 ^9 R( y; J, PStrMessage = Message
, z8 [- ~' m( q  E( n3 x. jSet ObjRSA = New clsRSA & {) i1 T- A5 g# v% ^4 U
ObjRSA.PrivateKey =LngKeyD
2 H* V. c  M5 Q: y. qObjRSA.Modulus=LngKeyN
- a4 v; `, m( D$ k* v# edecryptstr=ObjRSA.Decode(StrMessage)
; A1 {$ W1 S$ l% w# ]+ \( U# vSet ObjRSA = Nothing + Z, f% k4 P3 j, Y6 {$ d
end function 3 r$ H" ~: a/ d4 L7 O  t% N  Z- u, i
%>
4 ]% D3 k* N/ {===============================================
: K; ]0 H' T# m% G) `( j; x7 c
7 G" i8 P* T: D* ~% @1 ?还有一个用于测试这段代码的test.asp6 W& M) z2 p2 W& t+ \7 X4 M
有兴趣的自己搭建个IIS测试下
5 F7 {) E0 x0 F' c<!--#INCLUDE FILE="RSA.asp"-->
& j, V! A$ V& A3 @  Z$ I/ ~<%8 _0 b- T9 L4 c$ O3 k1 P0 p, ?
function Encryptstr(Message)
1 E' ?+ Y9 n8 B7 jDim LngKeyE 2 r9 J: k) x/ A9 G0 `! d
Dim LngKeyD
5 ^/ F! h8 @9 H' A: aDim LngKeyN
* P+ I% s& z( S! {" ]Dim StrMessage
8 C* f7 T7 v3 @9 i" z8 c; }9 PDim ObjRSA
7 G$ u8 d! ^2 s2 `6 VLngKeyE = "32823"
+ ]8 B7 ^& v& sLngKeyD = "20643" 1 }! t; `) {7 w/ p* z/ o) x, T9 {
LngKeyN = "29893" " [' X% Z# y+ f% S- c9 `
StrMessage = Message
3 k/ E/ x; s: r  T! \) l& F8 zSet ObjRSA = New clsRSA
' h/ h. b% Q- w' ^* C+ @# RObjRSA.PublicKey = LngKeyE
* b5 e+ T" ?5 p, s" pObjRSA.Modulus = LngKeyN   J# V  c3 D6 _4 `# M+ d0 F
Encryptstr = ObjRSA.Encode(StrMessage) # v0 Z8 N" B, v3 p# ?: k
Set ObjRSA = Nothing 2 d# E" u3 v* l$ w- }
end function
! A# Q5 A, \& r, C* n7 x7 f0 Kfunction decryptstr(Message) & I0 L/ v/ M- e  r% e1 \/ G
Dim LngKeyE
- t6 N0 H8 ?6 F  i2 FDim LngKeyD 9 p4 Y8 v2 a3 T+ ?! J2 M
Dim LngKeyN - Y; f3 q' {+ K
Dim StrMessage
. i6 m* S4 Z9 w9 p/ [) y) zDim ObjRSA
, a- T& l9 k+ |) ]3 B2 A4 P; SLngKeyE = "32823"
0 m, o/ f6 ?' @2 f5 w2 ~4 C! `LngKeyD = "20643" * f6 R7 x3 i3 s$ J, E
LngKeyN = "29893" : N* [7 }& P# r1 L/ F2 g' K% y1 x
StrMessage = Message ) f4 F# S, |( Z& q- S( U2 B% e+ v
Set ObjRSA = New clsRSA * f; \  Z: w5 b: Y: x1 N- G: ]
ObjRSA.PrivateKey =LngKeyD
" Z6 Y( G+ k3 Y/ U- t' XObjRSA.Modulus=LngKeyN & d" @6 w3 k' r# o
decryptstr=ObjRSA.Decode(StrMessage)
! ^% E0 d7 p8 CSet ObjRSA = Nothing & l5 O. Z5 N' V  {0 _/ ~$ A9 D
end function
+ n& j/ x: g4 g5 F% T( Wdim last,first 0 q+ q/ D9 r+ d1 B8 H8 y
first="!@#$%^&*()" 5 I& A* w( l0 y) n' G
Response.Write "加密前为:"&first 7 U; G' Q/ H( J0 f3 I4 K  s; b  s
last=Encryptstr(first) 3 i7 c" ^$ [0 E( ]
Response.Write "加密后为"&last
* R8 Z% d& \* F; i* s  y3 e2 HResponse.Write "解密后为" &decryptstr(last) 4 z3 M6 w# }! J4 o- K0 c
%> ==============================================, Q* j) E# D+ I* r# K$ |
剩下的就是字符的对照表了
8 S, V' o8 d& k! o0 n- G===================字符集================
& V+ T) R2 {8 H- D, ]( F1_____6EBB
  A, x1 Q  D, P  s+ N( M' Q0 V2_____5C1F6 c& Q% n" ~. Z5 G: j! u) N  Z1 C
3_____4D75+ |6 X& L$ A+ s2 z
4_____26CC
( c& G2 \7 X9 t1 G  b; L5_____4F88! `  P! }' R1 Y2 k9 x1 m5 N
6_____3F4E
) K; _% s7 Q8 \5 j; X7_____0A9D
3 q. L3 f, E, b# ^% e1 H! q. h8_____1A1C
. A  V% v* C7 ]3 N* B9_____6D20
! h* A4 x5 q# R0 ?0_____1089$ U9 H* i( \/ a# X4 [& g
a_____0F3E7 q0 `  X1 q0 z% @, l$ C; K; T/ C
b_____3159! O2 @3 }2 D# K8 v/ O& C
c_____35171 k! J7 N+ c; K$ H' Q0 ~' {3 q5 F
d_____419C) f0 N2 _: y! m9 Z7 F
e_____615C# X6 p( W/ M' e! F  c
f_____556F
7 M  \1 h" {! f" {! E! `5 _) u5 Gg_____2B7F  X7 M6 g' _& Y0 h! ~% ?: r2 q
h_____0F9C9 m( e7 T( @1 S0 A( F
i_____00FA% e% q* a- w0 X7 l
j_____5A50& l& a. I8 m- V$ v4 N) U
k_____2850
: j) d, Q4 m% H  n3 a2 G- ^l_____3E7B
% e2 T0 e: G9 n* J  _; A! W# Um_____71C5% N" P5 o- L* |$ w# r+ x  D# u
n_____1FC8! i2 S- B- {5 a( d/ [6 ~
o_____74C1
4 K5 G, `5 K2 o8 f6 a$ L1 zp_____5FB89 e) E( g! t3 y' n8 S
q_____60853 ?( h: \) _$ M& p
r_____3AC4
4 t# V( ~& C. x# ^/ o. R, ]( qs_____2F50
# P) ~4 }. O! L" x  Q& `( ot_____36F8
; @! P5 @# q$ j2 D( [  lu_____7010$ P! p( f. F0 q0 s4 M! Y
v_____0B42  D0 K. Q8 J- {
w_____1C7A
% W+ Z3 L& U9 u: Dx_____16F8! b- O' |- m6 g) i0 M7 M8 }& _
y_____2EE7
0 c* v6 ?5 m5 v- C6 t% B+ W% `1 Hz_____5CF3' ^3 y- z( \5 U) L8 j' ^- K
!_____62339 y. \2 ^1 |7 J  o/ L  G
@_____3A45
( R  _) y3 |3 y: ~5 I#_____2291% c/ z6 P* @8 v' U6 Y
$_____5D5C( Q* |9 o7 R* H& m' l. y8 B
%_____09B93 |( R+ [4 Z5 y
^_____43EA
) r7 W8 d( {% M" D8 g2 Q&_____62B9) p! A' U( z1 Y. T
*_____6301' `6 Y; X+ u0 P9 ~# [$ B
(_____4659
0 B5 ]5 y9 n9 ], |7 g) F# [)_____5C82
作者: 鱼儿无心    时间: 2011-12-4 17:17

收藏了。。。。。。。。




欢迎光临 【3.A.S.T】网络安全爱好者 (http://3ast.com/) Powered by Discuz! 7.2