没有 require、没有 include、没有 url 重写,但脚本执行时不在 url 中
我正在尝试跟踪一些遗留代码中的执行流程。我们正在访问一份报告,
http://site.com/?nq=showreport&action=view
这就是难题:
- 在
index.php
中,没有$_GET['nq']
或$_GET['action' ]
(并且没有$_REQUEST
之一)、 index.php
或其包含的任何源,请勿- 在
.htaccess< 中 包含
showreport.php
/code> 还没有 url 重写
,showreport.php
被执行。
我可以访问服务器上的 cPanel(但没有 apache 配置文件),这是我不能随意使用的实时代码。
是什么导致了这种情况发生?我应该去哪里看?
更新
有趣的是——在状态更新中向客户发送了这个问题的链接,让他随时了解情况;几分钟后,所有访问权限均被撤销,客户通知我该项目已取消。我相信我已经足够小心,没有在代码实际所在的位置留下任何痕迹……
我很欣慰现在它已经从我身上拿走了,但我也很想知道它是什么!
感谢大家的时间和帮助。
I am trying to trace the flow of execution in some legacy code. We have a report being accessed with
http://site.com/?nq=showreport&action=view
This is the puzzle:
- in
index.php
there is no$_GET['nq']
or$_GET['action']
(and no$_REQUEST
either), index.php
, or any sources it includes, do not includeshowreport.php
,- in
.htaccess
there is no url-rewriting
yet, showreport.php
gets executed.
I have access to cPanel (but no apache config file) on the server and this is live code I cannot take any liberty with.
What could be making this happen? Where should I look?
Update
Funny thing - sent the client a link to this question in a status update to keep him in the loop; minutes latter all access was revoked and client informed me that the project is cancelled. I believe I have taken enough care not to leave any traces to where the code actually is ...
I am relieved this has been taken off me now, but I am also itching to know what it was!
Thank you everybody for your time and help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
有“数百种”方法可以在各个层(系统、httpd 服务器、CGI 脚本)中解析 URL。因此,根据您提供的信息无法具体回答您的问题。
您留下了一个非常明显的提示“遗留代码”。我认为您的意思是,您不想完全阅读代码,甚至不想理解它来找到正在解析该参数的相关应用程序的部分。
不过,如果您留下一些提示“代码的遗留程度”:年龄、目标 PHP 版本等,那就太好了。这会有所帮助。
并不总是使用
$_GET
来访问这些值($_REQUEST
也是如此,它们是表兄弟)。我们来看看PHP 3手册镜像< /strong>:
该脚本可能使用这个数组吗?这只是一个猜测,在相当长的一段时间内这是访问这些参数的有效方法。
无论如何,这一定不是您要搜索的内容。有一个经常被误解和误用(实际上是滥用)的功能,称为注册全局变量< /em> PHP 手册(PHP 语言)。因此,您可能只是搜索
$nq
。接下来,总是有请求 uri 和 apache/环境/cgi 变量。请参阅上面的 PHP 3 手册的链接,其中列出了其中的许多内容。将其与当前手册进行比较以获得广泛的理解。
无论如何,您可能有
grep
或多文件搜索功能(如果您需要检查某些 IDE 中的遗留代码,Eclipse 有一个很好的内置功能)。因此,最终您可能只是查找类似
nq
、'nq'
、"nq"
或$ 的字符串nq
。然后检查此搜索会显示什么。基于字符串的搜索是进入您根本不知道的代码库的一个很好的入口。There are "a hundreds" ways to parse a URL - in various layers (system, httpd server, CGI script). So it's not possible to answer your question specifically with the information you have got provided.
You leave a quite distinct hint "legacy code". I assume what you mean is, you don't want to fully read the code, understand it even that much to locate the piece of the application in question that is parsing that parameter.
It would be good however if you leave some hints "how legacy" that code is: Age, PHP version targeted etc. This can help.
It was not always that
$_GET
was used to access these values (same is true for$_REQUEST
, they are cousins).Let's take a look in the PHP 3 manual Mirror:
Is the script making use of this array probably? That's just a guess, this was a valid method to access these parameter for quite some time.
Anyway, this must not be what you search for. There was this often misunderstood and mis-used (literally abused) feature called register globals PHP Manual in PHP. So you might just be searching for
$nq
.Next to that, there's always the request uri and apache / environment / cgi variables. See the link to the PHP 3 manual above it lists many of those. Compare this with the current manual to get a broad understanding.
In any case, you might have
grep
or a multi file search available (Eclipse has a nice build in one if you need to inspect legacy code inside some IDE).So in the end of the day you might just look for a string like
nq
,'nq'
,"nq"
or$nq
. Then check what this search brings up. String based search is a good entry into a codebase you don't know at all.我会安装 xdebug 并使用它的 函数跟踪 逐段查看它在做什么。
编辑:
好的,只是一个想法,但是...也许您的应用程序是某种包含地狱般的应用程序,我有时被迫在工作中搞砸?一个文件包含另一个文件,它包含另一个文件,并且再次包含原始文件...那么也许您的索引文件包含某个文件,最终导致该文件被包含?
另一个编辑:
或者,有时应用程序开发人员不知道什么是 $_GET 变量并自行解析 url ->手动包含基于 url 的内容。
I’d install xdebug and use its function trace to look piece by piece what it is doing.
EDIT:
Okay, just an idea, but... Maybe your application is some kind of include hell like application I’m sometimes forced to mess at work? One file includes another, it includes another and that includes original file again... So maybe your index file includes some file that eventually causes this file to get included?
Another EDIT:
Or, sometimes application devs didn’t know what is a $_GET variable and parsed the urls themselves -> doing manual includes based to based urls.
我不知道它是如何工作的,但我知道 Wordpress/Silverstipe 正在使用自己的 url 重写来解析 url 以查找帖子/标签/等。所以 url 解析可能在 PHP 脚本中完成。
I don't know how it works, but I know that Wordpress/Silverstipe is using is own url-rewriting to parse url to find posts/tags/etc. So the url parsing maybe done in a PHP script.
检查您的配置文件(php.ini 和 .htaccess),您可能有
auto_prepend_file
< /a> 设置。Check your config files (php.ini and .htaccess), you may have
auto_prepend_file
set.检查你的 crontab,[抱歉,我不知道你会在 cpanel 中的哪里找到它]
- 脚本是否在特定时间触发,或者您是否可以看到它确实仅在您请求特定页面时触发?
-肖恩
编辑:
如果 crontab 已退出,请查看 index.php [及其包含] 并查找循环遍历 url 参数而无需特别注明“nq”的代码以及任何可能解析查询字符串的代码 [可能类似于:$_SERVER ['QUERY_STRING'] ]
-肖恩
check your crontab, [sorry I don't know where you would find it in cpanel]
- does the script fire at a specific time or can you see it definitely fires only when you request a specific page?
-sean
EDIT:
If crontab is out, take a look at index.php [and it's includes] and look for code that either loops over the url parameters without specifically noting "nq" and anything that might be parsing the query string [probably something like: $_SERVER['QUERY_STRING'] ]
-sean
您应该给出
debug_backtrace()
(或debug_print_backtrace()
尝试一下。输出类似于 Exception-stacktrace 的输出,因此应该帮助你找出何时何地调用什么如果您无法在本地开发系统上运行该应用程序,请确保其他人无法看到输出。You should give
debug_backtrace()
(ordebug_print_backtrace()
a try. The output is similar to the output of an Exception-stacktrace, thus it should help you to find out, what is called when and from where. If you don't have the possibility to run the application on a local development system, make sure, that nobody else can see the output您确定您正在查看正确的配置或服务器吗?如果您访问上面的 URL,您会看到一个错误页面,该页面似乎表明该服务器实际上是一台 microsoft iis 服务器,而不是 apache 服务器。
Are you sure that you are looking at the right config or server? If you go the url above you get an error page that seems to indicate that the server is actually a microsoft iis server and not an apache one.