User Control Panel
Advertisements

HELP US, HELP YOU!

Perl string comparison

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl
View unanswered posts
Author Message
Teario
Member
Member


Joined: 25 Jun 2004
Posts: 126
Location: Liverpool(home) or Derby(uni), UK
Reputation: 58
votes: 3

PostPosted: Sun Jan 06, 2008 1:17 pm    Post subject: Perl string comparison Reply with quote

Something a little weird is happening here:

The bot sends the initial VER command to the msn server with the protocol that it wants to use. The server replies with a list of protocols that it will support. Then the bot loads the handlers for that protocol, as they differ between some.

Once the first NS gives you an XFR command, it closes the connection and you have to send a VER to a different NS and start over. Well the second time we do this I obviously dont want to reload the handlers as we know which protocol we are going to use already. I have a simple string comparison to check this, but its not working:

Code:
   my $fn = shift;
   my $srd = shift;
   my($cmd, $trid, @protos) = split(/ /,$srd);

   if($bot->{MSN}->{Details}->{Protocol} == 'Unknown')
   {
      &LoadProtocolHandlers($protos[0]);
      $bot->{MSN}->{Details}->{Protocol} = $protos[0];
   }


These are the results:
Quote:
Loading Routine: HtmlEncode
Loading Handler: Connect
Loading Handler: Dispatch
Loading Handler: Send
Loading Handler: SendMessage
Loading Handler: VER

OUT: VER 1 MSNP13 MSNP12 MSNP11 CVR0
IN: VER 1 MSNP13 MSNP12 MSNP11 CVR0
Protocol: Unknown
Loading MSNP13 Handler: CVR
Loading MSNP13 Handler: USR
Loading MSNP13 Handler: XFR
OUT: CVR 2 0x0409 winnt 6.0 i386 MSMSGR 8.5.1302 msmsgs xxx@hotmail.com
IN: CVR 2 1.0.0000 1.0.0000 1.0.0000 http://msgr.dlservice.microsoft.com http://messenger.msn.com
OUT: USR 3 TWN I xxx@hotmail.com
IN: XFR 3 NS 207.46.107.81:1863 U D

At this point we disconnect from this server and connect to 207.46.107.81:1863

OUT: VER 4 MSNP15 MSNP14 MSNP13 CVR0
IN: VER 4 MSNP15 MSNP14 MSNP13 CVR0
Protocol: MSNP13
Loading MSNP15 Handler: CVR
Loading MSNP15 Handler: USR
Loading MSNP15 Handler: XFR
OUT: CVR 5 0x0409 winnt 6.0 i386 MSMSGR 8.5.1302 msmsgs teario@hotmail.com
IN: CVR 5 1.0.0000 1.0.0000 1.0.0000 http://msgr.dlservice.microsoft.com http://messenger.msn.com


As you can see, two strange things are happening here but one is my fault. As I havent yet set up the detail loading, I have hard coded the protocol values in and got the second set wrong (P15 to 13 instead of 13 to 11). Even with this bug in, the second problem shouldnt happen but does:

"Protocol: Unknown" is the initial contents of $bot->{MSN}->{Details}->{Protocol}
The second, "Protocol: MSNP13" is the contents of the same variable the second time around. Then the value is checked against the constant string 'Unknown' and for some odd reason thinks that the strings 'MSNP13' and 'Unknown' are the same, so continues to reload the protocol specific handlers (in this case it loads the p15 handlers because of the bug I mentioned before).

Clearly this is wrong, but I dont know why it is happening. Anyone shed some light?
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Mon Jan 07, 2008 9:34 pm    Post subject: Reply with quote

Easy!

Code:
   if($bot->{MSN}->{Details}->{Protocol} == 'Unknown')


Should be:
Code:
   if($bot->{MSN}->{Details}->{Protocol} eq 'Unknown')


You seem to be getting a lil rusty on your Perl. Wink http://search.cpan.org/~rgarcia/perl-5.10.0/pod/perlop.pod#Equality_Operators____

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
Teario
Member
Member


Joined: 25 Jun 2004
Posts: 126
Location: Liverpool(home) or Derby(uni), UK
Reputation: 58
votes: 3

PostPosted: Mon Jan 07, 2008 11:41 pm    Post subject: Reply with quote

Doh! Sad Youre right, I am. Its coming back to me though Smile Got my bot on P11 now, almost working on P13.

Thanks for the help!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group