• Welcome to Valhalla Legends Archive.
 

Finished PHP Socket for Battle.net!

Started by Don Cullen, March 29, 2004, 02:36 AM

Previous topic - Next topic

Don Cullen

Topic resolved.
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.

effect

this has been covered here before , use the search feature provided to look for it.
Quote from: Mangix on March 22, 2005, 03:03 AM
i am an expert Stealthbot VBScript. Recognize Bitch.

Don Cullen

#2
Did. I ain't that stupid. Found some posts, but none of then answered my question about using sockets in php to connect to battle.net. If you actually found one, I'd be impressed since I searched the forum archives twice using different keywords. once, using PHP as keyword, twice using PHP socket. Useless results either way. PHP has WAY massive results, and i've waded thru it, only to find useless results and even more useless results, while PHP socket brought up only one post of relevance:

<<Post by Tuberload in response to PrivateWilly's post>>
You are either going to have to interface the PHP script with a bot made in another programming language, or make a bot of sort out of PHP that will connect, logon, join the specified channel, and gather information.

I would go with the first suggestion, but either should work. Keep in mind the second solution assumes PHP supports sockets, and I don't know whether it does or not.

Edit: PHP does have socket support, so code on!
<<End of post>>

As you can see, doesn't give info on how php sockets should be used in order to connect to battle.net and login via the telnet gateway. Trust me, I've used planetsourcecode.com's search, google.com's search, yahoo.com's search. Even asked two fellow php coders. they got hostile and didn't want to tell me how sockets should be used to connect to battle.net because they wanted to be "the only ones with working scripts that connected to battle.net and used it".

So as a result, I'm a tad bit quite sick of searching everywhere for something that doesn't exist or doesn't want to be found, and I'm tired of trying to pry this information out of people.

Forgive me if I've offended you, as that was quite unintentional.
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.

tA-Kane

#3
Quote from: LockesRabb on March 29, 2004, 02:36 AM<?
   $cfgServer = "useast.battle.net";
   $cfgPort = 6112;
   $cfgTimeOut = 10;
   $cfgUser = "something";
   $cfgPassword = "something";

   echo "Configuration set.\n";

   // open a socket
   if(!$cfgTimeOut){
       // without timeout
      echo "Connecting...\n";
      $usenet_handle = fsockopen($cfgServer, $cfgPort);
   } else {
       // with timeout
      echo "Connecting...\n";
      $usenet_handle = fsockopen($cfgServer, $cfgPort, &$errno, &$errstr, $cfgTimeOut);
   }
   if(!$usenet_handle) {
      echo "Connexion failed\n";
       exit();
   } else {
       echo "Connected!\n";
      $tmp = fgets($usenet_handle, 1024);
   }
   echo "Attempting to login...\n";
   echo $tmp."\n";
   fputs($usenet_handle, $cfgUser."\n");
   $tmp = fgets($usenet_handle, 1024);
   echo $tmp."\n";
   fputs($usenet_handle, $cfgPassword."\n");
   $tmp = fgets($usenet_handle, 1024);
   echo $tmp."\n";
?>
It does not appear as though you are identifying which type of connection you are, but are heading straight to sending your username and password.

Assuming you're trying to logon a CHAT client, you need to send 3 as a byte to identify yourself as a CHAT connection (rather than BnFTP, or game client, or perhaps others). Also, if you want to disable the server's echoing of what you sent, you need to also send 4 as a byte (which is only relevant with CHAT connections).

Lastly, please make use of the [ code ] tags.
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

Don Cullen

#4
Post cleared for security reasons.
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.

Don Cullen

#5
Post cleared for security reasons.
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.

Kp

Quote from: LockesRabb on March 29, 2004, 06:04 PMbut it seems to still be hanging right about where it attempts login... ideas?

If you haven't already, consider having your script just parrot whatever battle.net sends it to the end client.  That'll determine whether your parser is broken or whether the BNCS really isn't sending any other data.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!


Don Cullen

#8
E-mail me for the solution.
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.

Maddox

#9
If you want to get started on a Binary Bot, then here is a class that should help.


class buffer
{
   var $buffer   = "";
   var $size   = 0;

   function addSTRING($data)
   {
      $this->buffer .= $data . chr(0);
      $this->size += strlen($data) + 1;
   }

   function addDWORD($data)
   {
      $this->buffer .= $this->getDWORD($data);

      $this->size += 4;
   }

   function addWORD($data)
   {
      $this->buffer .= $this->getWORD($data);

      $this->size += 2;
   }

   function addBYTE($data)
   {
      $this->buffer .= chr($data);

      $this->size++;
   }

   function getDWORD($data)
   {
      $buf  = chr((($data & 0x000000FF) >>  0));
      $buf .= chr((($data & 0x0000FF00) >>  8));
      $buf .= chr((($data & 0x00FF0000) >> 16));
      $buf .= chr((($data & 0xFF000000) >> 24));

      return $buf;
   }

   function getWORD($data)
   {
      $buf  = chr((($data & 0x00FF) >> 0));
      $buf .= chr((($data & 0xFF00) >> 8));

      return $buf;
   }

   function output()
   {
      return $this->buffer;
   }
}

class bnetbuffer extends buffer
{
   function output($packetid)
   {
      $header = chr(0xff) . chr($packetid) . getWORD($this->size);

      return $header.$this->buffer;
   }
}
asdf.

SKiLLs

You know when you connect with Chat you got to send C.. Try it your self on Telnet. Make sur e u send C..

Link:
http://www.blizzard.com/support/?id=mall0578p

Don't know if you had this in your code or not, just trying to help out.
I like PHP and would love to hear someone did something like this!

Don Cullen

Quote from: SKiLLs on March 31, 2004, 09:26 PM
You know when you connect with Chat you got to send C.. Try it your self on Telnet. Make sur e u send C..

Link:
http://www.blizzard.com/support/?id=mall0578p

Don't know if you had this in your code or not, just trying to help out.
I like PHP and would love to hear someone did something like this!

Nah, don't need c to be in code- the script already sends the neccessary data to establish a connection. And the script is fully functional. Try it out for yourself! :-)
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.

Don Cullen

Quote from: Maddox on March 30, 2004, 09:57 PM
If you want to get started on a Binary Bot, then here is a class that should help.


class buffer
{
   var $buffer   = "";
   var $size   = 0;

   function addSTRING($data)
   {
      $this->buffer .= $data . chr(0);
      $this->size += strlen($data) + 1;
   }

   function addDWORD($data)
   {
      $this->buffer .= $this->getDWORD($data);

      $this->size += 4;
   }

   function addWORD($data)
   {
      $this->buffer .= $this->getWORD($data);

      $this->size += 2;
   }

   function addBYTE($data)
   {
      $this->buffer .= chr($data);

      $this->size++;
   }

   function getDWORD($data)
   {
      $buf  = chr((($data & 0x000000FF) >>  0));
      $buf .= chr((($data & 0x0000FF00) >>  8));
      $buf .= chr((($data & 0x00FF0000) >> 16));
      $buf .= chr((($data & 0xFF000000) >> 24));

      return $buf;
   }

   function getWORD($data)
   {
      $buf  = chr((($data & 0x00FF) >> 0));
      $buf .= chr((($data & 0xFF00) >> 8));

      return $buf;
   }

   function output()
   {
      return $this->buffer;
   }
}

class bnetbuffer extends buffer
{
   function output($packetid)
   {
      $header = chr(0xff) . chr($packetid) . getWORD($this->size);

      return $header.$this->buffer;
   }
}


Thanks for the info! But I won't be developing a binary bot in PHP since PHP sucks for that. If I was going to develop one, I'd probably do it in C. But I'll keep that info in storage for if I ever do decide to take on the project.
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.

AC_Drkan

Can't you just use telnet?

telnet useast.battle.net 6112
then type 'c' when you see the cursor
"The Arguments of Today Result in the Wars of Tomorrow" - Quote By Muah.
<@Logan> I spent a minute looking at my own code by accident.
<@Logan> I was thinking "What the hell is this guy doing?"

<kow`> "There are 10 types of people in the world... those who understand binary and those who don't."
<SpaceRain> That's only 2 types of people, kow.
<SpaceRain> STUPID


<[TN]FBMachine> i got kicked out of barnes and noble once for moving all the bibles into the fiction section

God i love Bash.org.

Forged

Yeah but then it wouldn't be a script on his site now woud it...
QuoteI wish my grass was Goth so it would cut itself