Abuse cURL to communicate with Redis Abuse cURL to communicate with Redis linux linux

Abuse cURL to communicate with Redis


When you want to use curl, you need REST over RESP, like webdis, tinywebdis or turbowebdis. See https://github.com/markuman/tinywebdis#turbowebdis-tinywebdis--cherrywebdis

$ curl -w '\n' http://127.0.0.1:8888/ping{"ping":"PONG"}

Without a REST interface for redis, you can use netcat for example.

$ (printf "PING\r\n";) | nc <redis-host> 6379 +PONG

For password protected redis you can use netcat like this:

$ (printf "AUTH <password>\r\n";) | nc <redis-host> 6379+PONG

With netcat you have to build the RESP protocol by your self. See http://redis.io/topics/protocol

update 2018-01-09

I've build a powerfull bash function which pings the redis instance at any cost over tcp

    function redis-ping() {            # ping a redis server at any cost            redis-cli -h $1 ping 2>/dev/null || \                    echo $((printf "PING\r\n";) | nc $1 6379 2>/dev/null || \                    exec 3<>/dev/tcp/$1/6379 && echo -e "PING\r\n" >&3 && head -c 7 <&3)    }

usage redis-ping localhost


Not curl, but doesn't require a HTTP interface or nc (great for something like a container where you don't have nc installed)

exec 3<>/dev/tcp/127.0.0.1/6379 && echo -e "PING\r\n" >&3 && head -c 7 <&3

Should give you

+PONG

You can read more about what's going on from this fantastic article.


I needed to add a sleep to the nc provided by @Markus to get it to work from a remote system:

(printf "PING\r\n"; sleep 1) | nc remote.redis.hostname 6379

See Request/Response protocols and RTT: Redis Pipelining for details.