Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Fuck you, win32 API

Name: Anonymous 2009-02-23 20:14

#include <windows.h>
#include <winreg.h>

#define CRYPTLEN    15
#define KEYLEN      29
#define KEYOFFSET   52
#define ALLOCSIZE    256

typedef unsigned char uchar;

char *str = "BCDFGHJKMPQRTVWXY2346789";

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
    HKEY CurrentVersion;
    DWORD type = REG_BINARY;
    uchar *key, *buf;
    int ret = EXIT_FAILURE, size = ALLOCSIZE, i, j, k, l;
   
    if(((NULL == (buf = (uchar*)HeapAlloc(GetProcessHeap(), 0, ALLOCSIZE))) || (NULL == (key = (uchar*)HeapAlloc(GetProcessHeap(), 0, KEYLEN + 1)))) && (buf = "HeapAlloc()"))
        goto _error_malloc;

    if(ERROR_SUCCESS != (i = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\0", 0, KEY_READ, &CurrentVersion)))
        goto _error_RegOpen;

    if((ERROR_SUCCESS != (i = RegQueryValueEx(CurrentVersion, "DigitalProductId\0", NULL, &type, buf, &size))) && RegCloseKey(CurrentVersion))
        goto _error_RegOpen;

    for (i = KEYLEN - 1; i > -1; i--) {
        if((i + 1) % 6 == 0)
            key[i] = '-';
        else {
            k = 0;

            for (j = CRYPTLEN; j > -1; j--) {
                l = (k << 8) | buf[j + KEYOFFSET];
                buf[j + KEYOFFSET] = l / 24;
                k = (l % 24);
            }
           
            key[i] = str[k];
        }
    }
    key[KEYLEN] = '\0';
    MessageBox(NULL, key, "Key:", MB_OKCANCEL);
   
    ret = EXIT_SUCCESS;
    goto _free;
   
    _error_RegOpen:
        FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, i, 0, buf, ALLOCSIZE, NULL);
    _error_malloc:
        MessageBox(NULL, buf, "Error", MB_OK);
    _free:
        HeapFree(GetProcessHeap(), 0, buf);
        HeapFree(GetProcessHeap(), 0, key);
        return ret;   
}

Name: Anonymous 2009-02-23 20:20

I can see several places where you forgot your NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL

Name: Anonymous 2009-02-23 20:21

PROGRAMMING is COOL!

If you are going to cry about it, do something else!

Name: Anonymous 2009-02-23 20:22

>>3
I'm going to reboot to linux now.

Name: Anonymous 2009-02-23 20:41

>>1
Uhh, way to make your code look convoluted by using inline assignments.
I mean don't get me wrong, the Win32 API does suck, but not for the reason you're trying to perpertrate.

Name: Anonymous 2009-02-23 20:57

LEARN RUBY!

Name: Anonymous 2009-02-23 21:07

>>6
But I heard it was NOT SO FAST

Name: Anonymous 2009-02-23 21:32

THIS CODE

LOOKS

LIKE

SHIT

Name: Anonymous 2009-02-23 22:29

Why the fuck are you allocating fixed-size buffers with functions for dynamic allocation?

Name: Anonymous 2009-02-23 22:41

>>9
Because you touch yourself at night.

Name: Anonymous 2009-02-23 23:40

"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\0"

"\0"


Why the fuck are you adding a null character on the end of your strings? You do know C automatically adds one for you, right?

Name: Anonymous 2009-02-24 9:15

>>11
I wrote my own compiler which doesn't.

Name: Anonymous 2009-02-24 9:15

ITT: BUTTHURT OP

Name: Anonymous 2009-02-24 9:26

>>12
ENJOY YOUR ANSI COMPLIANCE

Name: Anonymous 2009-02-24 9:30

>>8
Eternally this. Seriously, I wouldn't even look at this code if I was paid for it.

Name: Anonymous 2009-02-24 9:34

>>13
BUTTHURT

Back to /b/, please.

Name: Anonymous 2009-02-24 9:48

>>16
Sorry OP, the term butthurt doesn't come from /b/!

Name: Anonymous 2009-02-24 10:12

>>17
Butthurt comes from the gay community, where people spend most of their time with a haxxed anus.

Name: Anonymous 2009-02-24 11:11

>>18
So this meem is about repressed homosexual urges and not hacking?

Name: Anonymous 2009-02-24 11:17

>>19
Nothing repressed about it.

Name: Anonymous 2009-02-24 11:23

>>20
So why you use such euphemisms?

Name: Anonymous 2009-02-24 11:29

>>21
Go back to bed, FrozenVoid.

Name: Anonymous 2009-02-24 11:33

>>22
Why i would go to bed? It would remove me from discussion.

Name: Anonymous 2009-02-24 15:53

>>9
>>11
What they said -- plus why the fuck, OP, are you making spurious assignments to i in the calls to RegOpenKeyEx and RegQueryValueEx?

Name: Anonymous 2009-02-24 19:05

The OP only posted his code so we could see what a clever hacker he is.

Name: Anonymous 2009-02-24 21:51

What the hell is an ERROR_SUCCESS?

Name: Anonymous 2009-02-24 22:05

>>26
Mu.

Name: Anonymous 2009-02-25 0:03

in b4 null

Name: Anonymous 2009-02-25 2:52

>>26
0 ERROR_SUCCESS The operation completed successfully.

So

if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &CurrentVersion))
        goto _error_RegOpen;

Name: Anonymous 2009-02-25 2:53

Windows -- the only OS where something actually working is considered an error.

Name: Anonymous 2009-02-25 4:03

>>29,29
i is needed in _error_RegOpen.

Name: Anonymous 2009-02-25 4:58

>>1
OMG WTF IS THIS SHIT?!

Name: Anonymous 2009-02-25 5:18

>>29
return 0 on sucess is very old, as for ERROR_SUCCESS, it's simply that all return codes(almost all except sucess code that is) are erros, so they're labeled starting with ERROR_ . You can do convert a GetLastError() code to a meaningful string using the FormatMessage API.

>>32
A quick look at it seems to indicate that it's just a simple tool for extracting the encrypted Windows Product Key from the registry.

Name: Anonymous 2010-12-17 1:21

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Don't change these.
Name: Email:
Entire Thread Thread List