Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Building Security Awareness in .NET Assemblies : Part 1 - Learn to break a .NET Assembly

, 31 Oct 2004
Building Security Awareness in .NET Assemblies : Part 1 of 3
necodersarticle1_demo.zip
CrackingIL Executable pt1
CrackingIL.exe
CrackingIL.FrmSecureApp.resources
necodersarticle1_src.zip
CrackingIL Source Code pt1
App.ico
CrackingIL.csproj.user
HackingIL.resharperoptions
////////////////////////////////////////////////////////////////////////////
/// Building Security Awareness in .Net Assemblies 
/// Part 1
/// CrackingIL.sln
/// Developed by: Chua Wen Ching
/// Email me: chuawenching@necoders.com
/// Visit us: http://www.necoders.com
////////////////////////////////////////////////////////////////////////////

using System;
using System.ComponentModel;
using System.Security.Permissions;
using System.Windows.Forms;

// need this to call the RegistryKey
using Microsoft.Win32;

[assembly: IsolatedStorageFilePermission(SecurityAction.RequestMinimum, UserQuota=1048576)]
namespace CrackingIL
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class FrmSecureApp : Form
	{
		private Label lblHeader;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private Container components = null;

		public FrmSecureApp()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.lblHeader = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// lblHeader
			// 
			this.lblHeader.Font = new System.Drawing.Font("Arial", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblHeader.Location = new System.Drawing.Point(24, 16);
			this.lblHeader.Name = "lblHeader";
			this.lblHeader.Size = new System.Drawing.Size(216, 136);
			this.lblHeader.TabIndex = 0;
			this.lblHeader.Text = "Welcome To NeCoders";
			// 
			// FrmSecureApp
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(292, 173);
			this.Controls.Add(this.lblHeader);
			this.Name = "FrmSecureApp";
			this.Text = "Secure App v1.0";
			this.Load += new System.EventHandler(this.FrmSecureApp_Load);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new FrmSecureApp());
		}

		/// <summary>
		/// Verifies the registry to make sure the serial number is in there
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void FrmSecureApp_Load(object sender, EventArgs e)
		{
			RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Necoders");

			if (key == null)
			{
				MessageBox.Show("Please acquire a license to run this!");
				this.Dispose(true);				
			}
			else
			{
				string validSerial = "1111-1111-1111-1111";

				if ((string)key.GetValue("serial") == validSerial)
				{
					return;
				}
				else if (key.GetValue("serial") == null)
				{
					MessageBox.Show("Please acquire a license to run this!");
					this.Dispose(true);
				}
				else
				{
					MessageBox.Show("Wrong serial number");
					this.Dispose(true);
				}
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Chua Wen Ching
Software Developer
Malaysia Malaysia
I am Chua Wen Ching and it is great to be part of CodeProject network Smile | :)

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 1 Nov 2004
Article Copyright 2004 by Chua Wen Ching
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid