Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: OT: hiding strings in .exe

Author: Brian Kostick

Date: 13:57:45 04/27/05

Go up one level in this thread


On April 27, 2005 at 15:42:41, Dieter Buerssner wrote:

>On April 27, 2005 at 15:34:31, Brian Kostick wrote:
>
>>  For the reason mentioned by Dr. Hyatt. So the strings are not easy to detect
>>in the executable. What good a password when it's to easy to open the file in a
>>hex editor or notepad?
>
>The method given by Bob will work for the casual hex editor user, and is very
>easy to implement. But of course, it would take almost no time for a cryptology
>expert, to crack this. Sophisticating the method slightly, will also not help,
>then. Perhaps it would even be impossible, to have a secure method without a
>password, that comes from some external (=outside of the executable) source.
>
>Regards,
>Dieter

Thanks Dieter,

  Yes, from my original post: "or should I use an encryption". I knew this was
an option but for this _passing notes in class_ level of program I thought maybe
there was an ultra _simpler_ way to hide strings. I guess that's not going to
happen with a compiler or linker switch ;)

  In the meantime I wrote little encode and decode programs. For now the ^= 0xA5
is fine. encode program writes a text with int array ready for the decode
program.

  The program where I mask the strings is just part of the wrapper of my Win32
Password function. Code follows for anyone who has interest, not complex but
maybe obscure to those that do not code Win32 console.

Regards,
Brian


/* Password function for Win32 console
 * reads keystrokes but displays * to mask printable entries
 * first parameter: a pointer to a char array, buffer to hold password
 * second parameter: password buffer size, including null terminator
 * return value: funtion returns 1 if max buffer is reached, else returns 0
 */

int Password( char * buffer, int buffSize)
{
	int count = 0;
	INPUT_RECORD inRec;
	HANDLE hInput, hOutput;
	DWORD dwCharsRead, dwCharsWritten;

	buffSize--;

	hInput = GetStdHandle(STD_INPUT_HANDLE);
	hOutput = GetStdHandle(STD_OUTPUT_HANDLE);

	while(ReadConsoleInput(hInput, &inRec, 1, &dwCharsRead) && count < buffSize)
		if(inRec.EventType == KEY_EVENT && inRec.Event.KeyEvent.bKeyDown == TRUE
			&& isprint(inRec.Event.KeyEvent.uChar.AsciiChar))
			buffer[count++] = inRec.Event.KeyEvent.uChar.AsciiChar,
			WriteConsole(hOutput, "*", 1, &dwCharsWritten, NULL);
		else
		if(inRec.Event.KeyEvent.uChar.AsciiChar == '\r' &&
			inRec.Event.KeyEvent.bKeyDown == TRUE &&
			inRec.EventType == KEY_EVENT)
			break;
		else
		if(inRec.Event.KeyEvent.uChar.AsciiChar == '\b' &&
			inRec.Event.KeyEvent.bKeyDown == TRUE &&
			inRec.EventType == KEY_EVENT && count > 0)
			WriteConsole(hOutput, "\b \b", 3, &dwCharsWritten, NULL),
			count--;

	buffer[count] = '\0';

	if(count == buffSize)
		return(1);
	else
		return(0);
}






This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.