【问题标题】:Where is the browser getting these HTML form fields?浏览器从哪里获得这些 HTML 表单字段?
【发布时间】:2015-12-16 23:34:42
【问题描述】:

网站提供了一个登录表单,其中仅包含“用户名”和“密码”。按回车键或单击“登录”按钮即可登录。

HTML 表单(来自页面源代码)如下所示:

<form name="login" action="https://www.mywebsite.com/index.php?main_page=login&amp;action=process" method="post" id="loginForm"><fieldset>
<legend>Please Log In</legend>

<label class="inputLabel" for="email-address">Email Address:</label>
<input type="text" name="email_address" size = "41" maxlength= "96" id="email-address" /><br class="clearBoth" />

<label class="inputLabel" for="login-password">Password:</label>
<input type="password" name="password" size = "41" maxlength = "40" id="login-password" /><br class="clearBoth" />
<input type="hidden" name="securityToken" value="0330682553ea36639f62317144927f3f" /><div class="buttonRow forward"><input type="image" src="includes/templates/lite_grey/buttons/english/login.gif" alt="Sign In" title=" Sign In " /></div>
<div class="buttonRow back important"><a href="https://www.mywebsite.com/index.php?main_page=password_forgotten">Forgot password</a> | <a href="index.php?main_page=activation_email&resend=1">Re-send activation email</a></div>
</fieldset>
</form>

表单包含两个可见字段(email_address 和密码)和一个隐藏字段(securityToken)。

当我填写表单并在浏览器中按 Enter 时,浏览器会生成一个如下所示的 POST 请求:

POSTDATA=email_address=my@emailaddress.org&password=mypass123&securityToken=0330682553ea36639f62317144927f3f&x=37&y=15

(通过使用 Firefox 的“篡改数据”插件,我能够看到此发布数据。也通过 wireshark 确认)

注意浏览器发送的字段:email_address、password、securityToken - 以及 HTML 代码中不存在的另外两个字段:x=37 和 y=15。我不知道这些值是从哪里来的。

此外,这些值 x 和 y 在我每次登录网站时都会发生变化。

所有浏览器似乎都能很好地处理这个登录表单(不仅仅是 Firefox)。 HTML页面似乎没有被混淆或任何东西..

这些值的来源或我如何找到的任何想法?

谢谢

【问题讨论】:

  • 听起来像 Csrf:en.m.wikipedia.org/wiki/Cross-site_request_forgery,每次加载时在服务器端自动生成
  • 这些字段不是服务器生成的,因为它们会在 HTML 源代码中。
  • 同意@Tomalak。 POSTDATA 是我的浏览器发送的内容,因此是浏览器生成它们。我只是看不到 HTML 中的什么使它这样做...

标签: jquery html forms field


【解决方案1】:

当您的表单提交为 type="image" 时,始终会发送这些值(x 和 y 坐标):

<input type="image" src="includes/templates/lite_grey/buttons/english/login.gif" alt="Sign In" title=" Sign In " />

看到这个答案:https://stackoverflow.com/a/801722/870729

【讨论】:

  • 是的,这似乎是问题所在。当我按“Enter”而不是单击登录图像时,这些值始终为 0。非常感谢!
【解决方案2】:

编辑:虽然我的回答可能技术上在某些情况下是可能的,但 cale_b 的回答的可能性大约是 100,000,000 倍。谢谢cal_b。


他们必须使用 javascript 框架将 onSubmit 处理程序附加到表单,并在发送之前注入他们自己的字段。

在chrome中打开开发者工具,在源代码中搜索“onSubmit”、“post”等。你很可能会找到你的罪魁祸首。

如果您无法以这种方式找到它,请搜索“.preventDefault()”,但这可能会出现很多内容。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-06-27
  • 1970-01-01
  • 2021-08-24
  • 2011-10-21
  • 1970-01-01
  • 2010-12-04
  • 1970-01-01
相关资源
最近更新 更多