[Tutorial] Part II: How to make a Working (Fake) Keygen using AutoIt 3

Welcome to CPAElites - the original incentive CPA affiliate marketing forum online, solely based on "Cost Per Action".

Be a part of something great, join today! Learn CPA marketing with CPAElites, we will teach you everything such as the best CPA networks, CPA offers with highest payouts and best conversion rates, unsaturated CPA niches, most effective traffic sources and more.

Springfire

Well-known member
VIP Legends CPAElites Classic (1.0)
VIP Elites CPAElites Classic (1.0)
Joined
August 9, 2013
Messages
168
Reaction score
1
I’m glad to get some responses and requests based on my previous AutoIt tutorial here. So in this part, I’ll continue with things I’ve missed and we move onto creating a working (fake) keygen.


Skinning (Contd.)

For those users who want to create a custom skin for their game hack, should definitely checkout SkinBuilder. It allows us to customize every small detail of the GUI but it seems tedious to start everything from scratch.

TIP: Do you remember customizing your Windows XP with .msstyles? These formats can be imported and exported as .skf skins. You can get .msstyles from http://www.skinbase.org/Skins/msstyles/135 and some other sites. I got my Zune style back!


Making the Keygen to Work

Ah! The hard part of adding interactivity to the program, but believe me its fun! It’ll will be a lot easier when you understand “what happens next” i.e., the program flow and for help with the coding, there is always Google.

I’ll show you a complete example of creating a keygen with some basic functions which may help you to get started .


The Program

The program we will be making is Grand Theft Auto 5 Beta Key Generator, which upon open, prompts the user to enter a licence key. If the user doesn’t have the key, they must click Get Key button which will send them to FileIce survey containing Password.txt
After the user unlocks it, there will be a Generate button. On clicking it, a progress bar will load for 10 seconds and the key is displayed.


Design

First, we will start Koda Form Designer and design two forms: one for Enter License Key and another for Generator. Copy the code and keep them handy.

design_01.png


Linking Both GUIs

Now merge the code in SciTE Editor, declaring include statements only once. Also be sure to check no two variables are same. On loading, the License GUI only should be visible. So we wrap up the Generator GUI in a function (so it will not execute at start) and call the function in License GUI where we require – through Continue button after the user enters the correct key.


Button & Msg Box

There are two modes supported in AutoIt for interactivity: Message Loop and On-Event. We’ll work on Message Loop mode as it is easy :grin:

In Message Loop mode, the program will continously polls itself to see if something happened. There is atleast one event which will happen in all program which is user clicks the close button

Code:
While 1
		;After every loop check if the user clicked something in the GUI window
		$msg = GUIGetMsg()
		Select
			;Check if user clicked on the close button
			Case $msg = $GUI_EVENT_CLOSE
				;Destroy the GUI including the controls
				GUIDelete()
				;Exit the script
				Exit
		EndSelect
WEnd

Now if we want to check if the Continue Button is clicked, we add another Case statement:

Code:
While 1
		;After every loop check if the user clicked something in the GUI window
		$msg = GUIGetMsg()
		Select

			;Check if user clicked on the close button
			Case $msg = $GUI_EVENT_CLOSE
				;Destroy the GUI including the controls
				GUIDelete()
				;Exit the script
				Exit
			Case $msg = $ContinueBtn
				If GUICtrlRead($CodeIn) = "Springfire" Then
					GUIDelete()
					Generate()
				Else
					MsgBox(48,"Error","You've entered incorrect code")
				EndIf
		EndSelect
WEnd

What it does is on clicking Continue Button, the GUI checks the input box and if it is correct, it deletes itself and call Generate() function containing Generator GUI. If its wrong, it throws a error msg box

TIP: Check C:\Program Files (x86)\AutoIt3\Examples\GUI\Advanced\msgboxwizard.au3for different types of msg boxes


Open link in Default Browser

Same way, for Get Unlock Code button we add another Case statement:

Code:
Case $msg = $UnlockBtn
		ShellExecute("http://fileice.net")


Embedding Images

In the previous tutorial, you may have noticed a big header image, which I just drag and drop using KFD. If you compile, the image is not embedded into EXE rather points to the location of the file on YOUR hard disk. So, your keygen may not render properly on other PCs.

A user from AutoIt forum created a useful User Defined Function (UDF) called Resources.au3 to solve this. It works along with AutoIt3Wrapper.

Download:


We use three edits to force the compiler to embed the image to EXE.

At the top of the script, add your images like this:

Code:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=gta.ico
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_Res_File_Add=Images/unlock.gif, rt_rcdata, UNLOCKIMG
#AutoIt3Wrapper_Run_AU3Check=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

Note I’ve included unlock.gif and given the name UNLOCKIMG to it.


Next, include resources.au3 along with other includes. Make sure resources.au3 is in same folder.

Code:
#include <resources.au3>

Now change this line:

Code:
$Pic1 = GUICtrlCreatePic("Images/unlock.gif", 8, 16, 137, 137)

To this:

Code:
$Pic1 = GUICtrlCreatePic("", 8, 16, 137, 137)
_ResourceSetImageToCtrl($Pic1, 'UNLOCKIMG')

Important: Images will not appear in preview (F5). Press F7 to compile the script and check the image.


Bonus:

Resouces.au3 has added advantage of properly displaying transparent GIFs without blue background.

transillus_01.png


Adding Progress Bar

After you add progress bar through Koda Form Designer, its declaration looks something like this. Note the variable used. Here it is $ProgressBar

Code:
$ProgressBar = GUICtrlCreateProgress(352, 208, 281, 33)

We create a For Loop to update progress bar, sleep for some time, update, sleep and so on.. Reduce the Sleep() value to speed up the progress bar and vice versa.

Code:
For $i = 0 To 100
GUICtrlSetData($ProgressBar,$i)
Sleep(160)
Next


Generating Random Alpha-Numeric Key

Here is a ready-to-use function to create random keys. By default, calling randm() anywhere returns key of 5 characters eg., JQ76L. For 4 characters, call as randm(4).

Code:
Func randm($digits = 5)
$pwd = ""
Dim $aSpace[3]
For $i = 1 To $digits
    $aSpace[0] = Chr(Random(65, 90, 1)) ;A-Z
    $aSpace[1] = Chr(Random(97, 122, 1)) ;a-z
    $aSpace[2] = Chr(Random(48, 57, 1)) ;0-9
    $pwd &= $aSpace[Random(0, 2, 1)]
Next
Return $pwd
EndFunc


Adding Icon

Icon can be added to exe with a single line of code:

Code:
#AutoIt3Wrapper_Icon=gta.ico

TIP: Convert your image to 256x256 windows .ico using http://iconverticons.com/online/


The Complete Program

Code:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=gta.ico
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_Res_File_Add=Images/locked.gif, rt_rcdata, LOCK
#AutoIt3Wrapper_Res_File_Add=Images/gta5.gif, rt_rcdata, GTA5
#AutoIt3Wrapper_Run_AU3Check=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Resources.au3>

#Region ### START Koda GUI section ### Form=C:\Users\Media\Desktop\Form1.kxf

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("GTA 5 Beta Key Generator v1.02", 356, 158, -1, -1)
$Label1 = GUICtrlCreateLabel("Enter Unlock Code to Continue:", 168, 24, 152, 17)
$CodeIn = GUICtrlCreateInput("", 168, 56, 169, 21)
$ContinueBtn = GUICtrlCreateButton("Continue", 168, 88, 169, 25)
$UnlockBtn = GUICtrlCreateButton("Get Unlock code", 168, 120, 169, 25)

$LockedImg = GUICtrlCreatePic("", 8, 16, 137, 137)
_ResourceSetImageToCtrl($LockedImg, 'LOCK')

GUISetState()
#EndRegion ### END Koda GUI section ###

While 1
		;After every loop check if the user clicked something in the GUI window
		$msg = GUIGetMsg()

		Select

			;Check if user clicked on the close button
			Case $msg = $GUI_EVENT_CLOSE
				;Destroy the GUI including the controls
				GUIDelete()
				;Exit the script
				Exit
			Case $msg = $ContinueBtn
				If GUICtrlRead($CodeIn) = "Springfire" Then
					GUIDelete()
					Generate()
				Else
					MsgBox(48,"Error","You've entered incorrect code")
				EndIf
			Case $msg = $UnlockBtn
				ShellExecute("http://fileice.net")
		EndSelect

WEnd

Func Generate()
$Generator = GUICreate("GTA 5 Beta Key Generator v1.02", 651, 301, 294, 164)
$BlackBG = GUICtrlCreateGraphic(0, 0, 193, 300)
GUICtrlSetBkColor(-1, 0x000000)
$Logo = GUICtrlCreatePic("", 0, 0, 193, 177)
_ResourceSetImageToCtrl($Logo, 'GTA5')

$ProgressBar = GUICtrlCreateProgress(352, 208, 281, 33)
$GenerateBtn = GUICtrlCreateButton("Generate Beta Key", 208, 208, 129, 33)
$KeyDisplay = GUICtrlCreateInput("XXXX-XXXX-XXXX-XXXX-XXXX", 208, 256, 425, 28, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_UPPERCASE,$ES_READONLY))
GUICtrlSetFont(-1, 13, 400, 0, "Verdana")
$LogDisplay = GUICtrlCreateEdit("", 208, 16, 425, 177, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetData(-1, StringFormat("******************** GRAND THEFT AUTO 5 BETA KEY GENERATOR ****************\r\n\r\nPress Generate"))
GUISetState()
#EndRegion ### END Koda GUI section ###


While 1
		;After every loop check if the user clicked something in the GUI window
		$msg = GUIGetMsg()

		Select

			;Check if user clicked on the close button
			Case $msg = $GUI_EVENT_CLOSE
				;Destroy the GUI including the controls
				GUIDelete()
				;Exit the script
				Exit

				;Check if user clicked on the "OK" button
			Case $msg = $GenerateBtn
				For $i = 0 To 100
					If $i = 5 Then
						$Data = GUICtrlRead($LogDisplay)
						GUICtrlSetData($LogDisplay, $Data & @CRLF & @CRLF & "Checking installation..")
					ElseIf $i = 20 Then
						$Data = GUICtrlRead($LogDisplay)
						GUICtrlSetData($LogDisplay, $Data & @CRLF & @CRLF & "Connecting to Server..")
					ElseIf $i = 40 Then
						$Data = GUICtrlRead($LogDisplay)
						GUICtrlSetData($LogDisplay, $Data & @CRLF & @CRLF & "Connected. Waiting for reply..")
					ElseIf $i = 100 Then
						$Data = GUICtrlRead($LogDisplay)
						GUICtrlSetData($KeyDisplay, randm() & "-" & randm() & "-" & randm() & "-" & randm() & "-" & randm())
						GUICtrlSetData($LogDisplay, $Data & @CRLF & @CRLF & "Key successfully generated.")
					EndIf
					GUICtrlSetData($ProgressBar,$i)
					Sleep(160)
				Next
		EndSelect

WEnd
EndFunc

Func randm($digits = 5)
$pwd = ""
Dim $aSpace[3]
For $i = 1 To $digits
    $aSpace[0] = Chr(Random(65, 90, 1)) ;A-Z
    $aSpace[1] = Chr(Random(97, 122, 1)) ;a-z
    $aSpace[2] = Chr(Random(48, 57, 1)) ;0-9
    $pwd &= $aSpace[Random(0, 2, 1)]
Next
Return $pwd
EndFunc


Download

You must click the "Like" button below this post and reply to this message to view the hidden content (login required, page reload required afterwards).

Notice: A unique reply is required (no copy/paste), the English language is required (forum rules). The bypassing of the character limit with random characters or nonsense replies will result in your account receiving warnings or a permanent ban.

New members are required to create a thread at the "Introduction" forum first: More information
 

d980xt

Well-known member
VIP Legends CPAElites Classic (1.0)
VIP Elites CPAElites Classic (1.0)
Joined
May 17, 2013
Messages
79
Reaction score
0
Great tut OP! You've just motivated me to work more! Thanks Again OP!
 

hopsa

Well-known member
VIP Legends CPAElites Classic (1.0)
Joined
May 26, 2013
Messages
261
Reaction score
1
Springfire how comes when i use the code you put in here and i compile i can't see the pictures?
 

Springfire

Well-known member
VIP Legends CPAElites Classic (1.0)
VIP Elites CPAElites Classic (1.0)
Joined
August 9, 2013
Messages
168
Reaction score
1
hopsa said:
Springfire how comes when i use the code you put in here and i compile i can't see the pictures?

Just to make sure, check that you have

1. Resources.au3 in the same folder as your-keygen.au3
2. Installed SciTE4AutoIt full install (It is NOT the SciTE which comes with AutoIT install, see link in the post)

If that does not help, PM your SciTE compile log to me

compile_log.png
 

Doofenshmirtz

Well-known member
VIP Legends CPAElites Classic (1.0)
VIP Elites CPAElites Classic (1.0)
Joined
June 24, 2013
Messages
66
Reaction score
0
Springfire said:
hopsa said:
Springfire how comes when i use the code you put in here and i compile i can't see the pictures?

Just to make sure, check that you have

1. Resources.au3 in the same folder as your-keygen.au3
2. Installed SciTE4AutoIt full install (It is NOT the SciTE which comes with AutoIT install, see link in the post)

If that does not help, PM your SciTE compile log to me

/tctaop673/compile_log.png​

Can you explain more ? I install SciTE4AutoIt and Resources.au3 in the same folder as your-keygen.au3 but when I compile, file exe still not have image ?
 
Top Bottom