public void ScriptInvokeHandler(BabelShellfish sender, BabelShellfish.ScriptType type, String message) { if (!String.IsNullOrEmpty(this.LogPath)) { string logString = String.Format( CultureInfo.InvariantCulture, "{0:yyyy-MM-dd-HH:mm:ss} - {1}: {2}", DateTime.Now, type.ToString(), message); try { StreamWriter contentWriter; try { contentWriter = new StreamWriter( new FileStream(this.LogPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read)); contentWriter.BaseStream.Seek(0, SeekOrigin.End); } catch { contentWriter = new StreamWriter( new FileStream(this.LogPath, FileMode.Append, FileAccess.Write, FileShare.Read)); } contentWriter.AutoFlush = true; contentWriter.WriteLine(logString); contentWriter.Flush(); contentWriter.Close(); } catch (Exception) { } } }
public void ScriptInvokeHandler(BabelShellfish sender, BabelShellfish.ScriptType type, String message) { string logString = String.Format( CultureInfo.InvariantCulture, "{0:yyyy-MM-dd-HH:mm:ss} - {1}: {2}\n", DateTime.Now, type.ToString(), message); OutputDebugString(logString); }
public void ScriptScanHandler(BabelShellfish sender, BabelShellfish.ScriptType type, String message) { // Scan only if the source is not AMSI (to avoid endless loops) if (BabelShellfish.ScriptType.Amsi != type) { uint amsiResult = sender.ScanWithAmsi(message, null); if (1 < amsiResult) { throw new ParseException("This script contains malicious content and has been blocked by your antivirus software."); } } }