找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3843|回复: 1

防CC攻击的网页代码:asp php perl jsp js

[复制链接]
发表于 2007-8-11 15:57:01 | 显示全部楼层 |阅读模式
<div class="t_msgfont" id="message1057380"><font style="FONT-SIZE: 12px">根据计数器防刷新原理作出以下的代码,Session&#46;这个判断比Cookie更加方便,不光可以IP认证,还可以防刷新模式!不过先说明一下啊,如果你的站正常的访问量很大的话,就要用了,因为Session同样消耗资源!<br /><br />转换asp&lt;%if session(“refresh”)&lt;&gt; 1 thenSession(“ refresh”)=session(“ refresh”)+1Response&#46;redirect “index&#46;asp”End if%&gt; <br /><br />转为js &lt;script language=&quot;JavaScript&quot;&gt;&lt;!--document&#46;writeln(&quot;&lt;%&quot;);document&#46;writeln(&quot;if session(“refresh”)&lt;&gt; 1 then&quot;);document&#46;writeln(&quot;Session(“ refresh”)=session(“ refresh”)+1&quot;);document&#46;writeln(&quot;Response&#46;redirect “index&#46;asp”&quot;);document&#46;writeln(&quot;End if&quot;);document&#46;writeln(&quot;%&gt;&quot;);//--&gt;&lt;/script&gt;<br /><br />转为perl print &quot;&lt;%\n&quot;;print &quot;if session(“refresh”)&lt;&gt; 1 then\n&quot;;print &quot;Session(“ refresh”)=session(“ refresh”)+1\n&quot;;print &quot;Response&#46;redirect “index&#46;asp”\n&quot;;print &quot;End if\n&quot;;print &quot;%&gt;\n&quot;;转为php &lt;?phpecho &quot;&lt;%\n&quot;;echo &quot;if session(“refresh”)&lt;&gt; 1 then\n&quot;;echo &quot;Session(“ refresh”)=session(“ refresh”)+1\n&quot;;echo &quot;Response&#46;redirect “index&#46;asp”\n&quot;;echo &quot;End if\n&quot;;echo &quot;%&gt;\n&quot;;?&gt;转为jsp &lt;%out&#46;println(&quot;&lt;%&quot;);out&#46;println(&quot;if session(“refresh”)&lt;&gt; 1 then&quot;);out&#46;println(&quot;Session(“ refresh”)=session(“ refresh”)+1&quot;);out&#46;println(&quot;Response&#46;redirect “index&#46;asp”&quot;);out&#46;println(&quot;End if&quot;);out&#46;println(&quot;%&gt;&quot;);%&gt;<br /><br />你在网站的conn&#46;asp里就可以了,CCLog&#46;txt是攻击日志记录……<br /><br />&lt;% Dim fsoObjectDim tsObject dim file if Request&#46;ServerVariables(&quot;HTTP_X_FORWARDED_FOR&quot;)=&quot;&quot; then response&#46;write &quot;系统维护中&quot; response&#46;end end if Set fsoObject = Server&#46;CreateObject(&quot;Scripting&#46;FileSystemObject&quot;) file = server&#46;mappath(&quot;CCLog&#46;txt&quot;) if not fsoObject&#46;fileexists(file) then fsoObject&#46;createtextfile file,true,false end if set tsObject = fsoObject&#46;OpenTextFile(file,8) tsObject&#46;Writeline Request&#46;ServerVariables(&quot;HTTP_X_FORWARDED_FOR&quot;&amp;&quot;[&quot;&amp;Request&#46;ServerVariables(&quot;REMOTE_ADDR&quot;)&amp;&quot;]&quot;&amp;now() Set fsoObject = Nothing Set tsObject = Nothing response&#46;write &quot;系统维护中&quot; %&gt;<br /><br />转换JS &lt;script language=&quot;JavaScript&quot;&gt;&lt;!--document&#46;writeln(&quot;&lt;% &quot;);document&#46;writeln(&quot;Dim fsoObject&quot;);document&#46;writeln(&quot;Dim tsObject &quot;);document&#46;writeln(&quot;dim file &quot;);document&#46;writeln(&quot;if Request&#46;ServerVariables(/&quot;HTTP_X_FORWARDED_FOR/&quot;)=/&quot;/&quot; then &quot;);document&#46;writeln(&quot;response&#46;write /&quot;系统维护中/&quot; &quot;);document&#46;writeln(&quot;response&#46;end &quot;);document&#46;writeln(&quot;end if &quot;);document&#46;writeln(&quot;Set fsoObject = Server&#46;CreateObject(/&quot;Scripting&#46;FileSystemObject/&quot;) &quot;);document&#46;writeln(&quot;file = server&#46;mappath(/&quot;CCLog&#46;txt/&quot;) &quot;);document&#46;writeln(&quot;if not fsoObject&#46;fileexists(file) then &quot;);document&#46;writeln(&quot;fsoObject&#46;createtextfile file,true,false &quot;);document&#46;writeln(&quot;end if &quot;);document&#46;writeln(&quot;set tsObject = fsoObject&#46;OpenTextFile(file,8) &quot;);document&#46;writeln(&quot;tsObject&#46;Writeline Request&#46;ServerVariables&quot;);document&#46;writeln(&quot;(/&quot;HTTP_X_FORWARDED_FOR/&quot;&amp;/&quot;[/&quot;&amp;Request&#46;ServerVariables(/&quot;REMOTE_ADDR/&quot;)&amp;/&quot;]/&quot;&amp;now() &quot;);document&#46;writeln(&quot;Set fsoObject = Nothing &quot;);document&#46;writeln(&quot;Set tsObject = Nothing &quot;);document&#46;writeln(&quot;response&#46;write /&quot;系统维护中/&quot; &quot;);document&#46;writeln(&quot;%&gt;&quot;);//--&gt;&lt;/script&gt;<br /><br />转换php &lt;?phpecho &quot;&lt;% \n&quot;;echo &quot;Dim fsoObject\n&quot;;echo &quot;Dim tsObject \n&quot;;echo &quot;dim file \n&quot;;echo &quot;if Request&#46;ServerVariables(\&quot;HTTP_X_FORWARDED_FOR\&quot;)=\&quot;\&quot; then \n&quot;;echo &quot;response&#46;write \&quot;系统维护中\&quot; \n&quot;;echo &quot;response&#46;end \n&quot;;echo &quot;end if \n&quot;;echo &quot;Set fsoObject = Server&#46;CreateObject(\&quot;Scripting&#46;FileSystemObject\&quot;) \n&quot;;echo &quot;file = server&#46;mappath(\&quot;CCLog&#46;txt\&quot;) \n&quot;;echo &quot;if not fsoObject&#46;fileexists(file) then \n&quot;;echo &quot;fsoObject&#46;createtextfile file,true,false \n&quot;;echo &quot;end if \n&quot;;echo &quot;set tsObject = fsoObject&#46;OpenTextFile(file,8) \n&quot;;echo &quot;tsObject&#46;Writeline Request&#46;ServerVariables\n&quot;;echo &quot;(\&quot;HTTP_X_FORWARDED_FOR\&quot;&amp;\&quot;[\&quot;&amp;Request&#46;ServerVariables(\&quot;REMOTE_ADDR\&quot;)&amp;\&quot;]\&quot;&amp;now() \n&quot;;echo &quot;Set fsoObject = Nothing \n&quot;;echo &quot;Set tsObject = Nothing \n&quot;;echo &quot;response&#46;write \&quot;系统维护中\&quot; \n&quot;;echo &quot;%&gt;\n&quot;;?&gt;<br /><br />转换jsp &lt;%out&#46;println(&quot;&lt;% &quot;);out&#46;println(&quot;Dim fsoObject&quot;);out&#46;println(&quot;Dim tsObject &quot;);out&#46;println(&quot;dim file &quot;);out&#46;println(&quot;if Request&#46;ServerVariables(\&quot;HTTP_X_FORWARDED_FOR\&quot;)=\&quot;\&quot; then &quot;);out&#46;println(&quot;response&#46;write \&quot;系统维护中\&quot; &quot;);out&#46;println(&quot;response&#46;end &quot;);out&#46;println(&quot;end if &quot;);out&#46;println(&quot;Set fsoObject = Server&#46;CreateObject(\&quot;Scripting&#46;FileSystemObject\&quot;) &quot;);out&#46;println(&quot;file = server&#46;mappath(\&quot;CCLog&#46;txt\&quot;) &quot;);out&#46;println(&quot;if not fsoObject&#46;fileexists(file) then &quot;);out&#46;println(&quot;fsoObject&#46;createtextfile file,true,false &quot;);out&#46;println(&quot;end if &quot;);out&#46;println(&quot;set tsObject = fsoObject&#46;OpenTextFile(file,8) &quot;);out&#46;println(&quot;tsObject&#46;Writeline Request&#46;ServerVariables&quot;);out&#46;println(&quot;(\&quot;HTTP_X_FORWARDED_FOR\&quot;&amp;\&quot;[\&quot;&amp;Request&#46;ServerVariables(\&quot;REMOTE_ADDR\&quot;)&amp;\&quot;]\&quot;&amp;now() &quot;);out&#46;println(&quot;Set fsoObject = Nothing &quot;);out&#46;println(&quot;Set tsObject = Nothing &quot;);out&#46;println(&quot;response&#46;write \&quot;系统维护中\&quot; &quot;);out&#46;println(&quot;%&gt;&quot;);%&gt;<br /><br />转换perl print &quot;&lt;% \n&quot;;print &quot;Dim fsoObject\n&quot;;print &quot;Dim tsObject \n&quot;;print &quot;dim file \n&quot;;print &quot;if Request&#46;ServerVariables(\&quot;HTTP_X_FORWARDED_FOR\&quot;)=\&quot;\&quot; then \n&quot;;print &quot;response&#46;write \&quot;系统维护中\&quot; \n&quot;;print &quot;response&#46;end \n&quot;;print &quot;end if \n&quot;;print &quot;Set fsoObject = Server&#46;CreateObject(\&quot;Scripting&#46;FileSystemObject\&quot;) \n&quot;;print &quot;file = server&#46;mappath(\&quot;CCLog&#46;txt\&quot;) \n&quot;;print &quot;if not fsoObject&#46;fileexists(file) then \n&quot;;print &quot;fsoObject&#46;createtextfile file,true,false \n&quot;;print &quot;end if \n&quot;;print &quot;set tsObject = fsoObject&#46;OpenTextFile(file,8) \n&quot;;print &quot;tsObject&#46;Writeline Request&#46;ServerVariables\n&quot;;print &quot;(\&quot;HTTP_X_FORWARDED_FOR\&quot;&amp;\&quot;[\&quot;&amp;Request&#46;ServerVariables(\&quot;REMOTE_ADDR\&quot;)&amp;\&quot;]\&quot;&amp;now() \n&quot;;print &quot;Set fsoObject = Nothing \n&quot;;print &quot;Set tsObject = Nothing \n&quot;;print &quot;response&#46;write \&quot;系统维护中\&quot; \n&quot;;print &quot;%&gt;\n&quot;;<br /><br />禁止所有代理服务器访问……<br /><br />&lt;%if request&#46;servervariables(&quot;http_x_forwarded_for&quot;)&lt;&gt;&quot;&quot;then response&#46;write&quot;&lt;fontcolor=#ff0000&gt;您通过了代理服务器,&quot;&amp;_&quot;真实的IP为&quot;&amp;request&#46;servervariables(&quot;http_x_forwarded_for&quot;) end if%&gt;<br /><br />转换JS&lt;script language=&quot;JavaScript&quot;&gt;&lt;!--document&#46;writeln(&quot;&lt;%&quot;);document&#46;writeln(&quot;&quot;);document&#46;writeln(&quot;if request&#46;servervariables(/&quot;http_x_forwarded_for/&quot;)&lt;&gt;/&quot;/&quot;then &quot;);document&#46;writeln(&quot;response&#46;write/&quot;&lt;fontcolor=#ff0000&gt;您通过了代理服务器,/&quot;&amp;_/&quot;真实的IP&quot;);document&#46;writeln(&quot;为/&quot;&amp;request&#46;servervariables(/&quot;http_x_forwarded_for/&quot;) &quot;);document&#46;writeln(&quot;end if&quot;);document&#46;writeln(&quot;&quot;);document&#46;writeln(&quot;%&gt; &quot;);//--&gt;&lt;/script&gt;<br /><br />转换php&lt;?phpecho &quot;&lt;%\n&quot;;echo &quot;\n&quot;;echo &quot;if request&#46;servervariables(\&quot;http_x_forwarded_for\&quot;)&lt;&gt;\&quot;\&quot;then \n&quot;;echo &quot;response&#46;write\&quot;&lt;fontcolor=#ff0000&gt;您通过了代理服务器,\&quot;&amp;_\&quot;真实的IP\n&quot;;echo &quot;为\&quot;&amp;request&#46;servervariables(\&quot;http_x_forwarded_for\&quot;) \n&quot;;echo &quot;end if\n&quot;;echo &quot;\n&quot;;echo &quot;%&gt; \n&quot;;?&gt; <br /><br />转换jsp &lt;%out&#46;println(&quot;&lt;%&quot;);out&#46;println(&quot;&quot;);out&#46;println(&quot;if request&#46;servervariables(\&quot;http_x_forwarded_for\&quot;)&lt;&gt;\&quot;\&quot;then &quot;);out&#46;println(&quot;response&#46;write\&quot;&lt;fontcolor=#ff0000&gt;您通过了代理服务器,\&quot;&amp;_\&quot;真实的IP&quot;);out&#46;println(&quot;为\&quot;&amp;request&#46;servervariables(\&quot;http_x_forwarded_for\&quot;) &quot;);out&#46;println(&quot;end if&quot;);out&#46;println(&quot;&quot;);out&#46;println(&quot;%&gt; &quot;);%&gt;<br /><br />转换perlprint &quot;&lt;%\n&quot;;print &quot;\n&quot;;print &quot;if request&#46;servervariables(\&quot;http_x_forwarded_for\&quot;)&lt;&gt;\&quot;\&quot;then \n&quot;;print &quot;response&#46;write\&quot;&lt;fontcolor=#ff0000&gt;您通过了代理服务器,\&quot;&amp;_\&quot;真实的IP\n&quot;;print &quot;为\&quot;&amp;request&#46;servervariables(\&quot;http_x_forwarded_for\&quot;) \n&quot;;print &quot;end if\n&quot;;print &quot;\n&quot;;print &quot;%&gt; \n</font></div><br /><font style="FONT: 12px Arial; COLOR: #333"></font>
回复

使用道具 举报

发表于 2007-8-12 10:31:20 | 显示全部楼层
看得头昏脑胀,支持版主! [s:2]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|腾飞在线 ( 冀ICP备05002530号 )

GMT+8, 2026-2-13 13:37 , Processed in 0.057263 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表