【问题标题】:How to submit a POST request using data from webpage with curl & grep (or any busybox alternative)如何使用 curl 和 grep(或任何busybox替代方案)的网页数据提交 POST 请求
【发布时间】:2014-09-25 12:59:24
【问题描述】:

问题:

我在服务器上有一个这样的网页:

...
<form action="/" action="POST">
    ...
    <input type="hidden" name="4Tredir" value="/" />
    <input type="hidden" name="magic" value="(some hex number here)" />
    ...
    <input type="text" name="username" />
    <input type="password" name="password" />
</form>
...

是否可以使用busybox提供的命令(即curlgrep等)使用我自己的用户名、密码和magic将帖子提交到已知地址(例如http://exampleauth.com/)网页中的价值?

附加信息: HTML 全部写在一行中,没有换行符,幻数的格式是固定的。即[0-9a-f]{16}

【问题讨论】:

    标签: linux curl terminal grep


    【解决方案1】:

    在带有 curl 7.19.7 的 SElinux 上尝试了这个

        curl exampleauth.com | grep -ioE "[0-9a-f]{16}" | curl -F "username=abc" -F "password=123" -F magic=\<- exampleauth.com
    

    一步一步:

    1. 获取带有表单的html

      curl exampleauth.com 
      
    2. 用普通的 exp 找到魔法。您可能需要调整它

      grep -ioE "[0-9a-f]{16}" 
      
    3. 像提交表单一样发送数据。注意“

      curl -F "username=abc" -F "password=123" -F magic=\<- exampleauth.com 
      

    发现这些有用:
    Extract a pattern from the output of curl
    http://curl.haxx.se/docs/manpage.html

    【讨论】:

      【解决方案2】:

      你可以使用 /bin/echo 和 /usr/bin/nc

      [prompt] BODY='{"4Tredir":"","magic":"[0-9a-f]{16}","username":"johndoe",  "password":"mypassword"}'
      [prompt] LEN=$(busybox echo -n ${BODY} | wc -c)
      [prompt] echo -ne "POST /form.html HTTP/1.0\r\nHost:www.exampleauth.com\r\n\Accept: application/x-www-form-urlencoded\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: ${LEN}\r\n\r\n$BODY" | nc -i 3 www.exampleauth.com 8080
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-07-13
        • 2018-09-14
        • 1970-01-01
        • 2021-03-17
        • 2015-11-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多