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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

5.3 Data Archiving System<br />

5.3.1 Listening for a Connection<br />

The data archiving system is in an always listening state until a connection has been<br />

made, Figure 26 shows that this one is listening on port 13000 for an incoming TCP<br />

connection. When a Client connects it takes records some <strong>of</strong> its details, <strong>and</strong> it <strong>the</strong>n<br />

generates an RSA Key Pair, which is <strong>the</strong>n sent t <strong>the</strong> client.<br />

// Lisetn for a connection on port 13000.<br />

IPEndPoint ipep = new IPEndPoint(IPAddress.Any,13000);<br />

// Create a new socket for <strong>the</strong> connection.<br />

Socket newsock = new<br />

Socket(AddressFamily.InterNetwork,SocketType.Stream,<br />

ProtocolType.Tcp);<br />

// Bind <strong>the</strong> socket to <strong>the</strong> connection.<br />

newsock.Bind(ipep);<br />

// Place <strong>the</strong> socket into a listening state.<br />

newsock.Listen(10);<br />

Console.WriteLine("Waiting for a client...");<br />

Socket client = newsock.Accept();<br />

IPEndPoint clientep =(IPEndPoint)client.RemoteEndPoint;<br />

// Display a message when a client has connected.<br />

Console.WriteLine("Connected with {0} at port {1}",clientep.Address,<br />

clientep.Port);<br />

5.3.2 Generating Keys<br />

Figure 26: Server Listening for a Connection<br />

Figure 27 shows <strong>the</strong> routine that was used to generate both <strong>the</strong> public <strong>and</strong> private RSA<br />

keys, <strong>the</strong>se keys are <strong>the</strong>n exported to an XML string, <strong>the</strong> public key gets sent to <strong>the</strong><br />

Client <strong>and</strong> <strong>the</strong> Private key stays with <strong>the</strong> data archiving system.<br />

// Specify <strong>the</strong> size <strong>of</strong> <strong>the</strong> key that will be generated.<br />

int dwKeySize = 1024;<br />

// Create a new instance <strong>of</strong> RSACryptoServiceProvider to generate<br />

// public <strong>and</strong> private key data using <strong>the</strong> specified key size.<br />

RSACryptoServiceProvider RSAProvider = new<br />

RSACryptoServiceProvider(dwKeySize);<br />

// Convert <strong>the</strong> public <strong>and</strong> private keys into XML format.<br />

string publicAndPrivateKeys = RSAProvider.ToXmlString(true);<br />

// Convert <strong>the</strong> public key into XML format.<br />

string justPublicKey = RSAProvider.ToXmlString(false);<br />

Figure 27: Generating an RSA Key Pair<br />

45

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

Saved successfully!

Ooh no, something went wrong!