English | Italiano
by InRete.com

Struttura del linguaggio (Caronte Pcode Language)

Nel software Caronte Antispam v2, esistono quattro  “ambienti di programmazione”:

  1. ENV ANTISPAM
  2. ENV ADMIN
  3. ENV CRON
  4. ENV WEB

 

Ogni ambiente di programmazione in “Carontese P.L.”, eredita delle impostazione di classe predefinite in comune con gli altri ambienti , ma sviluppa però delle caratteristiche di funzionamento proprie visibile solo in tale  ambiente.

Gli ambienti a RUN TIME hanno dei contesti definiti e la loro inizializzazione avviene creando l’istanza di ambiente:

// ENV ANTISPAM
CS_ANTISPAM_SCRIPT this = new CS_ANTISPAM_SCRIPT($_this);

//ENV ADMIN
CS_ADMIN_SCRIPT this = new CS_ADMIN_SCRIPT($_this);

//ENV CRON
CS_CRON_SCRIPT this = new CS_CRON_SCRIPT($_this);

// ENV WEB
CS_WEB_SCRIPT this = new CS_WEB_SCRIPT($_this);

 

L’istanza di ambiente puo’ essere inizializzata solo se lo script si trova chiaramente nel contesto di tale ambiente, per fare un esempio pratico non è possibile inizializzare un WEB script dentro l’ambiente CS_ANTISPAM_SCRIPT o altro ambiente che non sia nel contesto WEB.

Ogni Contesto di Istanza viene generato automaticamente dal “Core di Caronte Antispam v2”, inserendo il relativo puntatore  nella variabile speciale “$_this”. Questo un volta inizializzato con l’operatore “new”,  genera l’istanza di ambiente,  sulla quale è possibile lavorare richiamando le funzioni di classe base o quelle di contesto.

Prima di entrare nel vivo della programmazione, è giusto per noi spiegare i meccanismi che si innescano, quando viene lanciato un script , dove  fondamentalmente, le fasi sono tre:

“PRE-COMPILE”. (precompilatore prima del run-time)
Viene analizzato la sintassi del codice sorgente, le sequenze di ESCAPE, e eseguito le funzioni MACRO come:
#ifdef
#ifndef
#else
#endif
#undef
#include
#import

 

“COMPILE STACK”.
Viene compilato il codice sorgente in Pcode creando la pila dello STACK, analizzando le istruzioni base come:

if ()  {} else {}
while () {}
do {} while ()
for () {}
continue
break
return
new
delete
sin
asin
cos
acos
tan
atan
log
exp
sqrt
rsq
rcp
fabs
rand
pow
floor

“RUN TIME”
Lo script viene eseguito, processando la pila dello STACK,.

In ognuna delle fase del meccanismo è possibile ricevere errori di sintassi, di compilazione o run time error.
Lo script in caso di errori cessa il proprio lavoro in qualsiasi fase si trovi e anche l’ambiente ad esso collegato cessa di funzionare alzando delle eccezioni.

Ogni ambiente ha delle funzioni evento "innalzate" a RUN TIME da Caronte Antispam .
Gli eventi variano a seconda dell'ambiente e vengono "alzati" se esistano nel codice sorgente.

EVENTI in ambiente ANTISPAM

OnStartClientConnection(int [id_connection]);
OnClientTimeOut();
OverWriteCommandError(int [count num error]);
OnAuthenticatedToMTA();
OnReplyMTA(string [command from MTA server]);
OnAllClientData( string [command from client email]);
OnHelo(string [greeting],string [type]);
OnMailFrom(string [mail from]);
OnRcptToError(string [rpct considerato errore]);
OnCommandNOOP();
OnCommandRSET();
OnCommandData(int [buffer length]);
OnAllDataMessage(string [buffer message], int [1 this is the end]);
OnEmailMessagesToAnalyzer();
OnDoneAntispamFilter();
OnDestroyThis();

EVENTI in ambiente CRON

main();

EVENTI in ambiente ADMIN

Main( CAdminRequest, CAdminResponse);

EVENTI in ambiente WEB

html();


Funzioni Base di Istanza comuni per tutti gli ambienti:

string this->Format(string,...);
void this->Exit();
void this->Print(string,...);
string this->SubStr(string,int,int);
string this->Trim(string);
string this->TrimLeft(string);
string this->TrimRight(string);
string this->TrimInternal(string);
string this->Lc(string);
string this->Uc(string);
string this->Split(string, char, int);
string this->Replace(string,string,string);
int this->StrLen(string);
char this->Chr(int);
in this->Ord(char);
float this->CharToFloat(string)
int this->CharToInt(string);
string this->FloatToChar(float)
string this->IntToChar(int);
in this->FloatToInt(float)
float this->IntToFloat(int)
int this->CompareStringNoCase(string, string);
string this->Encode64(string)
string this->Decode64(string);
string this->MD5(string);
string this->MD5File(string,string,int);
void this->MD5StartStream(void);
void this->MD5UpdateStreamB(pointer,int)
void this->MD5UpdateStream(string)
string this->MD5FinalStream(void);
string this->DecodeHtmlSpecialChar(string);
string this->EncodeHtmlSpecialChar(string);
string this->DeOfuscate(string);
string this->HtmlToText(string);
string this->URLDecode(string);
string this->URLEncode(string);
int this->HextoInt(string);
int this->Time(void);
string this->DateTimeFormat(string,int)
int this->GetTickCount(void)
void this->Sleep(int);
int this->REeq(string,string,int);
string $1();
string $2();
string $3();
string $4();
string $5();

Ambiente ADMIN e CRON funzioni di instanza

void this->WriteLog(int,string,string);
string this->GetConfig(string,string):
int this->GetConfigToArray(class HashArray,string)
void this->SetConfig(string,string,string);
void this->DeleteFromConfig(string,string,string);
void this->WaitForReplaceConfig(void);
void this->SaveConfig(void);

float this->DNSBL_Score(string);
string this->DNSBL_Ns(string);

string this->DNS_Reverse(string);
string this->DNS_Resolve(string);
string this->DNS_MX(string)
string this->DNS_NS(string);
string this->DNS_TXT(string);

void this->SetLevelReBootConfig(int);
void this->SetRebootConfig(int);

string this->GetClientIP(void);
string this->GetClientReverseDns(void);
int this->IsAllowIpAdmin(string);
int this->InsertDomain(string);
CDomainConf this->GetDomain(string);
int this->DeleteDomain(string);
CDB_Ram this->GetDBRamDomains(void);
void this->SaveDomains();
void this->LoadDomainsConfig(void);
void this->AddVarToDomainTemplate(string,string,string);
void this->DeleteVarFromDomainTemplate(string,string);

CDB_Ram this->GetDBRamSpamTrap();
CDB_Ram this->GetDBRamIpInferno();
CDB_Ram this->GetDBRamHelo();
CS_RulesDB this->GetRulesDB();
bool this->SetHeloRefresh();
CS_Bayes  this->GetDBBayes();
int this->ViewGreyListDB(HashArray, int,int,string,int)
int this->ViewALWLDB(HashArray,int,int,string,int);
void this->AddALWL(string,string);
int this->IsALWL(string,string);
void this->LoadALWL();
int this->DCTest(string);
int this->DCRefreshServer();
void this->DCGetServer(HashArray);
void this->ViewPhishingDB(HashArray);
int this->AddDomainPhishing(string);
int this->UpDateDomainPhishing(string,string);
int this->DeleteDomainPhishing(string);
int this->UpDateDBPhishingFromWWW();
void this->LoadDBPhishing();
string this->GetDBPhishingDate()
int this->RunScript(string)

Solo ADMIN

int this->AddCronJob(string,string);
int this->DeleteCronJob(string, string);
void this->ViewCronJob(HashArray ,string,int);
int this->PlugInInstall(string,string);
int this->PlugInUninstall(string,string);
void this->GetPlugInInstalled(HashArray );
int this->AddAntispamScript(string,int);
int this->DeleteAntispamScript(string);

class CAdminRequest {

void CAdminRequest();
int GetCmd();
int GetRecordCount();
int GetColCount();
void Reset();
HashArry GetRow();

};

class CAdminResponse {
void CAdminResponse();
int GetRecordCount();
int GetColCount();
void Reset();
void Addnew();
void SetFieldAt(string,int);
void SetFieldBinaryAt(int, pointer,int);
int Send(int,int);

} ;

Solo CRON

pointer this->GetPersistentOBJ(string,string);
pointer this->CreatePersistentOBJ(string,string);
void this->DeletePersistentOBJ(string);

WEB

string this->CGI_GET_VAR(string);
string this->CGI_POST_VAR(string);
string this->CGI_COOKIE_VAR(string);
void this->CGI_TO_ARRAY(HashArray ,string);
string this->GETENV(string);
void this->Echo(string);
void this->echo(string);
string this->includeHTML(string,int);
Void this->SetCookie(string,string,int,string,string,int)
Void this->HeaderOption(string);
Void this->HeaderRedirect(string);
Void this->HeaderContentType(string);

void CGI_SESSION_START(string,int);
void CGI_SESSION_DELETE(string);
void CGI_SESSION_VAR(string,string);
void CGI_SESSION_WRITE_VAR(string,string,string);

ANTISPAM

string this->GetClientIP(void);
string this->GetClientReverseDns();
string this->GetMTAIP();
int this->IsIpInferno(string);
void this->AddIpInferno(string,int);
int this->IsIpWhiteList(string);
int this->IsIpMaxSession(string);
void this->RegisterSessionIp();
int this->ConnectToDefaultMTA();
int this->ConnectToMTA(string,string);
string this->GetNameServerMTA();
string this->GetReplaceNameServerMTA();
void this->InjectionExtensionMTA(string);
void this->DropExtensionMTA(string);
int this->IsRelayIp(string);
int this->IsLanIp(string);
int this->ClientIsRelay();
void this->SendToMTA(string);
void this->SendToClient(string);
void this->CloseClientConnection();
void this->CloseMTAConnection();
void this->CloseAllConnection();
void this->DropBufferToMTA();
void this->DropBufferToClient();
void this->CloseClientConnAfterSendingQueue();

void this->AddALWL(string,string);
int this->IsALWL(string,string);
int this->ViewALWLDB(HashArray ,int,int,string,int);

void this->StatisticValue(string,int,int,float,int);

int this->IsForgetHelo(string);

int this->SPFQuery(string,string,string);
string this->SPFResultString(int);

int this->GetErrorCountRFC();
void this->SetErrorCountRFC(int);
int this->IsLocalDomainByRCPT_TO(string);
int this->IsWhiteBlackList(string,string);
int this->IsSpamLover(string,string);

int this->GetSessionProperty();
void this->RegisterSessionProperty();
float this->RecalculatingScoreByUser(float,float,string);

int this->IsSpamTrap(string);
string this->GetSpamTrapResponse();

int this->IsValidKeyDanteCommunity();
void this->DanteCommunityAnnunce(string,string,string);
float this->DanteCommunityQuery(string,string,string);
string this->DanteCommunityGetEnumStringFormScore(float);

Int this->IsWhiteIpGreyList(string);
string this->PrepareTriplesGreyList(string,string,string,string,string);

int this->PassGreyList(string);
int this->GetForgedCountGreyList(string);
void this->ResetForgedCountGreyList(string);
void this->AddToGreyList(string);
int this->ViewGreyListDB(HashArray,int,int,string,int);

int this->BayesianCheck(string);
void this->AddToBayesianQuarantine(string,string,int, CS_ParseMail );
 
int this->IsPhishing(CS_ParseMail)
string this->GetFakePhishingDomain();

string this->GetEmailBody();
string this->GetEmailHeader();
string this->GetEmailSubject();
string this->GetEmailMailFrom();
string this->GetEmailMailTo();
string this->GetEmailMailTo();
string this->GetEmailContentType();
string this->GetEmailRaw();
int this->GetEmailAttachmentCount();
int this->GetEmailLen();
string this->GetEmailAttachmentBuffer(int);
string this->GetEmailAttachmentContentType(int);

float this->RegularExpressionCheck(CS_ParseMail = 0, CS_RulesResult = 0)

pointer this->GetPersistentOBJ(string,string);
pointer this->CreatePersistentOBJ(string,string);
void this->DeletePersistentOBJ(string);

void this->WriteHeaderMessage(string);
void this->ModifyHeaderSubject(string);

pointer this->GetPersistentOBJ(string,string);
pointer this->CreatePersistentOBJ(string,string);
void this->DeletePersistentOBJ(string);

Classi per tutti gli ambienti


CLASS HashArray
void HashArray();
void AddValueS(string,string);
void AddValueI(string,int);
void AddValueF(string,float);
string GetS(string);
int GetI(string);
float GetF(string);
int GetLenValue(string);
string GetByIndexS(int);
int GetByIndexI(int);
float GetByIndexF(int);
int GetIndexByKey(string);
string GetKeyByIndex(int);
void Reset();
int GetRecordCount();
void Merge(HashArray)
int KeyExists(string);

CLASS CDB_Ram
void CDB_Ram();
bool Open(string);
bool Load();
int Query(string, HashArray ,int,int);
int Insert(string,string,int);
int Update(string,string);
int Delete(string);
int GetCount();
int Save();
void Reset();
int Close();

CLASS  CS_ParseMail
void CS_ParseMail();
void AddStreaming(string);
string GetBody();
string GetHeader();
string GetSubject();
string GetRawEmail();
string GetMailFrom();
string GetMailTo();
string GetContentTransferEncoding();
string GetCharset();
string GetContentType();
int GetAttachmentCount();
int GetLen();
int Parse();
string GetAttachmentBuffer(int);
string GetAttachmentContentType(int);
string GetAttachmentContentTransferEncoding(int);
string GetAttachmentCharset(int);
int LoadMail(string);
int LoadFromFile(string);

CLASS  CS_BayesWord
void CS_BayesWord();
int Elaborate(CS_ParseMail)

CLASS  CS_Bayes
void CS_Bayes();
void SetMinOccurrences(float);
void PopolateDB(CS_BayesWord,int);
voit RemoveNeutral(int);
int  AddQuarantine(CS_ParseMail,string,string,int,CS_Statistic);
CDB_Ram GetDBRam(string);
int GetWordsCount(string);
int IsSpam(CS_BayesWord, HashArray );
void Load();

CLASS  XMLChild
void XMLChild();
bool AddValue(string,string);
string GetValue(string);
int GetCount();

CLASS  XMLParse
void XMLParse();
int  LoadFile(string,string,string);
void SetMaxChild(int);
void SetStreamingTimeOut(int);
void SetPartSeek(int);
int  GetCountChild();
XMLChild GetChild(int);

CLASS  CaronteServerConn
void CaronteServerConn(string,string,string);
void SetOptions(string,string,string);
int  Connect();
bool IsConnected();
void Disconnect();
void SetTimeOut(int);

CLASS  CaronteRecordSet
void CaronteRecordSet(CaronteServerConn);
void AddNew();
void SetFieldAt(int,string);
void SetFieldBinaryAt(int,pointer,int);
bool Query(int);
void Reset();
HashArray GetRow();
int GetLastError();
int RecordCount();
int ColCount();

CLASS  CDomainConf
void CDomainConf();
void WaitForSession();
void StartSession();
void EndSession();
string GetVar(string);
void SetVar(string,string);
string GetDomainName();
CDB_Ram GetDBRam(string);
void Save();
void Delete();

CLASS  CS_RulesResult
void CS_RulesResult();
int GetRulesCount();
string GetRulesName(int);
string GetRulesRE(int)
float GetRulesScore(int);

CLASS  CS_RulesDB
void CS_RulesDB();
bool Open(string);
bool Load();
bool Save();
int AddRule(string,string,int,float,int);
void ViewRules(HashArray);
string RuleTest(CS_ParseMail,string,int,int,HashArray);
bool DeleteRule(string);
float RegularExpressionCheck(CS:PArseMail,Cs_RulesResult);

CLASS  CNetInfo
void CNetInfo();
int BuildNetInfo(HashArray);

CLASS  CS_Dns
 void CS_Dns();
string DNS_Reverse(string);
string DNS_Resolve(string);
string DNS_MX(string);
string DNS_NS(string),
string DNS_TXT(string);
void AddNameServerDNS(string);
void SetTimeOut(int);

CLASS  CS_Buffer
void CS_Buffer();
void Allocate(int);
int  GetLen();
string ToString();
void Write(string,int);
CS_buffer GetBuffer();
pointer GetPointer();
string GetAt(int);

CLASS  CS_Socket
void CS_Socket(int);
int IsOpen();
void Close();
int ConnectTo(string,string,string);
int Send(string,int,int);
int SendB(pointer,int,int);
int Riceve(CS_Buffer,int);

CLASS  CS_FileSystem
void CS_FileSystem();
int UnLink(string);
int FileExists(string);
int DirExists(string);
int CopyFile(string,string,int);
int ReadDir(string,HashArray);
int FileSize(string);
int Exec(string);
string AppPath();

CLASS  CS_File
void CS_File();
bool Open(string,int);
void WriteB(pointer,int);
void Write(string,int);
int Read(CS_Buffer);
int Seek(int,int);
void Flush();
void Close();

CLASS  CS_MemoryFile
void CS_MemoryFile(int);
void Close();
void Flush();
int Read(CS_Buffer);
void Write(string,int);
void WriteB(pointer,int);
string ToString(),
pointer GetPointer();
int GetLength();

CLASS  CS_Statistic
void CS_Statistic();
void AddItem(string,int,int,float,int);
void Reset();
int Load(string);
int Save();
void PopulatedArray(HashArray);

CLASS  CS_HttpClient
void CS_HttpClient();
int SendRequest(int,string,string);
string GetHeader();
string GetResult();
void SetTimeOut(int);
void SetAgentName(string);
void SetMaxBufferLen(int);
void SetIPAdatper(string);

CLASS  CS_MySqlConn
void CS_MySqlConn();
int Connect(string,string,string,string,int);
void Close();
int State();
void Execute(string);
string GetError();

CLASS  CS_MySqlRecordSet
void CS_MySqlRecordSet();
int Open(string,CS_MySqlConn);
void Close();
int RecordCount();
HashArray FetchRow();

CLASS  CS_FileCfg
void CS_FileCfg();
int Load(string);
bool LoadByString(string);
boll Save(string);
string ReadVar(string,string);
void WriteVar(string,string,string);
int IsKeyExist(string,string);
void DeleteKey(string,string);
int GetConfigToArray(HashArray);

CLASS  CS_Flag
void CS_Flag();
void SetFloat(float);
void SetInt(int);
void SetBool(bool);
void SetString(string);
float GetFloat();
int   GetInt();
bool  GetBool();
string GetString()


Start project 10-10-2003 - Copyright © 2000-2015 C&G Servizi Web s.rl. Tutti i diritti riservati. P.IVA : 01404430470 .