I am attempting to send a POST request to a website's API using the curl command line. I obtained the request headers and body through packet sniffing. After executing the curl command, the response is saved in output.txt. However, upon inspection, the file appears in an unexpected format. The response may be compressed using gzip, deflate, or Brotli based on the headers. I have tried using various commands like brotli, inflate, zcat, and gzip -d to decompress the file, but none have been successful. How can I correctly decompress and view the response in output.txt?
url = https://www.my_site.com/api/register
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.5
Alt-Used: www.my_site.com
Connection: keep-alive
Content-Length: 134
content-type: application/json
Cookie: cf_clearance=uvzZt00yfK5h2O_SEVu2YPNL.5cJT9AnkYJr9YhwhoU-1706709249-1-AUHiOWO+oTJ91OHoTxQWgHVGPNkJF+yqyHbsLFotZWuDb2Uivu/a/ETDZP5fupnkUX6z9mt/+nRhMTEZ7jPmT5c=
Host: www.my_site.com
Origin: https://www.my_site.com
Referer: https://www.my_site.com/?ref=bJsbQYkc
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/115.0
Body:
{"username":"my_phone_no","password":"xGxfUu4ljy9yR8n","captcha":"hF5X","ref":"bJsbQYkc","phone":"my_phone_no","rand":"9142","opt":"hF5X"}
curl -X POST https://www.my_site.com/api/register \
-H "Accept: */*" \
-H "Accept-Encoding: gzip, deflate, br" \
-H "Accept-Language: en-US,en;q=0.5" \
-H "Alt-Used: www.my_site.com" \
-H "Connection: keep-alive" \
-H "Content-Length: 134" \
-H "Content-Type: application/json" \
-H "Cookie: cf_clearance=uvzZt00yfK5h2O_SEVu2YPNL.5cJT9AnkYJr9YhwhoU-1706709249-1-AUHiOWO+oTJ91OHoTxQWgHVGPNkJF+yqyHbsLFotZWuDb2Uivu/a/ETDZP5fupnkUX6z9mt/+nRhMTEZ7jPmT5c=" \
-H "Host: www.supercharles.day" \
-H "Origin: https://www.my_site.com" \
-H "Referer: https://www.my_site.com/?ref=bJsbQYkc" \
-H "Sec-Fetch-Dest: empty" \
-H "Sec-Fetch-Mode: cors" \
-H "Sec-Fetch-Site: same-origin" \
-H "User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/115.0" \
-d '{"username":"my_phone_no","password":"xGxfUu4ljy9yR8n","captcha":"hF5X","ref":"bJsbQYkc","phone":"my_phone_no","rand":"9142","opt":"hF5X"}' \
-o output.txt
┌──(kali㉿localhost)-[~]
└─$ cat output.txt
�#��ړ�Y��>��!S�K�)�*�sQ⚆a)�{��ה��ˑ7���$�|HVJ9.ǫ�p�}9���
Below are commands I tried in process of decompressing the file in output.txt
┌──(kali㉿localhost)-[~]
└─$ brotli -d output.txt
input file [output.txt] suffix mismatch
┌──(kali㉿localhost)-[~]
└─$ inflate output.txt
Usage: inflate [OPTIONS] START END [AMOUNT]
Try 'inflate --help' for help.
Error: Invalid value for 'START': 'output.txt' is not a valid integer.
┌──(kali㉿localhost)-[~]
└─$ zcat output.txt
gzip: output.txt: not in gzip format
┌──(kali㉿localhost)-[~]
└─$ gzip -d output.txt
gzip: output.txt: unknown suffix -- ignored
After executing these commands, the decompressed response should be available in the newly created output.txt. This solved the issue for me, and I hope it helps others facing a similar problem.