25.12.2014 Views

Analysis and Evaluation of the Windows Event Log - Bill Buchanan

Analysis and Evaluation of the Windows Event Log - Bill Buchanan

Analysis and Evaluation of the Windows Event Log - Bill Buchanan

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Barrie Codona, BSc (Hons) Network Computing, 2007<br />

public static void OnRenamed(object source, Renamed<strong>Event</strong>Args e)<br />

{<br />

// Specify what is done when a file is renamed.<br />

string message = "" + DateTime.Now +<br />

"" + GlobalClass.user + ""<br />

+ e.ChangeType + "" + e.FullPath +<br />

"";<br />

}<br />

// Pass <strong>the</strong> ‘message’ to <strong>the</strong> next stage.<br />

sendmsg(message);<br />

Figure 22: Capturing <strong>Event</strong>s<br />

5.2.4 HMAC<br />

Figure 23 shows <strong>the</strong> code that is used to generate <strong>the</strong> HMAC checksum. The ‘key’ is<br />

taken from a user input when <strong>the</strong> application is first launched; it is <strong>the</strong>n passed into<br />

<strong>the</strong> following code along with <strong>the</strong> events that have been generated by <strong>the</strong><br />

‘FileSystemWatcher’ class. The resulting checksum value is <strong>the</strong>n wrapped in XML<br />

tags <strong>and</strong> attached to <strong>the</strong> end <strong>of</strong> <strong>the</strong> captured events string.<br />

// Declare a new instance <strong>of</strong> Ascii Ecnoding called ‘encoding’.<br />

System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();<br />

// Convert <strong>the</strong> HMAC key to a byte value.<br />

byte[] keyByte = encoding.GetBytes(key);<br />

// Create a new instance <strong>of</strong> HMAC with SHA1.<br />

HMACSHA1 hmac = new HMACSHA1(keyByte);<br />

// Convert <strong>the</strong> message to a byte value.<br />

byte[] messageBytes = encoding.GetBytes(chkMessage);<br />

// Compute <strong>the</strong> hash signature.<br />

byte[] hashmessage = hmac.ComputeHash(messageBytes);<br />

// Update <strong>the</strong> value <strong>of</strong> <strong>the</strong> ‘chkMessage’ string.<br />

chkMessage = chkMessage + "" + ByteToString(hashmessage) +<br />

"";<br />

Figure 23: Generating an HMAC hash signature<br />

5.2.5 Encrypting<br />

Figure 24 shows <strong>the</strong> code that is used to encrypt <strong>the</strong> <strong>Event</strong> Message, <strong>the</strong> code for it is<br />

from a program by Ma<strong>the</strong>w Schlabaugh (CodeProject, 2008). The cipher text is<br />

generated by breaking down <strong>the</strong> plain text into blocks that are smaller than <strong>the</strong> key<br />

that is used to encode <strong>the</strong>m. The smaller blocks are <strong>the</strong>n encoded with <strong>the</strong> Servers<br />

public key, this <strong>the</strong>n makes <strong>the</strong>m ready to be sent to <strong>the</strong> server.<br />

43

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!