动态网站制作指南 [  QQ表情  ]
[ 投票调查 ]
[ 企业邮箱 ]
[ 网站空间 ]
网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
ASP源码 | .Net源码 | PHP源码 | JSP源码 | JAVA源码 | CGI源码 | VB源码 | C++源码 | Delphi源码 | PB源码 | VF源码 | 汇编 | 服务器
电脑书籍下载:程序设计书籍 | 数据库教程书籍 | 平面与多媒体书籍 | 网络通讯书籍 | 系统管理书籍 | 网络安全书籍 | 认证考试书籍
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > ASP技巧
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
文章搜索服务
邮件订阅
输入你的邮件地址,
你将不会错过任何关于:
[ ASP技巧 ]的信息



本月文章推荐
.系统时间格式问题而导致BLOG不正.
.flash和asp分页的一点心得.
.用asp做access的远程接口.
.连接各种数据库的代码的总结.
.排序方式解决“上下主题”问题(.
.如何把ASP编写成DLL .
.ASP中使用ServerVariables集合详.
.配置IIS4实现应用程序隔离.
.如何在ASP中通过ODBC调用Excel中.
.ASP.NET中的XML表单控件.
.用Asp修改注册表.
.Adodb.Command 平时很少注意到的.
.禁用html页面的缓存.
.ASP中实现的类似URLEncode的编码.
.ODBC Drivers错误'80004005'的解.
.在 Access 中使用“存储过程”.
.解决使用ASP无法连接ORACLE 9i数.
.ASP技术在论坛中的运用(六)(吐血.
.DateDiff的用法.
.到亿位的金额小写转大写JS代码.

加密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.



上一篇:利用global.asp定时执行ASP 人气:11969
下一篇:关于释放session的两篇文章(一) 人气:11659
浏览全部的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-7-3 PBDigg v2.0 Build 20080702 Fin
2008-7-3 Drupal v7.x-dev Build 080702
2008-7-3 FleaPHP v1.0.70.1078 (开源 PHP
2008-7-3 Bitrac单用户博客 v1.13 Build 2
2008-7-3 94xhcms v1.0 正式版
2008-7-3 天空网络电影系统SKYUC v2.5.1 B
2008-7-3 雅虎音乐小偷修改版 v1.1
2008-7-3 来路分析系统 v0.1
2008-7-3 AmEav WebSite 企业网站管理系统
2008-6-21 PocketTouch简化iPod控制工具 v1
2008-6-21 HidePod万能隐藏 v1.0.9破解版
2008-6-21 TouchPad触摸板破解补丁 v4.42
2008-6-21 iCountDown倒计时工具 v2.0
2008-6-21 tt-Clock语音时钟 v1.0
2008-6-21 PowerManager重启工具
2008-6-21 JasonKit(iLM)离线地图切换软件
2008-6-21 iSlsk P2P下载工具 v0.2.1b
2008-6-21 MCaller来电归属地查询 v0.3破解


  发表评论
姓 名: 验证码:
内 容:
[ 汉字翻译拼音 ] [ 广告代码 ] [ 符号对照表 ] [ 进制转换 ] [ 经典小工具 ] [ 个税计算 ] [ 汉字简繁转换 ] [ 普通单位换算 ] [ 公制单位换算 ]
[ 生辰老黄历 ] [ 国内电话区号 ] [ 国家代码与域名缩写 ] [ 文字加密解密 ] [ 健康查询 ] [ 万年历 ] [ 手机号码查询 ] [ ip搜索 ] [ Google PR查询 ]
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号
ホームページ制作 不動産検索システム 求人情報