Results 1 to 8 of 8

Thread: I need some help to make a keygen

  1. #1
    g_ramzi
    Guest

    Unhappy I need some help to make a keygen

    how to make a keygen for this?


    the "strkey" must be like this :: 11111111-1111111-111111111-111111111


    public static void SetLicence (string strKey)

    {

    string str = "";
    string str2 = "";
    string str3 = "";
    string str4 = "";
    if ((strKey != "") && (strKey.Length == 35))
    {
    StringBuilder builder = new StringBuilder();
    for (int i = 0; i < strKey.Length; i++)
    {
    if ((strKey[i] > 'F') && (strKey[i] < '['))
    {
    builder.Append('0');
    }
    else
    {
    builder.Append(strKey[i]);
    }
    }
    strKey = builder.ToString();
    str = strKey.Substring(0, 8);
    strKey = strKey.Replace(str + "-", "");
    str2 = strKey.Substring(0, 8);
    strKey = strKey.Replace(str2 + "-", "");
    str3 = strKey.Substring(0, 8);
    strKey = strKey.Replace(str3 + "-", "");
    str4 = strKey;
    long num2 = 0L;
    num2 += Convert.ToInt32(str.Substring(0, 3), 16);
    num2 += Convert.ToInt32(str2.Substring(0, 3), 16);
    num2 += Convert.ToInt32(str3.Substring(0, 3), 16);
    if (num2 == Convert.ToInt32(str4, 16))
    {
    FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
    string str5 = Convert.ToInt32(str.Substring(0, 6), 16).ToString();
    if ((versionInfo.FileMajorPart.ToString("0") + versionInfo.FileMinorPart.ToString("00")) == str5.Substring(0, 3))
    {
    string code = GetCode();
    long num3 = 0L;
    for (int j = 0; j < code.Substring(6).Length; j++)
    {
    num3 += (long) code.Substring(6)[j];
    }
    if (Convert.ToInt32(str2, 16) == ((num3 * 999) % 0x7fffffffL))
    {
    MessageBox.Show("Good Work!!!!");
    }
    }
    }
    }
    if (menmLicenseType == LicenseType.Demo)
    {
    MessageBox.Show("Try again!!!!");
    }


    }





    //// And Thanks a lot!!!!
    I promise that I have read the FAQ and tried to use the Search to answer my question.

  2. #2
    Seeing as you have the source code...or part of the source code?

    I would suggest compiling it and adding debug messages
    (ie MessageBox.Show(code); ) after it gets assigned to see what the value is, basically you just need to understand the code very well.


    PS source code = keygen. You should be able to edit any source code to make its own keygen.

  3. #3
    g_ramzi
    Guest

    My friend thanks for help. You are the only person to give me some help

    ///This is what i've done until now

    ///I'm planning to use this code to protect my program after making a keygen ///for it




    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Diagnostics;
    using System.Reflection;
    using System.Runtime.InteropServices;

    namespace Keygen
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
    //MessageBox.Show(Convert.GetTypeCode(textBox1.Text).ToString());
    textBox2.Text = Convert.ToInt32(textBox1.Text, 16).ToString();
    }

    private void button2_Click(object sender, EventArgs e)
    {
    // MessageBox.Show(DecimalToBase(Convert.ToInt32(textBox2.Text), 16,8));
    string code = GetCode();
    long num3 = 0L;
    for (int j = 0; j < code.Substring(6).Length; j++)
    {
    num3 += (long)code.Substring(6)[j];
    }
    MessageBox.Show(DecimalToBase((int)((num3 * 2457) % 2147483647),16,8));

    }


    private static string DecimalToBase(int iDec, int numbase, int intLength)
    {
    char[] chArray = new char[] { 'A', 'B', 'C', 'D', 'E', 'F' };
    string str = "";
    int[] numArray = new int[20];
    int num = 20;
    while (iDec > 0)
    {
    int num2 = iDec % numbase;
    numArray[--num] = num2;
    iDec /= numbase;
    }
    for (int i = 0; i < numArray.Length; i++)
    {
    if (((int)numArray.GetValue(i)) >= 10)
    {
    str = str + chArray[((int)numArray.GetValue(i)) % 10];
    }
    else
    {
    str = str + numArray.GetValue(i);
    }
    }
    str = str.TrimStart(new char[] { '0' });
    string str2 = "";
    for (int j = 1; j <= (intLength - str.Length); j++)
    {
    str2 = str2 + "0";
    }
    return (str2 + str);

    }

    public static string GetCode()
    {
    FileVersionInfo fileVersionInfo1 = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
    int i1 = (((fileVersionInfo1.FileMajorPart * 100000) + (fileVersionInfo1.FileMinorPart * 1000)) + fileVersionInfo1.FileBuildPart);
    i1 *= 2;
    string string1 = string.Format("{0:X6}", i1);
    string string2 = GetVolumeSerial(Assembly.GetExecutingAssembly().Location.Substring(0, 1));
    return (string1 + string2);

    }

    [DllImportAttribute("kernel32.dll", EntryPoint = "GetVolumeInformation", CharSet = CharSet.None, ExactSpelling = false, SetLastError = false, PreserveSig = true, CallingConvention = CallingConvention.Winapi, BestFitMapping = false, ThrowOnUnmappableChar = false)]
    [PreserveSigAttribute()]
    private static extern long GetVolumeInformation(string PathName, StringBuilder VolumeNameBuffer, uint VolumeNameSize, ref uint VolumeSerialNumber, ref uint MaximumComponentLength, ref uint FileSystemFlags, StringBuilder FileSystemNameBuffer, uint FileSystemNameSize);
    private static string GetVolumeSerial(string strDriveLetter)
    {
    string s = "";
    uint uInt32_1 = uint.MinValue;
    uint uInt32_2 = uint.MinValue;
    StringBuilder stringBuilder1 = new StringBuilder(256);
    uint uInt32_3 = uint.MinValue;
    StringBuilder stringBuilder2 = new StringBuilder(256);
    strDriveLetter = (strDriveLetter + ":\\");
    long int64_1 = GetVolumeInformation(strDriveLetter, stringBuilder1, ((uint)stringBuilder1.Capacity), ref uInt32_1, ref uInt32_2, ref uInt32_3, stringBuilder2, ((uint)stringBuilder2.Capacity));
    s = Convert.ToString(uInt32_1).Replace("-", "");
    return s;
    }
    }
    }
    I promise that I have read the FAQ and tried to use the Search to answer my question.

  4. #4

    well...

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Diagnostics;
    using System.Reflection;
    using System.Runtime.InteropServices;
    
    namespace Keygen
    {
    	public partial class Form1 : Form
    	{
    		public Form1()
    		{
    			InitializeComponent();
    		}
    
    		private void button1_Click(object sender, EventArgs e)
    		{
    			//MessageBox.Show(Convert.GetTypeCode(textBox1.Text).ToString());
    			textBox2.Text = Convert.ToInt32(textBox1.Text, 16).ToString();
    		}
    
    		private void button2_Click(object sender, EventArgs e)
    		{
    			// MessageBox.Show(DecimalToBase(Convert.ToInt32(textBox2.Text), 16,8));
    			string code = GetCode();
    			long num3 = 0L;
    			
    			for (int j = 0; j < code.Substring(6).Length; j++)
    			{
    				num3 += (long)code.Substring(6)[j];
    			}
    			
    			MessageBox.Show(DecimalToBase((int)((num3 * 2457) % 2147483647),16,8));
    		}
    
    
    		private static string DecimalToBase(int iDec, int numbase, int intLength)
    		{
    			char[] chArray = new char[] { 'A', 'B', 'C', 'D', 'E', 'F' };
    			string str = "";
    			int[] numArray = new int[20];
    			int num = 20;
    			
    			while (iDec > 0)
    			{
    				int num2 = iDec % numbase;
    				numArray[--num] = num2;
    				iDec /= numbase;
    			}
    			
    			for (int i = 0; i < numArray.Length; i++)
    			{
    				if (((int)numArray.GetValue(i)) >= 10)
    				{
    					str = str + chArray[((int)numArray.GetValue(i)) % 10];
    				}
    				else
    				{
    					str = str + numArray.GetValue(i);
    				}
    			}
    			
    			str = str.TrimStart(new char[] { '0' });
    			string str2 = "";
    			
    			for (int j = 1; j <= (intLength - str.Length); j++)
    			{
    				str2 = str2 + "0";
    			}
    			return (str2 + str);
    
    		}
    
    		public static string GetCode()
    		{
    			FileVersionInfo fileVersionInfo1 = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
    			int i1 = (((fileVersionInfo1.FileMajorPart * 100000) + (fileVersionInfo1.FileMinorPart * 1000)) + fileVersionInfo1.FileBuildPart);//get version info and format it
    			i1 *= 2; //double our version number...
    			string string1 = string.Format("{0:X6}", i1); //take version info (doubled) and get the HEX string of it
    			string string2 = GetVolumeSerial(Assembly.GetExecutingAssembly().Location.Substring(0, 1)); //volume serial using drive letter in some weird fashion 
    			return (string1 + string2); //concatenates version with serial
    		}
    
    		[DllImportAttribute("kernel32.dll", EntryPoint = "GetVolumeInformation", CharSet = CharSet.None, ExactSpelling = false, SetLastError = false, PreserveSig = true, CallingConvention = CallingConvention.Winapi, BestFitMapping = false, ThrowOnUnmappableChar = false)]
    		[PreserveSigAttribute()]
    		
    		private static extern long GetVolumeInformation(string PathName, StringBuilder VolumeNameBuffer, uint VolumeNameSize, ref uint VolumeSerialNumber, ref uint MaximumComponentLength, ref uint FileSystemFlags, StringBuilder FileSystemNameBuffer, uint FileSystemNameSize);
    		
    		private static string GetVolumeSerial(string strDriveLetter)
    		{
    			string s = "";
    			uint uInt32_1 = uint.MinValue;
    			uint uInt32_2 = uint.MinValue;
    			StringBuilder stringBuilder1 = new StringBuilder(256);
    			uint uInt32_3 = uint.MinValue;
    			StringBuilder stringBuilder2 = new StringBuilder(256);
    			strDriveLetter = (strDriveLetter + ":\\"); //concatenate drive letter such as "C" with ":\"
    			long int64_1 = GetVolumeInformation(strDriveLetter, stringBuilder1, ((uint)stringBuilder1.Capacity), ref uInt32_1, ref uInt32_2, ref uInt32_3, stringBuilder2, ((uint)stringBuilder2.Capacity));
    			s = Convert.ToString(uInt32_1).Replace("-", ""); //remove our dashes from return (lpVolumeSerialNumber)
    			return s; //send back lpVolumeSerialNumber without dashes
    		}
    	}
    } 
    
    
    
    
    
    
    
    public static void SetLicence (string strKey) {
    	string str = "";
    	string str2 = "";
    	string str3 = "";
    	string str4 = "";
    	if ((strKey != "") && (strKey.Length == 35)) //length must be 35, or quit
    	{
    		StringBuilder builder = new StringBuilder();
    		
    		for (int i = 0; i < strKey.Length; i++) //loop through the 35 
    		 {
    			if ((strKey[i] > 'F') && (strKey[i] < '[')) // check if its between 70 and 91 (ascii codes for values), if so make it zero
    			{											// this is F-Z basically
    				builder.Append('0');
    			}
    			else  //if it's below 70 or above 90 keep it.
    			{     // That makes it 0-9 and A-F as well as a-z if there is no toUpper command.
    				builder.Append(strKey[i]);
    			}
    		}
    		
    		strKey = builder.ToString(); //Missing the code for the function, but make our array into 3 strings again?
    		
    		str = strKey.Substring(0, 8); // get the first 9 characters
    		strKey = strKey.Replace(str + "-", ""); //remove a dash
    		str2 = strKey.Substring(0, 8);// get the next 9 characters
    		strKey = strKey.Replace(str2 + "-", "");//remove a dash
    		str3 = strKey.Substring(0, 8);// get the last 9 characters
    		strKey = strKey.Replace(str3 + "-", "");//remove a dash
    		str4 = strKey; //str4 holds our whole serial now
    		
    		long num2 = 0L;
    		
    		num2 += Convert.ToInt32(str.Substring(0, 3), 16); //make 32 bit int (of the first 4 letters of str), add it to zero
    		num2 += Convert.ToInt32(str2.Substring(0, 3), 16); //make 32 bit int(of the first 4 letters of str2), add it to the last one
    		num2 += Convert.ToInt32(str3.Substring(0, 3), 16); //make 32 bit int(of the first 4 letters of str3), add it to the last one
    		
    		if (num2 == Convert.ToInt32(str4, 16)) //make the whole serial into a 32 bit int
    		{
    			FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); //Returns name of application
    			string str5 = Convert.ToInt32(str.Substring(0, 6), 16).ToString(); //convert first 7 chars of str to an int, then to a string
    			
    			if ((versionInfo.FileMajorPart.ToString("0") + versionInfo.FileMinorPart.ToString("00")) == str5.Substring(0, 3)) //Returns version info
    			{
    				string code = GetCode(); //returns (version*2 in hex) + with volume serial (without dashes)
    				long num3 = 0L; //new variable...
    				
    				for (int j = 0; j < code.Substring(6).Length; j++) //loop through the code from above.
    				{
    					num3 += (long) code.Substring(6)[j]; //sum up all the values of the code
    				}
    				if (Convert.ToInt32(str2, 16) == ((num3 * 999) % 0x7fffffffL)) //recall what str2was as a 32bit int, check if it == num3*999 modulus 2147483647
    				{
    					MessageBox.Show("Good Work!!!!"); 
    				}
    			}
    		}
    	}
    	if (menmLicenseType == LicenseType.Demo)
    	{
    		MessageBox.Show("Try again!!!!");
    Last edited by personmans; November 9th, 2008 at 14:14. Reason: UPDATE

  5. #5
    (One thing I'm missing is what the Substring(6) does, I THINK it grabs everything after the 6th value, which means it ignores the whole version number thing, and adds up the digits of the volume serial.)
    Updated commented code, I'm still not sure what you are doing with this. Are you writing a protection or trying to figure out what it does?

    If you are trying to figure it out, write down your computers serial number without dashes and add up the digits of the volume serial.Now multiply by 999 and modulus 2147483647.
    This is the number you want to equal.

    Now take the 2nd set of characters from the serial number that you have
    (say its 11111111-11111111-11111111-11111111)

    and run it through the loop at the start of the program:
    In this case, you still get 11111111
    Then "Convert.ToInt32" it.
    And it has to == that number (in bold) above
    Last edited by personmans; November 9th, 2008 at 14:32.

  6. #6
    g_ramzi
    Guest

    Thanks for help

    In fact, i've ripped the code using reflector and i want to make a keygen in order to be able to use it for protecting my program.
    Due to its complexity, i want to reverse it than i will use it after making some changes surely.
    I promise that I have read the FAQ and tried to use the Search to answer my question.

  7. #7
    Quote Originally Posted by g_ramzi View Post
    In fact, i've ripped the code using reflector and i want to make a keygen in order to be able to use it for protecting my program.
    Due to its complexity, i want to reverse it than i will use it after making some changes surely.
    If you are still stuck on making a keygen, please read up on .NET code or get a compiler and see what the results of each variable would be at each step of the program. By looking at the outputs, you will be able to determine what has changed and then make a keygen to copy that functionality.

    It seems to me like, in order to make this scheme work, you would have to get the volume serial and version number from the user. -> I would make an option in the program to output these using a reversible encryption and ask the user to email it to you. That way you reverse the encryption, plug the values in your keygen, and provide them with a key.

    All in all I don't think this code would make the strongest keys.

  8. #8
    g_ramzi
    Guest

    Ok my friend!

    Always thank you for the help. I'm still trying to understand the functioning of the code but it is really a little bit complex. I do not lose the hope .
    I promise that I have read the FAQ and tried to use the Search to answer my question.

Similar Threads

  1. Process to make keygen when FlexLM protected software with extra check item
    By bridgeic in forum Advanced Reversing and Programming
    Replies: 4
    Last Post: July 21st, 2012, 10:41
  2. my first keygen!
    By yellow24 in forum Off Topic
    Replies: 2
    Last Post: April 5th, 2010, 11:00
  3. keygen masm
    By tHE SnaKe in forum Malware Analysis and Unpacking Forum
    Replies: 3
    Last Post: June 17th, 2002, 10:48
  4. win xp keygen
    By mambox in forum Advanced Reversing and Programming
    Replies: 10
    Last Post: December 10th, 2001, 12:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •