From 5c84883c43a2347ffbfa294d86bc6be92f57ff8d Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Sun, 13 Jul 2025 11:49:22 -0400 Subject: [PATCH] Problem with TEXT extraction within dns_is_blacklisted --- app/Makefile | 1 + app/scarmt.c | 10 ++++++++-- lib/unidns.c | 29 +++++++++++++++++++++++++++++ lib/unidns.h | 3 +++ sql/datatest.sql | 4 ++++ 5 files changed, 45 insertions(+), 2 deletions(-) diff --git a/app/Makefile b/app/Makefile index 1e7fc30..06647e8 100644 --- a/app/Makefile +++ b/app/Makefile @@ -118,6 +118,7 @@ sorter.o: sorter.c \ scarmt.o: scarmt.c \ ../lib/devsql.h \ ../lib/gessql.h \ + ../lib/unidns.h \ ../lib/unipar.h \ ../lib/uniprc.h \ ../lib/unisig.h \ diff --git a/app/scarmt.c b/app/scarmt.c index b131a59..b34524f 100644 --- a/app/scarmt.c +++ b/app/scarmt.c @@ -17,6 +17,7 @@ #include "devsql.h" #include "gessql.h" +#include "unidns.h" #include "unipar.h" #include "uniprc.h" #include "unisig.h" @@ -71,7 +72,12 @@ while (proceed==true) { srv->lastscan=time((time_t *)0); if (dnsbls!=(char **)0) { while (*dnsbls!=(char *)0) { - (void) rou_alert(0,"%s JMPDBG scan <%s> against <%s>",OPEP,rmtip,*dnsbls); + char *listed; + + (void) rou_alert(0,"%s JMPDBG scan <%s> against <%s> result=<%s>", + OPEP,rmtip,*dnsbls,listed); + listed=dns_is_blacklisted(*dnsbls,reversip); + listed=rou_freestr(listed); dnsbls++; } } @@ -156,7 +162,7 @@ while (proceed==true) { while (taille>0) { taille--; ptr=line+taille; - if ((*ptr!=' ')&&(*ptr!='\t')) + if ((*ptr!=' ')&&(*ptr!='\t')&&(*ptr!='\n')&&(*ptr!='\r')) break; *ptr='\000'; } diff --git a/lib/unidns.c b/lib/unidns.c index 3296dd8..6b76682 100644 --- a/lib/unidns.c +++ b/lib/unidns.c @@ -528,3 +528,32 @@ return status; #undef OPEP } +/* + +*/ +/********************************************************/ +/* */ +/* Procedure to probe one black list site about the*/ +/* remote IP and return a TXT if it is blacklisted.*/ +/* */ +/********************************************************/ +PUBLIC char *dns_is_blacklisted(char *blssite,char *reversip) + +{ +#define OPEP "unidns.c:dns_is_blacklisted," + +char *listed; +char **txt; +char dnsquest[300]; + +listed=(char *)0; +(void) snprintf(dnsquest,sizeof(dnsquest),"%s%s",reversip,blssite); +(void) rou_alert(12,"%s, checking <%s>",OPEP,dnsquest); +if ((txt=gettxt(dnsquest,T_TXT,"TXT"))!=(char **)0) { + (void) rou_asprintf(&listed,"%s -> %s",blssite,txt[0]); + txt=(char **)rou_freelist((void **)txt,(genfree_t)rou_freestr); + } +return listed; + +#undef OPEP +} diff --git a/lib/unidns.h b/lib/unidns.h index 1e58cfa..489548d 100644 --- a/lib/unidns.h +++ b/lib/unidns.h @@ -42,4 +42,7 @@ extern _Bool dns_matchiprec(char *hostname,AFNTYP *afnnum,int mask); //smtp server extern LOCTYP dns_is_domain_local(const char *domain,AFNTYP **afns); +//procedure returning a string if remote IP si blacklisted +extern char *dns_is_blacklisted(char *blssite,char *reversip); + #endif diff --git a/sql/datatest.sql b/sql/datatest.sql index e04f86c..8894854 100644 --- a/sql/datatest.sql +++ b/sql/datatest.sql @@ -33,6 +33,9 @@ INSERT INTO remotes (remoteip,credit,lastscan) \ values ('127.127.0.25',10,now()); //--------------------------------------------------------------- //selected IP from 'known' spammer +INSERT INTO remotes (remoteip) \ + values ('122.175.193.134'); +#ifdef BIGRE INSERT INTO remotes (remoteip) \ values ('27.151.45.98'); INSERT INTO remotes (remoteip) \ @@ -47,6 +50,7 @@ INSERT INTO remotes (remoteip) \ values ('209.85.218.68'); INSERT INTO remotes (remoteip) \ values ('216.246.113.145'); +#endif //selected IP from from 'clean' server INSERT INTO remotes (remoteip) \ -- 2.47.3