Jump to content
SubSpace Forum Network

Recommended Posts

Posted

I have read the subspace protocol page on catid's website, I just do not know how to implement the login procedure as it would look when you send it. I am making a bot core in perl, for my own personal use. An example of what I do not get would be the key exchange.

 

:Key exchange

 

00 01 - Connection request

00 01

NOTE: Key must be negative, Encryption type = 1 for SubSpace

 

 

00 02 - Connection affirmation

00 02

NOTE: Key will be unary -SentKey

 

Now how would I send this to the server? Would I send it as "00 01 -04 1"? I do not know how to implement this. Could you please tell me how, maybe a code example (don't matter what language) without any variables. Thanks

Posted

No, the means that a required field called "Key" is 4 bytes long. All multi-byte fields are in little-endian byte order so if your key is:

 

0xDEADBEEF

 

then your packet would look like:

 

00 01 EF BE AD DE 01 00

 

Note that 0xDEADBEEF is a negative integer and the last 01 00 = encryption type 0x0001 in little-endian byte order. The key sent in the connection request is a randomly generated integer less than 0.

 

-Snrrrub

Posted

Ok THANKS, so this is what it would look like in code:

 

$key="00 01 EF BE AD DE 01 00";

$remote->send($key);

 

Does the server exepts the packets send like this? Where $key is the data being sent.

 

Also is there a fast way to get a response from the server, to make sure im connecting right, if not what do I have to do to get a resonse from the server.

Posted
Ok that is wrong, I know its not a string you send. Do I send it like 0x00 0x01 0xDEADBEEF 0x01 0x00? What do these packets look like when they are sent?
Posted

No, it's not sent as a string. Basically, SubSpace uses UDP datagrams for communication and each hex digit pair you see in the docs is one byte in the datagram. So when I said your packet looks like:

 

00 01 EF BE AD DE 01 00

 

I mean that the bytes are arranged that way in the datagram. That is, 0x00 is the first byte, 0x01 is the second byte and so on. As far as code goes, you might have something like:

 

Packet p;
p.appendByte(0x00);
p.appendByte(0x01);
p.appendInt(0xDEADBEEF);
p.appendShort(0x0001);

 

Hope this helps.

 

-Snrrrub

Posted

Yea I saw something like that in the twcore bot. Could I just send it like: key = 0x0001DEADBEEF0001

 

or could I send each individually like:

key = 0x00

send

key = 0x01

send

key = 0xDEADBEEF

send

key = 0x0001

send

Posted

If you managed to store that in an integer, then sent it, I think the byte order will get reversed because of the little endian thing. Mind you it doesn't matter what it looks like in transit so long as what you receive is the same as what you sent.

 

I don't know perl, but you might could make a packet class that stores a packet in a string. Then you can use the appendbyte(), appendint() style functions mentioned earlier and send the string through the socket.

Posted

This is what im doing:

 

$keyp=pack("s*", 0x00, 0x01, -72, -54, -23, -68, 0x01, 0x00);

print "$keyp\n";

defined(send(SOCKET, $keyp, 0, $portaddr)) || die "send $server: $!";

print "Key sent\n";

 

$maxlen=128;

$portaddr = recv(SOCKET, $keyr, $maxlen, 0) or die "recv: $!";

($port, $ipaddr) = sockaddr_in($portaddr);

$host = gethostbyaddr($ipaddr, AF_INET);

print "$host($portno) said ".$keyr."\n";

 

output is:

¸ÿÊÿéÿ¼ÿ

Key sent

 

I don't get any reply

 

 

I also tried using an array:

@key=(0x00, 0x01, -72, -54, -23, -68, 0x01, 0x00);

print "@key\n";

defined(send(SOCKET, "@key", 0, $portaddr)) || die "send $server: $!";

 

print "Key sent\n";

 

$maxlen=128;

$portaddr = recv(SOCKET, $keyr, $maxlen, 0) or die "recv: $!";

($port, $ipaddr) = sockaddr_in($portaddr);

$host = gethostbyaddr($ipaddr, AF_INET);

print "$host($portno) said ".$keyr."\n";

 

output:

0 1 -72 -54 -23 -68 1 0

Key sent

 

I still did not get any reply

 

 

 

 

Am I sending these packets wrong?

Posted

Nevermind I got it, finally. You just have to make the packets into characters, then send it. I just used an already made bot and made a server to get the first packet, and saw that the bot was sending characters. Also on the core packet type 05, this is what I got:

@syncR = (0x00, 0x05, 0x6D, 0xE1, 0x1E, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x

00, 0x00, 0x00);

(I got that from twcore)

 

One place in http://catid.ssihosting.com/files/addendum.txt it says:

00 05 SS SS RR RR

'SS = Number of connections since last recycle

'RR = Random number

 

And in another place it says:

00 05 - Sync. request

00 05 [ ]

NOTE: As you notice, the packet counts are optional.

 

Could someone tell me what one I should be using please?

Posted

Getting a 00 05 after sending the initial packet is a sort of hack. You don't need to know why or how, just if you correctly handle the 00 05/00 06 sync packets in the first place, it will work anyway.

 

I wouldn't worry about the extra stuff on the end of that 00 05, it's best to use a minimum length check on packets instead of an exact length check.

Guest
This topic is now closed to further replies.
×
×
  • Create New...