返回列表 发帖

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

原创作者:柔肠寸断 [3.A.S.T]  http://www.3ast.com.cm3 Z1 n5 s4 g  \$ e2 z
原始出处:http://www.3ast.com.cm
1 t0 A/ l! E+ }6 D5 o+ v( p1 D; n5 H, _& F/ H
看不懂的直接绕过" K) [# P, i) A2 F0 P
加密前为:hwy123456. J8 i5 L  z9 w9 F
加密后为0F9C1C7A2EE76EBB5C1F4D7526CC4F883F4E
6 @9 V8 I0 G" f8 G( |9 \7 A6 V4 O5 T& A6 M% x9 x6 t
============================================9 ^+ ]# Y8 B0 l* K: E
上面是当时自己校内的心情。现在已经解破出来了,分享给大家0 a6 p9 i2 m3 A1 I
也就不隐瞒大家什么了,这个是国内某知名大学的后台加密算法
* {6 u. C5 [; s8 p! N3 q以下是RSA算法文件# i% Z/ O& f8 p2 q$ p

1 P$ p$ u: s4 Q( s0 d% \# N, b文件名RSA.ASP
/ ^1 t. _  z! i8 I- _3 w===============================================2 B, C/ g  N8 Z
<%
: ~1 O6 a+ \  @* iClass clsRSA
8 B0 W. p% }  H; a' r. L* XPublic PrivateKey 4 W2 k! ~7 @& i, |2 g" u- }
Public PublicKey 8 m6 z; h, _0 i) i  t: @5 \
Public Modulus 9 }; `# ?0 V( l3 X. E) A4 [8 `
Public Function Crypt(pLngMessage, pLngKey)
( j3 G/ ~& G6 x1 Z' r# ^9 U" IOn Error Resume Next
3 \& s/ R' Y+ [6 SDim lLngMod
6 {$ ]' f3 y$ O# o# ]9 KDim lLngResult
/ `# ]' t( I- k) YDim lLngIndex
4 U& C: D7 |: A$ V0 \If pLngKey Mod 2 = 0 Then
8 f! H7 p' x7 y: g% plLngResult = 1 ) t$ S5 s$ ^: b5 i- a) d
For lLngIndex = 1 To pLngKey / 2   Z) }: k5 P- @& u1 s
lLngMod = (pLngMessage ^ 2) Mod Modulus
  O8 u; {" i. h' _, {( Q* F6 j7 |% ^' Mod may error on key generation # T/ m% i. `( R  V
lLngResult = (lLngMod * lLngResult) Mod Modulus . V& C* x; ^! G$ Z- a
If Err Then Exit Function & U3 z6 J# `# S# j1 Y3 v: T0 v; j- N2 ?
Next . c) Y4 o# M9 s  {
Else + |$ |2 ~  U* j) L& y
lLngResult = pLngMessage
& h3 g9 e3 q! d5 e8 J# C* ~* zFor lLngIndex = 1 To pLngKey / 2 ' H' _( A  a4 P: k
lLngMod = (pLngMessage ^ 2) Mod Modulus ) i. p3 I& Q- ~3 J
On Error Resume Next
# V- }$ L6 N' O% i' Mod may error on key generation
" j, j* f1 r8 w: a4 c9 t3 llLngResult = (lLngMod * lLngResult) Mod Modulus 5 u0 U. W1 C# Z
If Err Then Exit Function 3 ?$ z, _, j, ?) H. ^# V
Next & d6 F7 [' _0 ]- M" ]
End If
, `9 p! ?* g  X# m6 c- QCrypt = lLngResult
& I8 H% H, D4 X: o. u8 gEnd Function* N" J$ g( t# R2 w! e- ?  c

/ q5 V5 c3 X; J% v  m8 QPublic Function Encode(ByVal pStrMessage) 3 n  q# ]- v- |* {8 }* `( r4 h
Dim lLngIndex
6 o; h9 X- C$ q8 |" l) O) zDim lLngMaxIndex
. j$ ?8 _( C( ]; h3 CDim lBytAscii / G6 K1 G$ `/ y: P1 U
Dim lLngEncrypted
0 I  c* Y% p( V* i. M3 XlLngMaxIndex = Len(pStrMessage)
7 Z6 i% B! s9 d  @8 F7 yIf lLngMaxIndex = 0 Then Exit Function
/ b7 o6 {  S1 i" `For lLngIndex = 1 To lLngMaxIndex 0 v+ n) |* ]) V
lBytAscii = Asc(Mid(pStrMessage, lLngIndex, 1)) * o# C: X( k3 w5 ^1 F
lLngEncrypted = Crypt(lBytAscii, PublicKey) 6 t, |  g, l  A" F% f4 \
Encode = Encode & NumberToHex(lLngEncrypted, 4) / t% |: R+ Q' C$ x" e
Next
/ x8 r1 ?" P$ g9 E% B# sEnd Function + c, i2 @1 K$ i
Public Function Decode(ByVal pStrMessage) 6 |  z- r1 u/ c$ ?% u
Dim lBytAscii - Q# N: E- j) R" t7 V: V, w, R
Dim lLngIndex ! {9 [# ]! {( f2 |, X4 i/ H) i
Dim lLngMaxIndex 6 U2 J: m( M7 Q6 M4 ?* l
Dim lLngEncryptedData ) B, r% |# F8 e5 F/ ^
Decode = ""
) l( c: F* p2 o3 J# {6 I0 slLngMaxIndex = Len(pStrMessage)
9 m3 K  m. V# tFor lLngIndex = 1 To lLngMaxIndex Step 4
4 i0 d$ Z' ?: R# K  k% q' rlLngEncryptedData = HexToNumber(Mid(pStrMessage, lLngIndex, 4))
: q% d; h9 _# o0 elBytAscii = Crypt(lLngEncryptedData, PrivateKey) 6 F0 m5 O" g. E( ]0 a" |
Decode = Decode & Chr(lBytAscii)
; V9 H& \3 H) l' @& L  rNext
" }' q0 k3 t/ ?0 G% o6 xEnd Function
3 c& k7 ]6 U+ h6 f  F' c2 }6 M) g" [Private Function NumberToHex(ByRef pLngNumber, ByRef pLngLength) ; a, M& J7 ]% a0 f
NumberToHex = Right(String(pLngLength, "0") & Hex(pLngNumber), pLngLength)
* [$ O+ c% K# ]& h+ vEnd Function 3 j6 c# y6 R2 c2 M) v
Private Function HexToNumber(ByRef pStrHex)
  F( P0 \+ w. UHexToNumber = CLng("&h" & pStrHex)
: n$ G! p) S6 iEnd Function & k' c; T* D3 p9 U
End Class
0 m; c) ]  ?$ Z" r* ofunction Encryptstr(Message)
, D' }' w" @: C" ]( H. oDim LngKeyE 0 Y9 m3 m( X& @& l, [+ _3 X4 u2 `
Dim LngKeyD / P) w* P  N$ R3 u( f5 o
Dim LngKeyN
5 ^; M% Z" i' j/ sDim StrMessage
( z6 }& n5 P6 VDim ObjRSA
5 X$ D) B9 ^# Z2 D( dLngKeyE = "32823"
( g9 g4 c4 ~0 j6 ^  _0 j7 rLngKeyD = "20643"
1 L; I* v/ M: ]; w) k6 XLngKeyN = "29893" 1 c4 s0 I5 R2 x
StrMessage = Message $ Q" [# A( H6 Z. Z, r& Y
Set ObjRSA = New clsRSA - s( u% T% b, H. L+ ~/ C" i3 K( Q+ c; q/ ?
ObjRSA.PublicKey = LngKeyE 2 V1 W  v9 r0 z
ObjRSA.Modulus = LngKeyN
. u: P1 H- s4 NEncryptstr = ObjRSA.Encode(StrMessage) # ?/ F3 F& ]3 G7 Q$ B( t& P. L
Set ObjRSA = Nothing ( {' ~- |# o. F- p8 O/ l
end function
! x0 n9 w) ~" J6 T/ }% Q" P. `Function Decryptstr(Message) " S6 g. p# O# C( H4 M+ j  V
Dim LngKeyE 7 L( [" n4 e) W' @
Dim LngKeyD
' _. g8 a. S5 F& MDim LngKeyN
" `1 P3 K  W; j2 T+ g8 YDim StrMessage
. M& h, y$ ]4 N# ODim ObjRSA
% e$ Y2 w5 N% B) y* E' ?LngKeyE = "32823"
# U9 Y! a7 k2 A3 SLngKeyD = "20643"
! h9 G) M% ?6 o% a' PLngKeyN = "29893"
, Y/ e2 i$ L8 D- }. T8 r; @: RStrMessage = Message
) J8 d+ o& a; W' a2 G& w5 E/ [( DSet ObjRSA = New clsRSA 7 |6 {! P  k6 a
ObjRSA.PrivateKey =LngKeyD
$ ]; ~( {7 m: r1 q1 w* U8 }ObjRSA.Modulus=LngKeyN
. n: k) m$ Q) E4 k& C! ^decryptstr=ObjRSA.Decode(StrMessage) ( Q% i* y* K% z, O" N
Set ObjRSA = Nothing
, |$ v6 G; T$ Y' oend function
% W; O. T- I3 g- P* X: g" S3 o%>/ o% r5 m, E& J5 c$ e( y( ]
===============================================& J5 s, R+ V+ _2 ~6 V
2 m$ m: Z% |- @9 u
还有一个用于测试这段代码的test.asp
# j; w/ `% @% n$ g. q& P7 W* }有兴趣的自己搭建个IIS测试下
/ Q* k- o; [8 e  R5 O4 I0 R8 u4 `5 j<!--#INCLUDE FILE="RSA.asp"--> - g$ O. S% o  n5 d/ R7 [. Q
<%- O( [) I( c- S: C" P/ I5 `. X
function Encryptstr(Message) 8 ?5 @7 ^, |: {. a
Dim LngKeyE
$ ]/ Q- f" P. E) O* v" NDim LngKeyD 7 Y7 L9 P' `4 e' P" R: S5 ^
Dim LngKeyN
6 y( G) _, q- r, oDim StrMessage . ~% s4 f7 {# u: y( J/ q4 p
Dim ObjRSA / r! z, o" c! C' @+ b1 ]' t, ^! v
LngKeyE = "32823"
3 S! Q0 I5 e8 v  Q) @( t! ~% {* Q7 cLngKeyD = "20643" " I1 D- a6 t7 F  z$ H; ?$ T
LngKeyN = "29893"
2 u8 e8 i8 a* k" y# m1 Y3 o% EStrMessage = Message 7 r2 t5 l1 L, ?# v5 c0 X& X- j
Set ObjRSA = New clsRSA ; X" N- `( i- {% p* s& Z" X4 G7 ?% V3 p4 L
ObjRSA.PublicKey = LngKeyE ! y' x3 O! o9 s& @, @
ObjRSA.Modulus = LngKeyN 0 W. u( y$ L6 ?9 V+ j+ N( v2 u
Encryptstr = ObjRSA.Encode(StrMessage)
! {, r* b, D3 M; Y! T* A, B& B: TSet ObjRSA = Nothing
! S& X# h2 [. ?3 u5 ^  T  P1 Hend function
( h$ X' J, T/ Q' Y/ U4 ?function decryptstr(Message) ; [9 ~* H9 t" \& j4 ^) w
Dim LngKeyE + e7 X. [+ _; {* ^! c  U7 U
Dim LngKeyD + E3 n5 {5 I& x  q+ }4 Y
Dim LngKeyN : ?) l4 ?# r# m! w) o+ a( n
Dim StrMessage
" f3 N- k0 d' f/ uDim ObjRSA
7 G0 r' b7 {) ^% J  q& t6 V5 j9 QLngKeyE = "32823"
5 ~( X8 Z' I: n5 N9 K9 |1 kLngKeyD = "20643"
" e# w1 k! d* |& K# E- L4 }LngKeyN = "29893"
+ j; u3 y1 s( dStrMessage = Message / f6 J; S/ u. n
Set ObjRSA = New clsRSA
$ N! O- ^# q& E* ?' j" H5 Z: a5 Z2 c9 TObjRSA.PrivateKey =LngKeyD
/ f; ^: T# ?: bObjRSA.Modulus=LngKeyN
2 A# @' @# e$ r/ v) ^+ Vdecryptstr=ObjRSA.Decode(StrMessage) : k  Q. N! B4 D
Set ObjRSA = Nothing
- u5 W" y$ M4 f( @. `$ tend function 7 i! p+ Z2 W( _' n( Q7 c" `
dim last,first : u" ^$ Z2 H$ l
first="!@#$%^&*()"
  K, E- J0 o6 v' B( w7 IResponse.Write "加密前为:"&first
( S3 j+ j& i9 k3 P! _last=Encryptstr(first) 2 n6 L. G; s' q  w
Response.Write "加密后为"&last
9 k- k2 O! x% s$ H/ U( TResponse.Write "解密后为" &decryptstr(last) ! Q: H' c( B/ Y  `/ l2 Q0 A
%> ==============================================
* w' x/ g8 Z2 c& Z3 N$ c剩下的就是字符的对照表了
' T1 E3 O9 A" [% S- {===================字符集================
2 D0 x0 B; x  @$ h3 f1_____6EBB! N, w6 F9 ^6 ?3 {- }
2_____5C1F8 c. Y8 s; i0 |
3_____4D75( r# a$ s- S$ R% ^0 }
4_____26CC+ H3 L! S$ M; w$ F' I
5_____4F881 S( V! a; `; T3 Y7 m
6_____3F4E7 B! d8 l2 A: P$ k$ s, R
7_____0A9D- I( _. U9 l6 S1 _# p
8_____1A1C
' i! \" {  k* F4 ^+ h6 g9_____6D20
5 Q& R0 J5 c$ B0_____1089
- ]0 h3 @5 v& ca_____0F3E
3 N( X# s- g1 w2 a  g( ~b_____31594 Y1 y& s4 @3 x- _! `
c_____35172 s. b# O6 L" K# w& ^
d_____419C( R4 _; e2 x/ `* h4 ~, R4 [8 p
e_____615C* Y  k5 v) B; V' g8 A7 }% u
f_____556F
$ ?( Y9 x# L* T5 s; R& bg_____2B7F
, @2 W0 g* n8 Vh_____0F9C* @- X4 V1 ^  x1 {# d
i_____00FA1 d. j/ _4 |( Q7 y1 P" l: r
j_____5A50
: h* L$ w3 x& y. R7 ~3 wk_____2850/ O& U( G9 P1 M. V* V- ^
l_____3E7B
3 [; d* r3 p- M0 \m_____71C5
5 R2 ]7 |# n. G2 M# Dn_____1FC8
3 ~8 y- L$ {( jo_____74C1
& X- ]5 K  {$ _$ g; dp_____5FB8
6 q# i7 w  U" m# H6 Mq_____6085' p' a$ ^. s# w% U+ j
r_____3AC4
7 Q6 o5 \9 J$ m4 Ys_____2F50
6 B& t' ]+ ]# s& {t_____36F8* d2 {% M) O) ]$ w4 ?: x) m$ t" ]
u_____7010& T& D1 R0 b1 d+ T8 I" ?/ m
v_____0B42
1 x& [+ J) J8 @+ a( hw_____1C7A
7 e  a- f" `5 g7 T' ~& v1 ]x_____16F8
/ T" k* U' s# P4 S9 @( Ey_____2EE7
* t9 z0 w7 T* u/ y7 n. Vz_____5CF3
! ]6 ]; c5 Y, ?" }) S: b8 m!_____6233
( A" d4 U: h, Z) ]. Q' O% e5 D@_____3A45
  O# D4 [9 I. |: j! \#_____2291
/ i: F  N2 A# n9 n* [+ T, \0 ?) U. J" L$_____5D5C+ i( d; F, W& N8 F  z
%_____09B9
% |" s1 a6 H! i+ G8 k/ i^_____43EA
1 B- j" d' d! L/ S7 @( k&_____62B9
6 s& G% D. _0 F*_____6301- b" g$ D6 u+ ^' Q( `. p# S! v
(_____4659
8 J) l0 E$ P3 j% r2 L' K$ Y# ])_____5C82
希望做站长本人的学生请点击
http://www.3ast.com/viewthread.php?tid=13841
QQ790653916只负责SEO以及收费教学等方面联系,他人勿扰

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

收藏了。。。。。。。。

TOP

返回列表