返回列表 发帖

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

原创作者:柔肠寸断 [3.A.S.T]  http://www.3ast.com.cm, V- c. p; B/ B! P6 r' u
原始出处:http://www.3ast.com.cm9 y5 }2 l4 A, M$ Y7 G, a1 _
9 ]( a1 w4 F# P3 s6 @
看不懂的直接绕过
/ A2 u2 O4 X9 B+ C% h加密前为:hwy123456" `- i8 i) q4 R' D
加密后为0F9C1C7A2EE76EBB5C1F4D7526CC4F883F4E
' E; B+ v6 I+ E) B- P% Q) O- c# J) ~/ ?6 F$ |! ~. s
============================================1 U  ~- |/ o* o5 e. b4 n2 @6 A
上面是当时自己校内的心情。现在已经解破出来了,分享给大家1 k: O' ?" a/ d0 I
也就不隐瞒大家什么了,这个是国内某知名大学的后台加密算法
5 T' I, L9 d6 r+ D$ ?& z. x* l+ A以下是RSA算法文件9 ^5 d4 L) \7 j2 c5 |3 X5 k8 X$ Y0 A
$ H8 p' d7 r+ G
文件名RSA.ASP
' O4 }0 ?8 @8 T5 z- y===============================================
' x6 ^% b7 _4 g- j" A8 v. p<% 3 B8 A9 f4 o5 ~: Z/ ?6 r, O  f
Class clsRSA + E  H/ s: }5 ?$ L8 u. C% W
Public PrivateKey * f& ^3 }+ O, y+ H# M
Public PublicKey
6 t1 m5 v. T# Q3 e% j8 j# \Public Modulus
) T8 U2 v! R: j6 r0 W- rPublic Function Crypt(pLngMessage, pLngKey) & T( V. M, e( N  {% ^8 S
On Error Resume Next
/ F' i/ E8 \, {( h6 M1 F. dDim lLngMod
8 B3 x3 [9 T1 n  K  `Dim lLngResult 3 k# P0 z4 w  R$ G( E
Dim lLngIndex ! O5 s, E1 O/ K
If pLngKey Mod 2 = 0 Then ; L1 d# x, D* k, [# o- h' V
lLngResult = 1 - P, j# ?- h. p
For lLngIndex = 1 To pLngKey / 2 # S" K. P/ z# ]- S: X: j/ J
lLngMod = (pLngMessage ^ 2) Mod Modulus 5 S. _6 e% q7 w& N2 s) F; ]4 j
' Mod may error on key generation * u3 c/ q% x8 d% ]& J; P1 Z% r  L" C
lLngResult = (lLngMod * lLngResult) Mod Modulus ! \! N% v% y5 K' r
If Err Then Exit Function - `' ]9 ]6 X, K$ h- E9 Q1 M$ a
Next
2 l" e- |3 D. B- j$ aElse 6 ?6 `  G3 C! Y, n3 D; t
lLngResult = pLngMessage
' s) D5 I, ]6 _For lLngIndex = 1 To pLngKey / 2
* I! Q& G) M' b( [: c/ w/ i+ ElLngMod = (pLngMessage ^ 2) Mod Modulus ! A  \& Y! Q& u) R8 d* }. ?
On Error Resume Next 2 p9 }* F) w# T8 e% O& {
' Mod may error on key generation
) c. ^8 I) ~" h5 p) JlLngResult = (lLngMod * lLngResult) Mod Modulus
/ A/ D. i, a9 c0 g8 ^& ^If Err Then Exit Function 7 J, @& [3 h! ]  Y" }# R5 K' ~8 D( x
Next
2 a3 V- |1 |9 f1 D1 AEnd If
8 M" z6 \1 B! f8 M) WCrypt = lLngResult
2 N# t! w  E& H( f& AEnd Function. B0 k' H8 O; k
7 b. N; H( N/ {3 h8 b0 X, ^
Public Function Encode(ByVal pStrMessage)
/ v" s: R2 w* y# bDim lLngIndex
) J% n2 @. }5 L" ^- {Dim lLngMaxIndex
; i, J" o9 f- JDim lBytAscii
3 E) {! L' Q$ o4 y- c% t# ADim lLngEncrypted
4 n+ f0 C& Z0 [) c* W  I- clLngMaxIndex = Len(pStrMessage)
4 ?. l5 E* y. cIf lLngMaxIndex = 0 Then Exit Function
! F  \1 j) z6 Q# w6 _) K  o0 E& MFor lLngIndex = 1 To lLngMaxIndex
4 T; V- o- L( ?+ n8 r% X5 ClBytAscii = Asc(Mid(pStrMessage, lLngIndex, 1))
! D9 Q9 h+ ~0 B0 T$ {lLngEncrypted = Crypt(lBytAscii, PublicKey) - X4 I% W. ~% ~  E
Encode = Encode & NumberToHex(lLngEncrypted, 4) , L+ i) c% q( A6 ~
Next
6 Z# @4 I, X) ^- [End Function 0 L. k; O6 E8 u! q/ x" D3 i+ k
Public Function Decode(ByVal pStrMessage) , z0 C+ L$ y. R( P8 q% ?
Dim lBytAscii
+ n' q3 V) r7 \) {8 rDim lLngIndex
- {& ?) Q0 F& [$ |" E% qDim lLngMaxIndex : |( Y7 I# E3 \2 g: l1 _
Dim lLngEncryptedData   y- j1 b. b! e- [8 q
Decode = ""   j8 O! q. q$ A4 f) {8 U# [5 s
lLngMaxIndex = Len(pStrMessage)
0 u7 c/ i% p5 @/ Y6 w3 |For lLngIndex = 1 To lLngMaxIndex Step 4 " p) t$ m  t) H5 D
lLngEncryptedData = HexToNumber(Mid(pStrMessage, lLngIndex, 4)) % ^  J+ K, V6 E- g5 Q: I8 k0 C
lBytAscii = Crypt(lLngEncryptedData, PrivateKey)
9 r6 Q! F$ y8 b8 |$ YDecode = Decode & Chr(lBytAscii) , c! Z3 p" {# V! Q( M+ U
Next
0 R0 {* `% E% c, Z) |End Function
, O7 d6 U6 Q- m0 x( V: H* zPrivate Function NumberToHex(ByRef pLngNumber, ByRef pLngLength)
/ d$ i7 R8 U% t3 F$ d* A. yNumberToHex = Right(String(pLngLength, "0") & Hex(pLngNumber), pLngLength)   J& g. S( x) }5 F; r
End Function 1 i, g: C; H/ i4 [& Y7 k& w
Private Function HexToNumber(ByRef pStrHex)   @, d; d2 e; F
HexToNumber = CLng("&h" & pStrHex) % [1 h( Y+ X' }3 r5 `8 B" V6 ]
End Function
- Q) m9 w2 ~9 a& u0 gEnd Class
3 C, {5 V/ ^, i8 d, Z2 e* ~7 Kfunction Encryptstr(Message) 8 E, X, J4 M; _
Dim LngKeyE 8 U5 s( y* L" H0 c; K3 u3 t# x
Dim LngKeyD
' w# D! r  |9 V" y5 X/ cDim LngKeyN
- p2 z) {) i8 o' O( w; WDim StrMessage
# G9 ?" B# K9 x2 ?! j) I8 U/ L1 DDim ObjRSA
0 F' b2 |5 I$ e' ILngKeyE = "32823"
) [  q1 m  w+ [+ ~$ G/ j, \LngKeyD = "20643"
6 ~! V% h9 U3 m7 F5 I9 kLngKeyN = "29893"
! q5 W/ C, E" x. p2 d/ ]# RStrMessage = Message 4 |5 I/ ^$ o3 r2 f
Set ObjRSA = New clsRSA $ z. T' l! U" \
ObjRSA.PublicKey = LngKeyE
/ I. _2 O- @2 |7 _) h# @ObjRSA.Modulus = LngKeyN " E+ @( \' S) y
Encryptstr = ObjRSA.Encode(StrMessage)
8 o5 h# `+ Q/ P7 OSet ObjRSA = Nothing $ e6 u7 \( g+ G- ~' l- l0 E( c
end function  h0 H6 x* `; O7 _; q
Function Decryptstr(Message) 5 t8 o- G6 d- P- a6 p
Dim LngKeyE % o* r) f+ _. q& V9 i
Dim LngKeyD
* C. N$ S( `% w% o+ t5 |0 b5 oDim LngKeyN
4 l  l* o  u9 i; G- ^7 hDim StrMessage ! B8 G/ h4 ~, c3 B9 ]2 n! c
Dim ObjRSA ( q  i! {- b9 g: J  g$ B! o
LngKeyE = "32823" . Y' {0 b4 r% c' v1 j( z$ {5 D" Q
LngKeyD = "20643"
+ z4 d, t# G( ?5 r& D$ GLngKeyN = "29893"
) r4 f4 ]) H, _# x# |+ p8 {) _StrMessage = Message & s: K+ ]: Y" C( m
Set ObjRSA = New clsRSA : L5 M% W" r/ E3 l, J
ObjRSA.PrivateKey =LngKeyD
# Z5 D( w: M( m4 r9 Y# DObjRSA.Modulus=LngKeyN
, C! y" N, i4 E8 t; N) @8 sdecryptstr=ObjRSA.Decode(StrMessage) 8 y! ^" I2 [" Z: x
Set ObjRSA = Nothing
8 b3 y% t0 @. ]end function
3 T  M/ R. Q& j% M4 B, T( q%>5 Q: P) T4 Q; ^
===============================================
3 U1 e" H. `0 n& s: T. c% _
4 w: \: Z, t. k) B1 y% i1 K还有一个用于测试这段代码的test.asp. r7 }: Q" I) M" O! V0 U
有兴趣的自己搭建个IIS测试下  J2 G  H$ }. o& F# V* K
<!--#INCLUDE FILE="RSA.asp"--> 6 A# e; E' w8 J# a1 |
<%' |* ?- n, u5 G" s* I; z' t
function Encryptstr(Message) ; V; `) Y0 W5 A" q" O
Dim LngKeyE
, C% R3 v4 y% U0 `8 GDim LngKeyD & O$ I+ D. n8 d! E  ^: y+ H
Dim LngKeyN ) X1 ^% t' K- \' ^5 |
Dim StrMessage
' q* e. M8 Q) s  c8 T7 w; w: PDim ObjRSA " A$ D  D3 d" \# O
LngKeyE = "32823" * e3 i1 J+ c: X
LngKeyD = "20643" , e0 g! \: X. h( I7 i
LngKeyN = "29893"
, \; N1 t" p8 H( jStrMessage = Message 3 ]6 z# h( S; Y' F6 Q
Set ObjRSA = New clsRSA - Y0 c; j8 S9 D$ h7 u
ObjRSA.PublicKey = LngKeyE
1 }) Q' Z% U* b; H* i* UObjRSA.Modulus = LngKeyN * y. \  `  Z. _# A* o; W: m
Encryptstr = ObjRSA.Encode(StrMessage)
# {$ o- S4 X6 J0 VSet ObjRSA = Nothing
7 K0 q9 j  w' Dend function 8 H* ^, W0 N% f3 X7 p( @! }% l) G% V) O( M
function decryptstr(Message) " y. r' z! H+ J  @
Dim LngKeyE
9 A/ h/ q# Y8 oDim LngKeyD * {- K- `' i: g5 n
Dim LngKeyN 5 O3 ~9 j- ~1 ]4 A- d
Dim StrMessage 0 x# ^, D0 Q9 x9 |; ]3 j
Dim ObjRSA
  ]7 k% r- I( w0 uLngKeyE = "32823"
7 \- W( J. \) `! A9 oLngKeyD = "20643"
- a' A1 k# K" e0 N1 c2 }0 MLngKeyN = "29893"
8 i, o& o7 t6 E9 dStrMessage = Message 8 V( s  {- q8 ~& E9 k
Set ObjRSA = New clsRSA ! C$ G& c- A% S; |' K
ObjRSA.PrivateKey =LngKeyD
" U' }( V- q9 SObjRSA.Modulus=LngKeyN
+ m( R! K  h+ t! Z+ }( k% n. xdecryptstr=ObjRSA.Decode(StrMessage) * E2 [- M& A# _. m  d: f: U
Set ObjRSA = Nothing
3 w# q2 C' n0 o* Tend function 8 s. B# ~; O# ?% T, }3 o* V  \
dim last,first
6 A" T; D$ f" j# X% R. afirst="!@#$%^&*()" 9 \+ c: n3 `, Q/ }: A0 X4 \
Response.Write "加密前为:"&first
; o- [7 y9 q& Olast=Encryptstr(first)
0 d$ |. ]0 _* R' [1 Y4 @Response.Write "加密后为"&last
. ~% P* ]" ]$ O7 KResponse.Write "解密后为" &decryptstr(last) 8 k; y) o8 p/ |5 E8 V* j
%> ==============================================
  @  {: S+ H2 @& K8 ~" S剩下的就是字符的对照表了, L6 G* R2 X3 u- H  W/ [
===================字符集================; ]% h9 G# t# D: J6 p. m
1_____6EBB
) y; e) w- A* U& e0 h4 ?9 h2_____5C1F' {/ h9 f. K% z+ l2 G6 ?+ G* m
3_____4D75& i8 `+ i3 k  u" I8 f
4_____26CC
9 O  h. ~# `" I6 X5 Q& \5_____4F887 O' _: I% p* l( H+ K- }$ B7 B
6_____3F4E  F1 a; z$ q- [3 B. a& C; ^! {# O
7_____0A9D0 l: t( V- F/ H4 q" w) y. l
8_____1A1C- g6 ?% ~; D6 c; H5 @- q8 x# o  f
9_____6D20; X! i' }: {8 i! y; n, u$ c- y: {
0_____1089
  k' a' q8 o) ^: @5 n/ B0 S! L/ ga_____0F3E
; h% ~! v  @  s6 a* P! c* w9 Gb_____31594 u! s- l' J6 o9 ~# |
c_____3517
, n1 ^' i( r% D, F, Id_____419C
7 A/ T, v/ B5 d, me_____615C+ J/ q) @6 j- F, G2 U8 l* k
f_____556F
) z) X9 J4 j% m. q7 v# e" wg_____2B7F
  B9 C2 o9 `* {' g, n1 W6 f3 I: wh_____0F9C
1 ?# F! ?3 L+ i7 di_____00FA6 w( w( j" X) ]0 ?
j_____5A50
. X/ A" S3 [1 P5 R; Rk_____28503 N0 h* `1 F9 A  D0 E
l_____3E7B
  `% D" N  v0 I9 w: F, x% I# @m_____71C5
, P: H$ U+ {# M$ Sn_____1FC8. @8 W# J! l+ N- r% ]
o_____74C1( _0 |: \* h% w
p_____5FB8
! n; {9 S4 O- vq_____6085# [5 O' F/ Y% p) N" [* H; v0 `( Z% d
r_____3AC4; {# g+ R+ D% e
s_____2F50
, f9 Y' J+ t) D5 Ot_____36F82 c( y+ i0 |9 U6 l9 Z
u_____7010
+ X+ \  X4 ?0 r) S4 G/ Cv_____0B42
6 [7 a: {8 ?* T4 r& _" \w_____1C7A
* u' M* P. ?; k8 }: z% P- U* Ox_____16F8
' Q+ c4 D: K2 o: q) c: X7 e9 Ny_____2EE7
9 h- J% s1 @6 t$ b0 vz_____5CF3. S3 ]9 u8 g4 Z1 a8 d4 [2 b
!_____6233
, P/ l) G) Y" ~+ J: Z: x@_____3A45
. b) A2 W2 u+ s7 E& @$ a) r- D#_____2291& W6 s' }8 T8 F8 z! c, B, ~4 s
$_____5D5C
3 {& O+ O: P" I0 E7 A! C, f%_____09B9
0 U- i% T1 y4 k7 w7 \^_____43EA
  o- @4 [9 c2 o& }1 P&_____62B9
) z/ D0 _7 @* X5 x/ M/ p6 I*_____63015 L. e- Y# s9 Y1 _; }4 N" l. ]
(_____4659: M/ a6 ^; I4 b" c" h; q
)_____5C82
希望做站长本人的学生请点击
http://www.3ast.com/viewthread.php?tid=13841
QQ790653916只负责SEO以及收费教学等方面联系,他人勿扰

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

收藏了。。。。。。。。

TOP

返回列表