无忧启动论坛

标题: 12 [打印本页]

作者: king    时间: 2001-10-1 10:04
标题: 12
T35.com is not a place to put:
- Pornographic content or direct links to pornographic websites
- Pirate software/mp3 or links to it.
- Large/numerous files primarily for storage purposes and not made viewable to the public through html pages.
- Only cgi scripts (you must have at least some html pages, and not have your account be only a cgi script, ex: UBB).
- Non-English sites, including but not limited to, Japanese Anami sites, etc..
- Any content that is considered inappropriate at the sole discretion of T35.com

Welcome to T35.com. We at T35.com do our best to create an environment in which individuals of many different backgrounds are able to express themselves through personal publishing, building a climate within which we can all discuss the issues that face us in daily life, or just be entertained. It is the goal of these Terms of Service to outline the responsibilities of those who participate in the T35.com community. The T35.com Membership Guidelines and Terms of Service are available at http://www.T35.com/terms/
I. T35.com Services and Conditions of Use
These Terms of Service govern the use of the T35.com Web Site (www.T35.com), hereafter referred to as the "Site" or "T35". The term "T35.com" shall be used to refer to T35. The Site provides registered members (each a "Member") with access to content and services ("Membership"). T35.com may, at its discretion, add, delete, or modify the Terms of Service without notice. By registering as a Member, you agree to use the Site in a manner consistent with all applicable local, state and federal laws and regulations and in accordance with the Terms of Service discussed below.
Basic T35.com services and content are available FREE OF CHARGE, exclusive of other Internet or other telecommunications fees.
Even though the aggregate bandwidth you may use is not limited, your web site must be used primarily for the display of HTML pages, and the total amount of data transferred from your web site space may not exceed one megabyte for every two html page views. All use of web site space shall be subject to all the terms and conditions set forth herein. T35.com retains the authority to restrict your website as to file types and size, and to restrict transfer rates or amounts.
Members shall not attempt to defeat such features in any manner. Any conduct that causes a member page to not display T35.com ads correctly shall be grounds for termination of membership.
T35.com reserves the right to delete any page at any time for any reason or no reason at all.
T35.com may terminate any Membership (and any and all related information, communications, postings, or Web pages) at any time, without notice, for conduct that violates local, state or federal laws or regulations, these Terms of Service or other policies or guidelines set out by T35.com elsewhere on the Site, or for material that T35.comin its sole discretion believes is harmful to other Members, the business of T35.com, or other third-party information providers. Individuals who have had their Memberships terminated may not continue to utilize member privileges in any manner or for any reason without the express written permission of T35.com.
III. Terms of Membership
a) Membership is available to anyone over the age of 13 who registers and accurately provides all the required information, provides a legitimate electronic mail address and obtains a unique T35.com Member Name and password. Membership is non-transferable. T35.com does not discriminate on the basis of age, gender, race, ethnicity, nationality, religion, or sexual orientation. Children under the age of 13 can only register with the express consent of a parent or guardian.
b) T35.comallows one Membership per individual with a legitimate electronic mail address.
c) Please be courteous when selecting your T35.com Member Name. T35.com does not permit the use of vulgar or offensive language for your Member Name. You may not use the name of any person other than yourself, the name of any entity or organization, or any term that is a trademark, service mark, or copyright, or that violates any other proprietary right held by another. T35.com may, at its discretion and without notice, delete or revoke any Membership associated with a Member Name of this nature.
IV. Member Web Pages
a) T35.com provides Members with Web pages (a "Member Web Page") and the associated storage as a free service to Members. T35.comMember Profiles are intended to be brief descriptions of Members and the content contained in Member Profiles must conform to the same content standards set forth in the Member Content Guidelines.
b) T35.com is not responsible for the content of any Member Web Page, and the views expressed on T35.com Member Web Pages are the responsibility of the posting Member and not T35.com. T35.comdoes not preview Member Web Pages in any way before they appear on the Member Area of the Site. The selection of a site for inclusion in a specialized section of the Member Area does not imply an endorsement of that site or its content by T35.com.
c) By submitting a Member Web Page to T35.com, you grant T35.com a royalty-free license to copy and distrubute the content for the LIMITED purposes of backing up content, moving data in case of server/ISP upgrades, and other background maintenance work.
VI. T35.com Member Web Page and Member Conduct Guidelines
The following is a non-exclusive list of actions and content that are prohibited on the Site. T35.com may cancel any Membership associated with such actions or content or may remove any associated Member Web Page with or without prior notice, in its sole discretion.
a) Any use of copyrighted, trademarked, patented or servicemarked material without the express permission of the author or owner, the commission of any acts of copyright, trademark, patent, trade secret or other intellectual property infringement, or contributing to, inducing, or facilitating such infringement. This prohibition shall include, without limitation, the following forms of software piracy:
i) Making available copyrighted software which has been "cracked", for example, the copyright protection has been removed from the software;
ii) Making available serial numbers for software that can be used to illegally validate or register software;
iii) Making available tools that can be used for no purpose other than for "cracking" software (this does not include tools that have legitimate uses for software developers, system administrators, etc.);
iv) Making available any software files for which the user does not own the copyright or have the legal right to make available.
b) Material concerning any software, information or other material that contains a virus, corrupted data or any other harmful or damaging component.
c) Material that exploits the images of children under 18 years of age, or that discloses personal identifying information belonging to children under 18 years of age. T35.com reserves the right to report violations of this provision to, and will cooperate with, law enforcement authorities.
d) Material that is, in T35.com' view, grossly offensive to the T35.com Community, including, but not limited to clear expressions of bigotry, racism, or other hate speech, or threats of violence.
e) Pages that promote illegal activity and any promotion of or provision of instructions for illegal activity.
f) Material that defames, abuses, or threatens others or is libelous.
g) Material that is invasive of privacy or publicity rights, including posting another person's private information.
h) Material that (i) depicts sexual content or nudity; (ii) is contrary to customary standards for material suitable for public display; and (iii) lacks serious literary, artistic, political, educational, or scientific value.
i) Use of a Member Web Page as storage for remote loading, or as a door or signpost to another home page.
j) Creation of a Member Web Page that contains hyperlinks to content not permitted on T35.com.
k) Transmission of unsolicited advertising, promotional materials, or other forms of solicitation via email or news groups that lists a Member Web Page.
l) Development of Member Web Pages that restrict access to pages through the use of password protection or other means, other than through services provided by T35.com.
m) Misrepresentation of your identity or impersonation of any person including, but not limited to, employees of T35.com.
n) Use of T35.com for the purpose of gathering personal identifying information from individuals for commercial or unlawful purposes.
o) Acting in a manner that disrupts the flow of normal conversation in a chat room including, but not limited to, the harassment of other members, the excessive use of vulgarity, or the use of hate speech.
p) Conduct that is deemed by T35.com, in its sole and absolute discretion, harmful to T35.com, any third party content provider, or other individuals.
q) Materials regarding or links to any raffle, contest or game requiring payment of a fee by participants.
r) If there is no activity related to a Member Web Page for ninety days.
s) Any use of a Member Web Page in connection with "spamming" or the sending of unsolicited messages.
All judgments concerning the application of these guidelines are made at the sole and absolute discretion of T35.com.
If, in its sole discretion, T35.com determines that law enforcement officials should be notified regarding any Member Web Page, T35.com will provide copies of the Member Web Page in question to the appropriate officials without notice to the user. T35.com will cooperate with all law enforcement efforts to locate persons who have posted Member Web Pages that are illegal or that promote illegal conduct. This may result in T35.com disclosing to law enforcement officials user information and Internet protocol addresses pursuant to a subpoena or court order or, in circumstances where T35.com in its sole discretion deems appropriate, at the request of law enforcement officials.
VII. Reporting a Violation of these Terms of Service
If you witness a violation of these guidelines, please notify us at abuse@T35.com. Complaints may be investigated by T35.com but T35.com is under no obligation to act or not act with regards to any complaint. Any action taken will be at the sole discretion of TopCities.
It is the policy of T35.com to respond expeditiously to claims of intellectual property infringement. T35.com will promptly process and investigate notices of alleged infringement and will take appropriate actions under the Digital Millennium Copyright Act ("DMCA") and other applicable intellectual property laws. Upon receipt of notices complying or substantially complying with the DMCA, T35.com will act expeditiously to remove or disable access to any material claimed to be infringing or claimed to be the subject of infringing activity and will act expeditiously to remove or disable access to any reference or link to material or activity that is claimed to be infringing. T35.com will terminate access for subscribers and account holders who are repeat infringers.
Please put "Notice of Infringement" in the subject line of all such notifications.
When T35.com removes or disables access to any material claimed to be infringing, T35.com may attempt to contact the user who has posted such material in order to give that user an opportunity to respond to the notification, although T35.com makes no promise to do so. Any and all counter notifications submitted by the user will be furnished to the complaining party. T35.com will give the complaining party an opportunity to seek judicial relief in accordance with the DMCA before T35.com replaces or restores access to any material as a result of any counter notification.
If T35.com becomes aware of the presence of material on its server that violates any other right of any party, either in the course of its ordinary and reasonable business activities, or through notification by a third party who alerts T35.com, preferably by certified mail, of the specific location of the alleged presence of such materials, T35.com will contact the member responsible for the material and alert him or her of the allegations and notify the person that within five days he or she must respond as to why the material does not violate the rights in question. T35.com also will alert the Member that, absent such a response, T35.com reserves the right to delete the Member Web Page; and, if the member fails to respond within five days, T35.com will make a decision whether to remove the Member Web Page. In all cases, if in its sole and absolute discretion, T35.com concludes that one of the Member Web Pages violates the rights of any other party, T35.com reserves the right to delete the offending Member Web Page at any time without prior notice.
VIII. Privacy
T35.com knows that if our dream of creating a vital online community is to come true, we must do everything we can to develop and maintain that old-fashioned village sense of trust. This statement discloses the privacy practices for the Site. Questions regarding this statement should be directed to T35.com Membership Services at account@T35.com for clarification.
Our Privacy Vow
We at T35.com believe that strong electronic privacy is crucial for the ongoing success of the Internet as a service, commercial, and entertainment medium but we do need to understand user behavior in order to server you better. To achieve this goal, we need to understand what differentiates you from each of our millions of other unique users. We collect information in two ways: registration and cookies.
Registration
T35.com gathers information about our Members that allows us to offer compelling services and easily accessible online content in a manner that provides personal privacy protection as well. When you join T35.com we ask you to provide us information such as your first and last name, zip code, email address, and country. We ask these questions in the event that we need to verify your identity for security purposes.
Cookies
As a standard practice, T35.com assigns a random number to each user for anonymously tracking content preferences and traffic patterns. This random number lets us keep track of "How many" times customers are doing specific things - like visiting our site each month - without really knowing who those customers are. This random number is kept in a file on your computer called a "cookie." Cookies are pieces of information that Web sites transfer to your computer's hard drive for record-keeping purposes. T35.com uses cookies to make visiting the Site easier. Cookies allow us to save passwords and preferences for you so that you won't have to re-enter them the next time you visit. Cookies, by themselves, cannot be used to determine the identity of any user: Unless you specifically tell us, T35.com will never know who you are.
In addition, third party advertising networks may issue cookies when serving advertisements. The use of cookies is now an industry standard, and you'll find them used on most major web sites. Most browsers are initially set up to accept cookies. If you prefer, you can restart your browser either to notify you when you've received a cookie, or to refuse to accept cookies. You should understand that areas of certain sites will not function properly if you set your browser to not accept cookies.
Use of Information
Any information you provide to T35.com when registering for T35.com's products and services is maintained and accessible only by T35.com and only a few of T35.com's service providers. We use the information collected to provide you the best products and service on the Web and the ability to personalize portions of our site. Some of these personalized services are made available directly by T35.com. In other instances it is our service providers who provide these tailored services.
We analyze search habits in hope of presenting our users with the most relevant and valuable advertising information. We develop summary - not individual - reports for our advertisers. The advertisers who make it possible for you to use T35.com for free need information to determine the effectiveness of their advertising investments. We never tell our advertisers who it was that saw or clicked on their advertisements unless you have specifically told us this is acceptable.
Occasionally, we will send you communications via email providing you useful information about product enhancements or new products and services. It is our policy only to send email to customers who give us permission to do so. Instructions for unsubscribing are included in these emails. For further instructions, please see the "Opt-out Policy " below.
Except as described in this Privacy statement, T35.com will not disclose any information about any individual user except to comply with applicable law or valid legal process or to protect the personal safety of our users or the public.
Sharing of Information
Except as described in this Privacy statement, T35.com will never willfully disclose individually identifiable information about its customers to any third party without first receiving that customer's permission. The individually identifiable information that you provide will be used extensively within the T35.com to provide a personalized experience to you. It will also be shared with T35.com's partners that provide some of the personalized content on our site (see "Use of the Information" above for some examples) and other third parties unrelated to offerings on the T35.com, but only if you have given your permission for this to occur. Our privacy guarantee to you remains unchanged.
Opt-Out Features
T35.com believes its users should control the communications directed to them. Every time we collect name and address information about you:
* You can tell us if you don't want to receive communication from T35.com such as email newsletters announcing contests or new features
* You can tell us if you don't want to receive communication from third-party companies who offer a product or service that we think would be of value to you.
Deleting/Delist
Currently, as a T35.com member you can reach our Membership Services Department (account@T35.com) to delete or deactivate your information from the database.
IX. Limitations of Liability and Warranty
a) THE MEMBER AGREES THAT THE USE OF THE SITE IS ENTIRELY AT THE MEMBER'S OWN RISK. THE SITE IS PROVIDED FREE OF CHARGE, ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND. ALL EXPRESS, IMPLIED, AND STATUTORY WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF PROPRIETARY RIGHTS, ARE EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. TO THE FULLEST EXTENT PERMITTED BY LAW, T35.comDISCLAIMS ANY WARRANTIES FOR THE SECURITY, RELIABILITY, TIMELINES, AND PERFORMANCE OF THE SITE. TO THE FULLEST EXTENT PERMITTED BY LAW, T35.com DISCLAIMS ANY WARRANTIES FOR OTHER SERVICES OR GOODS RECEIVED THROUGH OR ADVERTISED ON THE SITE OR THROUGH ANY LINKS PROVIDED ON THE SITE, AS WELL AS FOR ANY INFORMATION OR ADVICE RECEIVED THROUGH THE SITE OR THROUGH ANY LINKS PROVIDED IN THE SITE. NEITHER T35.comNOR ANY THIRD-PARTY CONTENT PROVIDER MAKES ANY WARRANTY WITH RESPECT TO ANY CONTENT, INFORMATION, SERVICES, OR PRODUCTS PROVIDED THROUGH OR IN CONJUNCTION WITH THE SITE.
b) UNDER NO CIRCUMSTANCES SHALL T35.com BE LIABLE TO ANY USER ON ACCOUNT OF THAT USER'S USE OR MISUSE OF THE SITE OR RELIANCE ON THE SITE. SUCH LIMITATION OF LIABILITY SHALL APPLY TO PREVENT RECOVERY OF DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL, PUNITIVE AND EXEMPLARY DAMAGES (EVEN IF T35.com HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES). SUCH LIMITATION OF LIABILITY SHALL APPLY WHETHER THE DAMAGES ARISE FROM USE OR MISUSE OF THE SITE OR RELIANCE ON THE SITE, FROM INABILITY TO USE THE SITE, OR FROM THE INTERRUPTION, SUSPENSION, OR TERMINATION OF THE SITE OR SERVICES OFFERED ON THE SITE (INCLUDING SUCH DAMAGES INCURRED BY THIRD PARTIES). SUCH LIMITATION SHALL ALSO APPLY WITH RESPECT TO DAMAGES INCURRED BY REASON OF OTHER SERVICES OR GOODS RECEIVED THROUGH OR ADVERTISED ON THE SITE OR RECEIVED THROUGH ANY LINKS PROVIDED ON THE SITE, AS WELL AS BY REASON OF ANY INFORMATION OR ADVICE RECEIVED THROUGH OR ADVERTISED ON THE SITE OR RECEIVED THROUGH ANY LINKS PROVIDED ON THE SITE. SUCH LIMITATION SHALL APPLY, WITHOUT LIMITATION, TO THE COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, OR LOST DATA. SUCH LIMITATION SHALL APPLY WITH RESPECT TO THE PERFORMANCE OR NON-PERFORMANCE OF THE SITE OR ANY PRODUCTS, SERVICES, INFORMATION, OR MERCHANDISE THAT APPEARS ON, OR IS LINKED OR RELATED IN ANY WAY TO, THE SITE. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. SUCH LIMITATIONS SHALL APPLY TO THE FULLEST EXTENT PERMITTED BY LAW.
c) T35.com MAKES NO IMPLIED OR EXPRESS REPRESENTATIONS OR WARRANTIES ABOUT THE RELIABILITY, OR ACCESSIBILITY OF THE MEMBER PAGES OR THE ASSOCIATED STORAGE FACILITIES. T35.com IS NOT RESPONSIBLE FOR ANY DAMAGE CAUSED BY LOSS OF ACCESS TO, DELETION OF, FAILURE TO STORE, FAILURE TO BACK UP, OR ALTERATION OF MEMBER WEB PAGES; INDIVIDUAL MEMBERS ARE RESPONSIBLE FOR MONITORING AND CREATING BACKUPS OF THEIR PAGES, IN THE CASE OF PREMIUM MEMBERSHIPS, T35.com's ENTIRE LIABILITY, IF ANY, SHALL NOT EXCEED THE AMOUNT OF THE PREMIUM MEMBER'S MOST RECENT MEMBERSHIP FEE PAYMENT.
d) The Member specifically agrees that T35.com and third party content providers are not liable for any conduct by Members associated with the Site, including, but not limited to, Member Web Pages, resumes, Member Profiles, surveys, chat rooms, or conferencing.
e) T35.com and third-party content providers make no guarantee of the accuracy, correctness, or completeness of any information on the Site and are not responsible for (i) any errors or omissions arising from the use of such information; (ii) any failures, delays, or interruptions in the delivery of any content or services contained within the Site; or (iii) losses or damages arising from the use of the content or services provided by the Site.
f) T35.com is not responsible for the delivery of any goods or services sold or advertised through its sponsors, advertisers or its members' commercial home pages or affiliate program pages.
g) T35.com makes available certain information provided by third parties related to various professional fields such as medicine, law, and accounting. T35.com does not give advice in any such fields and in no way endorses any of the information provided in this manner. If you intend to use any such information, you should carefully re-read capitalized words set forth above, as they will have special importance for you. All information made available through the Site is made available subject to these Terms of Service, including this Section X. T35.com STRONGLY SUGGESTS THAT YOU SEEK ADVICE FROM A COMPETENT PROFESSIONAL REGARDING ISSUES IN ANY PROFESSIONAL FIELD.
X. Indemnity and Release
Each Member agrees to indemnify T35.com and any third-party content provider against any and all claims and expenses, including attorneys' fees, arising from the Member's use of the Site. This includes, without limitation: (i) Member's responsibility for any and all liability arising from the violation or infringement of proprietary rights, copyrights, trademarks, or servicemarks and (ii) Member's responsibility for any and all liability arising from any libelous or unlawful material contained within Member Web Pages, resumes, profiles, or postings.
By using the Site you are hereby agreeing to release T35.com and its affiliates, officers, and employees from any and all claims, demands, debts, obligations, damages (actual or consequential), costs, and expenses of any kind or nature whatsoever, whether known or unknown, suspected or unsuspected, disclosed or undisclosed, that you may have against them arising out of or in any way related to such disputes and/or to our products and services. You hereby agree to waive all laws that may limit the efficacy of such releases.
XI. Choice of Law
This Agreement shall be constructed and controlled by the laws of New Jersey, without regard to its conflict of law provisions. Any dispute arising hereunder will be governed by the laws of B.C, Canada. Each Member agrees to personal jurisdiction by tile state and federal courts of British Columbia.
XII. Merger Clause
These Terms of Service constitute the entire agreement between the parties with respect to the subject matter contained herein and supersedes any other agreement, proposals and communications, written or oral, between T35.com representatives and each Member with respect to the subject matter hereof. T35.com may amend these Terms of Service at any time without notice.
We hope your enjoyment of T35.com's services and content will be enhanced by the application of the Terms of Service outlined in this document. It is our belief that you understanding of the guidelines that we have sent forth will allow the T35.com community to continue to be a place where each of us can prosper, grow, and enjoy ourselves within an open and non-threatening environment. Thank you for taking the time to read the T35.com Terms of Service and we hope you enjoy our services.


作者: king    时间: 2001-10-1 10:05
标题: 12
perl脚本中的一些安全问题

--------------------------------------------------------------------------------

perl脚本中的一些安全问题

翻译:eastdark(eastdark)
来源:http://www.seceye.com
by lavender
http://www.seceye.com
引言
对一种编程语言而言,在设计这种语言的时候,一般是不会产生安全隐患的,事实上,这种隐患是由程序员引入的。几乎每一种编程语言都有一定这样的漏洞,这种漏洞将会在某种程度上导致不安全软件的产生,但是一个如软件整体的安全性仍然大部分依赖于这个软件制造者的知识面、理解能力和他的安全意识。Perl也有它安全上令人担忧的部分,然而大多数程序员完全没有意识到这些方面。
在这篇文章里,我们将会看一下Perl中一些最普遍被误用和忽视的属性。我们将会看到它们的误用将会怎样对运行它们的系统的安全以及它们的用户造成威胁。我们将会演示怎样把这些弱点挖掘出来以及如何去修改、避免它们。

用户输入上的弱点
Perl脚本中产生安全问题的一个很大的来源是没有经过正确确认(或根本就没有确认)的用户的输入。每次当你的程序要从一个不信任用户那里获取输入信息的时候,即使采用的是非直接的方式,你都应该小心。举个例子来说吧,如果你在Perl中写CGI脚本,你要预期到恶意的用户将会发送给你假的输入。 不正确的用户输入,如果没有经过确认就被认可并使用了,将会导致许多方面出错。最常见和明显的错误是,没有经过确认就去执行有用户自定义参数的其他程序。

syetem()和exec()函数
Perl以能被用作一种“粘合”语言而著称——它能够通过如下方式完成一个出色的工作:在调用其他程序来为它工作的时候,通过采集一个程序的输出,将它重新格式成一种特定的方式后传递到其他程序的输入的方式仔细的协调它们的运行。这样各个程序就能很好的运行了。
正如Perl发布标语告许我们的,我们有不止一种方法可以做同样的事。
一种执行一个外部程序和一个系统命令的方法事通过调用exec()函数。当Perl遇到一个exec()语句的时候,它审视exec()被调用处的参数,然后启动一个新的进程来执行这条特定的命令。Perl从不会返回控制给调用exec()的原来的那个进程。
另一个相似的函数是system()。system()的运行方式非常象exec()。它们之间的唯一的大的区别是Perl会首先从父进程中分叉出一个子进程,子进程作为提供给system()的一个参数。父进程等到子进程结束运行后再接着运行程序的其余部分。我们将会在下面更详细的讨论system()调用,但这些讨论大部分也适用于exec()。
传递给system()的参数是一个列表——列表里的第一个元素是要被执行的这个程序的程序名,其他元素是传给这个程序的参数。然而,如果只有一个参数的的话,system()的执行方式会发生差异。在那种情形下,Perl将会扫描这个参数看它是不是包含任何shell转换字符。如果有的话,它就要把这些字符通过shell来解释。所以产生一个shell命令行来工作。不然,Perl会降字符串拆成单词然后调用效率更高的c库函数execvp(),这个函数不能理解特殊的shell字符。
现在假设我们有一张CGI表单,它要询问用户名,然后显示包含这个用户统计信息的一个文件。我名可以如下使用system()来调用’cat’实现那种要求:
system ("cat /usr/stats/$username");
用户名来自这样的一个表单:
$username = param ("username");
. 举个例子,当用户在表单里添上username = jdimov,然后提交后。Perl在字符串``cat /usr/stats/jdimov''中没有找到任何转换字符创,所以它就调用execvp()函数运行”cat”后返回到我们的脚本中。这个脚本也许看起来没有害处可言,但是它容易被一个恶意的攻击者所利用。
问题是这样的,通过在表单的”username”域内使用特殊的字符,一个攻击者可以通过 shell来执行任何命令。举个例子,我们可以这样说,如果攻击者传递这样的字符串"jdimov; cat /etc/passwd",Perl会把分号当作一个转换字符,然后把它传递到shell中:
cat /usr/stats/jdimov; cat /etc/passwd
攻击者既可以获得亚元文件,又可以获得密码文件。如果攻击者想要搞破坏的话,他只要发送"; rm rf /*"就可以了。
我们在前面提到system()有一个参数表,并且将第一个元素看作命令来执行,而将其余的元素作为参数来传递。所以我们可以稍微改变一下我们的脚本,使只有我们想让执行的程序能够被执行:
system ("cat", "/usr/stats/$username");
既然我们分开来指定程序的参数,那么shell就永远也不会被调用了。所以发送";rm -rf /*"也就不会起作用了,因为攻击字符串将只会被解释成一个文件名而已。
这种方法比单个参数的版本要好多了,因为它避免了使用shell命令,但是仍然有潜在的缺陷。特别的,我们要考虑到$username的值会不会被利用产生程序中能被执行的弱点。举例来说,一个攻击者仍然可以利用我们重写的代码版本,通过把$username设置成字符串"../../etc/passwd"来获得系统的密码文件。
使用那样的程序的时候很多地方会出错,举例来说,一些应用程序将特殊的字符序列解释成执行一条shell命令的请求。一个普遍的问题是有些版本的Unix邮件工具当它们在一定的上下文背景下看到有”~!…”等字符序列的时候将会执行一个shell命令。所以在一个消息体中的空白行中包含"~!rm -rf *"的用户输入将会在某种情形下产生问题。
只要是谈及安全的,上面论及system()函数的任何内容也适用于exec().
Open()函数
在Perl中open()函数被用来打开文件。在最为常见的形式中,它是这样使用的:
open (FILEHANDLE, "filename");
这样使用的时候,’filename”是以只读方式打开的。如果”filename”是含有”>”标志的前缀,那么它是为输出而打开的,并且在文件已经存在的时候覆盖原文件;如果含有”>>”前缀,那么是为追加打开的;前缀”<”打开文件来进行输入操作,但这也是不含前缀的时候的默认方式。用未经确认的用户输入作为文件名的一部分所产生的一些问题应该总是比较明显的。举例来说,向后回溯浏览目录的骗招在这里仍然能用。还有其他值得担忧的问题。现在我们使用open()替换”cat”来修改我们的脚本文件。我们象这样的命令:
open (STATFILE, "/usr/stats/$username");
然后我们从文件中读取代码并显示它。Perl文档告许我们:如果文件名是以”|”开始的,文件名将会被解释成一个输出管道命令;反之,如果文件名以”|”结束的话,文件名将会被解释成将让我们进行输出的管道。
于是,只要加上一个”|”前缀,用户就可以在/usr/stats目录下运行任何命令了。向后回溯目录的操作能够让用户在这个系统里执行任何程序。
一种解决这个问题打方法是:对于你想要打开并向其中输入的文件总是要求通过加”<”标识显式的指明.
有时我们确实要调用一个外部的程序,比如,我们想要改表我们的脚本文件以让他能够读取旧的纯文本文件/usr/stats/username,但是在显示给用户之前要先通过一个HTML过滤器。我们有一个马上就可以使用的便利的方法来实现这个意图。一种方法可以这样做:
open (HTML, "/usr/bin/txt2html /usr/stats/$username|");
print while <HTML>;
不幸的是,这依然要通过shell层。然而我们可以采用open()调用的另一个形式来避免牵涉到shell:
open (HTML, "-|")
or exec ("/usr/bin/txt2html", "/usr/stats/$username");
print while <HTML>;
当我们打开一个管道命令,或者是为了读(“-|”),或者是为了写(”|-“)的时候,Perl在当前进程中产生分支,并且返回子进程的PID给父进程,返回0给子进程。”or”语句用来决定我们是在父进程还是在子进程。如果我们在父进程(返回值为非零),我们继续执行print()语句。否则我们在子进程中,就执行txt2html程序,使用多于一个参数的exec()的安全版本来避免传递任何命令到shell层。所发生的是,子进程答应txt2html产生的STDOUT输出,然后就默默的消亡了(记住:exec()从不返回),同时父进程从STDIN中读取结果。象这样的技术可以被用来通过管道将输出输到一个外部程序的技术:
open (PROGRAM, "|-")
or exec ("/usr/bin/progname", "$userinput");
print PROGRAM, "This is piped to /usr/bin/progname";
在我们需要管道的时候,open()的以上这些形式应该总是比直接的管道open()命令优先采用,因为它们不通过shell层。现在让我们设想我们要将静态文本转化成格式化很好的HTML页面,并且,基于方便考虑,要存放在显示这些页面的Perl脚本相同的目录下。那么我们的open语句看起来可能是如下形式:
open (STATFILE, "<$username.html");
当用户通过表单中传递username=jdimo的时候,脚本显示jdimov.html。这里仍然有被攻击的可能。不同于c++和c ,perl不用空字节来结束字符串,这样的话字符串jdimov/”jdimov/lo/bah在绝大数c库调用中解释为”jdimo”,但是在Perl中却是”jdimov\0blah”。当perl传递一个含空字符的字符串给用c写的程序的时候,这个问题就突出了。UNIX内核以及绝大多数UNIX 和shell 都 是纯c 语言的。Perl自身也主要是且c编写,当用户如下调用我们的脚本:
statscrit.plusername=jdimov/%00
会发生什么呢?我们的程序传递字符串”jdimov/%。html”到对应的系统调用里以打开它,但是因为那些系统调用是用c编写,接受的是空字节的字符串方式。结果怎样呢?如果有文件”jdimov”的话就会显示这个文件,可能并没有这个文件,即使有也不是很有用。但是如果用"statscript./pusername=statscript。p/%"来调用脚本,会发生什么呢?如果脚本和我们的html文件在同一个目录下的话,这样我们可以用这个输入来期骗脚本,来显示给我们所有的内容。在这种情况下或许不是什么大的安全危险,但是它肯定能被其它的程序使用,因为它允许攻击者分析其他可利用的缺陷的来源。
单引号
在perl中,另一种读取外部程序的输出的方法是把命令放在单引号里。所以如果我们想在分等级的$stats的文件中保存我们stats文件的内容的话,我们可以这样做:
$stats=’cat/user/stats/$username’;
这确实要通过shell层来实现。任何把用户输入包含在一对单引号内的脚本都有发生前面讨论的所有的安全问题的危险。有很多方法可试图使shell不要误解一席可能的转换字符。但是最安全的事就是不要用但引号。取而代之的是,打开一个通到STDIN的管道,然后分叉执行外部程序,就像我们在前一节open()所做的一样。
Eval()和/e 修饰符
函数eval()可以在运行时间执行一个Perl代码块,并返回上一次经评估语句的值。这种函数功能经常用于诸如配置文件,它可以写成perl代码,除非你绝对相信输进eval()的源代码,否则不要做诸如eval/$userinput,之类的事,这也适用于一个常规表述中的/e 修饰符,用来使perl在执行之前解释该表述。
过滤用户输入
用于本节我们所讨论的所有问题的过滤用户输入的一个通常方法(FU In OCA )就是过滤任何不需要的转换字符和有问题的数据。例如我们可以在任何时段过滤来避免向后的目录查看。类似的,我们一旦看见非法的字符,就让程序运行失败,这种策略被称为”黑名单”这种哲学就是如果某东西没有明确禁止,那它肯定是好的。一个更好的策略就”白名单”,它指如果某东西没有被明确认可,那么它必须禁止。黑明单的最重要的问题是它非常难保持完整性并得到更。你也许会忘掉过滤某一特定字符,或者你的程序或许不得不随不同的转换字符集合转到一个不同shell中。不过滤掉不需要的转换字符和其他危险输入,相反,只过滤进合法的输入。下面的片段就是一个例子,它会停止执行一个安全性有问题的操作,如果有户输入中包含了除字母,数字,点和@符号外任何东西(@经常用于用户的电子邮件地址)
unless($useradress=~/^[-@/w。]+)$/)
{print”secrity error。/n”exit(1);
}
基本的思想是不去编译一个特定值的列表来保护,而是产生一个安全列表来接受可接受的输入值的列表。可接受的输入输入值的选择当然会随着不同的应用程序而变化。可接受的值应该采用某种能将破坏的可能性降到最小的方式来选择。
避免shell
当然,你也必须尽可能的避免shell,然而这种技术可被广泛地应用。如果你调用一个有特定序列的编辑器。你必须确认这些特定序列是不被允许使用的。一般,通过使用现存perl模块,你能避免使用外部程序来执行一个外部函数,CPAN是一个能完成几乎所有标准UNIX工具集能做的任何事的经测试的函数的模块来源,然而它或许会费点劲来包含一个模块,并且调用它,而不是调用一个外部程序,模块方法一般来说更安全和灵活,为解释清楚这一点,使用Net::SMTP,而不用exec()’ing sendmail/--T会帮你少一些使用shell的麻烦,并能防止你的用户在sendmail代理中寻求已知的弱点。
其它安全问题的来源(不安全环镜变量)
用户输入实际上是perl程序的主要安全问题的来源,但是还有其它因素是在写安全的perl源代码时所必须考滤的,经常 在shell下运行的脚本的易受攻击的弱点或者通过网络服务器是不安全的环镜变量,最通常的是PATH /变量。当你从你代码内部中使用一个外部应用程序或功能,而仅仅指明了一条相对路径的时候,你就使 你这个程序和运行它的系统处于危险中。如果你有如下一个system()调用:
system(“txt2html”,”user/stats/jdiov”);
对于这种调用,你假设txt2htm文件是包含在PATH变量某处的目录下,但是假如发生这种情况,一个攻击者改变你的路径指向含有相同的名字的其他带恶意的程序中,你的系统的安全性就得不到保证。为了避免例似的事情发生,每个需要含有远程安全意识的程序都应该这样开始写:
#!/usr/bin/perl -wT
require 5.001;
use strict;
$ENV{PATH} = join ':' => split (" ", << '__EOPATH__');
/usr/bin
/bin
/maybe/something/else
__EOPATH__
如果程序依赖于其他环境变量,它们也要在它们使用前明确的定义出来。
另一个危险变量(这个更是针对perl的)是@INC距阵变量,它非常像PATH,只不过它 指明Perl到哪里去找要包含在程序中的模块。有关@INCR 的问题和PATH是非常相似的。有人可能会把你的perl指向一个具有相同的名字模块,而且如你所料的做同样的事,但是它也背地里做一些坏事,因此@INC同PATH都不值的信任。在包括任何外部模块之前都 必须完全重新定义。
Setuid脚本
通常一个Perl程序是以执行它的用户的权限来运行的。通过产生一个setuid脚本,它的有效用户的ID可以设定成更高的权限,这个权限使这个用户可以访问他实际没有访问权限的资源,比如passwd程序使用setuid来获取对系统password文件的写的权限,这样允许用户来更改自已的密码,因为执行程序是通过CGI界而来执行的,该界面是在使用网络服务器的用户权限下运行的,CGI程序员经常 试图使用setuid技巧来让他们的脚本执行一些恶作剧。这有可能用,但也可能十分危险,对一个事情,如果一个攻击者发现一各方法可以利用脚本的弱点他们不仅是获得访误问系统的权限,但是他们会用有效的UID的特权来获得存在着另外几种类似的种族状况,在一个程序当中,这类缺陷是比较容易监控的,尤其是对有经验的程序员来说,目前相关方面的工作正在积极的探索着。关于这个问题,目前还没有一个既容易又完全有效的解决方法,常常在种族状况存在的可能情况下,用到的最好的方法是使用原子操作方式来进行,这就意味着仅仅使用一种系统来同时检查和生存档案。而不必使用处理器,在二者之间进行切换。当然,这不可能是常有的。
另外我们所作的一种标准模式是使用SYSOPEN来确定一种只读模式,不必再设定删减标志。
通过这种方法,即使我们的文件名确实已经形成,当我们打开文件进行写操作的时候 ,我们也不会破坏文件。注意:Fcnt1模快必须包含进来,以便让sysopen()函数起作用,因为这个模块是如下常数,O_RDONLY, O_WRONLY, O_CREAT,等被定义的地方。
缓冲区溢出和perl
一般来说,perl脚本是不容易发生缓冲区溢出的,因为perl能在需要的时候动态的扩展它的数据结构。Perl跟踪为每个字符串分配的大小。在一个字符串每次被赋值之前,perl保证有足够的空间可以利用,如果需要的话,也可以为那个字符串分配更多的空间。
然而在一些较老的perl实现方法中有几种熟为人知的缓冲区溢出情形。一个明显的例子是5。003版本会因为缓冲区溢出而崩溃。所有的suidperl版本(一种设计用来工作在为某些内核)都是在早于5。004版本的perl的不同分类的基础上建立起来的。
结论:
在我们以后的文章中,我们将会化一定的时间来熟悉perl提供给我们的安全特性,尤其是perl的”taint 模式“,并且,我们将会证明,如果我们不小心的话,即使在如此坚固的安全机制下,依然可能会出现的一些问题。在学习perl的这些方面以及一些典型的例子的时候。我们的目标是为了培养我们的一种直觉,这种直觉能帮助我们在看perl脚本的第一眼时就能够意识到其中的安全问题,以避免在我们的程序中犯类似的错误。






欢迎光临 无忧启动论坛 (http://bbs.wuyou.net/) Powered by Discuz! X3.3