MCPcopy Index your code
hub / github.com/codeyourweb/irma / MemoryAnalysis

Function MemoryAnalysis

analysis.go:94–127  ·  view source on GitHub ↗

MemoryAnalysis sub-routine for running processes analysis

(proc *ProcessInformation, pQuarantine string, pKill bool, pNotifications bool, pVerbose bool, rules *yara.Rules)

Source from the content-addressed store, hash-verified

92
93// MemoryAnalysis sub-routine for running processes analysis
94func 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
130func QuarantineProcess(proc *ProcessInformation, quarantinePath string) (err error) {

Callers 1

MemoryAnalysisRoutineFunction · 0.85

Calls 5

logMessageFunction · 0.85
PerformYaraScanFunction · 0.85
NotifyUserFunction · 0.85
QuarantineProcessFunction · 0.85
KillProcessByIDFunction · 0.85

Tested by

no test coverage detected