gpt4 book ai didi

bash - 使用 curl 发布二进制数据

转载 作者:行者123 更新时间:2023-11-29 08:40:57 28 4
gpt4 key购买 nike

基本上,我正在尝试编写一系列脚本来与 Dot Net Nuke 进行交互。我一直在分析流量,现在可以登录并执行一些基本任务。但是,我从来没有用 curl 处理过二进制文件上传。有人愿意看这个来帮助我吗?这是请求的剖析:

http://pastebin.com/qU8ZEMaQ

到目前为止,这是我对 curl 的了解:

http://pastebin.com/LG2ubFZG

编辑:对于懒惰的人 -

文件的长度已达到并存储在 LENGTH 中
STUFF 只是复制/粘贴带有参数的请求 URL,减去 URL 本身。

curl -L --cookie ~/.cms --data-binary "@background.jpg" \
--header "Content-Length: $LENGTH" \
--header "Content-Disposition: form-data" \
--header "name=\"RadFileExplorer1_upload1file0\"" \
--header "Content-Type: image/jpg" \
--header "Filename=\"background.jpg\"" \
--data $STUFF \
--referer "Kept-Secret" \
"Kept-Secret"

最佳答案

你不需要--header "Content-Length: $LENGTH"

curl --request POST --data-binary "@template_entry.xml" $URL

请注意,GET 请求并不广泛支持内容正文。

还要记住 POST 请求有 2 种不同的编码模式。这是第一种形式:

  $ nc -l -p 6666 &  $ curl  --request POST --data-binary "@README" http://localhost:6666POST / HTTP/1.1User-Agent: curl/7.21.0 (x86_64-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.15 libssh2/1.2.6Host: localhost:6666Accept: */*Content-Length: 9309Content-Type: application/x-www-form-urlencodedExpect: 100-continue.. -*- mode: rst; coding: cp1251; fill-column: 80 -*-.. rst2html.py README README.html.. contents::

您可能会要求:

-F/--form name=content           (HTTP) This lets curl emulate a filled-in form in              which a user has pressed the submit button. This              causes curl to POST data using the Content- Type              multipart/form-data according to RFC2388. This              enables uploading of binary files etc. To force the              'content' part to be a file, prefix the file name              with an @ sign. To just get the content part from a              file, prefix the file name with the symbol <. The              difference between @ and < is then that @ makes a              file get attached in the post as a file upload,              while the < makes a text field and just get the              contents for that text field from a file.

关于bash - 使用 curl 发布二进制数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9134003/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com