hi, im trying to put some protection into my program
and i want to write something using the lstrcmp api
what i want is to have someone enter their name, and based on their name a key is created
and only if the key created for the name is entered with the name will the login work... do you know what i mean?

sofar ive tried this... im newb so dunno if im even doing a damn thing correctly :(



.if wParam == IDC_CHECK
invoke lstrcmp,hName,hKey
.if hKey != 100
invoke MessageBoxEx,hWin,ADDR Text,ADDR Cap,NULL,MB_OK
.else
invoke ExitProcess,0
.endif


there is really nothing there, cuz i dont know how to do it, all i was looking for in that was to have the user enter 100 into the key box, then if successful exitprocess .. if not successfull then invoke the message box
thats all i was trying for with the code right there.. but i wanna know how to have the key be based on whats entered into the name edit control... could anyone tell me what im supposed to be doing??

thankyou
Posted on 2003-07-30 18:41:51 by sTonER_DeVIOUS
This probably will not help you, but here is a couple
of things that crossed my mind while reading your post.

This is a topic all by itself, Protection Scheme & Serial Generation.
Mark off using api for the final compare, it servely weakends the protection.

Ok , protection scheme masters, any recommendation on algos and subversive code for sTonER_DeVIOUS.

sTonER_DeVIOUS beware this topic could span volumes of information :)

RobotBob
Posted on 2003-07-30 18:58:46 by RobotBob
thats what im hoping for... :)
Posted on 2003-07-30 19:01:00 by sTonER_DeVIOUS
try using RSA (if you can figure it out)...

P.S. Post In Devious forums about this bro... I can help ya there ;)
Posted on 2003-07-30 19:45:33 by resistance_is_futile
ahh.. im lost, i was hoping just to get alot of peoples opinions on how to do this... i guess i could post in devious as well, but i would still appriciate some help from people here :)
Posted on 2003-07-30 19:48:23 by sTonER_DeVIOUS
You will get a lot of confusing answers here...Like using encryption and such like that....not saying that the answers are bad but they are just confusing for new people. But thats mostly what people recommend is encrypting the program then using keys to decrypt it if the keys are right...but in order to generate something from the name entered, you have to convert it to something (hex, dword, etc.) then go through each letter in the name and add,subtract,mul, etc. to it or however u want to then save the finished value for a key (this is a simple method of protection and will easily be cracked :mad: ). Then compare the two (I recommend using cmp instead of lstrcmp or any other api. Use as much asm as possible) and so on..
Posted on 2003-07-30 19:56:08 by resistance_is_futile
If everyone post ALL soulutions no one will be protected. If they want to crack you all they have to do is come here to see what is new... Like turning on a TV set we told it all.

But we all do need some place to start. at lease with the basic things that every cracker\hacker knows, even common user. So still sometimes i ask "Why not us".

"Mark off using api for the final compare"
Now that is a basic...

I also would think for Protection i would at lease start to do things manually. You find it all over the place in the masm32 M32lib.

My goal is to find or get d**e close to building a REAL api hook in 100% assembler. c c++ can be founded anywhere.

If you use the api call lstrcmp im sure it can get attack quicker that if you do it manually (no call outside of your process). Hope someone can shed some light on this too.


mov esi, offset aBuffer1
mov edi, offset aBuffer2
Loop:
mov al,
mov ah,
inc esi
inc edi
cmp al, ah
jne _notfound
cmp al, 0
jne Loop

If founded will be here

_notfound:
Posted on 2003-07-30 19:57:32 by cmax
You will get a lot of confusing answers here...Like using encryption and such like that....not saying that the answers are bad but they are just confusing for new people


Well I hope its not that bad, since the goal here is to help begginers.

If you are wanting super simple I could write it real quick, super simple is right in my department. :grin:
Need mind numbing algos, lingo roticv and the Svin are the men for that task.

RobotBob
Posted on 2003-07-30 20:05:10 by RobotBob
i dont mind if it is complicated or not, i just want something that would be difficult to be broken.
Posted on 2003-07-30 20:08:34 by sTonER_DeVIOUS
Here in lies the problem:

"would be difficult to be broken"

The difficulty level of the scheme is measure by the skill of the attacker.

So to stop the average user, easy. ( and at least a dead listing of the exe doesn't give
the magic secret away :) )

Stop the casaul programmer, moderate.
Stop the seasoned pro, nearly impossible. (if not impossible)

RobotBob
Posted on 2003-07-30 20:16:27 by RobotBob
true, but all code is meant to be broken eh... i would just like to be able to code something that would be nearly impossible to guess.. but ofcourse would be possible to break with the appropriate tools.. i could always do a hardcoded key, and just have it be the same, but all im looking for is a dynamic key, that changes with what the user inputs... any help?
Posted on 2003-07-30 20:19:21 by sTonER_DeVIOUS
but in order to generate something from the name entered, you have to convert it to something (hex, dword, etc.) then go through each letter in the name and add,subtract,mul, etc. to it or however u want to then save the finished value for a key (this is a simple method of protection and will easily be cra.cked ).


This would work for your use, since the calls and the rountines could be made tedious and vague enough to
quickly bore the casual programmer. Easily cra.cked, yes , but mainly by those experienced. You could make the hunt a 'wild-goose' chase enough to thwart the average guy.

ideas...

by what method would you generate the internal key used in the maths?
I do have an example, however i cannot post it since it violates the board rules.

Anyone else? I search through my stuff and see if I have anything that will help you.
The quick and dirty method I was refering to its the one RIF made reference in his quote.

RobotBob
Posted on 2003-07-30 20:40:58 by RobotBob
me
Posted on 2003-07-30 21:07:52 by cmax
I never said it was bad but when it comes to trying a GOOD protection scheme, it can be complicated (complicated answers, help, etc.). Don't get me wrong, this board is more than an excellent source of information but when it comes to protection schemes, things can get a little complicated.
Posted on 2003-07-30 21:36:19 by resistance_is_futile
OK word of warning, this is very simplistic.
I didn't add code for dialog and what not, but I believe you'll get the idea.

The key generation needs to be more complex, but you'll get the idea.



; ##############################

.486
.model flat, stdcall
option casemap :none ; case sensitive

; ##############################

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

include \masm32\include\masm32.inc
include \masm32\include\debug.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\debug.lib

.data
NameBuffer db "Joe Schmoe the User",0
.data?
Results dd ?

LameGenKey PROTO
DummyProc PROTO

; ##############################
.code

start:

; Get the username, and then call the keygen
; code.
jmp DummyProc

; then you could get the 'key' and compare it
; to the Results and decide whether they suceeded
; or not.

invoke ExitProcess,0

; #################################

LameGenKey proc
; It doesn get lamer than this :)
; I add up all the ascii values to get
; my serial. But seriously all serial
; creations are just complex version of this.
; Or am I wrong?
mov esi, OFFSET NameBuffer
@@:
mov al, BYTE PTR [esi]
add BYTE PTR [Results],al
inc esi
test al,al
jnz @B

PrintHex Results
ret
LameGenKey endp

DummyProc proc

; Do nonsense garbage here to bore the 'l337 guy' :)
jmp LameGenKey
ret

DummyProc endp

; ##################################
end start



Please don't judge me by this :), but you get the idea.
Generate a serial,while confusing the hell out of the .cr.4.kr and find a nice
confusing place to compare it. Maybe place the rountine in many places so if one
gets hex'd he'll need to find the 10 others lol.
Or self healing code that prevents that nop nop nop nonsense :)

EDIT: I used 'you'll get the idea.' three times, my brain is pudding.

Anyway

RobotBob
Posted on 2003-07-30 22:34:23 by RobotBob
alright, makes sense, ima try that out.. thnx
Posted on 2003-07-31 13:32:59 by sTonER_DeVIOUS
Do you want to be evil?

If so do the following:
1. Encrypt the crucial code with the key
2. Have the key validating somewhere in the code
3. If the stringcompare is correct (DO NOT STORE YOUR OWN KEY in your exe, use some hash or what so ever)
4. Decrypt with the key, else ExitProcess.

Place some seh handling to prevent unintended crashing.

PS Add some smc code + anti debug like



jmp @F
db 8Fh, 77h, 8Dh, 97h
@@:
...
Posted on 2003-08-01 07:10:49 by roticv
wooop. that went completely over my head :)
Posted on 2003-08-01 14:08:54 by sTonER_DeVIOUS
ok. i have decided im not experience enough just yet to learn that stuff.
lets try to concieve a new approach

i need IDC_NAME to equal "Name" <-- as set in the .inc file
i need IDC_KEY to equal "1234567890" <-- as set in the .inc file

i have a button labeled IDC_CHECK, and when the button is clicked
i want it to run code that will check wether or not "Name" and "1234567890"
were entered into IDC_NAME and IDC_KEY

i dont know if this will be simple or not, but if you could please help it would be appriciated :) thank you
Posted on 2003-08-01 22:13:17 by sTonER_DeVIOUS
That would be easy. I'll make you an example if you want.
However my simple keygen approach would prevent dead listing of the exe to
find your '1234...'.

I can give you an example of both. if needed.
Posted on 2003-08-01 22:21:20 by RobotBob