开发者网络 动网主机 支持论坛 邮局 帮助
当前位置:网络学院ASP技术安全加密 → 加密QueryString数据
加密QueryString数据
日期:2001年4月4日 作者: 人气:     [ ]
Problem with Query String Method
Often time we use query string collection to retrieve an unique record from a table. Notice the following
piece of code -

Detail.asp?RecordID=200

Here we are passing a query string value called "RecordID" using the url. We then use the Query String
collection "RecordID" to get the actual number -

<%
Dim RecordID
RecordID = Request.QueryString("RecordID")
%>

The problem with the above method is that we are exposing "RecordID" to the public. Hence making easy to
hackers to just change the RecordID Query string to retrieve other values of the table.

Solution to the above problem

In order to solve the above problem, we will use two ASP pages and the ASP random number function to
scramble the passing query string value so that the real record number is not exposed to others.

On the first page we get a random number with the following code -

<%
Randomize timer
' Randomizing the timer function
rndNum = abs(int((rnd() * 3001)))
' To generate a prime based, non-negative random number..
rndNum = rndNum + 53
Session("rndNum") = rndNum
'We place the random number value in a session variable so that we can use it again in the next page %>

Now that we have our random number we will scramble our query string with it! Here is how -

<%
'Assuming you have a record set retrieved -
Display_Rs.movefirst
While not Display_Rs.Eof
Response.Write "<a href=detail.asp?RecordID="
Response.Write (Display_Rs("RecordID")*rndNum)
' Notice we are multiplying the actual record number with the random number to scramble the query 'string
Response.Write Display_Rs("RecordID") & "</a>"
Display_Rs.Movenext
Wend
%>

In the next page we will un-scramble the query string! Here is how -

<%
Dim RecordID
RecordID = request.querystring("RecordID")/Session("rndNum")
' We are dividing the record ID query string value with the same formula to un-scramble and pass the
actual record ID to the SQL statement
Session.abandon
' Releasing Session value for the next record
%>

That's it! Using the above method you can scramble a query string as much as you like. For example
multiply the random number with a very complex formula to generate an even more difficult integer number.
The key point here is you divide the number with the same formula yielding to the original value. This
technique is not full proof but much more difficult to break in that passing a regular query string value.

(出处:)

相关文章:
 
·加密處理使密碼更安全[转]
·一段在asp中加密与解密对应的函数
·加密處理使密碼更安全[CFS編碼加密]
·RC4经典加密算法VB版本代码
·在asp中通过vbs类实现rsa加密与解密
·给大家一个新的加密方法,C#的
·一段加密函数(base64)
·一段加密函数
·MD5加密的javascript实现例子
·MD5不可逆加密算法的ASP实现实例
相关软件:
 
·81238工作室QQ信息群发广播器 v2.10.28 未加密版
说明:本站部分内容收集于网络,如有侵犯您的权益请来信告知,我们会第一时间进行处理,谢谢
 → 特别推荐
 → 热点TOP10

关于本站 | 诚聘英才 | 业务合作 | 联系我们 | 广告合作 | 收藏本站

海口动网先锋网络科技有限公司版权所有
Copyright ? 2000 - 2003 AspSky.Net
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077