简体   繁体   English

创建表单时如何提出请求?

[英]How would you make a request when you created a form?

I am trying to hack a page that requires a "username" and "password". 我试图破解一个需要“用户名”和“密码”的页面。 I have created a form and I think it looks good; 我创建了一个表单,我认为它看起来不错;

  <form action="http://hackmefff.co/login">
  <input type="hidden" name = "username" value="hacker">
  <input type="hidden" name = "password" value="b678jk">
  </form>  

People have told me that my form looks good and that I need to create a request in javascript. 人们告诉我,我的表单看起来很好,我需要在javascript中创建一个请求。 I don't know how to create one because I just started learning javascript yesterday. 我不知道如何创建一个,因为我刚开始学习javascript。 I have searched on how to create a request of submit, and all I see is functions that look like they are making a form, which I already have, so am confused. 我已经搜索了如何创建提交请求,我所看到的只是他们正在制作表单的函数,我已经拥有,所以很困惑。 How would I send a request to log me into a website, assuming that url exists, and both name and password are correct. 如果存在URL,并且名称和密码都正确,我将如何发送登录网站的请求。

EDIT: I have formatted the code below because I don't want the page to show any text at all even though am logged in, it should just be blank. 编辑:我已经格式化下面的代码,因为我不希望页面显示任何文本,即使登录,它应该是空白。 But a test page shows that I didn't get logged in; 但测试页面显示我没有登录;

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

<html>
    <head>
      <title>Test page for your custom form</title>
      <script type="text/javascript">
        function submitform()
        {
           document.yourform.submit();
        }
      </script>
   </head>
  <body>
    <form name="yourform" action="http://hackmefff.co/login">
      <input type="hidden" name = "username" value="hacker">
      <input type="hidden" name = "password" value="b678jk">
    </form>
    <input type='hidden' name='query' />
    <a href="javascript: submitform()"></a>
  </body>
</html>

你不需要Javascript,只需在表单中添加一个提交按钮:

<input type="submit" value="Submit">
<html>
    <head>
        <title>Test page for your custom form</title>
        <script type="text/javascript">
            function submitform()
            {
               document.yourform.submit();
            }
        </script>
    </head>
    <body>
        <form name="yourform" action="http://hackmefff.co/login" method="post">
        <input type="hidden" name = "username" value="hacker">
        <input type="hidden" name = "password" value="b678jk">
        </form>
        Search: <input type='text' name='query' />
        <a href="javascript: submitform()">Login</a>
</body>
</html>

Note that I have modified your form slightly to include a name so that we can reference it from the JavaScript function. 请注意,我稍微修改了您的form以包含name以便我们可以从JavaScript函数中引用它。

This answer of course assumes that you have to use JavaScript. 这个答案当然假设您必须使用JavaScript。

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

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