首钢禽兽 发表于 2023-2-25 21:53:50

PhpStorm配置debug环境的详细过程

phpstorm配置debug环境

众所周知,在渗透测试进行代码审计的时候,往往要审计代码的执行过程,亦或是在开发php项目的时候,需要了解代码的执行逻辑,并从大量的代码跳转执行中精确找到bug错误是很困难的,这就需要我们进行像java或者是c#那样进行debug,所以在phpstorm添加xdebug插件可以快速帮我们解决问题,进行自动调试和跳转,无疑是如虎添翼!

0x1所需工具


[*]phpstudy2018
[*]phpstorm

0x2配置文件

phpstudy2018 php配置文件 php.ini
修改原的配置,替换成下面的内容,前面三个的路径不同,改成自己的文件路径即可,修改完记得重启


xdebug.profiler_output_dir="C:\...\phpstduy2018\PHPTutorial\tmp\xdebug"                                         ;optional
xdebug.trace_output_dir="C:\...\phpstduy2018\PHPTutorial\tmp\xdebug"                                                 ;optional
zend_extension="C:\...\phpstduy2018\PHPTutorial\php\php-5.6.27-nts\ext\php_xdebug.dll"          ;xdebug扩展的位置,每个人可能不一样,必须确定的
xdebug.remote_enable=On                                                                                                                 ;启动远程调试,必须确定
xdebug.remote_host=127.0.0.1                                                                                                         ;需要调试的远程主机
xdebug.remote_port=9001                                                                                                                ;远程主机与phpstorm通信的端口,必须确定
xdebug.remote_handler=dbgp                                                                                                                 ;通信协议,optional
xdebug.auto_trace=on                                                                                                                         ;启用代码自动跟踪,optional
xdebug.idekey=PHPSTORM                                                                                                                        ;optional
xdebug.collect_return=On                                                                                                                 ;收集返回值,optional
xdebug.collect_params=On        
0x3配置php解释器和debug解释器

记得每一步完成都要点击apply应用,使其生效
第一:配置php解释器和debug.dll
https://img.jbzj.com/file_images/article/202301/202301150904291.png
https://img.jbzj.com/file_images/article/202301/202301150904292.png
第二:Debug
Debug设置端口9001,与配置文件一致
https://img.jbzj.com/file_images/article/202301/202301150904293.png
第三:DBGp
PHP下面的DBGp
https://img.jbzj.com/file_images/article/202301/202301150904294.png
第四
Servers: 设置debug的名字
https://img.jbzj.com/file_images/article/202301/202301150904295.png
第五
Edit Configurations 编辑配置文件
https://img.jbzj.com/file_images/article/202301/202301150904306.jpg
++
https://img.jbzj.com/file_images/article/202301/202301150904307.png
第六
选择PHP Web Page
https://img.jbzj.com/file_images/article/202301/202301150904308.png
编辑网页文件
https://img.jbzj.com/file_images/article/202301/202301150904309.png
填完方框的内容之后apply,再点击蓝色的Validate
Validate来确认是否安装完成
https://img.jbzj.com/file_images/article/202301/2023011509043010.png
第七
六个打勾即可完成
https://img.jbzj.com/file_images/article/202301/2023011509043011.png
第八
Run勾选上Break at first line in PHP scripts
https://img.jbzj.com/file_images/article/202301/2023011509043012.jpg

0x4使用方法

下面是使用phpstorm的debug调试环节,出现下面的图片即可快乐的调试代码
https://img.jbzj.com/file_images/article/202301/2023011509043013.jpg
当用phpstorm进行debug调试的时候,记得开启监听模式,调试完记得关闭监听让流量进行正常转发
开启
https://img.jbzj.com/file_images/article/202301/2023011509043014.png
关闭
https://img.jbzj.com/file_images/article/202301/2023011509043015.png
当时间久了它会断开连接,我们可以快速刷新url或者重发即可再次连接
http://www.sqli.com/Less-18/?id=1&XDEBUG_SESSION_START=PHPSTORM
https://img.jbzj.com/file_images/article/202301/2023011509043016.jpg
当我们想快速跳转到想要执行的语句的时候,可以右键点击红色Force Run to Cursor进行强制跳转
https://img.jbzj.com/file_images/article/202301/2023011509043117.png

总结

到此这篇关于PhpStorm配置debug环境的文章就介绍到这了,更多相关PhpStorm配置debug环境内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

来源:https://www.jb51.net/article/272725.htm
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作!
页: [1]
查看完整版本: PhpStorm配置debug环境的详细过程