void vmsHttpFlvTrafficAnalyzer::FindDialogsByUniqueUrlWordsMatch(LPCSTR pszSwfContext, const HTTPDLGLIST &vDlgs, HTTPDLGLIST &vResult) { LOGFN ("vmsHttpFlvTrafficAnalyzer::FindDialogsByUniqueUrlWordsMatch"); vResult.clear (); vector < vector <string> > vvUniqueWords; vmsWinSockHttpTrafficAnalyzer::FindUniqueUrlWords (vDlgs, vvUniqueWords); assert (vvUniqueWords.size () == vDlgs.size ()); for (size_t iDlg = 0; iDlg < vvUniqueWords.size (); iDlg++) { vector <string> &vWords = vvUniqueWords [iDlg]; if (vWords.empty ()) continue; for (size_t iW = 0; iW < vWords.size (); iW++) { if (strstr (pszSwfContext, vWords [iW].c_str ()) != NULL) { vResult.push_back (vDlgs [iDlg]); LOG ("Unique url word \"%s\" is containing in source text", vWords [iW].c_str ()); LOG ("|-dialog url-%s", vDlgs [iDlg]->strRequestUrl.c_str ()); break; } } } }
void vmsHttpFlvTrafficAnalyzer::FindDialogsByFileUrlMatch(LPCSTR pszSrcText, const HTTPDLGLIST &vDlgs, HTTPDLGLIST &vResult) { assert (pszSrcText != NULL && *pszSrcText != 0); vResult.clear (); int iDlgFound = -1; for (size_t iDlg = 0; iDlg < vDlgs.size (); iDlg++) { string strFileUrl; vmsHttpHelper::ExtractFileUrl (vDlgs [iDlg]->strRequestUrl.c_str (), strFileUrl); if (strFileUrl.empty ()) continue; if (strstr (pszSrcText, strFileUrl.c_str ()) != NULL) { if (iDlgFound == -1) { iDlgFound = iDlg; } else if (vDlgs [iDlgFound]->strRequestUrl != vDlgs [iDlg]->strRequestUrl) { iDlgFound = -1; break; } } } if (iDlgFound != -1) vResult.push_back (vDlgs [iDlgFound]); }
void vmsLogHelper::LogHttpDlgList(LPCSTR pszListName, const HTTPDLGLIST &vDlgs) { LOG ("%s:", pszListName); if (vDlgs.empty ()) { LOGsnl ("|-(empty)"); return; } for (size_t i = 0; i < vDlgs.size (); i++) LOG ("|-(%I64d bytes)-%s", (__int64)vDlgs [i]->nContentLength, vDlgs [i]->strRequestUrl.c_str ()); }
void vmsHttpFlvTrafficAnalyzer::FindDialogsByUniqueUrlWordsMatch2(LPCSTR pszSomeUrl, const HTTPDLGLIST &vDlgs, HTTPDLGLIST &vResult) { LOGFN ("vmsHttpFlvTrafficAnalyzer::FindDialogsByUniqueUrlWordsMatch2"); assert (pszSomeUrl != NULL); vResult.clear (); if (!pszSomeUrl) return; vector <string> vWords; vmsUrlWords::ExtractWords2 (pszSomeUrl, vWords); if (vWords.empty ()) return; string strWords; for (size_t i = 0; i < vWords.size (); i++) { strWords += vWords [i]; strWords += ' '; } FindDialogsByUniqueUrlWordsMatch (strWords.c_str (), vDlgs, vResult); }
void vmsHttpFlvTrafficAnalyzer::FindDialogsByUrlExactMatch(LPCSTR pszSrcText, const HTTPDLGLIST &vDlgs, HTTPDLGLIST &vResult) { assert (pszSrcText != NULL && *pszSrcText != 0); vResult.clear (); string strTmp; for (size_t i = 0; i < vDlgs.size (); i++) { HTTPDLG pDlg = vDlgs [i]; LPCSTR pszFlvUrl = pDlg->strRequestUrl.c_str (); if (pszFlvUrl [pDlg->strRequestUrl.length ()-1] == '&') { strTmp.assign (pszFlvUrl, pDlg->strRequestUrl.length ()-1); pszFlvUrl = strTmp.c_str (); } if (strstr (pszSrcText, pszFlvUrl)) vResult.push_back (pDlg); } }
void vmsHttpFlvTrafficAnalyzer::FindFlvDownloadInInBetweenDlgs(const vmsHttpTrafficCollector *pTraffic, HTTPDLG pWebPage, LPCSTR pszSwfUrl, LPCSTR pszFlashVars, LPCSTR pszSwfContext, HTTPDLGLIST vFlvs, FindFlvDownloadInInBetweenDlgs_Type enFindType) { LOGFN ("vmsHttpFlvTrafficAnalyzer::FindFlvDownloadInInBetweenDlgs"); if (!pszSwfUrl) { assert (pWebPage != NULL); if (!pWebPage) return; pszSwfUrl = pWebPage->strRequestUrl.c_str (); } string strBody; if (!pszSwfContext) { assert (pWebPage != NULL); if (!pWebPage) return; strBody.assign ((LPSTR)&pWebPage->vbResponseBody [0], pWebPage->vbResponseBody.size ()); pszSwfContext = strBody.c_str (); } int nStartIndex = pWebPage ? pTraffic->getHttpDialogIndex (pWebPage) + 1 : 0; HTTPDLGLIST vFlvs2; DWORD adwCTs [] = { vmsHttpTrafficCollector::HttpDialog::AMF, vmsHttpTrafficCollector::HttpDialog::X_WWW_FORM_URL_ENCODED, vmsHttpTrafficCollector::HttpDialog::XML, vmsHttpTrafficCollector::HttpDialog::HTML, }; for (int iCT = 0; iCT < sizeof (adwCTs) / sizeof (DWORD); iCT++) { HTTPDLGLIST vBetwDlgs; pTraffic->GetHttpDialogs (nStartIndex, -1, adwCTs [iCT], vBetwDlgs); HTTPDLGLIST vBetwDlgs2; vector <HTTPDLGLIST> vBetwToFlvMap; for (size_t iDlg = 0; iDlg < vBetwDlgs.size (); iDlg++) { HTTPDLG pDlg = vBetwDlgs [iDlg]; if (pDlg->vbResponseBody.empty ()) continue; if (pDlg->enCT == vmsHttpTrafficCollector::HttpDialog::HTML && pDlg->vbResponseBody.size () > 1000) continue; string strBody; if (pDlg->enCT == vmsHttpTrafficCollector::HttpDialog::AMF) { for (size_t i = 0; i < pDlg->vbResponseBody.size (); i++) { if (pDlg->vbResponseBody [i] >= ' ') strBody += pDlg->vbResponseBody [i]; } } else if (pDlg->enCT == vmsHttpTrafficCollector::HttpDialog::X_WWW_FORM_URL_ENCODED) { string str; str.assign ((LPSTR)&pDlg->vbResponseBody [0], pDlg->vbResponseBody.size ()); vmsHttpHelper::DecodeUrl (str.c_str (), strBody); } else { strBody.assign ((LPSTR)&pDlg->vbResponseBody [0], pDlg->vbResponseBody.size ()); } if (enFindType == FDT_EXACTURLMATCH) FindDialogsByUrlExactMatch (strBody.c_str (), vFlvs, vFlvs2); else if (enFindType == FDT_FILEURLMATCH) FindDialogsByFileUrlMatch (strBody.c_str (), vFlvs, vFlvs2); else if (enFindType == FDT_BYUNIQUEWORDS) FindDialogsByUniqueUrlWordsMatch (strBody.c_str (), vFlvs, vFlvs2); else return; if (!vFlvs2.empty ()) { vBetwDlgs2.push_back (pDlg); vBetwToFlvMap.push_back (vFlvs2); } } if (vBetwDlgs2.empty ()) continue; LOGHTTPDLGLIST ("List of dialogs with FLVs", vBetwDlgs2); LOGsnl ("Found dialogs with FLVs. Find their source."); HTTPDLGLIST vBetwDlgsFoundInSwfContext; FindDialogsByUrlExactMatch (pszSwfContext, vBetwDlgs2, vBetwDlgsFoundInSwfContext); LOGHTTPDLGLIST ("List of these dialogs belonging to source page (exact match)", vBetwDlgsFoundInSwfContext); if (vBetwDlgsFoundInSwfContext.empty ()) { FindDialogsByFileUrlMatch (pszSwfContext, vBetwDlgs, vBetwDlgsFoundInSwfContext); LOGHTTPDLGLIST ("List of these dialogs belonging to source page (file url match)", vBetwDlgsFoundInSwfContext); } if (vBetwDlgsFoundInSwfContext.empty ()) { FindDialogsByUniqueUrlWordsMatch (pszSwfContext, vBetwDlgs, vBetwDlgsFoundInSwfContext); LOGHTTPDLGLIST ("List of these dialogs belonging to source page (unique url word match)", vBetwDlgsFoundInSwfContext); } if (vBetwDlgsFoundInSwfContext.empty ()) { FindDialogsByUniqueUrlWordsMatch2 (pszSwfUrl, vBetwDlgs, vBetwDlgsFoundInSwfContext); LOGHTTPDLGLIST ("List of these dialogs belonging to source page (unique url words2 match)", vBetwDlgsFoundInSwfContext); } if (!vBetwDlgsFoundInSwfContext.empty ()) { wstring wstrTitle; if (pszFlashVars) ExtractTitleFromFlashVars (pWebPage, pszFlashVars, wstrTitle); if (wstrTitle.empty () && pWebPage) ExtractTitleFromHtml (pWebPage, wstrTitle); for (size_t i = 0; i < vBetwDlgsFoundInSwfContext.size (); i++) { for (size_t j = 0; j < vBetwDlgs2.size (); j++) { if (vBetwDlgs2 [j] == vBetwDlgsFoundInSwfContext [i]) { HTTPDLG pBetwDlg = vBetwDlgs2 [j]; for (size_t k = 0; k < vBetwToFlvMap [j].size (); k++) { HTTPDLG pFlvDlg = vBetwToFlvMap [j][k]; wstring wstrTitle2; if (pBetwDlg->enCT == vmsHttpTrafficCollector::HttpDialog::X_WWW_FORM_URL_ENCODED) ExtractTitleFromXWwwFormUrlEncoded (pBetwDlg, wstrTitle2); else if (pBetwDlg->enCT == vmsHttpTrafficCollector::HttpDialog::XML) ExtractTitleFromXml (pBetwDlg, wstrTitle2, pFlvDlg); if (wstrTitle2.empty ()) wstrTitle2 = wstrTitle; AddFlvDownload (pWebPage, pFlvDlg, wstrTitle2.c_str ()); } break; } } } return; } } }