What is the wget command to submit data to this form? - wget

I am trying to post the name, email address, and message to this page:
http://zenlyzen.com/test1/index.php?main_page=contact_us
using wget. This command:
wget --post-data 'contactname=test&email=a#a.com&enquiry=testmessage' http://www.zenlyzen.com/test1/index.php?main_page=contact_us\&action=send%20method="post"
saves this page:
http://www.zenlyzen.com/wgettest.html
I've poked around with cookies and session cookies, to no avail.
Thanks in advance,
Mark

Using curl :
$ mech-dump --forms 'http://zenlyzen.com/test1/index.php?main_page=contact_us'
(...)
POST http://zenlyzen.com/test1/index.php?main_page=contact_us&action=send&zenid=075b74c66fbc5a701712880eb31f39f3 [contact_us]
securityToken=b48dfdc80002c49fa5f6b07f7dc9be65 (hidden readonly)
contactname= (text)
email= (text)
enquiry= (textarea)
should_be_empty= (text)
<NONAME>=<UNDEF> (image)
(...)
mech-dump command comes with libwww-mechanize-perl under Debian and derivateds.
Finally :
curl -A "Mozilla/5.0" -L -b cookies.txt -c cookies.txt -s -d "contactname=XXX&mail=XXXX&enquiry=XXXX&should_be_empty="
(replace XXX with your inputs). This should work !
You can use LiveHttpHeaders firefox module to see the headers to reproduce.
See man curl to understand all the switches.

Related

Trouble downloading ADYEN report

I'm using this script:
wget -O C:\FlairnetLab\output\x.csv --http-user='[My User]' --http-password='[Password]' --no-check-certificate https://ca-test.adyen.com/reports/download/MerchantAccount/FlairnetECOM/payments_accounting_report_2021_06_10.csv
But i get no file found response. But if i type the url in the browser using the same credential i can download the file.
Can some help me?
The problem is likely to be the encoding of the credentials (both Adyen-generated username and password include several special characters).
An option is to generate the base64-encoded string username: password with a command line (or with an online generator)
# example on Mac
$ echo -n '<username>:<password>' | openssl base64
cmVwb3J0.......5LX4=
then pass it in the Authorization header
# example with wget
wget --header "Authorization: Basic cmVwb3J0.......5LX4=" https://ca-test.adyen.com/reports/download/MerchantAccount/MyMerchantAccount/payments_accounting_report_2021_01_01.csv
# example with curl
curl -H "Authorization: Basic cmVwb3J0.......5LX4=" -X GET https://ca-test.adyen.com/reports/download/MerchantAccount/MyMerchantAccount/payments_accounting_report_2021_01_01.csv

Wget, preventing session log out

I'm trying to crawl a website which needs to be logged in with wget but it stops everytime it finds a logout url (https://example.com/logout/).
I've tried excluding the directories but without success.
This is my command:
wget --content-disposition --header "Cookie: session_cookies" -k -m -r -E -p --level=inf --retry-connrefused -D site.com -X */logout/*,*/settings/* -o log.txt https://example.com/
I've tried with -R option instead of -X but that didn't work.
Can be solved by the keyword "--reject-regex", like this: "--reject-regex logout", see:wget-devTips

Atlassian Confluence : Updating parent container of an attachment

I'd like to move an attachment to a different space (i.e, update the parent container of an attachment in a Confluence page) using Cloud REST API and "curl" command. I looked up REST API endpoint URL and found this:
PUT /rest/api/content/{id}/child/attachment/{attachmentId}
Could somebody provide an example for a correctly constructed JSON input to achieve this? I tried the one below to move an attachment called "test.jpeg" with ID "att000" and current version 5 to parent with ID 1234, but it fails:
curl -v -u 'admin:password' -X PUT -H 'Content-Type:application/json' -d '{"id":"att000","type":"attachment","title":"test.jpeg","version":{"number":5,"minorEdit":false},"ancestors":[{"id":1234}]' -H ‘X-Atlassian-Token:access-token' https://test.atlassian.net/wiki/rest/api/content/170234/child/attachment | python -m json.tool
Given below is the error message
< HTTP/1.1 415 Unsupported Media Type
.
.
.
No JSON object could be decoded
Thank you for your time!
I believe in your curl example you are uploading it under space which is not possible. Attachments in Confluence needs to be under content. Take a look at following example:
curl -v -S -u admin:admin -X POST -H "X-Atlassian-Token: no-check" -F "file=#myfile.txt" -F "comment=this is my file" "http://localhost:8080/confluence/rest/api/content/3604482/child/attachment" | python -mjson.tool
You have to set the container property in the request object.
Specify "container":{"id":"123456","type":"attachment"}
curl -v -u 'admin:password' -X PUT -H 'Content-Type:application/json' -d '{"id":"att000","type":"attachment","title":"test.jpeg","version":{"number":5,"minorEdit":false},"container":{"id":"123456","type":"attachment"}, "ancestors":[{"id":1234}]' -H ‘X-Atlassian-Token:access-token' https://test.atlassian.net/wiki/rest/api/content/170234/child/attachment | python -m json.tool
id => id of the page where attachment is being moved.

How to save Charles session to a file from command line?

I wonder how to save charles session to a file.
Consider following script :
open -ga Charles --args -headless -config charles.xml results.chls
#...some interactions here
pgrep -f Charles | xargs kill
I'm expecting to see something in the results.chls but file is empty....
I figured it out myself. Seems like the only way is enable web control access for Charles and use http like this:
curl --silent -x localhost:8888 http://control.charles/session/export-har -o "${EXPORT_FILE}" > /dev/null

wget -k -p -r exampleserver.com doesn't download images?

Title says it all. I try to download a page with wget -k -p -r and it downloads .html .js and robots.txt only. I need those images as well. They didn't land in my folder. What's wrong? I used same command on another page and it did what i wanted.
Add -H option and it works. -H is for Host
No it does not. It only downloaded a load of crap.