簡體   English   中英

如何使用curl和grep(或任何busybox替代品)的網頁數據提交POST請求

[英]How to submit a POST request using data from webpage with curl & grep (or any busybox alternative)

題:

我在服務器上有一個網頁,如下所示:

...
<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}

下面在帶有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. 定期找魔術。 您可能需要調整它

     grep -ioE "[0-9a-f]{16}" 
  3. 就像提交表單一樣發送數據。 注意“ <-”的意思是“使用STDIN”

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

發現這些有用:
從curl的輸出中提取圖案
http://curl.haxx.se/docs/manpage.html

您可以使用/ 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM