MemoryAnalysis sub-routine for running processes analysis
(proc *ProcessInformation, pQuarantine string, pKill bool, pNotifications bool, pVerbose bool, rules *yara.Rules)
| 92 | |
| 93 | // MemoryAnalysis sub-routine for running processes analysis |
| 94 | func MemoryAnalysis(proc *ProcessInformation, pQuarantine string, pKill bool, pNotifications bool, pVerbose bool, rules *yara.Rules) { |
| 95 | if pVerbose { |
| 96 | logMessage(LOG_INFO, "[INFO] [MEMORY] Analyzing", proc.ProcessName, "PID:", proc.PID) |
| 97 | } |
| 98 | |
| 99 | result := PerformYaraScan(&proc.MemoryDump, rules, pVerbose) |
| 100 | if len(result) > 0 { |
| 101 | // windows notifications |
| 102 | if pNotifications { |
| 103 | NotifyUser("YARA match", proc.ProcessName+" - PID:"+fmt.Sprint(proc.PID)+" match "+fmt.Sprint(len(result))+" rules") |
| 104 | } |
| 105 | |
| 106 | // logging |
| 107 | for _, match := range result { |
| 108 | logMessage(LOG_INFO, "[ALERT]", "[MEMORY] YARA match", proc.ProcessName, "PID:", fmt.Sprint(proc.PID), match.Namespace, match.Rule) |
| 109 | } |
| 110 | |
| 111 | // dump matching process to quarantine |
| 112 | if len(pQuarantine) > 0 { |
| 113 | logMessage(LOG_INFO, "[INFO]", "DUMPING PID", proc.PID) |
| 114 | err := QuarantineProcess(proc, pQuarantine) |
| 115 | if err != nil { |
| 116 | logMessage(LOG_ERROR, "[ERROR]", "Cannot quarantine PID", proc.PID, err) |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | // killing process |
| 121 | if pKill { |
| 122 | logMessage(LOG_INFO, "[INFO]", "KILLING PID", proc.PID) |
| 123 | KillProcessByID(proc.PID, pVerbose) |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | } |
| 128 | |
| 129 | // QuarantineProcess dump process memory and cipher them in quarantine folder |
| 130 | func QuarantineProcess(proc *ProcessInformation, quarantinePath string) (err error) { |
no test coverage detected