From ba3a53c707b1ee4cfbb01d259d38347735e661a2 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Mon, 14 Jul 2025 23:04:29 -0400 Subject: [PATCH] Starting to implement the debug ORGN: command ("ORGN is back!") --- app/feeder.c | 9 ++++----- data-feed/feed05.tst | 4 ++-- lib/lvleml.c | 29 +++++++++++++++++++++++++++++ lib/unieml.c | 3 +++ lib/unieml.h | 4 ++++ 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/app/feeder.c b/app/feeder.c index e040dfd..b080e19 100644 --- a/app/feeder.c +++ b/app/feeder.c @@ -44,7 +44,7 @@ typedef enum { //List of command cmd_connect, //Start connection with smtp server cmd_data, //start the SMTP data sequence cmd_gotls, //going in tls mode - cmd_ipfrom, //Change peer IP origin + cmd_orgn, //Change peer IP origin cmd_restart, //restart connection with remote server cmd_wait, //delay exchange with remote cmd_unknown @@ -373,7 +373,7 @@ static struct { {cmd_connect,"CONNECT"}, {cmd_data,"DATA"}, {cmd_gotls,"GOTLS"}, - {cmd_ipfrom,"IPFROM"}, + {cmd_orgn,"ORGN:"}, {cmd_restart,"RESTART"}, {cmd_wait,"WAIT"}, {cmd_unknown,(const char *)0} @@ -431,10 +431,9 @@ switch (getcmd(line)) { if ((status=gomodetls(fd->socptr))==false) (void) report(*numline,line,"Unable to set TLS mode"); break; - case cmd_ipfrom : //Change/set the client IP + case cmd_orgn : //send command to override client IP if (param!=(char *)0) { - fd->srcip=rou_freestr(fd->srcip); - fd->srcip=strdup(param); + (void) sendout(fd->socptr,line); } else { (void) report(*numline,line,"Missing new PEER IP value"); diff --git a/data-feed/feed05.tst b/data-feed/feed05.tst index 9adf397..5f1ac1f 100644 --- a/data-feed/feed05.tst +++ b/data-feed/feed05.tst @@ -1,8 +1,8 @@ T:(feed05) Email testing remote server -C:IPFROM 127.127.99.25 -C:CONNECT #==================================================== R:220 mailleur.example.com, ESMTP (cleartext) mailleur... +C:ORGN: 91.199.160.44 +R:220 xxxmailleur.example.com, ESMTP (cleartext) mailleur... S:helo example.com R:250 mailleur.example.com, link (cleartext) ready, your IP/FQDN=[127.127.99.25/No.Reverse] S:MAIL FROM: diff --git a/lib/lvleml.c b/lib/lvleml.c index eca1017..04f3f74 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -1326,6 +1326,30 @@ return done; */ /************************************************/ /* */ +/* Procedure to manage a "ORGN:" */ +/* command from the SMTP client. */ +/* Purpose of this command is to simulate */ +/* (or overide) the IP remote client. */ +/* */ +/* NOTE: Only compiled in debug mode. */ +/* */ +/************************************************/ +#ifdef MODEDEBUG +static _Bool setnewrmtip(CONTYP *contact,char *rmtip) + +{ +_Bool isok; + +isok=true; +(void) rou_alert(0,"JMPDBG"); +return isok; +} +#endif +/* + +*/ +/************************************************/ +/* */ /* Procedure to manage a "MAIL FROM:" */ /* ommand from the SMTP client. */ /* */ @@ -2184,6 +2208,11 @@ while (proceed==true) { case c_mail : //MAIL FROM: checking originator proceed=checkfrom(contact,line); break; +#ifdef MODEDEBUG + case c_orgn : //Debug mode to override remote IP + proceed=setnewrmtip(contact,line); + break; +#endif case c_auth : //Auth request if (getauth(contact,line)==false) proceed=false; //Authentication failed diff --git a/lib/unieml.c b/lib/unieml.c index 3134fe9..f79f849 100644 --- a/lib/unieml.c +++ b/lib/unieml.c @@ -35,6 +35,9 @@ static VOCTYP vocsmtp[]={ {c_helo,"HELO"}, {c_mail,"MAIL FROM:"}, {c_noop,"NOOP"}, +#if MODEDEBUG + {c_orgn,"ORGN:"}, +#endif {c_quit,"QUIT"}, {c_rcpt,"RCPT TO:"}, {c_rset,"RSET"}, diff --git a/lib/unieml.h b/lib/unieml.h index e1bd85a..23c993c 100644 --- a/lib/unieml.h +++ b/lib/unieml.h @@ -63,6 +63,10 @@ typedef enum { //list of SMTP protocol keyword c_helo, //Basic Helo command c_mail, //'mail from:' sequence detected c_noop, //No Operation request +#ifdef MODEDEBUG +//command available ONLY if compiled in debug mode + c_orgn, //to force remote IP to a specific value +#endif c_quit, //quit exchange c_rcpt, //'rcpt to:' sequence detected c_rset, //resetting session -- 2.47.3