dongweiben5229 2013-03-19 14:33
浏览 46

重定向后PHP脚本是否可以继续? [重复]

This question already has an answer here:

I am working on an existing website, looking for security issues. Is it safe to say that a PHP script aborts after the browser is redirected away or can a crafty user somehow force the script to continue. Assume "is_logged_in" returns 1 or 0 if the user is currently logged in. Assume there are no vulnerabilities in this function. The code is as follows:

<?
$fp = fopen("./debug.txt", "a");
fwrite("BEFORE LOGIN CHECK
");

if(!is_logged_in()) {
         fwrite("Not authed 
");
         header("Location: $url", TRUE, 302);
}
fwrite("Passed auth check 
");
/* Code to do some logged in functionality here */
?>

Using a normal browser with a logged in user I get

BEFORE LOGIN CHECK
Passed auth check

with a not logged in user I get

BEFORE LOGIN CHECK
Not authed

Is it possible to hold the script open (and ignore the redirect), using raw requests so that I get

BEFORE LOGIN CHECK
Not authed
Passed auth check

Essentially go into the if block, get the redirect header, ignore it, and have the script continue executing.

If not I would correct the issue by doing:

if(!is_logged_in()) {
         fwrite("Not authed 
");
         header("Location: $url", TRUE, 302);
         die();
}

But I'm not sure if this is even an issue.

</div>
  • 写回答

3条回答 默认 最新

  • dran0703 2013-03-19 14:36
    关注

    If you don't exit; after the header then the script should continue to run.

    I have used this before when sending HTTP 200 to the client, and content-length: 0. So the client doesn't do anything, and PHP continues executing.

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入