douzhang6646 2010-01-29 04:17
浏览 67
已采纳

这个重定向脚本会打开我的代码注入或远程文件包含吗?

Recently I ran across a blog article about using PHP scripts to redirect affiliate links. It got me thinking whether this script was safe or not. I've heard that using the $_GET variable can lead to a vulnerability.

Any suggestions would be appreciated. Would checking the input for alphanumerics and the hyphen ('-') be enough to guard against this?

For this script, links in would be of the form:

http://www.somesite.com/amazon.php?asin=XXXXXXXXXX

or

http://www.somesite.com/amazon.php?id=some-keyword

Here is amazon.php:

   <?php

    $id = $_GET['id'];
    $asin = $_GET['asin'];

    if ($asin != NULL)
    {
        header("Location:http://www.amazon.com/exec/obidos/ASIN/".$asin."/fantasticaffiliate-20");
        exit;
    }

    else
    {
        $links = array(
            "keyword-one" => "http://www.amazon.com/b/?node=1122334455&tag=fantasticaffiliate-20",
            "keyword-two" => "http://www.amazon.com/exec/obidos/ASIN/1352434213/fantasticaffiliate-20"
            );          

        header("Location:".$links[$id]);
        exit;
    }

?>

Thanks as always!

  • 写回答

1条回答 默认 最新

  • douxin2011 2010-01-29 04:21
    关注

    Yes, it would. None of those characters in any combination is enough to cause a XSS problem.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计
  • ¥23 (标签-bug|关键词-密码错误加密)
  • ¥66 比特币地址如何生成taproot地址
  • ¥20 数学建模数学建模需要