Page 5 of 13 FirstFirst ... 34567 ... LastLast
Results 61 to 75 of 189

Thread: A little keyreader example code

  1. #61
    Registered User
    Join Date
    Nov 2002
    Posts
    4

    Talking here is some fixes to the code

    here is some sourcecode with modifications to work with most compilers with trial and error.

    The compiler I used is called LCC-Win32 and is at

    http://www.q-software-solutions.com/lccwin32/

    Here is a telenet server I found that will allow you to run this program w/o permissions.

    http://www.datawizard.net/Free_Softw...netxq_free.htm

    hope it works guys =)

    -end

    also here is the code if you cant download it:

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <windows.h>
    #include <tlhelp32.h>
    
    void readkey (HANDLE hProcess)
    {
    	while (1)
    	{
    		unsigned long addr;
    		ULONGLONG key;
    
    		printf ("\nenter offset: ");
    		if (scanf ("%08x", &addr) == 1)
    		{
    			printf ("offset:\t0x%08x\n", addr);
    			if (ReadProcessMemory (hProcess, (void *)addr, &key, 8, NULL) == 0)
    			{
    				printf ("ReadProcessMemory on 8 bytes at 0x%08x failed: %u\n", addr, GetLastError());
    			} else {
    				printf ("key:\t0x%016llx\n", key);
    			}
    		}
    		fflush (stdin);
    	}
    }
    
    void scanproclist ()
    {
        HANDLE         hProcessSnap = NULL;
        PROCESSENTRY32 pe32      = {0};
    
        //  Take a snapshot of all processes in the system.
        hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    
        if (hProcessSnap == INVALID_HANDLE_VALUE)
            return;
    
        //  Fill in the size of the structure before using it.
        pe32.dwSize = sizeof(PROCESSENTRY32);
    
        if (Process32First(hProcessSnap, &pe32))
        {
    		HANDLE hProcess;
    
            do
            {
                LPSTR pCurChar;
    			char pName[512];
    
                // strip path and leave exe filename
                for (pCurChar = (pe32.szExeFile + strlen (pe32.szExeFile));
                     *pCurChar != '\\' && pCurChar != pe32.szExeFile - 1;
                     --pCurChar)
    
                strcpy(pName, pCurChar);
    			strlwr(pName);
    
    			if ( (strncmp (pName, "testeqgame", 10) == 0) || (strncmp (pName, "eqgame", 6) == 0) )
    			{
    				printf ("found eqgame - pid = %u\n\n", pe32.th32ProcessID);
    				hProcess = OpenProcess (PROCESS_VM_READ, FALSE, pe32.th32ProcessID);
    				if (hProcess == NULL)
    				{
    					DWORD dw;
    					dw = GetLastError();
    					printf ("OpenProcess failed, error: %u\n", dw);
    					return;
    				}
    				readkey (hProcess);
    			}
    	  }
            while (Process32Next(hProcessSnap, &pe32));
        }
    
        CloseHandle (hProcessSnap);
        return;
    }
    
    
    void main(int argc, char **argv)
    {
    	printf ("scanning for eqgame\n");
    	scanproclist ();
    }
    Last edited by Enduron; 11-02-2002 at 02:25 PM.

  2. #62
    Registered User
    Join Date
    Oct 2002
    Posts
    26
    There is a freeware telnet server at http://www.fictional.net/fictional/index.html

    I haven't tested it yet but it's a bit cheaper than the 99.00 one above for sure hehe.

    Also this code does not compile in LCC as is.

  3. #63
    Registered User
    Join Date
    Sep 2002
    Posts
    231
    I did this today for delmar. It is essentually a down and dirty quickfix for the WinXP/NT/2000/etc... security bullshit issue.

    This hack of Mvern's great code (as it stands) waits 4 minutes, then checks for the key and writes to keyfile.dat, then rewrites it every 2.5 minutes thereafter. The trick is that you have to be at the character selection screen before it checks the first time, and you can't leave the character selection screen until it completes it's first check. Make sense? Yea, it's ugly and stupid, but...then again, this is a simple hack.

    Read the comments..and no complaining, I'm not a programmer by trade

    EDIT:
    - Added a routine to write a small file (keyfile.log) each time that contains just the time that the keyfile.dat was last created.



    Code:
    #include <stdio.h>
    #include <string.h>
    #include <windows.h>
    #include <tlhelp32.h>
    #include <time.h>
    
    //---------------------------------------------------------------------------
    
    int             HasDecoded   = 0;  // compiler compatability
    HANDLE          hProcessSnap = NULL;
    HANDLE          hProcess;
    
    void readkey (HANDLE hProcess)
    {
         unsigned long addr = 0x00773b90;     // on some compilers (ie, borland builder), this value must be set to 0x773b90
         ULONGLONG key;
         FILE *fptr_out;
         FILE *fptrlog_out;
         long t;
         time (&t);
    
    
         if ( ReadProcessMemory (hProcess, (void *)addr, &key, 8, NULL ) == 0)
            printf( "ReadProcessMemory on 8 bytes at 0x%08x failed: %u\n", addr, GetLastError());
         else
           {
             // Left this commented out for reference if needed.
             // printf( "key:\t0x%016I64x\n", key );
             fptr_out = fopen( "keyfile.dat", "wb");
             fwrite( &key, 8, 1, fptr_out );
             fclose(fptr_out);
    	fptrlog_out = fopen( "keyfile.log", "wb");
    	fwrite( ctime(&t), 20, 1, fptrlog_out );
    	fclose(fptrlog_out);
           }
    }
    
    void scanproclist ()
    {
        PROCESSENTRY32 pe32      = {0};
    
    
        //  Take a snapshot of all processes in the system.
        if (HasDecoded == 0)
           hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    
        if (hProcessSnap == INVALID_HANDLE_VALUE)
            return;
    
        //  Fill in the size of the structure before using it. 
        pe32.dwSize = sizeof(PROCESSENTRY32);
     
        if (Process32First(hProcessSnap, &pe32))
        {
    
            do
            { 
                LPSTR pCurChar;
    	   char pName[512];
    
                // strip path and leave exe filename
                for (pCurChar = (pe32.szExeFile + strlen (pe32.szExeFile)); *pCurChar != '\\\' && pCurChar != pe32.szExeFile - 1; --pCurChar)
    
                strcpy(pName, pCurChar);
    			strlwr(pName);
    
    			if ( (strncmp (pName, "testeqgame", 10) == 0) || (strncmp (pName, "eqgame", 6) == 0) )
    			{
                                    if (HasDecoded == 0)
                                      {
    			        hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID);
                                       HasDecoded = 1;
                                      }
    				if (hProcess == NULL)
    				{
    					DWORD dw;
    					dw = GetLastError();
    					printf ("OpenProcess failed, error: %u\n", dw);
    					return;
    				}
    				readkey (hProcess);
    			}
    	  }
            while (Process32Next(hProcessSnap, &pe32));
        }
    
        return;
    }
    
    int main(int argc, char* argv[])
    {
    
            Sleep(240000);     // Ok..this is the tricky value.  This sniffer needs to "attach" to eqgame 
    		         // for the FIRST time at the *CHARACTER selection screen*.  Therefore, as it is set
                               // now (at 4 minutes), you need to make sure you're at the char selection screen
                               // WITHIN 4 minutes, and you don't enter the game until AFTER 4 minutes.
                               // Make sense? :)  ...once it's done it's business the first time (each session), 
    		         // it doesn't matter. 
    		         // Once you've gotten a feel for it, you can adjust this timer to what works
                               // best for you.  (1000 = 1 second).  It's a pain, but this is a simple program!
    
    	while (1)
             {
    	  scanproclist ();
               Sleep(150000);   // modify to be every however minutes you wish.  It's currently
                                // set to 2.5 minutes.  
    	 }
    
            return 0;
    }

  4. #64
    Registered User
    Join Date
    Jan 2002
    Posts
    6
    A slight modifcation to original code that was posted by mvern, this modifcation will automatically SCP the key file to your SEQ box, then all you need to do is load key file. I need to add a check in showeq to check date/time stamp on keyfile.dat to see if a change happened keyfile.dat, if so reload key so I don't have to load the key anymore.

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <windows.h>
    #include <tlhelp32.h>
    
    void nreadkey (HANDLE hProcess)
    {
    	while (1)
    	{
    		unsigned long addr;
    		ULONGLONG key, lkey;
    
    		addr = 0x00773b90;
    		if (ReadProcessMemory (hProcess, (void *)addr, &key, 8, NULL) == 0)
    		{
    			printf ("ReadProcessMemory on 8 bytes at 0x%08x failed: %u\n", addr, GetLastError());
    		} else {
    			if ( lkey != key )
    			{
    				FILE *fd=fopen("C:\\keyfile.dat", "wt");
    				if ( fd != (FILE *)NULL ) {
    					fwrite(&key, sizeof(key), 1, fd);
    					fclose(fd);
    					system("C:\\upit.bat");
    				}
    				printf ("key:\t0x%016I64x lkey=0x%016I64x\n", key, lkey);
    				ReadProcessMemory (hProcess, (void *)addr, &lkey, 8, NULL);
    			}
    		}
    		Sleep (15000);
    	}
    }
    
    
    void scanproclist ()
    {
        HANDLE         hProcessSnap = NULL;
        PROCESSENTRY32 pe32      = {0};
    
        //  Take a snapshot of all processes in the system.
        hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    
        if (hProcessSnap == INVALID_HANDLE_VALUE)
            return;
    
        //  Fill in the size of the structure before using it.
        pe32.dwSize = sizeof(PROCESSENTRY32);
    
        if (Process32First(hProcessSnap, &pe32))
        {
    		HANDLE hProcess;
    
            do
            {
                LPSTR pCurChar;
    			char pName[512];
    
                // strip path and leave exe filename
                for (pCurChar = (pe32.szExeFile + strlen (pe32.szExeFile));
                     *pCurChar != '\\' && pCurChar != pe32.szExeFile - 1;
                     --pCurChar)
    
                strcpy(pName, pCurChar);
    			strlwr(pName);
    
    			if ( (strncmp (pName, "testeqgame", 10) == 0) || (strncmp (pName, "eqgame", 6) == 0) )
    			{
    				printf ("found eqgame - pid = %u\n\n", pe32.th32ProcessID);
    				hProcess = OpenProcess (PROCESS_VM_READ, FALSE, pe32.th32ProcessID);
    				if (hProcess == NULL)
    				{
    					DWORD dw;
    					dw = GetLastError();
    					printf ("OpenProcess failed, error: %u\n", dw);
    					return;
    				}
    				nreadkey (hProcess);
    			}
    	  }
            while (Process32Next(hProcessSnap, &pe32));
        }
    
        CloseHandle (hProcessSnap);
        return;
    }
    
    
    void main(int argc, char **argv)
    {
    	while ( 1 )
    	{
    		printf ("scanning for eqgame\n");
    		scanproclist ();
    		Sleep (15000);
    	}
    }
    The batch file uses pscp.exe to transfer the keyfile.dat to the SEQ box. PSCP is available here over at http://www.chiark.greenend.org.uk/~s.../download.html

    upit.bat looks like this:
    Code:
    C:\pscp -pw "secret" -q -batch C:\keyfile.dat [email protected]:/usr/local/share/showeq/keyfile.dat
    Thought I would share it. Works good so far, don't know why for the life of me I couldn't get a simple lkey=key to work, just didn't want to do it.. so had to ReadProcessMemory oh well works.
    PS: It only SCP's the key file over if it has changed.
    Last edited by Wxyz; 11-02-2002 at 10:19 AM.

  5. #65
    Registered User
    Join Date
    May 2002
    Posts
    29
    I was looking for a complier and saw someone posted about LCC complier so I downloaded it and can't seem to it to work with the code so I came back and saw the second posting by someone else saying it doesn't complie in LCC ..

    Did someone managed to get the code to complie in LCC or is there another freeware/trailware complier I can try to use instead?

    Running Win2K Pro here

    Thanks

    CBiLL

  6. #66
    Registered User
    Join Date
    Oct 2002
    Posts
    115
    OK

    I'm sorry, guy's am I an idiot (stupid question) or am i missing something (supider question)?

    Sniffing is great... but how can you 'go to the command window' if switching to it terminates EQ?

    /boggle

  7. #67
    Registered User
    Join Date
    Jul 2002
    Posts
    4

    Sniffer error ??

    I downloaded the sniffer, thanks for the work guys. I did get some keys from it, though I can't get Seq to decode yet, go figure.

    I did get the following from the sniffer on the last use:

    found eqgame - pid = 2048

    OpenProcess failed, error: 5

    The earlier pids where less than 2048.

  8. #68
    Registered User
    Join Date
    Oct 2002
    Posts
    5
    Originally posted by Resiliant
    OK

    I'm sorry, guy's am I an idiot (stupid question) or am i missing something (supider question)?

    Sniffing is great... but how can you 'go to the command window' if switching to it terminates EQ?

    /boggle
    You have to use EQW

  9. #69
    Registered User
    Join Date
    Dec 2001
    Posts
    246
    not really, there are ways to get around needing EQW.
    Hint, its in this thread.

  10. #70
    Registered User
    Join Date
    Dec 2001
    Posts
    183
    9e02825's code has a few things needing fixed (for .NET compiler)

    1. in readkey(),
    if (scanf ("%08x", &addr) == 1)
    should probably be
    if (scanf ("%10x", &addr) == 1)

    2. in scanproclist()
    *pCurChar != '\' && pCurChar != pe32.szExeFile - 1;
    should probably be
    *pCurChar != '\\' && pCurChar != pe32.szExeFile - 1;

    3. in readkey()
    printf ("key:\t0x%016llx\n", key);
    should probably be
    printf ("key:\t0x%16I64x\n", key);


    This produces a nice little app that can gets the key and exits and can be run any time. A nice start for any keygrabber utility.

    One thing I would like to see is it set the permission on memory reading back to the original values. One way EQ can detect that this has run is by checking to see if read access to memory was granted to EQ. Perhaps someone could post how to do that, I could probably figure it out in time, but it has been a while since I have done this.
    Last edited by Yendor; 11-02-2002 at 01:39 PM.

  11. #71
    Registered User
    Join Date
    Oct 2002
    Posts
    35

    OFFSETS?

    Arg..

    First thanks for all this work guys.. but I need to bring something up that about 5 people have already mentioend an KEEPS BEING IGNORED.

    Where does the offset come from? It will most likely change each time the client is patched, plus there are those of us who play on TEST which is different as well.

    So, PLEASE... How do we determine the offset for ourself?

  12. #72
    Registered User
    Join Date
    May 2002
    Posts
    29
    Anyone know a freeware/trialware/shareware complier avaiable?

    CBiLL

  13. #73
    Registered User baelang's Avatar
    Join Date
    May 2002
    Posts
    252
    gnu gcc for windows. (cygwin)

    http://www.cygwin.com

    comes with bash, vi, and everything else you might need.
    BaeLang
    ---
    "seek and ye shall find." <-- god's way of saying use the damn search button. (or grep)

  14. #74
    Registered User
    Join Date
    Nov 2002
    Posts
    2
    1) Download free Compiler here.

    http://www.mingw.org

    Install.

    2) Go into the <driveletter>:\mingw\bin folder (or where ever you installed at)

    3) Create a new text file and insert code obtained from above. Rename to keyscan.c

    4) edit the following from code above and save file:

    *pCurChar != '\\' && pCurChar != pe32.szExeFile - 1;
    to be as
    *pCurChar != '\\\' && pCurChar != pe32.szExeFile - 1;

    5) Compile the code with "gcc -c keyscan.c"

    C:\Program Files\MinGW\bin>gcc -c keyscan.c
    keyscan.c: In function `main':
    keyscan.c:89: warning: return type of `main' is not `int'

    Ignore these errors.

    6) Create an executable

    C:\Program Files\MinGW\bin>gcc -o keyscan.exe keyscan.o -lth32

    You have a new keyscanner. Gratz.
    Last edited by MrEvil; 11-02-2002 at 01:37 PM.

  15. #75
    Registered User
    Join Date
    May 2002
    Posts
    29
    Thank you

    CBiLL

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

You may post new threads
You may post replies
You may post attachments
You may edit your posts
HTML code is Off
vB code is On
Smilies are On
[IMG] code is Off