[Help] Packet Editor - Comparing Socket Data.

07/27/2011 11:44 pokeninja2#1
Hello, I want to save and compare the data of a 2 packets,

and finding out if they contain the same data...

Thanks to u-coRe & Metin2Spieler97 i have something like this, and its working great!

Thanks for the help!!!

This part saves the 1rst packet to be compared.
PHP Code:
bool paso0(const charbuf,int len){

            
buf2 = (char*) malloc (len);
            
tam_buf2=len;
            for (
int i 0len; ++i)    /
                
buf2[i] = buf[i];            
            return 
true;

This part check if the packets are the same :)
PHP Code:
bool check(const charbuf,int len,charbufb,int lenb){
        
bool check=false;
        
int i=0;
        if(
len!=lenb){

        }else{
            while (
len) {
                if (
memcmp(bufb,buf,len)==0){
                    
check true;
                }else{
                    
check false;
                    
i=len;
                }
                
i++;
            }}
        return 
check;
    } 
Now i need to build an interface!!! ANY SUGGESTIONS?
07/27/2011 12:39 buFFy!#2
how come u use strcmp? a packet doesnt has to be a string. use memcmp instead
07/27/2011 18:35 pokeninja2#3
Quote:
Originally Posted by u-coRe View Post
how come u use strcmp? a packet doesnt has to be a string. use memcmp instead
Same error... I'm Using Wireshark to analize what's in the packet Data and for example:
Packet data with Wireshark= d7
Content of buf = 126FA51E0B (Using printf ("DATA: %X\n",buf); )
Why is that?
07/27/2011 19:11 buFFy!#4
tbh, i have no clue. never used wireshark.

try to check the length parameter and compare with wireshark. this could help debugging
07/27/2011 22:38 ms​#5
Quote:
Originally Posted by pokeninja2 View Post
Same error... I'm Using Wireshark to analize what's in the packet Data and for example:
Packet data with Wireshark= d7
Content of buf = 126FA51E0B (Using printf ("DATA: %X\n",buf); )
Why is that?
You're printing the pointer instead of what it points to. If you want to print out the buffer content instead you need to iterate over it.

Code:
int i;
printf("DATA: ");
for (i = 0; i < len; ++i)
    printf("%02X ", buf[i]);
printf("\n\n");
07/28/2011 00:02 pokeninja2#6
Quote:
Originally Posted by Metin2Spieler97 View Post
You're printing the pointer instead of what it points to. If you want to print out the buffer content instead you need to iterate over it.

Code:
int i;
printf("DATA: ");
for (i = 0; i < len; ++i)
    printf("%02X ", buf[i]);
printf("\n\n");
Thank you !!! I knew that the problem was in me reading de pointer instead of the data, but i didn't knew how to fix it :)

Now I have to compare each data and find out if they are equal.
07/28/2011 10:44 buFFy!#7
actually, memcmp is still the right way.
07/28/2011 12:12 ms​#8
Quote:
Originally Posted by pokeninja2 View Post
Thank you !!! I knew that the problem was in me reading de pointer instead of the data, but i didn't knew how to fix it :)

Now I have to compare each data and find out if they are equal.
Quote:
Originally Posted by pokeninja2 View Post
if (memcmp (azules,buf,1024) == 0){
The 3. argument of memcmp has to be the length of your array, which is len in your case.
07/29/2011 03:34 pokeninja2#9
Thanks for the help!!!
This part saves the 1rst packet to be compared.
PHP Code:
bool paso0(const charbuf,int len){

            
buf2 = (char*) malloc (len);
            
tam_buf2=len;
            for (
int i 0len; ++i)    /
                
buf2[i] = buf[i];            
            return 
true;

This part check if the packets are the same :)
PHP Code:
bool check(const charbuf,int len,charbufb,int lenb){
        
bool check=false;
        
int i=0;
        if(
len!=lenb){

        }else{
            while (
len) {
                if (
memcmp(bufb,buf,len)==0){
                    
check true;
                }else{
                    
check false;
                    
i=len;
                }
                
i++;
            }}
        return 
check;
    } 
Now i need to build an interface!!! ANY SUGGESTIONS?
07/29/2011 10:56 buFFy!#10
mfc? you should try using google