cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: How do I post a file from command line

From: Doug McNutt <douglist_at_macnauchtan.com>
Date: Thu, 23 Apr 2009 09:30:19 -0600

At 08:43 +0100 4/23/09, David Hounsome wrote:
>When I started work on this nightmare of a problem, the first thing I
>did was to use WireShark to intercept the communication between
>browser and target hardware. It was the result of this that made me
>think this would be possible.

I do believe that it's possible. I'm injecting some comments into a trimmed version of the activity log.

>POST /tcf HTTP/1.1
>Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
>application/x-shockwave-flash, */*

That shockwave reference scared the hell out of me but the line was split and that's just IE . What I know about IE and Windows would fit on my thumbnail with a magic marker.

>Referer: http://10.90.4.41/tcf?cgi=showdoc&tab=Save/Load&file=config.htm

You might need that line. In curl it would be the -A option in curl.

>Accept-Language: en-gb
>Content-Type: multipart/form-data;
>boundary=---------------------------7d92fd0a04d4
>Accept-Encoding: gzip, deflate
>User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
>.NET CLR 2.0.50727)
>Host: 10.90.4.41
>Content-Length: 7542
>Connection: Keep-Alive
>Cache-Control: no-cache

You should send back the cookie. curl -b

You might also try curl-ing the box with the -D option set to a file which will receive headers sent back. It's likely the cookie will appear there. If not it's getting set by JavaScript which curl doesn't do.

>Cookie: Status=http%3A//10.90.4.41/tcf%3Fcgi%3Dshow%26%24path%3D/Status
>

The next lines are the hidden form items I mentioned. You can use curl's -F option or you can add them to the URL using the & to extend the URL, The 12 hex digit values don't make sense to me.

>-----------------------------7d92fd0a04d4
>Content-Disposition: form-data; name="cgi"
>dcp
>-----------------------------7d92fd0a04d4
>Content-Disposition: form-data; name="method"
>set
>-----------------------------7d92fd0a04d4
>Content-Disposition: form-data; name="path"
>/
>-----------------------------7d92fd0a04d4
>Content-Disposition: form-data; name="content"
>text/html
>-----------------------------7d92fd0a04d4

I believe what you tried with the -F and the 2 option will pass your xml file but C:\ means nothing to me.

Below here is the start of stuff sent back by the box. I really worry about the 6 separate javascripts that it expects the browser to load and possibly execute. curl is not going to do that for you. If they are actually used in the form processing you'll have to divine what they do and hopefully just create equivalent names, values, and cookies that, hopefully, won't change.

>HTTP/1.0 200 OK
>Content-type: text/html
>Server :Tandberg Television Web server
>
><?xml version="1.0" encoding="UTF-8"?>
><!-- TANDBERG Television DCP -->
><dcpDoc ver="1.0"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
>"http://www.w3.org/TR/html4/strict.dtd">
><html>
><head>
><title>DCP status</title>
><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
><meta http-equiv="Pragma" CONTENT="no-cache">
><link rel="stylesheet" href="tcf?cgi=url&file=XPOstyles.css" type="text/css">
><script language="JavaScript1.2" src="tcf?cgi=url&file=mouse.js"></script>
><script language="Javascript" src="tcf?cgi=url&file=tcheck.js"></script>
><script language="JavaScript" src="tcf?cgi=url&file=TCFparam.js"></script>
><script language="JavaScript" src="tcf?cgi=url&file=XPObase.js"></script>
><script language="JavaScript" src="tcf?cgi=url&file=XPOform.js"></script>
><script language="JavaScript" src="tcf?cgi=url&file=XPOobjects.js"></script>
></head>
><body>
><style type="text/css">
>body {margin-left:0px; margin-right:0px; margin-top:0px; margin-bottom:0px;}
></style><script language="JavaScript">
> function clearResult()
> {
> self.location.href = 'tcf?cgi=emptyresult';
> }
></script>
><table class="result" width="100%" border="0">
><tr class="head">
><td class="ok" valign="middle" noWrap colspan="2">
><p>Result: SUCCESS</p></td>
></tr>
><tr class="subtitle">
><td>
><p>Type</p>
></td>
><td>
><p>Description</p>
></td>
></tr>
><tr class="alt1">
><td>
><p class="note">Note</p>
></td>
><td>
><p>Transaction performed (6863 bytes received)</p>
></td>
></tr>
></table>
></body>
></html>
></dcpDoc>
>-------------------------------------------------------------------

-- 
--> From the U S of A, the only socialist country that refuses to admit it. <--
-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2009-04-23