返回列表 发帖

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

原创作者:柔肠寸断 [3.A.S.T]  http://www.3ast.com.cm
6 `3 K% W$ {6 y  [' B' J* `3 h原始出处:http://www.3ast.com.cm2 V, h1 i' x+ F

1 A/ @: N7 K+ H+ h- w看不懂的直接绕过
' p- ]1 k/ N* j" W* Y: C/ m# U加密前为:hwy1234566 W! o5 ^7 S$ M1 g8 t5 g
加密后为0F9C1C7A2EE76EBB5C1F4D7526CC4F883F4E4 l, E( V" ~, i
9 r7 f! P* r6 ^' p0 D( F( @. [7 R. T
============================================
* @: ^, R" S! b上面是当时自己校内的心情。现在已经解破出来了,分享给大家
7 \: H# X$ A. y$ ]+ E6 T! n( }也就不隐瞒大家什么了,这个是国内某知名大学的后台加密算法1 a- S) k5 m# }+ `: L0 {- _
以下是RSA算法文件
& f, B8 |, C  f, Z% \( B/ l: J/ u: U
文件名RSA.ASP* i; d+ T* {  j1 S* F
===============================================
6 Y8 o8 Y. B0 S& E# [6 i1 E! W<% 9 z* u6 m( d3 G( P7 y4 f
Class clsRSA
( D& Q% \: `1 l- a' U9 ?Public PrivateKey 7 y7 A7 \1 ?, l; \
Public PublicKey
! a1 [  o* ~6 Y6 rPublic Modulus
1 z* z" g6 ?( [8 RPublic Function Crypt(pLngMessage, pLngKey)
5 [# W, u. G1 \# ~) @On Error Resume Next
0 P7 q  V; l4 B  U0 gDim lLngMod
9 T2 E. F. M, M5 K+ `Dim lLngResult
3 o( ]5 ^' T- i* @+ y4 WDim lLngIndex
  a9 U* w/ {8 y6 U% s" kIf pLngKey Mod 2 = 0 Then
5 a# y0 Q' ~# N$ ZlLngResult = 1
3 h* w, x/ [5 Z4 oFor lLngIndex = 1 To pLngKey / 2 7 k4 K3 ~5 m( K( d# X9 Z; \
lLngMod = (pLngMessage ^ 2) Mod Modulus + c( v: ^# c: }; K! x% r
' Mod may error on key generation
3 [2 _8 n& s& c' s0 B  W" alLngResult = (lLngMod * lLngResult) Mod Modulus 1 j( v" O) O5 ]* C5 {. n
If Err Then Exit Function
. Y3 n  q, ~$ n$ \+ LNext 0 Y8 \" Z. R+ U) U9 \
Else
* A1 C5 C; a( A8 X& S$ W3 H+ W3 TlLngResult = pLngMessage
+ _1 @+ N, q9 a" x6 K4 ]For lLngIndex = 1 To pLngKey / 2 ( [6 L* A7 c' C$ R. `# O, P6 k
lLngMod = (pLngMessage ^ 2) Mod Modulus 8 g( O2 O! _5 M6 X0 G9 m8 Z
On Error Resume Next % T1 u3 x6 T, n% U6 w
' Mod may error on key generation
3 a* j# G& ]- S5 Q. z9 YlLngResult = (lLngMod * lLngResult) Mod Modulus
- a$ n( O4 t2 c# JIf Err Then Exit Function
8 C( h! j1 A5 u$ v. W( B& MNext
, B) i9 [4 W: r3 ^! J: xEnd If ) t3 ]* L; z4 F" \# S' d( G8 m# \
Crypt = lLngResult & w$ Q; L& o; N
End Function
; a( ?0 S( P# X& b% S, k" b" [$ V' r' L4 \" I7 p) Y: g
Public Function Encode(ByVal pStrMessage) ; U: F! Q8 G+ E/ p
Dim lLngIndex * e1 ?) H8 S( b0 ?( p4 I
Dim lLngMaxIndex
) y( z1 ^/ F" EDim lBytAscii
0 b" F& P* q% e' y* IDim lLngEncrypted
1 ]* x0 }( V8 JlLngMaxIndex = Len(pStrMessage)
2 v. v: ]7 ~/ aIf lLngMaxIndex = 0 Then Exit Function
, k! Q# e7 A/ @1 tFor lLngIndex = 1 To lLngMaxIndex
1 Q) V! ^* D0 R- ?, {lBytAscii = Asc(Mid(pStrMessage, lLngIndex, 1)) # X) L- D, p* j* G) a
lLngEncrypted = Crypt(lBytAscii, PublicKey)
( |3 X: `6 I, X8 q  TEncode = Encode & NumberToHex(lLngEncrypted, 4)
+ v/ ^& G. g; E1 i' y% P$ l* _( r# gNext 6 d7 O7 _( b' Q9 R9 n+ ?
End Function 0 w9 m/ E4 Q( w1 l
Public Function Decode(ByVal pStrMessage)
! T8 ]+ M4 t/ b$ A3 s8 bDim lBytAscii + W" M2 g) k% r( O7 d
Dim lLngIndex
. b$ B! B0 @9 |9 d( gDim lLngMaxIndex
+ O0 v) d7 i9 B' F4 zDim lLngEncryptedData 5 q+ d3 s, R  W7 l2 Z! l7 T0 l6 c
Decode = "" # _& G9 L1 a; |" `) V9 R9 I
lLngMaxIndex = Len(pStrMessage) 3 A& ~7 V) w" J+ Z0 h
For lLngIndex = 1 To lLngMaxIndex Step 4
8 ?1 v  k8 B( @, n2 W) elLngEncryptedData = HexToNumber(Mid(pStrMessage, lLngIndex, 4))
" Z* ~& y" c2 v  a$ h, [lBytAscii = Crypt(lLngEncryptedData, PrivateKey) " d. ~2 g# E% ?4 ?" k/ V; T9 w
Decode = Decode & Chr(lBytAscii)
) z3 j" e8 q; A4 ^Next - ?3 X" x: W, x1 ]% _) s3 N7 q
End Function . c6 A4 j4 S1 a
Private Function NumberToHex(ByRef pLngNumber, ByRef pLngLength) . U1 h9 _  z- M: v9 @
NumberToHex = Right(String(pLngLength, "0") & Hex(pLngNumber), pLngLength) . m# L5 v2 D' H* W( g) @
End Function + |" z. a0 {. w/ l( [
Private Function HexToNumber(ByRef pStrHex)
$ p3 x$ s4 J* p* Y, j+ h9 A4 uHexToNumber = CLng("&h" & pStrHex) ) I4 i4 l) k7 ^: ?
End Function
$ l2 Y( Y7 I, [# j  E: J2 z  G# DEnd Class 1 C0 [, y- O* Z( ?( U( r3 I! b
function Encryptstr(Message)
0 J" o6 i) h5 D& B* d1 f* a1 |8 WDim LngKeyE
$ G& O# t: J. PDim LngKeyD
0 Y6 K% y) j) H+ ^Dim LngKeyN
# ]) n3 E0 L9 R0 B! a* L. ~; z* QDim StrMessage
- j$ ]8 ]* F& X# u5 l0 U0 wDim ObjRSA 6 [; j$ [0 x' k+ P
LngKeyE = "32823" 4 J  T; t+ E3 [- w7 C5 f
LngKeyD = "20643" + P7 P/ o5 e. k, V- F2 p! M
LngKeyN = "29893"
, t& W" s. d. N& @4 AStrMessage = Message
, U/ W/ ]& N3 x* x  {Set ObjRSA = New clsRSA / G, b7 h( P/ y
ObjRSA.PublicKey = LngKeyE
( ?+ i% X! i7 w# Z# ]ObjRSA.Modulus = LngKeyN . I! d" ~* o* K* T  i; r* F
Encryptstr = ObjRSA.Encode(StrMessage)
' E# S1 e% ]% ySet ObjRSA = Nothing
4 h6 r) f- j1 P+ @3 ?! _end function
5 z! g3 V" f+ c3 HFunction Decryptstr(Message) & `: b8 K9 \; B$ f
Dim LngKeyE
2 c# \& O6 d% k3 [1 ^Dim LngKeyD
! h' y4 C) ?' _* Y  ?) e; @" ]Dim LngKeyN
- j, r' b' M. LDim StrMessage
1 f5 }* t( D3 g( {; n/ o: YDim ObjRSA ! O; W: ]& w- u. L
LngKeyE = "32823" 2 @# f1 Z4 T4 g" A
LngKeyD = "20643"
. o4 ?4 M( |+ m7 v, O+ g: b  ~! k) jLngKeyN = "29893" 2 l. W4 W* U- g8 ?2 Y  ^, D
StrMessage = Message
) O, b0 U1 d; NSet ObjRSA = New clsRSA
6 N0 {- E5 Y  S5 W/ @( J& p* \' w) RObjRSA.PrivateKey =LngKeyD , k! t$ n  D  g# K
ObjRSA.Modulus=LngKeyN
% p# ?/ z. A; k3 Ydecryptstr=ObjRSA.Decode(StrMessage)
8 `% D- B  }6 @  f% @Set ObjRSA = Nothing
2 c5 E+ }; i% b7 Eend function
1 W5 j6 Z; f& r6 X' r6 o%>
3 A. f% g! q9 ~" p9 M* y% T( x===============================================
/ X/ x- T* v* ]  q2 j
4 w$ [* a- n$ i' k/ U' f  P1 _还有一个用于测试这段代码的test.asp) o: m" _, H# p9 w0 z) f
有兴趣的自己搭建个IIS测试下
; z6 `1 W4 x& c8 c( v<!--#INCLUDE FILE="RSA.asp"--> + E( C+ L4 [7 x4 M! d
<%) a6 M/ z" b! v: f) o2 H5 d/ ?* H
function Encryptstr(Message) $ Q; p2 y, Z6 {1 @  d4 I
Dim LngKeyE ) L8 Y( _) R8 m5 X0 j/ w
Dim LngKeyD 6 ?* m) }6 @; C8 |6 ^/ x6 ?9 |- s
Dim LngKeyN
: j2 A; g) G# L  L: m+ xDim StrMessage
+ ^3 M- o$ }  @0 r& R$ YDim ObjRSA
" C1 x4 a& X' w4 r3 wLngKeyE = "32823"
8 ]+ u# _: T, L; o* s2 [LngKeyD = "20643" 3 p8 y( i3 [2 q! I
LngKeyN = "29893" ! ]; w. O2 _& s
StrMessage = Message
# v9 z$ Z: C0 R0 a9 K3 WSet ObjRSA = New clsRSA
6 F3 _  s- c9 ~& G! @% [) ?ObjRSA.PublicKey = LngKeyE 9 {$ r1 W& }/ ?% o( q: P
ObjRSA.Modulus = LngKeyN # }0 Z. ~: l6 q- U& Y. f' N% n* e
Encryptstr = ObjRSA.Encode(StrMessage) 2 n3 F8 S- V2 C5 ]: s& |. Q
Set ObjRSA = Nothing & v% Z- Q6 R& E+ P
end function
3 z  f( ]1 w; t) afunction decryptstr(Message) ( L5 x6 y/ o0 w# E0 z9 i
Dim LngKeyE & U/ }% U! \" h8 ~3 g
Dim LngKeyD
* |' I; ^2 N% w+ IDim LngKeyN # o7 {7 _% ^6 G  G# t2 s
Dim StrMessage
2 d5 L3 W- C; E  Q* LDim ObjRSA
; a& c- w$ ^/ }1 x. r7 ]LngKeyE = "32823"
1 q" u* @* n- e# ZLngKeyD = "20643" # t. g' C" u/ F4 R) f
LngKeyN = "29893"
4 |7 A7 p2 S4 rStrMessage = Message
2 }" G  J3 ~" T8 n2 ?8 YSet ObjRSA = New clsRSA
% q% }$ W3 s) `1 ?; z* _ObjRSA.PrivateKey =LngKeyD
+ H* \5 R2 M3 W7 R: Z/ L$ s4 r9 PObjRSA.Modulus=LngKeyN
9 C7 Q1 M6 ]% E1 i5 |# {decryptstr=ObjRSA.Decode(StrMessage)
9 L+ b7 X1 v2 o8 i& U' M: Y' SSet ObjRSA = Nothing % M- g5 ^0 a5 K% ~) E& G8 h9 Q
end function ) J( W+ u' I) V$ Z; r4 E
dim last,first 5 m% F$ R4 l" Y; O# k1 ^
first="!@#$%^&*()" & N# ~/ Z8 N6 i/ z
Response.Write "加密前为:"&first 2 Y2 Q( r( t( p( ^5 H
last=Encryptstr(first) # e9 a7 L& c$ [; m" r% X3 a
Response.Write "加密后为"&last * M  y  m: U5 k2 X& e
Response.Write "解密后为" &decryptstr(last) / K2 y' E; ]9 O+ g2 |, `
%> ==============================================
3 v. B! b+ v$ I9 \4 l3 ~/ F& C& p- G剩下的就是字符的对照表了
7 O$ f- e' T# X7 p/ e===================字符集================1 u+ K* I- z- E- a2 u
1_____6EBB
0 I6 V' L7 r& h6 i. [4 D$ o% t2_____5C1F
% d( `0 f" }$ o/ V3_____4D75& }9 N/ c" a! _! B" w1 @
4_____26CC
' Z$ c# @. n; j& g4 W$ ?# |5_____4F88
& Y9 G. c" P0 |# e, v$ j6_____3F4E+ j' l5 [1 ]" r2 G* M3 t# M9 }
7_____0A9D8 Z4 q" s  Z2 ]$ M! F+ ~$ O
8_____1A1C
+ a" L' K$ x6 C. H6 ~( O4 J9_____6D205 _. h3 z9 J, r7 B) O4 |7 s
0_____10891 P% k* O0 U, N+ W
a_____0F3E
$ S& _! B+ D6 Zb_____3159
3 C5 B5 n* f# e" G2 _, f2 O3 D# xc_____35177 W+ z) c: Y7 m4 p, T. m* G2 Y
d_____419C* G* x% a- i; B; n& o
e_____615C3 p1 D( Y7 k9 c: }3 w
f_____556F. i% c+ `& z- f7 Q
g_____2B7F
# W; y! \) N" ?+ Lh_____0F9C5 n$ p# }- {9 ?  t7 h6 j- W
i_____00FA
; |9 e, n! ^( J. V2 s' i: [j_____5A50
, f# W1 \7 S2 Ek_____2850
+ d4 W/ C! Y$ d/ jl_____3E7B7 }/ x* U0 Z$ `! b% M
m_____71C57 n, Q3 D% \0 d' p; d/ K
n_____1FC8- P! o; i  z7 m/ `
o_____74C1
, _9 P4 E( M4 y& y; F, W% _p_____5FB82 s' A3 l4 k) k- Z7 m, C) ~
q_____6085
4 X. y5 z+ B: Y- ar_____3AC4  Q$ Z2 G' B5 B# F/ P
s_____2F50, T9 \9 h& s8 R: f8 @1 Q4 h
t_____36F82 y7 E# G- g# e! F
u_____7010
+ g$ \0 M6 u* m2 w* _v_____0B42' Z4 i$ ^6 e: Z1 s& |. P/ e
w_____1C7A
) a9 r9 q8 s, H& P. c" p8 Ox_____16F85 o* z$ `" n$ ~  @" k2 P
y_____2EE7
' Y8 }, z- @# M, m9 V/ gz_____5CF31 X. X: s" B. T+ h7 k. F5 r
!_____6233  A: N7 O/ E9 {- ]0 I5 _( Y# T
@_____3A455 c  @8 l# M& O6 \
#_____2291
9 |9 p+ p0 H. ]2 l$_____5D5C4 {9 I9 f2 V; l3 h" X3 L8 D
%_____09B9# X2 R. {2 @. T3 K
^_____43EA
+ U) O; v; k0 G&_____62B9) U+ o9 C) w# x- K9 _/ X% B0 @+ }0 y
*_____6301
9 [7 j& ]! \1 N! B. o. L- z+ U! N4 _8 v(_____4659
& B- f% H( `' a9 p- z9 [! m)_____5C82
希望做站长本人的学生请点击
http://www.3ast.com/viewthread.php?tid=13841
QQ790653916只负责SEO以及收费教学等方面联系,他人勿扰

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

收藏了。。。。。。。。

TOP

返回列表