Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hiding information in a C program from strings......

Status
Not open for further replies.

programgo

Programmer
Jun 8, 2001
4
0
0
US
I have a specific program that handles some sensitive information.
I need to have some key codes in the program.
I have tried several different ways to hide the information from say
a search of the binary with "strings" but I have not been able
to hide the key strings.

Any ideas on how I can do this.
PS: I compile with -s also.

Thanks for your help.
 
may be u could try this out

[red] compile that particular code separately [/color]and create an obj file. while linking link this obj file. this should hide the unwanted data strings.

:-V
 
In your code itself you can make some changes. Take the ascii values of each element in the string and make some constant manipulation [ eg : "ABC" ; declare the char array like the following; char str = { 35, 36, 37, 0} here the ascii values are reduced by constant 30]

While printing the string add 30 to each element [not for \0 ] and print the string. You can make some complicated manipulation too.

This will affect the speed of your program but this will give only different strings in the binary file search and will not show the original.

Maniraja S
 
Or keep your string in different variable and catinate before using. Plus you can add SMANIRAJA advise. Just be careful, do not store all strings (and decode them) in one function, I can imagine that some compiler optimization can figured out that you are using only a catinated (or decoded) string and put original key in code.
Compiler can performe some constant operation, such as:
int myfunc()
{
int a = 4;
a=a-2;
return a;
}
It can initialize "a" by 2 and do not perform a=a-2; or even do not create "a" at all and just return 2. In most cases it is a mistery for me what opimization are doing to code, but since it works up to 5 times quicker I think it is doing a lot. So keep your coded string in static array and decode it in function. This should prefent it from "optimization". Or (in MS C++) you can just turn off optimization for some function.
Regards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top