riskdetect——恶意软件以及webshell检测
来源:互联网 发布:源美网络 半价商城 编辑:程序博客网 时间:2024/06/15 10:33
##检测方法
- 文件 hash 比较以及 fuzzy hash ([已知文件|未知文件]) (ssdeep)
- 代码特征值,危险函数检测 (yara)
最开始的思路就是调用yara和ssdeep这两个程序进行检测,但是后来发现直接用编译好的ssdeep进行检测的时候会有一些问题。于是就用go实现了ssdeep的绑定。可以参考我之前的文章《gossdeep——ssdeep的go绑定》
两个核心的检测方法代码如下:
package webshellimport ("github.com/MXi4oyu/Utils/subprocess""github.com/MXi4oyu/Utils/cnencoder/gb18030""github.com/MXi4oyu/Utils/walkpath""github.com/MXi4oyu/gossdeep/deepapi""context""time""strings""os""bufio""io""fmt""strconv")func Webshelldetect(shell_path ,ssdeep_features_path,yara_rule_path string) []string {res1:=make([]string,10,50)res2:=make([]string,10,50)res1=append(res1,res2[:]...)return res1}func Yara(rule_path,dir_path string) ([]map[string]string) {funny_res := make([]map[string]string,0,100)ctx, cancel := context.WithTimeout(context.Background(), time.Duration(6000)*time.Second)defer cancel()str,err:=subprocess.RunCommand(ctx,"yara",rule_path,"-r",dir_path)if err!=nil{fmt.Println(err.Error())}line:=gb18030.Decode(str)s:=strings.Split(line,"\n")for _,file_dir:=range s{var file_type,file_path stringif len(file_dir)>0{res:=make(map[string]string)ss:=strings.Split(file_dir," ")file_type=ss[0]file_path=ss[1]res["type"]=file_typeres["path"]=file_pathres["level"]="danger"res["like"]="100"funny_res=append(funny_res,res)}}return funny_res}var filehashmap = make([]string,0,100)//处理每一行func processLine(line []byte) {linestr:=string(line)linearray:=strings.Split(linestr,",")linehash:=linearray[0]filehashmap=append(filehashmap,linehash)}//逐行读取文件func FileReadLine(filepath string,hookfunc func([] byte)) error {f,err:=os.Open(filepath)if err!=nil{return err}defer f.Close()mybufReader:=bufio.NewReader(f)for{line,err:=mybufReader.ReadBytes('\n')hookfunc(line)if err!=nil{if err==io.EOF{return nil}return err}}return nil}func Ssdeep(rule_path,dir_path,suffix string) ([]map[string]string) {funny_res := make([]map[string]string,0,100)//提取所有样本文件中的hashFileReadLine(rule_path,processLine)//fmt.Println(filehashmap)//遍历要检测的目录下的所有文件files,err:=walkpath.WalkDir(dir_path,suffix)if err!=nil{fmt.Println(err.Error())}//提取文件的hash值for _,f :=range files{//fmt.Println(f)hashvalue:=deepapi.Fuzzy_hash_file(f)//遍历filehashmap,对比相似度for _,m := range filehashmap{res:=make(map[string]string)res["type"]="webshell"res["path"]=fif len(m)>5{similary:=deepapi.Fuzzy_compare(m,hashvalue)res["like"]=strconv.Itoa(similary)if similary>30{simi:=similary/10switch simi {case 3,4,5:res["level"]="info"funny_res=append(funny_res,res)breakcase 6,7,8:res["level"]="warning"funny_res=append(funny_res,res)breakcase 9,10:res["level"]="danger"funny_res=append(funny_res,res)break}}else{//fmt.Println("safe")}}}}return funny_res}没太多技术含量,可以关注我的github,参考完整代码。
https://github.com/MXi4oyu/riskdetect
后续还会更新,文章先写到这。
阅读全文
0 0
- riskdetect——恶意软件以及webshell检测
- 恶意软件反检测技术介绍
- CSDN视频频道检测到恶意软件!
- 第六章:iOS恶意软件和后门 ——6.1 iOS恶意软件史
- 第六章:iOS恶意软件和后门 ——6.3 后门、恶意软件实例
- 10个在线检测病毒和恶意软件网站
- 恶意软件反检测技术简介:反调试技术解析
- 恶意软件反检测技术简介:模拟器超限技术
- 机器学习之恶意软件分类和检测
- 基于静态分析的Android恶意软件检测
- WebShell的检测技术
- 浅谈webshell检测方法
- webshell检测方法归纳
- 威胁情报 应急响应 以及 恶意软件分析资料
- 恶意软件分析诀窍与工具箱——对抗“流氓”软件的技术与利器
- 恶意URL检测
- Android服务器——使用TomCat实现软件的版本检测,升级,以及下载更新进度!
- 绕过WAF检测WebShell通信
- python 面向对象(进阶篇)
- 制作嵌入式根文件系统的错误分析
- 国内最火的 HTML、CSS、JavaScript 开源项目 Top 榜
- mingw编译VTK
- Activity和Fragment的生命周期
- riskdetect——恶意软件以及webshell检测
- @ResponseBody注解的使用
- HEVC学习(四) —— 帧内预测系列之二
- TensorFlow 官方文档中文版
- Java中的值传递和引用传递
- BlockingQueue
- web前端性能优化总结
- Java静态方法为什么不能访问非静态方法
- 蓝牙HCI剖析(一)