Подтвердить что ты не робот

Проводка двоичных данных с завитком

В общем, я пытаюсь написать серию сценариев для взаимодействия с Dot Net Nuke. Я анализировал трафик и теперь могу войти в систему и выполнить некоторые основные задачи. Однако я никогда не занимался загрузкой двоичных файлов с помощью curl. Кто-нибудь захочет посмотреть на это, чтобы выручить меня? Вот анатомия запроса:

http://pastebin.com/qU8ZEMaQ

Вот что у меня есть для кудряшки:

http://pastebin.com/LG2ubFZG

редактировать: для ленивых -

длина файла достигается и сохраняется в ДЛИНЕ
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"
4b9b3361

Ответ 1

Вам не нужно --header "Длина содержимого: $ ДЛИНА".

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

Обратите внимание, что запрос GET не поддерживает широкое содержание контента.

Также помните, что запрос POST имеет 2 разные схемы кодирования. Это первая форма:

  $ 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::

Вы, вероятно, запрашиваете это:

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