I am trying to make a simple NASL script to replicate this simple curl and act on the result:
curl -v -k --silent --cookie “fooCookie” https://fooIP/bar.js
Which works without a problem.
I tried putting up a very simple NASL with:
(...) include("http_func.inc"); include("port_service_func.inc"); display("Starting up"); port = 443; host = http_host_name( port:port ); cookie = "fooCookie"; url = "/bar.js"; req = string( "GET ", url, " HTTP/1.1\r\n", "Host: ", host, "\r\n", "Cookie: ", cookie, "\r\n", "\r\n" ); display("Request: " + req); res = http_send_recv( port:port, data:req ); display("Result: "+ res); (...)
Then run it with:
openvas-nasl -t fooIP -i pathToPlugins thisCustom.nasl -X -T out.log -d --kb=“Ports/tcp/443=1”
And the result is:
:: Starting up
:: Request: GET /bar.js HTTP/1.1
:: set key nvt_debug_misc/ -> #-#http_send_recv(): Using a HTTP/1.1 request without a ‘User-Agent:’ header passed in ‘data’ variable. Adding it automatically to the request.
:: set key HostDetails -> EXIT_CODE
:: set key HostDetails/NVT/(null)/EXIT_CODE -> EXIT_NOTVULN
The result from http_send_recv is always empty. I have tried some different functions but to the same outcome. Couldn’t get much out of the out.log file.
As I have never worked with NASLs I guess this might be a newbie problem.
Thanks in advance