c++ Proxy

11/28/2011 05:09 kibbles18#1
Im writing a c++ proxy similar to nuconnector, and have gotten it to accept the connection from the bot and sro_client. what's next? how do i send packets etc get security bytes?
11/28/2011 08:23 Nezekan#2
reinventing the wheel, aren't you?
11/28/2011 17:12 kevin_owner#3
Take a look at some proxies by drew. It has a SilkroadSecurity class which generates those bytes for you. He also wrote an article about the silkroad security which you can find at scribd.com.

Or get one of his more recent releases the SilkroadSecurityApi which is written in C# but it shouldn't be a huge problem to convert it back to C++.

But like Nezekan also said it's kinda reinventing the wheel. NuConnector works fine and srproxy is also a nice one and there are a few others out there. Also the SilkroadSecurityApi which I just mentioned is a great library to create a proxy.
11/29/2011 00:37 kibbles18#4
What are the security bytes for?
im the type that wants to know how things work so i always code everything from scratch
11/29/2011 01:17 theoneofgod#5
Study Drews code. Drew is a legend in the Silkroad Online scene, so if you want reference, that is where you should look.
11/29/2011 02:47 kibbles18#6
ok but i hate how oop his code is makes it hard to read imo
11/29/2011 17:31 kevin_owner#7
Yeah his code is a bit hard to read cause it lacks of comments ect but it's at least something and he released it for free so I guess we should be happy for someone release such great things.

And the security bytes are just for the server to verify that it's really communicating with the client so it makes it harder for someone to create a bot or a clientless.

I'm also a guy who likes to reinvent the wheel and who wants to know how things are done in a program and how I got to know how that code worked was to create an own project add the code from drew's project till it works and then I started deleting/modifing parts to understand what it does.
11/30/2011 11:33 pushedx#8
To get a better idea of what is going on, try referring to the C# code instead. It's more modern and up to date compared to the C++ stuff I had released a long time ago, not to mention it probably has more comments. For C++ stuff, you want to just look over all my posted articles and code here on epvp. They are pretty outdated now and if I were coding them again today, they'd look a lot different, but that's just what happens as you become more experienced.

C++ just isn't a good language to use to try and convey new ideas or specific implementations to learn from, so that's why it's impossible to follow the code. Even I have trouble following some of my older stuff, but it's more because of how you have to approach programming when using C++ compared to other languages. That's a main reason I moved on from doing a lot of coding in C++ in favor of C#.

Anyways, there's a lot of concepts you have to be aware of to understand SilkroadSecurity. Overtime, as you learn them, you learn better ways to implement the API, which is why I had so many different versions over the years and never really came up with a "final solution".

First, you need to understand the concepts of TCP programming, Specifically, TCP is a stream of data, not a packet protocol like UDP. This means you have to buffer all your input data and then process it as you go along rather than all at once when you receive it. This is a big hurdle for a lot of people and even today commercial games still improperly use TCP.

Second, you need to understand the DH Key Exchange. This is part of the first steps for the Silkroad security. This is one of the most complex parts of the security, so it might take some time to understand everything going on.

Third, you just have to understand the Silkroad specific algos that are implemented and referenced in the code. There's no short cut in understanding this as you'd really have to reverse engineer them from the clients again to know what they were doing and your implementation in C++ would look just about the same as the code I have. So you can't really understand what's going on other than what you see in the code unless you talked to someone from Joymax that designed the system.

I wrote an article a while ago talking about the security, but it has some bugs and errors (for example, all my 0x7FF should be 0x7FFF). This was the very first version of my SecurityAPI, but I never got around to updating it. It's still mostly useful to get an idea about stuff though. It's attached to this post. A lot has changed since then too; I'd not recommend using WinSock API but rather a network library like boost::asio. It just makes life easier in the long run. It's more stuff to learn and work with, but it's just part of the deal when you use C++.

Once you understand the whole Silkroad Security system, you then have full control over the packet streams and can do whatever you want. If you are not familiar with proxy concepts, you can write a simple proxy to get started that doesn't use the API, but it won't work for the AgentServer connection unless you come up with a method to detour the client and connect to the correct address yourself (what I did for that to get started was simple write to a text file.)

Everything else you pretty much learn and get familiar with the more time you spend with it. For example, a lot of the design of my C# code might not seem apparent until you go through everything and then "discover" why it's setup as it is. It certainly does take time and patience, but if you are committed to learning about this stuff, you'll get it all down in time.
12/01/2011 05:20 kibbles18#9
thanks pushedx,
the proxy is coming along well i read thro the .pdf and created a connection to the server "121.128.133.30" port 15779 and now am in the process of processing the packets recieved. im just wondering how you reversed the packet structure yourself, like what did u look for to find the blowfish, security CRC etc.?

[Only registered and activated users can see links. Click Here To Register...]
*first line of proxy.exe should say "proxy started" instead of "bot"