18#include <gvm/util/mqtt.h>
19#include <gvm/util/nvticache.h>
30#define CERT_FILE "SSL certificate : "
31#define KEY_FILE "SSL private key : "
32#define PEM_PASS "PEM password : "
33#define CA_FILE "CA file : "
34#define CNX_TIMEOUT_PREF "Network connection timeout : "
35#define RW_TIMEOUT_PREF "Network read/write timeout : "
36#define WRAP_TIMEOUT_PREF "Wrapped service read timeout : "
37#define TEST_SSL_PREF "Test SSL based services"
39#define NUM_CHILDREN "Number of connections done in parallel : "
42#define TLS_PRIME_UNACCEPTABLE -2
43#define TLS_FATAL_ALERT -3
49#define G_LOG_DOMAIN "lib nasl"
59 snprintf (k,
sizeof (k),
"Services/%s", proto);
75 snprintf (k,
sizeof (k),
"Known/tcp/%d", port);
93 if (regcomp (&re, pattern, REG_EXTENDED | REG_NOSUB | REG_ICASE))
95 if (regexec (&re,
string, 0, NULL, 0))
106 post_log (
oid, desc, port,
"Chargen is running on this port");
113 post_log (
oid, desc, port,
"An echo server is running on this port");
123 snprintf (ban,
sizeof (ban),
"http-rpc-epmap/banner/%d", port);
129 snprintf (ban,
sizeof (ban),
"ncacn_http/banner/%d", port);
139 snprintf (ban,
sizeof (ban),
"vnc/banner/%d", port);
148 snprintf (ban,
sizeof (ban),
"nntp/banner/%d", port);
150 snprintf (ban,
sizeof (ban),
"An NNTP server is running on this port%s",
172 snprintf (ban,
sizeof (ban),
"A mldonkey server is running on this port");
182 snprintf (ban,
sizeof (ban),
"www/banner/%d", port);
184 snprintf (ban,
sizeof (ban),
"A web server is running on this port%s",
191 unsigned char *buffer,
int trp)
195 snprintf (ban,
sizeof (ban),
"AdSubtract/banner/%d", port);
197 snprintf (ban,
sizeof (ban),
198 "A (locked) AdSubtract server is running on this port%s",
207 post_log (
oid, desc, port,
"A gopher server is running on this port");
215 snprintf (ban,
sizeof (ban),
"realserver/banner/%d", port);
218 snprintf (ban,
sizeof (ban),
"A RealMedia server is running on this port%s",
228 snprintf (ban,
sizeof (ban),
"smtp/banner/%d", port);
231 if (strstr (buffer,
" postfix"))
235 char *report = g_malloc0 (255 + strlen (buffer));
236 char *t = strchr (buffer,
'\n');
239 snprintf (report, 255 + strlen (buffer),
240 "An SMTP server is running on this port%s\n\
241Here is its banner : \n%s",
251 char ban[512], *report, *t;
253 snprintf (ban,
sizeof (ban),
"snpp/banner/%d", port);
256 report = g_malloc0 (255 + strlen (buffer));
257 t = strchr (buffer,
'\n');
260 snprintf (report, 255 + strlen (buffer),
261 "An SNPP server is running on this port%s\n\
262Here is its banner : \n%s",
277 snprintf (ban,
sizeof (ban),
"ftp/banner/%d", port);
282 char *report = g_malloc0 (255 + strlen (buffer));
283 char *t = strchr (buffer,
'\n');
286 snprintf (report, 255 + strlen (buffer),
287 "An FTP server is running on this port%s.\n\
288Here is its banner : \n%s",
296 snprintf (report,
sizeof (report),
297 "An FTP server is running on this port%s.",
307 while ((buffer[strlen (buffer) - 1] ==
'\n')
308 || (buffer[strlen (buffer) - 1] ==
'\r'))
309 buffer[strlen (buffer) - 1] =
'\0';
310 post_log (
oid, desc, port,
"An ssh server is running on this port");
319 snprintf (ban,
sizeof (ban),
"An HTTP proxy is running on this port%s",
327 char *c = strchr (buffer,
'\n');
334 buffer2 = g_strdup (buffer);
335 for (i = 0; i < strlen (buffer2); i++)
336 buffer2[i] = tolower (buffer2[i]);
337 if (!strcmp (buffer2,
"+ok"))
340 snprintf (ban,
sizeof (ban),
"pop1/banner/%d", port);
343 else if (strstr (buffer2,
"pop2"))
346 snprintf (ban,
sizeof (ban),
"pop2/banner/%d", port);
348 post_log (
oid, desc, port,
"a pop2 server is running on this port");
353 snprintf (ban,
sizeof (ban),
"pop3/banner/%d", port);
355 post_log (
oid, desc, port,
"A pop3 server is running on this port");
365 snprintf (ban,
sizeof (ban),
"imap/banner/%d", port);
368 snprintf (ban,
sizeof (ban),
"An IMAP server is running on this port%s",
378 post_log (
oid, desc, port,
"An identd server is running on this port");
390 post_log (
oid, desc, port,
"A PostgreSQL server is running on this port");
398 "A Sphinx search server (MySQL listener) "
399 "seems to be running on this port");
407 post_log (
oid, desc, port,
"A MySQL server is running on this port");
415 post_log (
oid, desc, port,
"A CVS pserver server is running on this port");
422 post_log (
oid, desc, port,
"A CVSup server is running on this port");
430 post_log (
oid, desc, port,
"A CVSLock server server is running on this port");
437 post_log (
oid, desc, port,
"A rsync server is running on this port");
447 "A shell seems to be running on this port ! (this is a possible backdoor)",
457 snprintf (ban,
sizeof (ban),
458 "A telnet server seems to be running on this port%s",
470 snprintf (ban,
sizeof (ban),
471 "A Gnome 1.4 server seems to be running on this port%s",
485 "An eggdrop IRC bot seems to be running a control server on this port%s",
495 post_alarm (
oid, desc, port,
"NetBus is running on this port", NULL);
503 snprintf (ban,
sizeof (ban),
"linuxconf/banner/%d", port);
505 post_log (
oid, desc, port,
"Linuxconf is running on this port");
515 snprintf (tmp,
sizeof (tmp),
516 "A finger server seems to be running on this port%s",
527 snprintf (tmp,
sizeof (tmp),
"vtun/banner/%d", port);
534 snprintf (tmp,
sizeof (tmp),
535 "A VTUN server seems to be running on this port%s",
539 snprintf (tmp,
sizeof (tmp),
540 "A VTUN server seems to be running on this port%s\n"
541 "Here is its banner:\n%s\n",
553 snprintf (tmp,
sizeof (tmp),
"uucp/banner/%d", port);
558 snprintf (tmp,
sizeof (tmp),
559 "An UUCP server seems to be running on this port%s",
570 snprintf (tmp,
sizeof (tmp),
571 "A LPD server seems to be running on this port%s",
583 snprintf (tmp,
sizeof (tmp),
584 "A LysKOM server seems to be running on this port%s",
596 snprintf (tmp,
sizeof (tmp),
"A PH server seems to be running on this port%s",
607 snprintf (tmp,
sizeof (tmp),
608 "A time server seems to be running on this port%s",
619 snprintf (tmp,
sizeof (tmp),
620 "An iPlanet ENS (Event Notification Server) seems to be running on "
632 snprintf (tmp,
sizeof (tmp),
633 "a Citrix server seems to be running on this port%s",
644 snprintf (tmp,
sizeof (tmp),
645 "A GIOP-enabled service is running on this port%s",
658 snprintf (ban,
sizeof (ban),
"exchg-routing/banner/%d", port);
661 snprintf (ban,
sizeof (ban),
662 "A Microsoft Exchange routing server is running on this port%s",
674 snprintf (msg,
sizeof (msg),
675 "A tcpmux server seems to be running on this port%s",
686 snprintf (msg,
sizeof (msg),
687 "A BitTorrent server seems to be running on this port%s",
698 snprintf (msg,
sizeof (msg),
699 "A SNMP Multiplexer (smux) seems to be running on this port%s",
715 snprintf (tmp,
sizeof (tmp),
"A LISa daemon is running on this port%s",
731 post_log (
oid, desc, port,
"A MSDTC server is running on this port");
739 snprintf (ban,
sizeof (ban),
"pop3pw/banner/%d", port);
741 snprintf (ban,
sizeof (ban),
"A pop3pw server is running on this port%s",
766 snprintf (ban,
sizeof (ban),
"whois++/banner/%d", port);
768 snprintf (ban,
sizeof (ban),
"A whois++ server is running on this port%s",
787 snprintf (ban,
sizeof (ban),
"mon/banner/%d", port);
789 snprintf (ban,
sizeof (ban),
"A mon server is running on this port%s",
800 snprintf (ban,
sizeof (ban),
801 "A CheckPoint FW1 SecureRemote or FW1 FWModule server is running "
823 snprintf (ban,
sizeof (ban),
"A PsyBNC IRC proxy is running on this port%s",
842 snprintf (ban,
sizeof (ban),
"A shoutcast server is running on this port%s",
861 "An AdsGone (a popup banner blocking server) is running on this port%s",
889 snprintf (ban,
sizeof (ban),
"acap/banner/%d", port);
892 snprintf (ban,
sizeof (ban),
"An ACAP server is running on this port%s",
917 snprintf (ban,
sizeof (ban),
"A nagiosd server is running on this port%s",
934 snprintf (ban,
sizeof (ban),
"A teamspeak2 server is running on this port%s",
958 snprintf (ban,
sizeof (ban),
"A WEBSM server is running on this port%s",
972 snprintf (ban,
sizeof (ban),
973 "An OFA/Express server is running on this port%s",
989 snprintf (ban,
sizeof (ban),
990 "A SuSE Meta pppd server is running on this port%s",
1007 snprintf (ban,
sizeof (ban),
1008 "An upsd/upsmon server is running on this port%s",
1026 snprintf (ban,
sizeof (ban),
"The Sub7 trojan is running on this port%s",
1043 snprintf (ban,
sizeof (ban),
1044 "a spamd server (part of spamassassin) is running on this port%s",
1055 snprintf (ban,
sizeof (ban),
1056 "a quicktime streaming server is running on this port%s",
1067 snprintf (ban,
sizeof (ban),
"a dameware server is running on this port%s",
1077 snprintf (ban,
sizeof (ban),
1078 "a StoneGate authentication server is running on this port%s",
1089 snprintf (ban,
sizeof (ban),
1090 "A LISTSERV daemon seems to be running on this port%s",
1102 snprintf (ban,
sizeof (ban),
1103 "A FsSniffer backdoor seems to be running on this port%s",
1115 snprintf (ban,
sizeof (ban),
1116 "A RemoteNC backdoor seems to be running on this port%s",
1129 snprintf (msg,
sizeof (msg),
1130 "The service closed the connection after %d seconds "
1131 "without sending any data\n"
1132 "It might be protected by some TCP wrapper\n",
1186 return "Http-Rpc-Epmap";
1198 return "Compaq Management Server";
1200 return "CVSpserver";
1217 const unsigned char *banner,
int trp)
1219 char tmp[1600], *norm = NULL;
1223 snprintf (tmp,
sizeof (tmp),
"unknown/banner/%d", port);
1230 snprintf (tmp,
sizeof (tmp),
1231 "An unknown service is running on this port%s.\n"
1232 "It is usually reserved for %s",
1243 post_log (
oid, desc, port,
"gnuserv is running on this port");
1250 post_log (
oid, desc, port,
"ISS RealSecure is running on this port");
1260 snprintf (ban,
sizeof (ban),
1261 "A VMWare authentication daemon is running on this port%s:\n%s",
1274 snprintf (ban,
sizeof (ban),
1275 "An interscan viruswall is running on this port%s:\n%s",
1287 snprintf (ban,
sizeof (ban),
"A PPP daemon is running on this port%s",
1298 snprintf (ban,
sizeof (ban),
"zebra/banner/%d", port);
1300 snprintf (ban,
sizeof (ban),
1301 "A zebra daemon (bgpd or zebrad) is running on this port%s",
1313 snprintf (ban,
sizeof (ban),
1314 "An IRCXPro administrative server is running on this port%s",
1326 snprintf (ban,
sizeof (ban),
1327 "A gnocatan game server is running on this port%s",
1341 snprintf (ban,
sizeof (ban),
1342 "A PowerBroker master server is running on this port%s:\n%s",
1355 snprintf (ban,
sizeof (ban),
"A dictd server is running on this port%s:\n%s",
1368 snprintf (ban,
sizeof (ban),
1369 "A Netsaint plugin (pNSClient.exe) is running on this port%s",
1381 snprintf (ban,
sizeof (ban),
"VeritasNetBackup is running on this port%s",
1394 snprintf (ban,
sizeof (ban),
1395 "A PowerBroker locald server is running on this port%s:\n%s",
1405 snprintf (ban,
sizeof (ban),
1406 "jabber daemon seems to be running on this port%s",
1419 snprintf (ban,
sizeof (ban),
1420 "An avotus 'mm' server is running on this port%s:\n%s",
1430 snprintf (str,
sizeof (str),
"socks%d", ver);
1432 snprintf (str,
sizeof (str),
"A SOCKS%d proxy is running on this port. ",
1443 snprintf (str,
sizeof (str),
"A Direct Connect Hub is running on this port%s",
1452 post_log (
oid, desc, port,
"A MongoDB server is running on this port");
1465#define MAX_SHIFT (3 * 365 * 86400)
1466#define DIFF_1970_1900 2208988800U
1472#define ABS(x) (((x) < 0) ? -(x) : (x))
1474 time_t now = time (NULL);
1485 int timeout,
int *trp)
1487 const char *p =
"NORMAL:+ARCFOUR-128:%COMPAT";
1488 const char *lp =
"LEGACY:%COMPAT:%UNSAFE_RENEGOTIATION";
1503 g_debug (
"%s: NO_PRIORITY_FLAGS failed, retrying with "
1504 "INSECURE_DH_PRIME_BITS",
1515 g_debug (
"%s: %s failed, retrying with %s", __func__, p, lp);
1530 g_debug (
"%s: unable to establish a TLS connection to %s; falling "
1531 "back to unencrypted connection",
1544 char *head =
"Ports/tcp/", *host_fqdn;
1545 u_short unknown[65535];
1546 int num_unknown = 0;
1547 size_t len_head = strlen (head);
1549 int rw_timeout = 20, cnx_timeout = 20, wrap_timeout = 20;
1560 http_get = g_strdup_printf (
"GET / HTTP/1.0\r\nHost: %s\r\n\r\n", host_fqdn);
1563 if (rw_timeout_s != NULL && (x = atoi (rw_timeout_s)) > 0)
1565 if (cnx_timeout_s != NULL && (x = atoi (cnx_timeout_s)) > 0)
1567 if (wrap_timeout_s != NULL && (x = atoi (wrap_timeout_s)) >= 0)
1570 bzero (unknown,
sizeof (unknown));
1574 if ((strlen (h->data) > len_head) && !strncmp (h->data, head, len_head))
1581 unsigned char *banner = NULL, *bannerHex = NULL;
1582 size_t banner_len, i;
1583 int port = atoi ((
const char *) h->data + len_head);
1585 int unindentified_service = 0;
1586 int three_digits = 0;
1587 int maybe_wrapped = 0;
1591 int diff_tv = 0, diff_tv2 = 0;
1592 int type, no_banner_grabbed = 0;
1594#define DIFFTV1000(t1, t2) \
1595 ((t1.tv_sec - t2.tv_sec) * 1000 + (t1.tv_usec - t2.tv_usec) / 1000)
1597 bzero (buffer,
sizeof (buffer));
1599 snprintf (kb,
sizeof (kb),
"BannerHex/%d", port);
1601 if (type ==
ARG_STRING && bannerHex != NULL && bannerHex[0] !=
'\0')
1605 banner_len = strlen ((
char *) bannerHex) / 2;
1606 if (banner_len >=
sizeof (buffer))
1607 banner_len =
sizeof (buffer) - 1;
1608 for (j = 0; j < banner_len; j++)
1610 c1 = bannerHex[2 * j];
1611 if (c1 >= 0 && c1 <= 9)
1613 else if (c1 >=
'a' && c1 <=
'f')
1615 else if (c1 >=
'A' && c1 <=
'F')
1619 c2 = bannerHex[2 * j + 1];
1620 if (c2 >= 0 && c2 <= 9)
1622 else if (c2 >=
'a' && c2 <=
'f')
1624 else if (c2 >=
'A' && c2 <=
'F')
1628 buffer[j] = c1 << 4 | c2;
1632 banner = (
unsigned char *) buffer;
1635 if (banner_len == 0)
1637 snprintf (kb,
sizeof (kb),
"Banner/%d", port);
1640 banner_len = strlen ((
char *) banner);
1654 gettimeofday (&tv1, NULL);
1657 gettimeofday (&tv2, NULL);
1661 if (cnx >= 0 || banner_len > 0)
1663 int line_len, realfd = -1;
1669 snprintf (k,
sizeof (k),
"FindService/CnxTime1000/%d", port);
1671 GSIZE_TO_POINTER (diff_tv));
1672 snprintf (k,
sizeof (k),
"FindService/CnxTime/%d", port);
1675 GSIZE_TO_POINTER (((diff_tv + 500) / 1000)));
1676 if (diff_tv / 1000 > cnx_timeout)
1678 GSIZE_TO_POINTER (1));
1686 snprintf (report,
sizeof (report),
1687 "A %s server answered on this port\n",
1691 GSIZE_TO_POINTER (port));
1699 if (banner != (
unsigned char *) buffer)
1701 if (
len >=
sizeof (buffer))
1702 len =
sizeof (buffer) - 1;
1703 memcpy (buffer, banner,
len);
1709 snprintf (kb,
sizeof (kb),
"/tmp/NoBanner/%d", port);
1714 no_banner_grabbed = GPOINTER_TO_SIZE (p);
1716 no_banner_grabbed = atoi ((
char *) p);
1720 if (!no_banner_grabbed)
1728 FD_SET (realfd, &rfds);
1729 FD_SET (realfd, &wfds);
1731 (void) gettimeofday (&tv1, NULL);
1733 tv.tv_sec = rw_timeout;
1734 x = select (realfd + 1, &rfds, &wfds, NULL, &tv);
1745 if (FD_ISSET (realfd, &rfds))
1748 cnx, buffer, 1,
sizeof (buffer) - 2);
1751 (void) gettimeofday (&tv2, NULL);
1762 if (
len <= 0 && !timeout)
1767 (void) gettimeofday (&tv1, NULL);
1769 buffer[
sizeof (buffer) - 1] =
'\0';
1771 sizeof (buffer) - 1);
1779 && strncmp (buffer,
"HTTP/1.",
len) == 0)
1782 cnx, buffer +
len,
sizeof (buffer) - 1 -
len);
1787 (void) gettimeofday (&tv2, NULL);
1792 snprintf (k,
sizeof (k),
"FindService/RwTime1000/%d",
1795 GSIZE_TO_POINTER (diff_tv));
1796 snprintf (k,
sizeof (k),
"FindService/RwTime/%d", port);
1799 GSIZE_TO_POINTER ((diff_tv + 500) / 1000));
1800 if (diff_tv / 1000 > rw_timeout)
1802 GSIZE_TO_POINTER (1));
1809 banner = g_malloc0 (
len + 1);
1810 memcpy (banner, buffer,
len);
1813 for (i = 0; i <
len; i++)
1814 buffer[i] = (buffer[i] ==
'\0') ?
'x' : tolower (buffer[i]);
1816 line = g_strdup (buffer);
1818 t = strchr (line,
'\n');
1821 if (isdigit (banner[0]) && isdigit (banner[1])
1822 && isdigit (banner[2])
1823 && (banner[3] ==
'\0' || isspace (banner[3])
1824 || banner[3] ==
'-'))
1831 GSIZE_TO_POINTER (port));
1842 snprintf (kb,
sizeof (kb),
"FindService/tcp/%d/get_http",
1845 snprintf (kb,
sizeof (kb),
"FindService/tcp/%d/spontaneous",
1850 char buf2[
sizeof (buffer) * 2 + 1];
1856 if (
len >=
sizeof (buffer))
1857 len =
sizeof (buffer);
1859 for (y = 0; y <
len; y++)
1861 snprintf (buf2 + 2 * y,
sizeof (buf2) - (2 * y),
"%02x",
1862 (
unsigned char) banner[y]);
1863 if (banner[y] ==
'\0')
1871 origline = g_strdup ((
char *) banner);
1872 t = strchr (origline,
'\n');
1875 line_len = strlen (origline);
1881 if ((!strncmp (line,
"http/1.", 7)
1882 || strstr ((
char *) banner,
1883 "<title>Not supported</title>")))
1888 && (strstr (line,
"http/1.1 400 bad request")
1890 && !(strncmp (line,
"http/1.0 403 forbidden",
1891 strlen (
"http/1.0 403 forbidden"))
1893 && strstr (buffer,
"server: adsubtract") != NULL)
1896 "it looks like you are trying to access "
1897 "mongodb over http on the native driver port.")
1899 && strstr (buffer,
"content-length: 84")
1907 if (((u_char) buffer[0] == 255)
1908 && (((u_char) buffer[1] == 251)
1909 || ((u_char) buffer[1] == 252)
1910 || ((u_char) buffer[1] == 253)
1911 || ((u_char) buffer[1] == 254)))
1913 else if (((u_char) buffer[0] == 0)
1914 && ((u_char) buffer[1] == 1)
1915 && ((u_char) buffer[2] == 1)
1916 && ((u_char) buffer[3] == 0))
1918 else if (strncmp (line,
"http/1.0 403 forbidden",
1919 strlen (
"http/1.0 403 forbidden"))
1921 && strstr (buffer,
"server: adsubtract") != NULL)
1925 else if (strstr ((
char *) banner,
"Eggdrop") != NULL
1926 && strstr ((
char *) banner,
"Eggheads") != NULL)
1928 else if (strncmp (line,
"$lock ", strlen (
"$lock ")) == 0)
1930 else if (
len > 34 && strstr (&(buffer[34]),
"iss ecnra"))
1932 else if (
len == 4 && origline[0] ==
'Q' && origline[1] == 0
1933 && origline[2] == 0 && origline[3] == 0)
1934 mark_fw1 (desc, port, origline, trp);
1935 else if (strstr (line,
"adsgone blocked html ad") != NULL)
1937 else if (strncmp (line,
"icy 200 ok", strlen (
"icy 200 ok"))
1940 else if ((!strncmp (line,
"200", 3)
1942 "running eudora internet mail server")))
1943 || (strstr (line,
"+ok applepasswordserver")
1946 else if ((strstr (line,
"smtp")
1947 || strstr (line,
"simple mail transfer")
1948 || strstr (line,
"mail server")
1949 || strstr (line,
"messaging")
1950 || strstr (line,
"Weasel"))
1951 && !strncmp (line,
"220", 3))
1953 else if (strstr (line,
"220 ***************")
1954 || strstr (line,
"220 eSafe@"))
1957 else if (strstr (line,
"220 esafealert") != NULL)
1959 else if (strncmp (line,
"220", 3) == 0
1960 && strstr (line,
"groupwise internet agent") != NULL)
1962 else if (strncmp (line,
"220", 3) == 0
1963 && strstr (line,
" SNPP ") != NULL)
1965 else if (strncmp (line,
"200", 3) == 0
1966 && strstr (line,
"mail ") != NULL)
1968 else if (strncmp (line,
"421", 3) == 0
1969 && strstr (line,
"smtp ") != NULL)
1972 else if ((line[0] !=
'\0'
1973 || (strstr (buffer,
"mysql") != NULL))
1976 "^.x{3}\n[0-9.]+ [0-9a-z]+@[0-9a-z]+ release")
1978 buffer,
"^.x{3}\n[0-9.]+-(id[0-9]+-)?release"
1979 " \\([0-9a-z-]+\\)")))
1981 else if (line[0] !=
'\0'
1982 && ((strncmp (buffer + 1,
"host '", 6) == 0)
1983 || (strstr (buffer,
"mysql") != NULL
1984 || strstr (buffer,
"mariadb") != NULL)))
1986 else if (!strncmp (line,
"efatal", 6)
1987 || !strncmp (line,
"einvalid packet length",
1988 strlen (
"einvalid packet length")))
1990 else if (strstr (line,
"cvsup server ready") != NULL)
1992 else if (!strncmp (line,
"cvs [pserver aborted]:", 22)
1993 || !strncmp (line,
"cvs [server aborted]:", 21))
1995 else if (!strncmp (line,
"cvslock ", 8))
1997 else if (!strncmp (line,
"@rsyncd", 7))
2001 else if (strstr (buffer,
"rmserver")
2002 || strstr (buffer,
"realserver"))
2004 else if ((strstr (line,
"ftp") || strstr (line,
"winsock")
2005 || strstr (line,
"axis network camera")
2006 || strstr (line,
"netpresenz")
2007 || strstr (line,
"serv-u")
2008 || strstr (line,
"service ready for new user"))
2009 && !strncmp (line,
"220", 3))
2011 else if (strncmp (line,
"220-", 4) == 0)
2014 else if (strstr (line,
"220") && strstr (line,
"whois+"))
2016 else if (strstr (line,
"520 command could not be executed"))
2018 else if (strstr (line,
"ssh-"))
2020 else if (!strncmp (line,
"+ok", 3)
2021 || (!strncmp (line,
"+", 1) && strstr (line,
"pop")))
2023 else if (strstr (line,
"imap4") && !strncmp (line,
"* ok", 4))
2025 else if (strstr (line,
"*ok iplanet messaging multiplexor"))
2027 else if (strstr (line,
"*ok communigate pro imap server"))
2029 else if (strstr (line,
"* ok courier-imap"))
2031 else if (strncmp (line,
"giop", 4) == 0)
2033 else if (strstr (line,
"microsoft routing server"))
2036 else if (strstr (line,
"gap service ready"))
2038 else if (strstr (line,
"-service not available"))
2044 else if (strlen (line) > 2 && line[0] == 0x7F
2046 && strncmp (&line[2],
"ica", 3) == 0)
2049 else if (strstr (origline,
" INN ")
2050 || strstr (origline,
" Leafnode ")
2051 || strstr (line,
" nntp daemon")
2052 || strstr (line,
" nnrp service ready")
2053 || strstr (line,
"posting ok")
2054 || strstr (line,
"posting allowed")
2055 || strstr (line,
"502 no permission")
2056 || (strcmp (line,
"502") == 0
2057 && strstr (line,
"diablo") != NULL))
2059 else if (strstr (buffer,
"networking/linuxconf")
2060 || strstr (buffer,
"networking/misc/linuxconf")
2061 || strstr (buffer,
"server: linuxconf"))
2063 else if (strncmp (buffer,
"gnudoit:", 8) == 0)
2065 else if ((buffer[0] ==
'0'
2066 && strstr (buffer,
"error.host\t1") != NULL)
2067 || (buffer[0] ==
'3'
2070 "That item is not currently available")))
2073 else if (strstr (buffer,
2074 "www-authenticate: basic realm=\"swat\""))
2076 else if (strstr (buffer,
"vqserver")
2078 "www-authenticate: basic realm=/"))
2080 else if (strstr (buffer,
"1invalid request") != NULL)
2082 else if (strstr (buffer,
"get: command not found"))
2084 else if (strstr (buffer,
"microsoft windows") != NULL
2085 && strstr (buffer,
"c:\\") != NULL
2086 && strstr (buffer,
"(c) copyright 1985-") != NULL
2087 && strstr (buffer,
"microsoft corp.") != NULL)
2089 else if (strstr (buffer,
"netbus"))
2091 else if (strstr (line,
"0 , 0 : error : unknown-error")
2092 || strstr (line,
"0, 0: error: unknown-error")
2093 || strstr (line,
"get : error : unknown-error")
2094 || strstr (line,
"0 , 0 : error : invalid-port"))
2096 else if (!strncmp (line,
"http/1.", 7)
2097 && strstr (line,
"proxy"))
2100 else if (!strncmp (line,
"http/1.", 7)
2101 && strstr (buffer,
"via: "))
2103 else if (!strncmp (line,
"http/1.", 7)
2104 && strstr (buffer,
"proxy-connection: "))
2106 else if (!strncmp (line,
"http/1.", 7)
2107 && strstr (buffer,
"cache")
2108 && strstr (line,
"bad request"))
2110 else if (!strncmp (origline,
"RFB 00", 6)
2111 && strstr (line,
".00"))
2113 else if (!strncmp (line,
"ncacn_http/1.", 13))
2115 else if (line_len >= 14 &&
2118 strncmp (origline,
http_get, line_len) == 0)
2120 else if (strstr ((
char *) banner,
"!\"#$%&'()*+,-./")
2121 && strstr ((
char *) banner,
"ABCDEFGHIJ")
2122 && strstr ((
char *) banner,
"abcdefghij")
2123 && strstr ((
char *) banner,
"0123456789"))
2125 else if (strstr (line,
"vtun server"))
2127 else if (strcmp (line,
"login: password: ") == 0)
2129 else if (strcmp (line,
"bad request") == 0
2133 "invalid protocol request (71): gget / http/1.0")
2134 || (strncmp (line,
"lpd:", 4) == 0)
2135 || (strstr (line,
"lpsched") != NULL)
2136 || (strstr (line,
"malformed from address") != NULL)
2137 || (strstr (line,
"no connect permissions") != NULL)
2139 strcmp (line,
"bad request") == 0)
2141 else if (strstr (line,
"%%lyskom unsupported protocol"))
2143 else if (strstr (line,
"598:get:command not recognized"))
2145 else if (strstr (line,
"BitTorrent prot"))
2147 else if (banner[0] ==
'A' && banner[1] == 0x01
2148 && banner[2] == 0x02 && banner[3] ==
'\0')
2150 else if (!strncmp (line,
"0 succeeded\n",
2151 strlen (
"0 succeeded\n")))
2153 else if (strlen ((
char *) banner) == 3 && banner[2] ==
'\n')
2155 else if ((!strncmp (line,
"220", 3)
2156 && strstr (line,
"poppassd")))
2158 else if (strstr (line,
"welcome!psybnc@") != NULL)
2160 else if (strncmp (line,
"* acap ", strlen (
"* acap ")) == 0)
2162 else if (strstr (origline,
"Sorry, you (") != NULL
2163 && strstr (origline,
2164 "are not among the allowed hosts...\n")
2167 else if (strstr (line,
"[ts].error") != NULL
2168 || strstr (line,
"[ts].\n") != NULL)
2170 else if (strstr (origline,
"Language received from client:")
2171 && strstr (origline,
"Setlocale:"))
2173 else if (strncmp (origline,
"CNFGAPI", 7) == 0)
2175 else if (strstr (line,
"suse meta pppd") != NULL)
2177 else if (strncmp (origline,
"ERR UNKNOWN-COMMAND",
2178 strlen (
"ERR UNKNOWN-COMMAND"))
2181 else if (strncmp (line,
"connected. ", strlen (
"connected. "))
2183 && strstr (line,
"legends") != NULL)
2185 else if (strncmp (line,
"spamd/", strlen (
"spamd/")) == 0)
2187 else if (strstr (line,
" dictd ")
2188 && strncmp (line,
"220", 3) == 0)
2190 else if (strncmp (line,
"220 ", 4) == 0
2191 && strstr (line,
"vmware authentication daemon")
2194 else if (strncmp (line,
"220 ", 4) == 0
2195 && strstr (line,
"interscan version") != NULL)
2197 else if ((strlen ((
char *) banner) > 1) && (banner[0] ==
'~')
2198 && (banner[strlen ((
char *) banner) - 1] ==
'~')
2199 && (strchr ((
char *) banner,
'}') != NULL))
2201 else if (strstr ((
char *) banner,
"Hello, this is zebra ")
2204 else if (strstr (line,
"ircxpro ") != NULL)
2206 else if (strncmp (origline,
"version report",
2207 strlen (
"version report"))
2210 else if (strncmp (origline,
"RTSP/1.0", strlen (
"RTSP/1.0"))
2211 && strstr (origline,
"QTSS/") != NULL)
2213 else if (strlen (origline) >= 2 && origline[0] == 0x30
2214 && origline[1] == 0x11 && origline[2] == 0)
2216 else if (strstr (line,
"stonegate firewall") != NULL)
2218 else if (strncmp (line,
"pbmasterd", strlen (
"pbmasterd"))
2221 else if (strncmp (line,
"pblocald", strlen (
"pblocald")) == 0)
2224 line,
"<stream:error>invalid xml</stream:error>",
2226 "<stream:error>invalid xml</stream:error>"))
2229 else if (strncmp (line,
"/c -2 get ctgetoptions",
2230 strlen (
"/c -2 get ctgetoptions"))
2233 else if (strncmp (line,
"error:wrong password",
2234 strlen (
"error:wrong password"))
2237 else if (strncmp (line,
"1000 2", strlen (
"1000 2"))
2240 else if (strstr (line,
2241 "the file name you specified is invalid")
2242 && strstr (line,
"listserv"))
2244 else if (strncmp (line,
"control password:",
2245 strlen (
"control password:"))
2248 else if (strncmp (line,
"remotenc control password:",
2249 strlen (
"remotenc control password:"))
2252 else if (((p = (
unsigned char *) strstr (
2253 (
char *) banner,
"finger: GET: no such user"))
2255 && strstr ((
char *) banner,
2256 "finger: /: no such user")
2258 && strstr ((
char *) banner,
2259 "finger: HTTP/1.0: no such user")
2265 while (p - banner > 0 && isspace (*p))
2275 else if (banner[0] == 5 && banner[1] <= 8 && banner[2] == 0
2278 else if (banner[0] == 0 && banner[1] >= 90 && banner[1] <= 93)
2282 "it looks like you are trying to access mongodb "
2283 "over http on the native driver port.")
2287 unindentified_service = !flg;
2294 unindentified_service = 1;
2295#define TESTSTRING "OpenVAS Wrap Test"
2306 if (port == 513 || port == 514 )
2313 int nfd, fd, wx, flag = 0;
2324 tv.tv_sec = wrap_timeout;
2327 signal (SIGALRM, SIG_IGN);
2329 (void) gettimeofday (&tv1, NULL);
2330 wx = select (fd + 1, &rfds, NULL, NULL, &tv);
2331 (void) gettimeofday (&tv2, NULL);
2342 wx = recv (fd, &b, 1, MSG_DONTWAIT);
2343 if (wx == 0 || (wx < 0 && errno == EPIPE))
2360 if (send (fd,
"Z", 1, MSG_DONTWAIT) < 0)
2370 if (diff_tv2 <= 2 * diff_tv + 1)
2373 unindentified_service = 0;
2379 if (unindentified_service && port != 139 && port != 135
2386 unknown[num_unknown++] = port;
2417 kill (
sons[i], SIGTERM);
2430 waitpid (
sons[i], NULL, WNOHANG);
2442 struct kb_item *kbitem, *kbitem_tmp;
2457 if (key && key[0] !=
'\0')
2462 if (cert && cert[0] !=
'\0')
2467 if (cafile && cafile[0] !=
'\0')
2472 if (test_ssl_s != NULL)
2474 if (strcmp (test_ssl_s,
"None") == 0)
2477 g_free (test_ssl_s);
2487 if (pempass != NULL)
2495 if (num_sons_s != NULL)
2496 num_sons = atoi (num_sons_s);
2497 g_free (num_sons_s);
2505 for (i = 0; i < num_sons; i++)
2508 sons_args[i] = NULL;
2514 kbitem = kb_item_get_pattern (kb,
"Ports/tcp/*");
2517 kbitem_tmp = kbitem;
2518 while (kbitem_tmp != NULL)
2521 kbitem_tmp = kbitem_tmp->next;
2524 port_per_son = num_ports / num_sons;
2529 kbitem_tmp = kbitem;
2531 for (i = 0; i < num_sons; i = i + 1)
2535 if (kbitem_tmp != NULL)
2537 for (j = 0; j < port_per_son && kbitem_tmp != NULL;)
2540 g_slist_prepend (sons_args[i], g_strdup (kbitem_tmp->name));
2542 kbitem_tmp = kbitem_tmp->next;
2549 for (i = 0; (i < num_ports % num_sons) && kbitem_tmp != NULL;)
2552 g_slist_prepend (sons_args[i], g_strdup (kbitem_tmp->name));
2554 kbitem_tmp = kbitem_tmp->next;
2557 kb_item_free (kbitem);
2559 for (i = 0; i < num_sons; i++)
2560 if (sons_args[i] == NULL)
2565 for (i = 0; i < num_sons; i++)
2568 if (sons_args[i] != NULL)
2578 signal (SIGTERM, _exit);
2587 g_slist_free_full (sons_args[i], g_free);
2595 for (i = 0; i < num_sons; i++)
2599 while (waitpid (
sons[i], NULL, WNOHANG) && errno == EINTR)
2602 if (kill (
sons[i], 0) >= 0)
kb_t get_main_kb(void)
gets the main_kb. @description returns the previously set main_kb; when asserts are enabled it will a...
Header file to cache main_kb.
static void mark_giop_server(struct script_infos *desc, int port, int trp)
static void mark_mysql(struct script_infos *desc, int port)
static void mark_nagiosd_server(struct script_infos *desc, int port, int trp)
tree_cell * plugin_run_find_service(lex_ctxt *lexic)
static void sigchld(int s)
static void mark_time_server(struct script_infos *desc, int port, int trp)
static void mark_ofa_express_server(struct script_infos *desc, int port, int trp)
static void mark_cvslockserver(struct script_infos *desc, int port)
static void mark_shoutcast_server(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_adsgone(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_smppd_server(struct script_infos *desc, int port, int trp)
static void mark_sub7_server(struct script_infos *desc, int port, int trp)
static void mark_eggdrop_server(struct script_infos *desc, int port, int trp)
#define DIFFTV1000(t1, t2)
static int plugin_do_run(struct script_infos *desc, GSList *h, int test_ssl)
static void mark_avotus_mm_server(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_wild_shell(struct script_infos *desc, int port)
#define WRAP_TIMEOUT_PREF
static void mark_fssniffer(struct script_infos *desc, int port, int trp)
static void mark_teamspeak2_server(struct script_infos *desc, int port, int trp)
static void mark_mldonkey(struct script_infos *desc, int port)
static void mark_locked_adsubtract_server(struct script_infos *desc, int port, unsigned char *buffer, int trp)
static void mark_http_proxy(struct script_infos *desc, int port, int trp)
static void mark_cvsupserver(struct script_infos *desc, int port)
static void mark_listserv_server(struct script_infos *desc, int port, int trp)
static void mark_smtp_server(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_ncacn_http_server(struct script_infos *desc, int port, char *buffer)
static void mark_msdtc_server(struct script_infos *desc, int port)
static void mark_pnsclient(struct script_infos *desc, int port, int trp)
static void mark_nntp_server(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_lyskom_server(struct script_infos *desc, int port, int trp)
static void mark_gnocatan_server(struct script_infos *desc, int port, int trp)
static void mark_chargen_server(struct script_infos *desc, int port)
static int regex_match(char *string, char *pattern)
Compares string with the regular expression. Null characters in buffer are replaced by 'x'.
static void mark_LISa_server(struct script_infos *desc, int port, int trp)
static void mark_upsmon_server(struct script_infos *desc, int port, int trp)
static void mark_ftp_server(struct script_infos *desc, int port, char *buffer, int trp)
static void register_service(struct script_infos *desc, int port, const char *proto)
#define TLS_PRIME_UNACCEPTABLE
static void mark_interscan_viruswall(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_websm_server(struct script_infos *desc, int port, int trp)
static void mark_spamd_server(struct script_infos *desc, int port, int trp)
static void mark_gopher_server(struct script_infos *desc, int port)
static void mark_vnc_server(struct script_infos *desc, int port, char *buffer)
static void mark_fw1(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_unknown_svc(struct script_infos *desc, int port, const unsigned char *banner, int trp)
static void mark_direct_connect_hub(struct script_infos *desc, int port, int trp)
static void mark_telnet_server(struct script_infos *desc, int port, int trp)
static void mark_BitTorrent_server(struct script_infos *desc, int port, int trp)
static void mark_veritas_backup(struct script_infos *desc, int port, int trp)
static void mark_socks_proxy(struct script_infos *desc, int port, int ver)
static void mark_imap_server(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_dictd_server(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_mon_server(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_linuxconf(struct script_infos *desc, int port, unsigned char *buffer)
static void mark_cvspserver(struct script_infos *desc, int port)
static void mark_stonegate_auth_server(struct script_infos *desc, int port, int trp)
static void mark_tcpmux_server(struct script_infos *desc, int port, int trp)
static void mark_postgresql(struct script_infos *desc, int port)
static void mark_exchg_routing_server(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_whois_plus2_server(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_sphinxql(struct script_infos *desc, int port)
static void mark_lpd_server(struct script_infos *desc, int port, int trp)
static void mark_rsync(struct script_infos *desc, int port)
static void mark_auth_server(struct script_infos *desc, int port)
static void mark_swat_server(struct script_infos *desc, int port)
static void mark_dameware_server(struct script_infos *desc, int port, int trp)
static void mark_ph_server(struct script_infos *desc, int port, int trp)
static void mark_gnome14_server(struct script_infos *desc, int port, int trp)
static void mark_vtun_server(struct script_infos *desc, int port, unsigned char *banner, int trp)
static void mark_quicktime_streaming_server(struct script_infos *desc, int port, int trp)
static void mark_wrapped_svc(struct script_infos *desc, int port, int delta)
static void mark_snpp_server(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_vqserver(struct script_infos *desc, int port)
static void mark_iss_realsecure(struct script_infos *desc, int port)
static void mark_smux_server(struct script_infos *desc, int port, int trp)
static void mark_ens_server(struct script_infos *desc, int port, int trp)
static int may_be_time(time_t *rtime)
static void mark_finger_server(struct script_infos *desc, int port, int trp)
static void mark_ppp_daemon(struct script_infos *desc, int port, int trp)
static void sigterm(int s)
static void mark_ssh_server(struct script_infos *desc, int port, char *buffer)
static void mark_gnuserv(struct script_infos *desc, int port)
static void mark_psybnc(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_acap_server(struct script_infos *desc, int port, char *buffer, int trp)
static const char * port_to_name(int port)
static void mark_rmserver(struct script_infos *desc, int port, char *buffer, int trp)
static int retry_stream_connection(int test_ssl, struct script_infos *desc, int port, int timeout, int *trp)
static void mark_pop3pw_server(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_pop_server(struct script_infos *desc, int port, char *buffer)
static pid_t sons[MAX_SONS]
static void mark_netbus_server(struct script_infos *desc, int port)
static void mark_pblocald_server(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_citrix_server(struct script_infos *desc, int port, int trp)
static void mark_ircxpro_admin_server(struct script_infos *desc, int port, int trp)
static void mark_echo_server(struct script_infos *desc, int port)
static void mark_remote_nc_server(struct script_infos *desc, int port, int trp)
static void mark_http_server(struct script_infos *desc, int port, unsigned char *buffer, int trp)
static void mark_jabber_server(struct script_infos *desc, int port, int trp)
static void mark_vmware_auth(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_uucp_server(struct script_infos *desc, int port, unsigned char *banner, int trp)
static void mark_zebra_server(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_pbmaster_server(struct script_infos *desc, int port, char *buffer, int trp)
static void mark_mongodb(struct script_infos *desc, int port)
Header file for built-in plugins.
static struct timeval timeval(unsigned long val)
tree_cell * http_get(lex_ctxt *lexic)
struct struct_lex_ctxt lex_ctxt
const char * get_encaps_through(openvas_encaps_t code)
int openvas_get_socket_from_connection(int fd)
int read_stream_connection_min(int fd, void *buf0, int min_len, int max_len)
int open_stream_connection_ext(struct script_infos *args, unsigned int port, int transport, int timeout, const char *priority, int flags)
int read_stream_connection(int fd, void *buf0, int len)
void open_stream_tls_default_priorities(const char *p, const int pflag)
int write_stream_connection(int fd, void *buf0, int n)
int open_stream_connection(struct script_infos *args, unsigned int port, int transport, int timeout)
const char * get_encaps_name(openvas_encaps_t code)
int stream_set_timeout(int fd, int timeout)
int close_stream_connection(int fd)
Header file for module network.
@ OPENVAS_ENCAPS_TLScustom
#define INSECURE_DH_PRIME_BITS
#define NO_PRIORITY_FLAGS
void post_alarm(const char *oid, struct script_infos *desc, int port, const char *action, const char *uri)
void plug_set_ssl_cert(struct script_infos *args, char *cert)
void plug_set_ssl_CA_file(struct script_infos *args, char *key)
void plug_set_port_transport(struct script_infos *args, int port, int tr)
void plug_replace_key(struct script_infos *args, char *name, int type, void *value)
char * plug_get_host_fqdn(struct script_infos *args)
char * get_plugin_preference(const char *oid, const char *name, int pref_id)
Get the a plugins preference.
void plug_set_ssl_key(struct script_infos *args, char *key)
void plug_set_key(struct script_infos *args, char *name, int type, const void *value)
void * plug_get_key(struct script_infos *args, char *name, int *type, size_t *len, int single)
Get values from a kb under the given key name.
const char * get_plugin_preference_fname(struct script_infos *desc, const char *filename)
Get the file name of a plugins preference that is of type "file".
void plug_set_ssl_pem_password(struct script_infos *args, char *key)
void post_log(const char *oid, struct script_infos *desc, int port, const char *action)
Post a log message about a tcp port.
kb_t plug_get_kb(struct script_infos *args)
Header file for module plugutils.
struct script_infos * script_infos