unknowncheats uc-forum.com ucdownloads ucdownloads.com

Go Back   UC-Tutorials - Multiplayer Game Hacking and Cheat Tutorials > Programming > C and C++

- Sponsored Advertisement -
http://www.myfpscheats.com/


Reply
 
Thread Tools Display Modes
  #1  
Old 06-15-2007, 12:18 PM
Neo_Reloaded Neo_Reloaded is offline
Tutorial Admin
 
Join Date: Dec 2006
Posts: 259
Default (C) Find string in text file

By Chernobyl

This little application i wrote opens a text file (right now TEST.txt) and loads the entire thing into an array in memory, then scans for a few set words (in this example Chernobyl and Stephen). If it detects those words it prints "String Detected: " then the word it detected

The is actually the start of a different project of mine, the next version is actually going to scan binary files (exe's and dll's) for strings. Because somewhere in my AntiLeak.dll i will be storing a code, and the function will look for that code. If its not found it assumes its not the original Legit AntiLeak.dll and exits (or self deletes )

Code:
#include <stdio.h>
#include <string.h>

void main()
{
	short int i;
	char str1[1000];

	/* Scan text file for these words */
	static char *nameList[] = {
		"Chernobyl",
		"Stephen",
		NULL
	};

	FILE *inFile;
	inFile = fopen("TEST.txt", "r");

	if(inFile != NULL)
	{
		fgets(str1, sizeof(str1), inFile);
		fclose(inFile);

		for(i = 0; nameList[i] != NULL; i++)
		{
			if(strstr(str1, nameList[i]) != NULL)
				printf("String Detected: %s\n", nameList[i]);
		}
	}
	else
		printf("Cant locate text file");

	printf("\n\nPress ENTER to continue!");
	getchar();
}
Reply With Quote
Reply

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google
  • Submit Thread to Facebook
  • Submit Thread to My Yahoo!
  • Submit Thread to MySpace
  • Submit Thread to Twitter
  • Submit Thread to Reddit

Tags
file, string, text

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 05:24 AM.