卷曲二进制数据发布 [英] Binary Data Posting with curl
问题描述
所以基本上,我试图写一系列的脚本与斑点网核弹进行交互。我一直在分析流量,现在可以登录并做一些基本的任务。不过,我从来没有处理,卷曲的二进制文件上传。会有人愿意看这帮助我吗?这里的请求解剖:
下面是我已经得到了卷曲至今:
编辑:对于懒惰 -
的文件的长度,实现与存储在长度的
废话只是一个复制/带参数请求URL粘贴,减去URL本身。
卷曲-L --cookie〜/ --data的.cms二进制@ background.jpg\\
--header内容长度:$长度\\
--header内容处置:表格数据\\
--headerNAME = \\RadFileExplorer1_upload1file0 \\\\
--header内容类型:image / JPG\\
--header文件名= \\background.jpg \\\\
--data $ BULLSHIT \\
--referer养-秘密\\
养-秘密
您不需要的 - 头的Content-Length:$长度。
查找例如,对于谷歌的例子:
<一个href=\"http://$c$c.google.com/apis/gdata/articles/using_cURL.html#creating-entries\">http://$c$c.google.com/apis/gdata/articles/using_cURL.html#creating-entries
卷曲--request POST --data二进制@ template_entry.xml$网址
请注意,GET请求不支持数据传输。
还记得POST请求有2个不同的编码模式。这是第一种形式:
$ NC -l -p 6666&
$卷曲--request POST --data二进制@README的http://本地主机:6666POST / HTTP / 1.1
用户代理:卷曲/ 7.21.0下(x86_64-PC-Linux的GNU)的libcurl / 7.21.0的OpenSSL / 0.9.8o zlib的/的libidn 1.2.3.4 / 1.15 libssh2 / 1.2.6
主机:本地主机:6666
接受:* / *
内容长度:9309
内容类型:应用程序/ x-WWW的形式urlen codeD
期望:100-继续.. - * - 模式:第一个;编码:CP1251;填充柱:80 - * -
.. rst2html.py自述的README.html
..内容::
您可能请求该信息:
-F / - 表单名称=内容
(HTTP)这让卷曲模拟在填写的表格
用户有权pressed提交按钮。这个
使卷曲使用内容类型POST数据
根据RFC2388的multipart / form-data的。这个
启用对二进制文件等上传到强制
内容部分是一个文件,preFIX文件名
以@符号。以刚刚得到的内容部分从
文件,preFIX与符号的文件名。该
区别@是那么@使得
文件中获得附加在后作为一个文件上传,
而让一个文本字段和刚刚获得的
内容从一个文件中的文本字段。
So basically, I'm trying to write a series of scripts to interact with Dot Net Nuke. I've been analysing the traffic and can now login and do some basic tasks. However, I've never handled binary file upload with curl. Would someone be willing to look at this to help me out? Here's the anatomy of the request:
Here's what I've got for curl so far:
edit: For the lazy -
length of the file is achieved and stored in LENGTH Bullshit is just a copy/paste of the request URL with parameters, minus the URL itself.
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 $BULLSHIT \
--referer "Kept-Secret" \
"Kept-Secret"
You don't need --header "Content-Length: $LENGTH".
Look for example for Google example:
http://code.google.com/apis/gdata/articles/using_cURL.html#creating-entries
curl --request POST --data-binary "@template_entry.xml" $URL
Note that GET request does not support data transferring.
Also remember that POST request have 2 different coding schema. This is first form:
$ nc -l -p 6666 & $ curl --request POST --data-binary "@README" http://localhost:6666 POST / HTTP/1.1 User-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.6 Host: localhost:6666 Accept: */* Content-Length: 9309 Content-Type: application/x-www-form-urlencoded Expect: 100-continue .. -*- mode: rst; coding: cp1251; fill-column: 80 -*- .. rst2html.py README README.html .. contents::
You probably request this:
-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.
这篇关于卷曲二进制数据发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!