convert
writes to a different image file. To overwrite original image files use mogrify
.
Single file:
mogrify -resize 50% Pic.jpg
All .jpg
files:
mogrify -resize 50% *.jpg
Seems like you following a tutorial or book and this is a cheeky way to test if you got the basics down.
Calling http://103.200.7.150:7777/ via curl or browser yields the following output:
Please send me request method GET and POST with params "gimmeflag" and value "please"
Let's break it down into two parts since you want to know how its done with curl
(see man 1 curl
or the curl manual).
Using GET to send your request:
This one is pretty easy if you know how a query-string
looks like.
On the World Wide Web, a query string is the part of a uniform resource locator (URL) containing data that does not fit conveniently into a hierarchical path structure. The query string commonly includes fields added to a base URL by a Web browser or other client application, for example as part of an HTML form.
A web server can handle a Hypertext Transfer Protocol request either by reading a file from its file system based on the URL path or by handling the request using logic that is specific to the type of resource. In cases where special logic is invoked, the query string will be available to that logic for use in its processing, along with the path component of the URL.(source)
You want to send a parameter gimmeflag
and a value please
. So the line you want to request with curl
is :
curl -X GET http://103.200.7.150:7777/?gimmeflag=please
The result you get back from the server:
KSL{n0w_y0u_Know_How_To
Using POST to send your request:
Given the GET line the POST is pretty easy too just replace GET by POST:
curl -X POST http://103.200.7.150:7777/?gimmeflag=please
The result you get back from the server:
_S3nD_r3quesT_Meth0d_GET_AND_POST}
To conclude this:
# Thanks to @pa4080 for this line
printf '%s%s\n' \
"$(curl -X GET http://103.200.7.150:7777/?gimmeflag=please 2>/dev/null)" \
"$(curl -X POST http://103.200.7.150:7777/?gimmeflag=please 2>/dev/null)"
KSL{n0w_y0u_Know_How_To_S3nD_r3quesT_Meth0d_GET_AND_POST}
Best Answer
Bash doesn't expand in single quotes.
'{"image" : $( base64 ~/Pictures/1.jpg )}'
gets sent as-is. Instead, try:(Exit the opening quote before doing command substitution then open a quote again.)