Connecting to ClamAV with curl fails, but clamdscan succeeds

1.5k Views Asked by At

I have a ClamAV installed on a RHEL 8 box. clamd is running, listening on port 3310.
If I run the command 'clamdscan' on the same host, it succeeds.
As per the man page of clamd, I created a text file with clamd commands in it:
PING
VERSION
SHUTDOWN

I then connect to clamd via curl and send this file, using the command below and expecting a response, but it fails:

curl -v -T commands-file ftp://127.0.0.1:3310

I get this output:

*   Trying 127.0.0.1...
* TCP_NODELAY set
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to 127.0.0.1 (127.0.0.1) port 3310 (#0)
  0     0    0     0    0     0      0      0 --:--:--  0:00:30 --:--:--     0< COMMAND READ TIMED OUT
* response reading failed
  0     0    0     0    0     0      0      0 --:--:--  0:00:30 --:--:--     0
* Closing connection 0
curl: (56) response reading failed

So I wonder if clamdscan is doing some magic that I am missing.
Any help would be appreciated.

1

There are 1 best solutions below

0
On

Curl is the wrong tool to use as the ClamAV server is listening on TCP, not on HTTP/HTTPS.
To check connectivity to the ClamAV server, use telnet:

$ telnet clamav-server.my-org.com 3310
>> response will be similar to this:
Trying 192.168.12.13...
Connected to clamav-server.
Escape character is '^]'.    

>> Now type VERSION (all caps) and hit enter.
>> Response will be similar to this:
VERSION
ClamAV 0.103.4/26403/Sun Dec 26 11:19:29 2021
Connection closed by foreign host.