PDA

View Full Version : My program



KaL
11-02-2002, 11:30 AM
Here's what I came up with, heavily based on the previous post about writing a sniffer for the key.

Basically, it scans for eqgame in a loop.

Once it finds the pid, it goes to a loop that checks the key area of memory.

Once the key is != 0, it beeps and fires off "keymove.bat" (in hidden mode), which is a script I wrote that uses scp to copy the dat file over to my linux box. You can write one that uses tftp or ftp or whatever you want. Or, you can just make an empty batch file if you're keeping an active share between your machines.

After that, it keeps looping until the key changes, then fires the script off again (and beeps).

This should work without EQW.

Note: this compiles and works on XP using vc6.



#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <tlhelp32.h>
#include <fstream.h>

char argkey[256]="773b90";
ULONGLONG oldkey=0;

void readkey (HANDLE hProcess)
{
FILE *fp;


while (1)
{
unsigned long addr;
ULONGLONG key;

Sleep(1000);

if (sscanf (argkey, "%08x", &addr) == 1)
{
if (ReadProcessMemory (hProcess, (void *)addr, &key, 8, NULL) == 0)
{
printf ("ReadProcessMemory on 8 bytes at 0x%08x failed: %u\n", addr, GetLastError());
} else {

if (oldkey == key)
{
// key hasn't changed
}
else
{
printf ("New key found: 0x%016I64x\n", key);
Beep(500,500);
oldkey = key;

fp = fopen("\\mydirectory\\keyfile.dat", "wb");
fwrite(&key, sizeof(key), 1, fp);
fclose(fp);

WinExec("C:\\mydirectory\\keymove.bat", SW_HIDE);
}
}
}
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_ALL_ACCESS, FALSE, 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)
{
while (1) {
Sleep(10000); // Scan for EQGame only every 10 seconds, since it slows the system down. Makes loading slow.
scanproclist();
}
}

sequser5516
11-02-2002, 12:56 PM
Could you make the Linux box look for this file in a shared directory on your EQ machine? IE..sniffer Updates file on EQ machine, and Showeq opens that file over the network?

SeqTester
11-02-2002, 01:06 PM
ShowEQ is open source so you can do ANYTHING you want.

the best way to do it like this is have a mounted drive on your Windows box(easy but I never tried) and have ShowEQ look at a TXT file on that share every X-Secs and when updated add new key.

What I would do if I could code is, have ShowEQ kick off on or a few secs after the opcode for Zoning is detected, or even a trigger added to the KeyGen when new key is found(Instead of the Beep) to trigger ShowEQ to load a new key.

Just a few Ideas, for anyone to try if they can code in C

Amadeus
11-02-2002, 05:17 PM
WinExec("C:\\mydirectory\\keymove.bat", SW_HIDE);


That little line is a gem :) I always forget how to run things hidden like that ... too much usage of System() in my life /sigh

Nurseling
11-02-2002, 07:42 PM
I'm getting this when i try to compile any suggestions

C:\cygwin\bin>gcc -c key.c
key.c:5:21: fstream.h: No such file or directory
key.c: In function `main':
key.c:108: warning: return type of `main' is not `int'

Mr. Suspicious
11-02-2002, 07:52 PM
I'm getting this when i try to compile any suggestions

C:\cygwin\bin>gcc -c key.c
key.c:5:21: fstream.h: No such file or directory
key.c: In function `main':
key.c:108: warning: return type of `main' is not `int'


This isn't a "Cygwin" related messageboard (realy, you will be helped much better if you actually ask questions about an app at a relevant messageboard, asking questions about your faulty kitchensink won't result you a lot of helpfull posts at this board either).

Altho this isn't the "Cygwin" help board, you will still find the answer to your question if you use the searchfeature of this board.

from: http://seq.sourceforge.net/showthread.php?s=&threadid=2253&perpage=15&pagenumber=5



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.

monster69
11-02-2002, 08:23 PM
Mister S.

the problem he is having is that fstream.h is not an include file that comes with Cygwin or MinGW. I am running into the same error and trying to track down an alternate include to fstreams but not having much luck.

Monster

Nurseling
11-02-2002, 09:04 PM
Thank you Mr. suspicious not sure how your link helped. The fstream.h error and I knew to ignore the other readout.
If you you have any other helpful information please do not be shy.

monster let me know if you find out how to resovle the Fstream error. I will do the same so far i have a somewhat working version, just by removing that part of the codethe #include<fstream.h> another words i just deleted line 5 but not sure how that will effect the overall proggie.

monster69
11-02-2002, 10:27 PM
Okay nursling, heres how I fixed it.

Goto the keycode example thread and get wxyz's code and use it instead. :P

Monster

SynToad
11-03-2002, 01:31 AM
Originally posted by Nurseling

C:\cygwin\bin>gcc -c key.c
key.c:5:21: fstream.h: No such file or directory
key.c: In function `main':
key.c:108: warning: return type of `main' is not `int'

I'm not sure about cygwin, but fstream.h is included in MinGw, it is a c++ header, so you need to compile using g++ not gcc. then you also need to change the line:
*pCurChar != '\' && pCurChar != pe32.szExeFile - 1;
to
*pCurChar != '\\' && pCurChar != pe32.szExeFile - 1;

and change:
void main(int argc, char **argv)
to
int main(int argc, char **argv)

it should then compile for you with no errors in MinGw

Cali
11-03-2002, 02:18 AM
I get your code compiled when i input a numerical value 2.. where it errors..
I get code when i start EQ.. and everytime I zone.. I put the code. on SEQ where the Decoder drop down is.. Is this correct.. Cuz when I do . only 1 mob <dread collective> decodes.. rest stay unknown.?
Also. Do I need to input new codes.. every time I zone..

Don't mean to be stupid.. But trying to figure this all out..

I updated CVS as of 11/1/02 and Have the libEQ.a as of 11/1/02

Any help would be greatly appreciated..
Thanks

P.S. EDIT..
As of 1am 11/3/02 got new CVS and new libEQ.a and input the key .. everytime I zone.. and it decodes.. YOU ROCK. thanks.. Hope I'm doing it right :)

guice
11-03-2002, 02:17 PM
Ah, too sweet. SAMBA mounted my box onto my main system. Did a set copy over and it works like a champ.

Only two things:

One: Maps aren't centered. My guess is there might be something missing?

Two: Now, only if SEQ can load the keydat file when ever it changes automatically! ;)
(or does it and I've just been to impatient)

nvmy383z28
11-04-2002, 12:53 AM
While compiling the above I get an error :( Running Win XP - VC++6

Compiling...
getkey.cpp
c:\program files\microsoft visual studio\myprojects\getkey\getkey.cpp(109) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.

getkey.exe - 1 error(s), 0 warning(s)


I tested the "hello world" application and it compiled ok :(

Yes I used the search feature - I came up with one other person getting the cl.exe error - but it doesnt seem to be the same error

Thanks for any ideas/suggestions

nvmy383z28
11-04-2002, 01:31 PM
Havent been able to find a fix for this - have found many posts on other forums about the error - and tried everything suggested - still no worky :(

This is VC++6 Ent.

Compiling...
getkey.cpp
c:\program files\microsoft visual studio\myprojects\getkey\getkey.cpp(109) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.

getkey.exe - 1 error(s), 0 warning(s)


I tested the "hello world" application and it compiled ok and worked. It seems w hen I compile anything else - its broke.

Any suggestions?

I posted this here so that others might benefit from it with their future searches.... since there is only one other with the problem on the board at this time - and it is unrelated.

Thanks!

KaL
11-04-2002, 02:05 PM
/shrug, try one of the other examples.

gawker
11-04-2002, 02:34 PM
Select console application in the workspace wizard.

waldi
11-05-2002, 01:09 PM
Originally posted by KaL

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);


Because i am SOOO anal-retentive...

this is not a rant or meant to show ANY disrespect... i truely appreciate forums such as these...

the code snippet above from KaL's post HAPPENS to function correctly, but there really should be a semi-colon or a set of empty braces {} after the for-loop. It happens to work because the strcpy is just re-writing pName over and over, ending up at the place you want it to be anyways.

Sorry, but i felt compelled to mention it.

And, as soon as its fixed, my post will look inane, which means i'll eventually come edit it out =P