phpStudy V8 配置 Apache 2.0 Handler 环境 - microsoft
前言
phpStudy V8查看phpinfo信息时,有一项如下:
Server APICGI/FastCGI
如何查看phpinfo?
在www目录下新建phpinfo.php,内容为:
phpinfo();
?>
访问phpinfo.php(例如:http://localhost/phpinfo.php)即可看到。
这样就无法完成pikachu靶场XSS钓鱼演示,因为会一直弹框让输入账号、密码。
此外,也无法完成upload-labs靶场第四关通过上传.htaccess文件覆盖原本配置文件,使jpg用php解析。
百度搜索后发现了原因:
=频繁弹窗问题=
原因:PHP的HTTP认证机制仅在PHP以Apache模块方式运行时才有效,因此该功能不适用于CGI版本。
解决方案:重新部署环境
我们需要让Server API 显示 Apache 2.0 Handler。
教程原理
phpStudy2018里有Apache 2.0 Handler环境,先下载下来,复制到phpStudy V8中,修改配置文件就行了。
你可能会问,既然phpStudy2018可以演示XSS钓鱼,为什么不用phpStudy2018呢?
因为phpStudy V8 界面好看,而且我用旧版时,phpMyAdmin打开太慢了。如果你已经在用旧版了,就不用看下去了。
php文件名带nts的都是CGI/FastCGI,不带nts的是Apache 2.0 Handler。
phpStudy V8的php文件名都是带nts的,旧版本有部分是不带nts的。
一、下载phpStudy2018
下载页面:Windows版phpstudy下载 - 小皮面板(phpstudy)
解压打开,运行PhpStudy2018.exe,自动解压文件到指定目录下。
打开 D:\*PhpStudy2018\PHPTutorial。
Apache和php\php-5.5.38就是我们需要的文件。
把Apache复制到*\phpstudy_pro\Extensions目录下,即phpStudy V8的Extensions目录下。先重命名为Apache2.4.23-win32-VC11。(为什么是这个名字,后面会说)
把php\php-5.5.38复制到phpStudy V8的Extensions\php目录下。
二、配置Apache
先在phpStudy V8 中下载安装Apache2.4.43。等会我们再替换掉里面的内容。
需要修改的文件有三个:Apache2.4.23-win32-VC11\conf 下的 httpd.conf、vhosts.conf,Apache2.4.23-win32-VC11\conf\extra 下的 httpd-php.conf。
http.conf
第一处:
ServerRoot "D:/NetworkSecurity/PhpStudy2018/PHPTutorial/Apache"
修改Apache路径,参考如下:
Define SRVROOT "D:/NetworkSecurity/phpstudy_pro/phpstudy_pro/Extensions/Apache2.4.43"
ServerRoot "${SRVROOT}"
定义了一个SRVROOT。路径最后必须是Apache2.4.43,因为我们等会要替换里面已有的内容。注意是/不是\。
第二处:
DocumentRoot "D:\NetworkSecurity\PhpStudy2018\PHPTutorial\WWW"
修改参考如下:
DocumentRoot "D:\NetworkSecurity\phpstudy_pro\phpstudy_pro\WWW"
第三处:
AllowOverride None
Options None
Require all granted
把路径改为${SRVROOT}/cgi-bin,用到了第一处的SRVROOT。参考如下:
AllowOverride None
Options None
Require all granted
vhosts.conf
原文:
DocumentRoot "D:\NetworkSecurity\PhpStudy2018\PHPTutorial\WWW"
Options -Indexes -FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
修改一下路径。
参考如下:
DocumentRoot "D:\NetworkSecurity\phpstudy_pro\phpstudy_pro\WWW"
Options -Indexes -FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
httpd-php.conf
原文:
LoadFile "D:/NetworkSecurity/PhpStudy2018/PHPTutorial/php/php-5.4.45/libssh2.dll"
LoadFile "D:/NetworkSecurity/PhpStudy2018/PHPTutorial/php/php-5.4.45/php5ts.dll"
LoadModule php5_module "D:/NetworkSecurity/PhpStudy2018/PHPTutorial/php/php-5.4.45/php5apache2_4.dll"
PHPIniDir "D:/NetworkSecurity/PhpStudy2018/PHPTutorial/php/php-5.4.45/"
SetHandler application/x-httpd-php
修改路径。
参考如下:
LoadFile "D:/NetworkSecurity/phpstudy_pro/phpstudy_pro/Extensions/php/php-5.5.38/libssh2.dll"
LoadFile "D:/NetworkSecurity/phpstudy_pro/phpstudy_pro/Extensions/php/php-5.5.38/php5ts.dll"
LoadModule php5_module "D:/NetworkSecurity/phpstudy_pro/phpstudy_pro/Extensions/php/php-5.5.38/php5apache2_4.dll"
PHPIniDir "D:/NetworkSecurity/phpstudy_pro/phpstudy_pro/Extensions/php/php-5.5.38/"
SetHandler application/x-httpd-php
注意是/不是\。
删除Apache2.4.43内所有文件,把Apache2.4.23-win32-VC11里所有的文件复制到Apache2.4.43内。
三、配置php
打开Extensions\php\php-5.5.38目录下的php.ini。
第一处:
; Default timeout for socket based streams (seconds)
; http://php.net/default-socket-timeout
default_socket_timeout = 60
extension_dir="D:\NetworkSecurity\PhpStudy2018\PHPTutorial\php\php-5.5.38\ext"
修改路径
参考如下:
; Default timeout for socket based streams (seconds)
; http://php.net/default-socket-timeout
default_socket_timeout = 60
extension_dir="D:\NetworkSecurity\phpstudy_pro\phpstudy_pro\Extensions\php\php-5.5.38\ext"
第二处:
session.save_path="D:\NetworkSecurity\PhpStudy2018\PHPTutorial\tmp\tmp"
修改路径
参考如下:
session.save_path="D:\NetworkSecurity\phpstudy_pro\phpstudy_pro\Extensions\tmp\tmp"
第三处:
[XDebug]
xdebug.profiler_output_dir="D:\NetworkSecurity\PhpStudy2018\PHPTutorial\tmp\xdebug"
xdebug.trace_output_dir="D:\NetworkSecurity\PhpStudy2018\PHPTutorial\tmp\xdebug"
在Extensions\temp目录下新建文件夹xdebug,修改路径
参考如下:
[XDebug]
xdebug.profiler_output_dir="D:\NetworkSecurity\phpstudy_pro\phpstudy_pro\Extensions\tmp\xdebug"
xdebug.trace_output_dir="D:\NetworkSecurity\phpstudy_pro\phpstudy_pro\Extensions\tmp\xdebug"
四、测试
在phpStudy V8的网站页面,把pikachu、upload-labs等网站的php版本改为php-5.5.38。
启动需要VC11环境。
VC11微软官方下载页面
https://www.microsoft.com/en-us/download/details.aspx?id=30679
在首页启动MySQL和Apache2.4.43(实际上Apache是2.4.23版本)。
访问phpinfo.php查看php信息。
可以看到Server API 是Apache 2.0 Handler。
往下翻:
可以看到Apache Version是2.4.23 win32版本,这就是一开始重命名为Apache2.4.23-win32-VC11的原因。Server Root路径是2.4.43,但实际上内容已经替换为2.4.23版本了,相当于把phpStudy当做一个启动器去启动Apache。
测试一下pikachu靶场的XSS钓鱼:
打开存储型XSS。
输入payload:
根据实际情况自己修改,或者搜索相关教程。
重新进入存储型XSS页面,弹框输入账号、密码:
点击登录,弹框消失。去XSS后台页面查看钓鱼记录:
测试成功。
成功后,如果在同一个浏览器打开存储型XSS页面,可能不会再弹框了,保留了cookie,XSS后台会正常收到上一次输入的账号与密码。
测试upload-labs靶场第四关:
打开第四关:
http://localhost/upload-labs/Pass-04/index.php
上传1.jpg木马图片以及.htacess文件。两个文件内容图如下:
上传后能在upload-labs/upload目录下看到文件:
使用工具访问木马图片(这里使用蚁剑)。
连接成功。
测试结束。
五、其他
如果想用其他版本的Apache和php,提供如下下载链接:
php下载页面
https://windows.php.net/downloads/releases/archives/
Apache下载页面
这是VC11的:
https://www.apachelounge.com/download/VC11/
这是VC15的:
https://www.apachelounge.com/download/VC15/
以此类推,可能有些页面缺失。
Apache和php版本需要相匹配:
要么都是x86的,要么都是x64的。
VC版本需要一样。
例如:
Apache 2.4.38 Win32
httpd-2.4.38-win32-VC11.zip
php-5.5.38-win32-VC11-x86
php-5.5.38-Win32-VC11-x86.zip
VC版本下载链接:
VC各版本:(来源于网上搜索,如果有错,请指出)
VC6→ Microsoft Visual C++ 6
VC7→ Microsoft Visual C++ 2003 VC8→ Microsoft Visual C++ 2005 VC9→ Microsoft Visual C++ 2008 VC10→Microsoft Visual C++ 2010 VC11→Microsoft Visual C++ 2012 VC12→Microsoft Visual C++ 2013 VC14→Microsoft Visual C++ 2015 VC15→Microsoft Visual C++ 2017 VC16→Microsoft Visual C++ 2019
Apache网页提供了微软官方下载链接:
VC11:
Apache页面:https://www.apachelounge.com/download/VC11/
进入后,找到这句话: 拼多多帮助力入口
Be sure that you have installed Visual C++ Redistributable for Visual Studio 2012 : vcredist_x64/86.exe
点击“vcredist_x64/86.exe”即可跳转微软官方页面下载VC11。
以此类推。
如有错误,欢迎指出。
文章链接