Posted: Sun Mar 02, 2008 1:31 pm Post subject: Change Serial number
i wrote a small program in C++ and compiled it to binary. Then i tried to reverse the binary code using Ollydbg .
And i was able to patch the jump to get ‘Good Boy’ message. Now, i want to change the hard coded serial: 4321; but i was not able to locate it in OllyDbg. Please let me know how to proceed? The code is given below:
Thank you.
#include<iostream>
using namespace std;
int main()
{
int nbr;
int a;
cout<<"Enter a 4-digit number:\n";
cin>>nbr;
cin.ignore();
Search for your number in hexa format, it should be there...
If no luck doing in that way, the best is coding a messagebox in front of and behind the "if" sentence that contains your 1234. In that way you should find it better in OllyDbg.
I think the problem is that your serial is represented as an number (int).
If it was represented a string (char*), you would be able to find it in ollyDbg more easily.
If you found the 'goodguy' jump, then you must be able to find the CMP in front of it?
Doesn't it look something like this :
cmp eax, 10E1 ? _________________ Ignorance is bliss, knowledge is power
i changed the 'int' to ' char ' data type. Now the issue is about C++.
The if (nbr==4321) is evaluated to be ' not true ' and executes the ' else ' statement.
After compiling this , opened the file in Olly and found the "Good Boy" message is missing there too. could you please explain it ?
it is a satisfying experience to learn especially when understanding helping hands are nearby.
Your suggestion proved right ; it has taken me some Google search ; little effort to understand the string data declaration.
i was able to find the coded serial in Olly.
The if (nbr==4321) is evaluated to be ' not true ' and executes the ' else ' statement.
comparing your char* to 4321 actually compares the address where your string is stored with the address 4321. So in case your string would be stored at address 4321 it would return true. This is never the case in windows so it returns false every time.
Code:
char* nbr = "4321";
if (nbr =="4321")
{
//Goodboy
}
The above example also compares the string addresses instead of the actual string content, it won't work either. Though it looks valid if you are not familiar with C / C++
char* nbr = "4321";
if (!strcmp(nbr, "4321"))
{
//Goodboy
}
These 2 examples actually do compare the strings (the first by checking all the seperate chars, the second by using a handier method strcmp), but you probably figured that out by now _________________ Ignorance is bliss, knowledge is power
Well...
'String content and string address' are well explained by detten . And the code snippets accompanying it make the concept clearer...
Good clarity of subject and genuine willingness to share the knowledge with others.
This has helped me...
Though i had got my answer right following detten's initial tip; i would have not have learned why if (nbr 4321) is evaluated to be 'not true’ with out the additional explanation.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum