Creating a simple clientless login using Silkroad.Net

06/18/2021 22:15 brklol#1
Hi, I recently got back into the game and decided I want to familiarize myself with packets. I've noticed that there are a lot of resources available, which is very nice to see, however the majority of these resources are meant/made for vsro. I've been 'playing' GameGami's TRSRO and thought, why not give it a shot and try to mess around with the latest iSRO/TRSRO packets. This way I learn more about how Silkroad works under the hood, and at the same time I pick up some stuff about networking and C#.

My programming knowledge is Java for the most part, as most of my 9-5 day consists of programming in Java. So I thought I'd use the Silkroad.Net wrapper that was made for the SilkroadSecurityApi, since C# comes pretty close to Java.
So I took a shot at creating a simple program that attempts to clientlessly login to the TRSRO servers. However, since there's not many resources on the latest iSRO packets, data and whatnot, I'm getting stuck on some things. I managed to get up to the point where the program logs in, sends the secondary passcode and receives a valid/invalid response. After that, the program crashes due to it being unable to parse the incoming stream of data (I am assuming).
The following exception is thrown:
Code:
Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'Length')
   at Silkroad.Security.Blowfish.Decrypt(Span`1 input) in C:\Users\burak\RiderProjects\Silkroad.Net\Silkroad\Security\Blowfish.cs:line 272
   at Silkroad.Network.Messaging.Protocol.MessageProtocol.Decode(MessageSize size, Span`1 buffer) in C:\Users\burak\RiderProjects\Silkroad.Net\Silkroad\Network\Messaging\Protocol\MessageProtocol.cs:line 60
   at Silkroad.Network.Session.ReceiveAsync() in C:\Users\burak\RiderProjects\Silkroad.Net\Silkroad\Network\Session.cs:line 252
   at Silkroad.Network.Session.RunAsync() in C:\Users\burak\RiderProjects\Silkroad.Net\Silkroad\Network\Session.cs:line 356
   at SimpleClientless.Program.Main(String[] args) in C:\Users\burak\RiderProjects\Silkroad.Net\SimpleClientless\Program.cs:line 32
   at SimpleClientless.Program.<Main>(String[] args)
Since I am not very familiar with the SilkroadSecurity api, I was wondering if there are people who can help me and figure out what could be going wrong in my program.

Also there are some bytes in some packets that I was unable to parse myself, and was wondering if you guys have been able to. For example this one:
Code:
Message login = new Message(Opcodes.Gateway.Request.LOGIN2, true);
login.Write((byte) Local.SRO_TR_Official_GameGami);
login.Write(UserName, Encoding.Default);
login.Write(Password, Encoding.Default);
                
// Unknown 6 bytes (for now)
login.Write<ushort>(123);
login.Write<ushort>(456);
login.Write<ushort>(789);
                
login.Write(servers["Misis"].Id);
login.Write<byte>(1);
The source is available on my GitHub: [Only registered and activated users can see links. Click Here To Register...]

I'm also down to talk on Discord: Burak#5201

Update 19/06:
I decided to create an implementation in the original SilkroadSecurityApi. I did this so I could familiarize myself with the original api. See source code here: [Only registered and activated users can see links. Click Here To Register...]

Update 19/06 v2:
It is now possible to log in, select a character and join the game world. I've also added some pretty messages to login errors.

I shall delve deeper into the original api. Any form of feedback is always appreciated.
06/19/2021 00:13 DaxterSoul#2
This seems to contain the protocol code I originally wrote for [Only registered and activated users can see links. Click Here To Register...].
When the project was abandoned the implementation was still unstable and won't be updated by me. I don't know if 'zefiers' put any work into testing or stabilizing it.
You might want to try the original SilkroadSecurityApi from Drew Benton to rule out any protocol bugs I might've introduced.
06/19/2021 00:30 brklol#3
Quote:
Originally Posted by DaxterSoul View Post
This seems to contain the protocol code I originally wrote for [Only registered and activated users can see links. Click Here To Register...].
When the project was abandoned the implementation was still unstable and won't be updated by me. I don't know if 'zefiers' put any work into testing or stabilizing it.
You might want to try the original SilkroadSecurityApi from Drew Benton to rule out any protocol bugs I might've introduced.
Yeah I figured it might be better to become familiar with the original SilkroadSecurityApi to fully understand how if works, as the current one I'm using is a high level wrapper. I'll take a look at it, thanks :)

Today I took a shot at implementing the same clientless login in the original security api. And without surprise, everything works smoothly with the original api.

Source code was attached to the original post.
07/06/2021 13:06 zefiers#4
I am actually surprised to see that anyone is paying some attention to this project, a lot of people fear of trying something new, especially in this scene, yet me either is not paying attention to it recently as a result of being busy. Just as 'DaxterSoul' mentioned above this wrapper was actually extracted from project 'Phoenix' and yet I left a copyright note in the 'License' section in the README file at GitHub.

However it was planned to get this project 'Silkroad.Net' into a fully wrapper. but I'm just busy atm.
Feel free to contribute, and I will do the same after finishing what I'm doing atm.
However you should have created Issue in GitHub I would have seen this earlier.

Back to the problem, also I don't have much time atm, but may I ask why you are using [Encoding.Default] when writing Strings into the Packet/Message? Normally SRO uses ASCII but ISRO sometimes uses 'UTF16' especially with Packets/Messages related to the in-game chat. Encoding is not something that you choose based on your opinion.

In the current situation, the Login Message should be encoded in ASCII, this should work.

Also I have pushed a CRITICAL bug fix in the repo just a moment ago, make sure to check it out.
07/13/2021 14:12 pumpya19#5
You can also take a look on the sro server emulator I'm working on. At least the protocol seems to be stable for VSRO 188. It has client and server protocol implemented.

Here's the link: [Only registered and activated users can see links. Click Here To Register...]

If you have any questions regarding the code, just leave me a message