日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

clamav程序的研究总结

發布時間:2024/1/23 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 clamav程序的研究总结 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、clamav-0.100.1的整體的目錄如下:

|-Clamav-milter|-Clambc|-Clamconf|-Clamdscan|-Clamdtop|-Clamscan|-Clamsubmit|-Config|-Database|-Docs|-Etc|-Examples|-Freshclam|-Libclamav ? ? //重要目錄|-7z|-c++|-jsparse|-libmspack-0.5alpha|-lzw|-nsis|-regex|-tomsfastmath|-Libclamunrar ?//關于解壓縮文件的|-Libclamunrar_iface ?//同上|-Libfreshclam|-Libltdl ? //This is GNU libltdl, a system independent dlopen wrapper for GNU libtool.|-M4|-Shared|-Sigtool|-Test|-Unit_tests|-Win321.1 libclamav中的文件列表(關于具體后綴名的相關api處理有的比較難理解,這里沒有往下測試):|-7z-iface.c ? //7z壓縮文件的相關api|-adc.c ? ? ? //adc后綴文件的相關api|-apm.c ? ? ? //apm后綴文件的相關api|-arc4.c|-asn1.c ? ? ?|-aspack.c|-autoit.c ? //編輯器產生的默認后綴?|-binhex.c ??|-blob.c|->fileblobScan(const fileblob *fb)|->cli_matchmeta()|->cli_magic_scandesc() ? //此函數在其他的后綴名文件中也出現過|->cli_base_scandesc() ?//定義在scanners.c中|->magic_scandesc() ?//具體的調用都在這個函數中|-bytecode.c ? ? ? ? ? ? ? ? //Load, and verify ClamAV bytecode.|-bytecode_api.c|-bytecode_api_decl.c|-bytecode_detect.c|-bytecode_nojit.c|-bytecode_vm.c|-cache.c|-conv.c|-cpio.c|-crtmgr.c|-crypto.c|-cvd.c|-dconf.c|-disasm.c|-dlp.c|-dmg.c|-dsig.c|-elf.c|-entconv.c|-events.c|-explode.c|-filetypes.c? ? //其中列舉了一些文件類型放在ftmap[]結構體中|-filtering.c|-fmap.c|-fpu.c|-fsg.c|-gpt.c|-hashtab.c|-hfsplus.c|-hostid.c|-htmlnorm.c|-hwp.c|-inflate64.c|-iowrap.c|-ishield.c|-iso9669.c|-is_tar.c|-jpeg.c|-json_api.c|-libmspack.c|-line.c|-lzma_iface.c|-macho.c|-matcher-ac.c|-matcher-bm.c|-matcher-hash.c|-matcher-pcre.c|-matcher.c //這里僅列舉一下文件所包含的函數名|-cli_scanbuf()|-cli_scandesc()|-cli_fmap_scandesc()|-cli_exp_eval()|-cli_caloff()|-cli_checkfp()|-cli_checkfp_virus()|-cli_matchmeta()|-void cli_targetinfo()|-mbox.c|-mbr.c|-message.c|-mew.c|-mpool.c|-msdoc.c|-msexpand.c|-msxml.c|-msxml_parser.c|-ole2_extract.c|-ooxml.c|-openioc.c|-others.c|-packlibs.c|-pdf.c|-pdfdecode.c|-pdfng.c|-pe.c|-perflogging.c|-petite.c|-pe_icons.c|-phishcheck.c|-phish_domaincheck_db.c|-phish_whitelist.c|-png.c|-prtn_intxn.c|-qsort.c|-readdb.c|-rebuildpe.c|-regex_list.c|-regex_pcre.c|-regex_suffix.c|-rijndael.c|-rtf.c|-scanners.c|-sf_base64decode.c|-sis.c|-special.c|-spin.c|-stats.c|-stats_json.c|-str.c|-strlcat.c|-swf.c|-table.c|-text.c|-textdet.c|-textnorm.c|-tiff.c|-unarj.c|-uniq.c|-unsp.c|-untar.c|-unzip.c|-upack.c|-upx.c|-uuencode.c|-vba_extract.c|-version.c|-wwunpack.c|-www.c|-xar.c|-xdp.c|-xz_iface.c|-yara_arena.c|-yara_compiler.c|-yara_exec.c|-yara_grammar.y ?//yara規則文件后綴|-yara_hash.c|-yara_lexer.c|-yara_parser.c ? //yara的github地址:https://github.com/VirusTotal/yara,|-yc.c


? 1.2 yara的相關使用
? ? ?參考鏈接:https://blog.csdn.net/m0_37552052/article/details/79012453
二、安裝及測試
? ?2.1 參考鏈接:

? ? https://github.com/Cisco-Talos/clamav-faq/blob/master/manual/Installation_guide-ClamAV%200.99.2%2B_rhel%26centos.md
? 按照文檔中的步驟,最終的成功截圖如下:

? 2.2 clamav的官方pdf文檔介紹

? ? ? 鏈接:?https://github.com/Cisco-Talos/clamav-faq/blob/master/manual/clamdoc.pdf

? 2.3 libclamav庫API提供了病毒掃描的各種函數接口。libclamav庫使用的是病毒掃描法。從病毒中提取的特征字符串被用一定的格式組織在一起并加上簽名保護就形成了病毒庫,clamav使用的病毒庫一般后綴為.cvd文件。

? ? ? ?2.3.1 在使用libclamav之前,必須調用cl_init()函數來初始化,初始化成功以后,可以調用cl_engine_new()函數來創建一個新的掃描引擎。掃描結束以后,需要調用cl_engine_free()這個函數來釋放這個引擎結構。截圖如下(可以參考examples/ex1.c文件):

? ? ? ??

? ? ??

? ? ? ? ? ?上述三個函數的原型如下:

int cl_init(unsigned int options); struct cl_engine *cl_engine_new(void); int cl_engine_free(struct cl_engine *engine);

? ? ? ? ? ? ?cl_init()和cl_engine_free()兩個函數如果調用成功,將返回CL_SUCCESS,如果返回其他code,說明函數調用失敗。

? ? ? ? ? ? ?cl_init函數的實參傳入CL_INIT_DEFAULT即可。

? ? ? ? ? ? ?cl_engine_new()如果調用成功將返回一個指向struct cl_engine結構體的指針,如果失敗將返回NULL.

? ? ? ? ?2.3.2 得到新的掃描引擎以后,需要進行特征庫的加載,clamav提供了兩個函數:

const char *cl_retdbdir(void); int cl_load(const char *path, struct cl_engine *engine,unsigned int *signo, unsigned int options);

? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ?cl_retdbdir返回CLamav特征庫的默認路徑。

? ? ? ? ? ? ? ? ?cl_load函數根據給出的具體特征庫路徑,加載單個特征文件,或者加載幾個特征文件(給出的實參是文件夾)。第二個參數傳入cl_engine_new得到的engine,第三個參數傳入加載的特征碼的條數,最后一個參數為加載的選項,一般傳入CL_DB_STDOPT即可。

? ? ? ?2.3.3 以上的步驟完成以后,需要調用cl_engine_compile()函數做最后的文件掃描前的準備,函數原型為:

int cl_engine_compile(struct cl_engine *engine);

? ? ? 2.3.4 現在可以掃描文件了

? ? ? ? ?

? ? ? ? ? ?函數的原型為:

|->int cl_scanfile(const char *filename, const char **virname, unsigned long int *scanned, const struct cl_engine *engine,unsigned int options);|->cl_scandesc_callback()|->scan_common()|->cli_map_scandesc() //for map scans that are not forced to disk|->cli_mem_scandesc() |->cli_map_scan()|->cli_base_scandesc(fd, ctx, type); //多處調用了此函數,庫函數中的重要函數|->magic_scandesc(ctx, type); //此函數中處理各種不同接口函數,不再往下分析

? ? ? ? ? ? 該函數需要注意的一點是,virname在函數中指向了engine結構體的表示目標掃描文件名稱的內存,不能被直接釋放。

三、相關鏈接

? ? 鏈接:http://outstandingcandy.blog.163.com/blog/static/1627591192010101962351249/

? ? 上面鏈接主要是分析了clamav代碼。

總結

以上是生活随笔為你收集整理的clamav程序的研究总结的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。