Reputation: 1419
I'm trying to create a note on privnote.com from the contents of a file using a simple HTTP request (using cURL). The only information I can find only about this is this nodeJS app, so I'm using it as a reference, but so far with no luck.
This is what I've got so far:
curl -v \
-H "Host: privnote.com" \
-H "Connection: keep-alive" \
-H "Content-Length: 153" \
-H "Origin: https://privnote.com" \
-H "X-Requested-With: XMLHttpRequest" \
-H "User-Agent: privnote-cli/0.1.0 (https://github.com/nonrational/privnote-cli)" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: */*" \
-H "DNT: 1" \
-H "Referer: https://privnote.com/" \
-H "Accept-Encoding: gzip, deflate, br" \
-H "Accept-Language: en-GB,en-US;q=0.8,en;q=0.6" \
-X POST \
--data-binary "@pst-np-v1.pem" \
"https://privnote.com/legacy/"
When I do that request, I get 500 Internal Server Error
. Any ideas on how to get this working?
The end goal is: I'm trying to upload the contents of a file as a note and then fetching the URL all through command line.
Upvotes: 2
Views: 2854
Reputation: 45372
The content needs to be sent in application/x-www-form-urlencoded
with the following parameters :
The data
parameter contains the message encrypted in AES 256 CBC with a 9 character length password
password=siK2TDfjC
data=$(cat pst-np-v1.pem | openssl enc -e -aes-256-cbc -k $password -a -md md5)
curl -v 'https://privnote.com/' \
-H 'X-Requested-With: XMLHttpRequest' \
--data-urlencode "data=$data" \
--data "has_manual_pass=false&duration_hours=0&dont_ask=false&data_type=T¬ify_email=¬ify_ref="
The JSON field note_link
can be extracted using jq
JSON parser and concatenated to #$password
to get the full URI
Full example :
password=siK2TDfjC
message="a not so secret note"
data=$(echo "$message" | openssl enc -e -aes-256-cbc -k $password -a -md md5)
note_link=$(curl -s 'https://privnote.com/' \
-H 'X-Requested-With: XMLHttpRequest' \
--data-urlencode "data=$data" \
--data "has_manual_pass=false&duration_hours=0&dont_ask=false&data_type=T¬ify_email=¬ify_ref=" \
| jq -r --arg arg $password '.note_link + "#" + $arg')
echo "note URL is $note_link"
Upvotes: 3