Contribute  :  Web Resources  :  Past Polls  :  Site Statistics  :  Downloads  :  Forum  
    BiW ReversingThe challenge is yours    
 Welcome to BiW Reversing
 Monday, August 08 2022 @ 10:05 PM CEST
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Change Serial number

 
Post new topic   Reply to topic    www.reversing.be Forum Index -> Code Reversing
View previous topic :: View next topic  
Author Message
jackall
New to the board
New to the board


Joined: 25 Feb 2008
Posts: 10
Location: india

PostPosted: Sun Mar 02, 2008 1:31 pm    Post subject: Change Serial number Reply with quote

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

if(nbr==4321){
cout<<"Good Boy";
}else

for(a=0;a<15;a++){
cout<<"Bad.....Boy\n\n\n";
}
cin.get();
return 0;

}
Back to top
View user's profile Send private message Send e-mail
Nacho_dj
Frequent poster
Frequent poster


Joined: 03 Jan 2006
Posts: 52

PostPosted: Mon Mar 03, 2008 5:13 pm    Post subject: Reply with quote

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.

Cheers

Nacho_dj

_________________
http://arteam.accessroot.com
Back to top
View user's profile Send private message Visit poster's website
jackall
New to the board
New to the board


Joined: 25 Feb 2008
Posts: 10
Location: india

PostPosted: Mon Mar 03, 2008 6:41 pm    Post subject: Reply with quote

Thank you Nacho_dj for your tips.

i will try to follow your suggestion although it is not very clear to my shrunk brain
Hope i find a solution.
regards.
Back to top
View user's profile Send private message Send e-mail
detten
Site Admin


Joined: 05 Feb 2005
Posts: 317

PostPosted: Mon Mar 03, 2008 6:47 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
jackall
New to the board
New to the board


Joined: 25 Feb 2008
Posts: 10
Location: india

PostPosted: Tue Mar 04, 2008 7:03 am    Post subject: Reply with quote

Thanks detten ..

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.

Thank you once again..
Back to top
View user's profile Send private message Send e-mail
jackall
New to the board
New to the board


Joined: 25 Feb 2008
Posts: 10
Location: india

PostPosted: Tue Mar 04, 2008 8:54 am    Post subject: Reply with quote

detten ..

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.

regards.
Back to top
View user's profile Send private message Send e-mail
detten
Site Admin


Joined: 05 Feb 2005
Posts: 317

PostPosted: Tue Mar 04, 2008 6:24 pm    Post subject: Reply with quote

Quote:
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++
Code:

char* nbr = "4321";
if (nbr[0] == '4' && nbr[1] == '3' && nbr[2] == '3' && nbr[3] == '4' && nbr[4] == '\0')
{
//Goodboy
}

Code:

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 Wink

_________________
Ignorance is bliss, knowledge is power
Back to top
View user's profile Send private message Visit poster's website
jackall
New to the board
New to the board


Joined: 25 Feb 2008
Posts: 10
Location: india

PostPosted: Wed Mar 05, 2008 8:40 am    Post subject: Reply with quote

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.

Thank you.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    www.reversing.be Forum Index -> Code Reversing All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group
 Copyright © 2022 BiW Reversing
 All trademarks and copyrights on this page are owned by their respective owners.
Powered By Geeklog 
Created this page in 0.82 seconds