How to post incorrect byte characters such as curl

Asked 2 years ago, Updated 2 years ago, 111 views

I want to test the web app, but I don't know how to post characters like "\xff" as parameters.

Is there any way like this?

curl

2022-09-30 10:28

1 Answers

How about specifying a file containing a parameter string containing an incorrect byte as data?

$echo-e'str=\xff'>invalid_bytes.txt
$ hexdump-Cinvalid_bytes.txt 
000000007374 723d ff0a | str=..|
00000006
$ curl-d@invalid_bytes.txt http://httpbin.org/post
{
  "args": {}, 
  "data":", 
  "files": {}, 
  "form": {
    "str": "\ufffd"
  }, 
  "headers": {
    "Accept": "*/*", 
    "Connection": "close", 
    "Content-Length": "6", 
    "Content-Type": "application/x-www-form-urlencoded", 
    "Host": "httpbin.org", 
    "User-Agent": "curl/7.52.1"
  }, 
  "json"—null, 
  "origin": "xxx.xxx.xxx.xxx", 
  "url": "http://httpbin.org/post"
}

You can also pipe the results of echo.

$echo-e'str=\xff' | curl-d@-http://httpbin.org/post

It's almost the same, but you can also use command replacement.

$curl-d "$(echo-e'str=\xff')"http://httpbin.org/post

Instead of saving it to a file, you can also save it to a variable in the shell.

$DATA=$(echo-e'\xff') curl-d "str=${DATA}" http://httpbin.org/post

ヌル Please note that if you try to send null characters (\x00), they will be treated as string termination in some ways and you will not be able to send them well.(You can tell the difference by running the string as abc\x00abc and so on.)

Reference


2022-09-30 10:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.