标题:
[原创文章]
关于国内某知名大学网站加密算法的研究
[打印本页]
作者:
柔肠寸断
时间:
2009-4-19 21:52
标题:
关于国内某知名大学网站加密算法的研究
原创作者:柔肠寸断 [3.A.S.T]
http://www.3ast.com.cm
1 p3 j/ P z; Y% B* ^
原始出处:
http://www.3ast.com.cm
: m1 N+ k3 o0 b6 W) o
' v' U- }7 p2 O
看不懂的直接绕过
6 w4 H) s E% w
加密前为:hwy123456
9 b5 G S% j ~( [9 s5 U' _& U
加密后为0F9C1C7A2EE76EBB5C1F4D7526CC4F883F4E
5 ~ x. x) y1 G- C+ B: m5 B
) m9 K4 j0 s5 r- B( z
============================================
& Q' g; P6 A6 D4 q, |! T
上面是当时自己校内的心情。现在已经解破出来了,分享给大家
0 L7 X4 T w. C+ Q! h# t5 ^
也就不隐瞒大家什么了,这个是国内某知名大学的后台加密算法
) Y7 c k9 j' U' K6 ]$ \$ p
以下是RSA算法文件
! v- S4 j$ f" t! S- d+ ^' z: j) v
% x5 P. x |4 M+ u
文件名RSA.ASP
# j1 r/ f% ?. y6 Q% M
===============================================
; I2 a* o: N" q X# R$ J2 t
<%
% p1 R; u- @( M U, I1 P
Class clsRSA
; o, N9 D. S0 I P9 y8 k9 r
Public PrivateKey
% {4 ~: M) `7 @
Public PublicKey
, m) w$ r8 e* H3 b8 o% T$ P* ?
Public Modulus
5 X% e# s* K+ [4 g+ X% l. z- t
Public Function Crypt(pLngMessage, pLngKey)
5 w3 M u9 d. h: r8 ^& r
On Error Resume Next
& g @ b" A3 [: ]2 Y' Z# b
Dim lLngMod
, i9 Q0 r% V. m5 [, Y4 r/ W
Dim lLngResult
# d% B3 y( ^; k! x9 G
Dim lLngIndex
9 s3 K' f* ?) t4 m5 p( W
If pLngKey Mod 2 = 0 Then
8 ]8 H! H) e7 _5 D# ~
lLngResult = 1
% M4 c& N$ E& j: A% D _
For lLngIndex = 1 To pLngKey / 2
3 ~6 s- w& D! H! o1 J0 ^: W
lLngMod = (pLngMessage ^ 2) Mod Modulus
; U& Q" }1 a4 w6 ^ F
' Mod may error on key generation
3 K/ I# Z) b) L1 Z5 E; o; g
lLngResult = (lLngMod * lLngResult) Mod Modulus
* Y$ |# v1 o9 G/ f& v
If Err Then Exit Function
% C& q9 s4 o8 O* Y& p5 B( J
Next
- W4 K+ ^! n6 D6 u7 z0 ~1 P$ P
Else
" j- E: [( h$ v
lLngResult = pLngMessage
1 H/ G% p' S2 I% h; j3 C( |) |
For lLngIndex = 1 To pLngKey / 2
) V' t( e8 W% R' e9 @0 O$ C2 `
lLngMod = (pLngMessage ^ 2) Mod Modulus
$ h- U! r# _" E0 p
On Error Resume Next
2 V2 F! x. \. n8 P, a* W
' Mod may error on key generation
9 a8 S! s0 @% Q# m4 a4 x
lLngResult = (lLngMod * lLngResult) Mod Modulus
3 S& I6 y4 M7 G+ g+ f' Z, S
If Err Then Exit Function
0 i) z, \5 E E8 D; ~% }
Next
5 y; d7 s4 r! _4 P* g. o
End If
" g' I4 `! F+ ^! ~- n6 l' R! V
Crypt = lLngResult
9 Z1 \9 b9 k0 `1 r7 X+ Q
End Function
4 M1 T3 W; F- o
4 @# a3 K/ m3 u! h; p% a8 ]3 L
Public Function Encode(ByVal pStrMessage)
2 A5 N' |+ l( M6 i
Dim lLngIndex
. K, L \% |) o
Dim lLngMaxIndex
7 b2 F: L0 D6 g% C( S: `
Dim lBytAscii
0 F* @" y9 ^& S+ I% Y7 o9 h$ X
Dim lLngEncrypted
, j2 X3 i+ p3 B2 P8 ?1 A. Q
lLngMaxIndex = Len(pStrMessage)
: d( @0 d p. E1 v3 h4 c
If lLngMaxIndex = 0 Then Exit Function
, H& R7 K# ]5 Q' F6 c
For lLngIndex = 1 To lLngMaxIndex
3 N4 M! e1 V5 W/ f, g
lBytAscii = Asc(Mid(pStrMessage, lLngIndex, 1))
/ _* l* e: U2 j, H
lLngEncrypted = Crypt(lBytAscii, PublicKey)
; z7 w% r( {2 n2 [1 \0 _
Encode = Encode & NumberToHex(lLngEncrypted, 4)
! b/ D1 ~7 [0 i* L: x! m+ B
Next
6 B& P* S$ W9 P, q7 o' ~
End Function
4 A- i, x5 c. O
Public Function Decode(ByVal pStrMessage)
0 j1 N3 L- v& `! \8 ^( j: f5 H0 b* A
Dim lBytAscii
) t5 m+ Z7 G) _3 m
Dim lLngIndex
5 g3 P7 Y7 i! |
Dim lLngMaxIndex
; o; q- j: z4 C3 g2 K) {# X/ t* G! N
Dim lLngEncryptedData
$ B+ t w6 N0 l7 i& N
Decode = ""
+ o) L6 |! d2 Y0 z3 Z* m- u4 V
lLngMaxIndex = Len(pStrMessage)
3 n8 D/ V% [# h. z' t- }
For lLngIndex = 1 To lLngMaxIndex Step 4
0 q- ~/ X5 Y: Q( b x( i/ T
lLngEncryptedData = HexToNumber(Mid(pStrMessage, lLngIndex, 4))
3 z" G; c+ W# _' ?) p# w
lBytAscii = Crypt(lLngEncryptedData, PrivateKey)
5 V) j* w( ~/ C- j9 ]
Decode = Decode & Chr(lBytAscii)
% J% S& { h$ O) |
Next
7 J1 ?( N/ R/ M N+ B2 q) ]; l
End Function
9 S% K* @% m: l
Private Function NumberToHex(ByRef pLngNumber, ByRef pLngLength)
; [, b0 n n* K, j. ]
NumberToHex = Right(String(pLngLength, "0") & Hex(pLngNumber), pLngLength)
# `/ A5 J' |5 Q, @' F; t8 i
End Function
( f- J5 y# f9 l
Private Function HexToNumber(ByRef pStrHex)
& I6 a; a; M/ \9 V2 m: R
HexToNumber = CLng("&h" & pStrHex)
6 K5 m* K% N, X3 } v
End Function
[/ d9 ~4 q* o. k7 A
End Class
' X" n% P$ ?, F8 |! g
function Encryptstr(Message)
7 d& j4 N; `0 t. d1 o
Dim LngKeyE
3 [, y6 a4 `+ u: Q
Dim LngKeyD
9 K% d! b, V% w4 I, Y5 j0 Y
Dim LngKeyN
% p1 D+ _, o2 l/ _' b
Dim StrMessage
+ d7 }- `( {2 l# t) t! J
Dim ObjRSA
/ u$ B# ?9 x C! \3 C
LngKeyE = "32823"
2 p; x5 }5 `: P. d" p
LngKeyD = "20643"
) R% c7 K& _/ z6 K0 V
LngKeyN = "29893"
+ D- a# R* x+ W7 x* L0 ]6 ?3 x
StrMessage = Message
9 P2 e9 i% F. |0 r3 s
Set ObjRSA = New clsRSA
' [7 a9 Y8 c0 x, h5 W4 j( g5 ?- _
ObjRSA.PublicKey = LngKeyE
0 s6 k6 |$ X# {- ^/ @
ObjRSA.Modulus = LngKeyN
, v9 R Q1 S' J3 O, \+ X
Encryptstr = ObjRSA.Encode(StrMessage)
' r6 {9 F8 y. I0 m
Set ObjRSA = Nothing
" k* [* j+ `' T% f/ d
end function
2 g( z! o1 N, D+ x6 ]& A" ^- Q
Function Decryptstr(Message)
: b' Z9 \- `7 W& h
Dim LngKeyE
0 p9 N; N6 M. P
Dim LngKeyD
& `) I! W D: S" E( l/ Q
Dim LngKeyN
2 l- W: x7 i5 Z8 v
Dim StrMessage
, k2 y7 E8 F, q+ g
Dim ObjRSA
2 O. d( {+ v0 }
LngKeyE = "32823"
5 `, u: \! E1 L+ e' T# {" @
LngKeyD = "20643"
1 L2 Q: U8 |7 ]1 r
LngKeyN = "29893"
( J6 N/ G- n6 w+ q ~
StrMessage = Message
$ w3 C- v |% `1 E
Set ObjRSA = New clsRSA
# ?; O/ o5 `- \* B0 c( _
ObjRSA.PrivateKey =LngKeyD
1 w4 W$ r+ ^. _* m+ H5 o# S
ObjRSA.Modulus=LngKeyN
( }2 E3 p- f5 K+ w+ u
decryptstr=ObjRSA.Decode(StrMessage)
0 H/ j9 Z. K# s7 b, T9 N
Set ObjRSA = Nothing
) ^7 R' m% i5 B1 ]
end function
! x6 F' ^6 k# z2 ?
%>
3 T6 Y& r/ `5 [% {# K
===============================================
) X g9 s& C* X% L; t ~# f
0 |0 ^! e! M5 K9 m" D4 x) {
还有一个用于测试这段代码的test.asp
% G' o8 e: O4 K; Q7 o6 [
有兴趣的自己搭建个IIS测试下
1 _ y5 I/ c4 ]
<!--#INCLUDE FILE="RSA.asp"-->
' u5 o( ^3 F. a
<%
( m. r% f4 f& l0 `
function Encryptstr(Message)
2 j8 }. I) w0 i9 ?! c
Dim LngKeyE
( [* D P$ X9 Q% a9 [9 K- V
Dim LngKeyD
( D7 ^4 r# Z- P+ S
Dim LngKeyN
) G# M t+ v- [2 {8 O$ I0 W8 @
Dim StrMessage
2 a, W7 i( X, O4 y }# [0 N+ q
Dim ObjRSA
- T8 T2 c; \1 R# o; O
LngKeyE = "32823"
( M4 p$ B3 L/ s9 G/ b! Z2 ^
LngKeyD = "20643"
] p! T; @7 v! o6 F- Z8 d. d
LngKeyN = "29893"
& ~- r3 ^0 Q" `. E
StrMessage = Message
$ ?7 H# Y. N6 K8 J' k" e% M5 \
Set ObjRSA = New clsRSA
2 c+ M4 m- m. T/ }! y) r
ObjRSA.PublicKey = LngKeyE
0 X: R9 A/ V: ^' w" n
ObjRSA.Modulus = LngKeyN
% R. f7 T8 G: r4 \+ G
Encryptstr = ObjRSA.Encode(StrMessage)
# ?% [0 F y+ M$ {
Set ObjRSA = Nothing
9 o7 H6 k1 J- q' N
end function
4 h1 _1 G& A& C' ^
function decryptstr(Message)
/ A+ t# r& I1 E2 o; ]3 x
Dim LngKeyE
' e* ^/ C+ c5 [: L& R9 {
Dim LngKeyD
, u/ W) G3 b; P$ `; I# m
Dim LngKeyN
8 h# e# \' M& R, P4 A2 F
Dim StrMessage
' t) x" H. v: M7 W
Dim ObjRSA
$ m; |( }: H2 [- W
LngKeyE = "32823"
6 T; U L9 k/ s+ B. x! z
LngKeyD = "20643"
4 c$ W6 A2 n# U \9 `. y7 u* `
LngKeyN = "29893"
" p6 P8 `$ {- Y8 w
StrMessage = Message
. g* c' Y7 P& h. @' O) o; g* x2 v
Set ObjRSA = New clsRSA
2 |! q5 W; E0 e' t3 [6 i
ObjRSA.PrivateKey =LngKeyD
6 V* n E# K$ q- [
ObjRSA.Modulus=LngKeyN
! H0 a% E9 Y9 f1 ?, O5 t# [/ I
decryptstr=ObjRSA.Decode(StrMessage)
1 {7 H# v: x3 E0 e
Set ObjRSA = Nothing
3 \% s) v/ g/ R1 k" ]
end function
2 S) H+ U2 d- M, t# Q3 z; f# r
dim last,first
. L% J |3 Y; T: Z
first="!@#$%^&*()"
@4 t4 c% W+ `! t( e/ r' G
Response.Write "加密前为:"&first
2 y7 c; |, ]3 \! k$ _* f- g! w- g
last=Encryptstr(first)
/ Y2 j0 Y4 X' b1 U( U& |
Response.Write "加密后为"&last
% T1 i) Q; C0 y5 r- U% s* q
Response.Write "解密后为" &decryptstr(last)
5 A, h; C2 z: a% m! v9 U4 Y2 {: ~3 y
%> ==============================================
0 ?6 y' l" V7 H. P- ~$ p
剩下的就是字符的对照表了
( x- L+ p }; w# ?7 i) ~
===================字符集================
/ {% p; a* U! W* e
1_____6EBB
6 M& K d9 y9 v' i
2_____5C1F
! | Y% l% [1 {# |
3_____4D75
5 R) W! R$ ?6 W3 j( A# U
4_____26CC
5 ?1 q' a% I4 J* t4 r6 F
5_____4F88
; g! g' h# J# B. r+ ?3 `$ z
6_____3F4E
5 |1 ?, r, y7 @4 m. G! J- |
7_____0A9D
; ~, w# f# E% q, n
8_____1A1C
' q z& |+ }* n d
9_____6D20
; V# Q; u. E6 E/ J8 D" A
0_____1089
2 q. b- R2 n" N, c: e! x4 s, J/ c
a_____0F3E
& U5 t7 }7 i# u) ^, V
b_____3159
: w4 C G8 p A
c_____3517
* X, K. m6 N7 I# x6 s* l- u
d_____419C
! [- ^: Z: J, R3 n9 k$ V3 \
e_____615C
2 i$ N2 \/ V: y/ j5 T+ s
f_____556F
2 n; t+ n ^; K: S
g_____2B7F
) x b: t- u, f% }3 E9 `/ F5 M# ]+ B
h_____0F9C
2 {& O4 Y* w- y0 i
i_____00FA
# s" A8 g* J# D! G" d5 [5 b# Q* I `
j_____5A50
* l" `9 O- f- f9 t
k_____2850
1 N8 h" [8 }% t+ N& V
l_____3E7B
1 C, f3 w! ~, o* H' i Q+ S
m_____71C5
) z, p8 `- f+ ]* y, X
n_____1FC8
" k" {) C1 H* }% X4 x
o_____74C1
+ X$ y% B6 Y/ x! N* N9 Y' a3 c
p_____5FB8
5 {& i3 ]8 e8 e
q_____6085
" Y' z+ \% o; C' W6 ~/ t) J
r_____3AC4
; e: l v8 Y( q L, C4 \) D4 v% r
s_____2F50
- B; b9 j* E* ]$ h
t_____36F8
% Z* r! e1 G- \ Z9 O
u_____7010
0 y) \3 N+ `: O, N: z3 o+ c% T
v_____0B42
* F# j9 I, u V, L& ]( S" r; f
w_____1C7A
& _: C& N# d6 J# X1 F
x_____16F8
* |: ~, q5 T5 E( c5 [) f- V
y_____2EE7
. y% |# F/ `& u
z_____5CF3
# S* j/ O" D' t5 C& D
!_____6233
1 i$ m7 {. L9 }: [' \& o
@_____3A45
/ O$ J" S3 k' w/ E4 u
#_____2291
" P4 o! w+ z) ~0 A& ~
$_____5D5C
; [# ^2 s. u, G. k' | _
%_____09B9
( Z8 u! O) l6 g) K$ l
^_____43EA
/ j# i, b1 ], S9 |
&_____62B9
+ H9 I1 k( f8 w0 {, }5 T
*_____6301
! c6 q- b% b# S' F+ Q
(_____4659
9 D/ B% o9 N. y0 Q
)_____5C82
作者:
鱼儿无心
时间:
2011-12-4 17:17
收藏了。。。。。。。。
欢迎光临 【3.A.S.T】网络安全爱好者 (http://3ast.com./)
Powered by Discuz! 7.2