Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Dev]Golang login server

BloopBloop
Joined
Aug 9, 2012
Messages
892
Reaction score
275
incase of golang:

data[0] returns a byte. Then if you shift the bits lets say (data[0] <<8) (or more than 8) , you will Always get a value that is equal to "0" ( a byte does only have 8 bits)
Example:
lets say we have a byte with value "1 "

.........128 64 32 16 8 4 2 1
bits: ...0 ...0 ...0 ...0 0 0 0 1
now lets shift the bits 8 to the left, meaning that the 1 gets 8 positions to the left
result:
256 128 64 32 16 8 4 2 1
.....1.. 0.. 0... 0 ..0 0 0 0 0
However the byte does not have the "256" , so that bit will be "dropped", (Only the first 8 bits will be taken, who are all "0")
So you first need to cast the byte to a int and then shift the bits.

Here:
this function will return the correct length, what will be incase of:
[77 212 102 212] = 43
Code:
func GetHeaderLength(data []byte) uint16 {
    var num = ((int32(data[0])) | (int32(data[1]) << 8))|(int32(data[2]) << 16) |(int32(data[3]) << 24)
    return uint16((num >> 16) ^ (num & 0xFFFF))
}
 
Last edited:
Elite Diviner
Joined
Apr 7, 2008
Messages
494
Reaction score
66
incase of golang:

data[0] returns a byte. Then if you shift the bits lets say (data[0] <<8) (or more than 8) , you will Always get a value that is equal to "0" ( a byte does only have 8 bits)
Example:
lets say we have a byte with value "1 "

.........128 64 32 16 8 4 2 1
bits: ...0 ...0 ...0 ...0 0 0 0 1
now lets shift the bits 8 to the left, meaning that the 1 gets 8 positions to the left
result:
256 128 64 32 16 8 4 2 1
.....1.. 0.. 0... 0 ..0 0 0 0 0
However the byte does not have the "256" , so that bit will be "dropped", (Only the first 8 bits will be taken, who are all "0")
So you first need to cast the byte to a int and then shift the bits.

Here:
this function will return the correct length, what will be incase of:
[77 212 102 212] = 43
Code:
func GetHeaderLength(data []byte) uint16 {
    var num = ((int32(data[0])) | (int32(data[1]) << 8))|(int32(data[2]) << 16) |(int32(data[3]) << 24)
    return uint16((num >> 16) ^ (num & 0xFFFF))
}
@Hucaru

Code:
 func GetHeaderLength(pBuffer[]byte) int32 {
    var pLength int32 = int32(pBuffer[0]) | 
                        int32(pBuffer[1] << 8) |
                        int32(pBuffer[2] << 16) |
                        int32(pBuffer[3] << 24)
 return int32 (pLength >> 16) ^ (pLength & 0xFFFF)
 
Last edited:
BloopBloop
Joined
Aug 9, 2012
Messages
892
Reaction score
275
@Hucaru

Code:
func GetHeaderLength(pBuffer[]byte) int32 {
    var pLength int32 = int32(pBuffer[0]) | 
                        int32(pBuffer[1] << 8) |
                        int32(pBuffer[2] << 16) |
                        int32(pBuffer[3] << 24)
    return uint16 (pLength >> 16) ^ (pLength & 0xFFFF)

this should work :) cheers

you are a idiot.....

If you COPY the CODE IN MY POST and change the cast , make sure you do it correct, your code will cause for a compiler error. IT WILL ALSO GIVE THE WRONG LENGTH (if you "fix" it) (77 != 43)



EDIT: IDIOT 2.0

Even your edit is WRONG it will still return 77 ... while it should be 43.
@Hucaru

Code:
 func GetHeaderLength(pBuffer[]byte) int32 {
    var pLength int32 = int32(pBuffer[0]) | 
                        int32(pBuffer[1] << 8) |
                        int32(pBuffer[2] << 16) |
                        int32(pBuffer[3] << 24)
 return int32 (pLength >> 16) ^ (pLength & 0xFFFF)
 
Last edited:
Joined
Apr 10, 2008
Messages
4,087
Reaction score
1,264
you are a idiot.....

If you COPY the CODE IN MY POST and change the cast , make sure you do it correct, your code will cause for a compiler error. IT WILL ALSO GIVE THE WRONG LENGTH (if you "fix" it) (77 != 43)



EDIT: IDIOT 2.0

Even your edit is WRONG it will still return 77 ... while it should be 43.

Idiot 3.0:

ExtremeDevilz actually copied my code and turned into it a (wrongly syntaxed) Google go code.
 
Elite Diviner
Joined
Apr 7, 2008
Messages
494
Reaction score
66
Idiot 3.0:

ExtremeDevilz actually copied my code and turned into it a (wrongly syntaxed) Google go code.


I did not know that Diamondo25 actually copied your code and the syntax was cause it was a plain ported of MWLR

also Hilia

I dont see why I would copy your code for..

it is a modified of Hucaru

original code..
 
Everything is possible~
Loyal Member
Joined
Jan 9, 2008
Messages
818
Reaction score
847
The header code is from MapleShark actually. Thanks to Astaelan for that.
 
Newbie Spellweaver
Joined
Jan 23, 2010
Messages
17
Reaction score
6
Thanks for help guys.
Hilia I feel like such an idiot now! I need to read up more on bitwise operations as my knowledge is sketchy at best.

EDIT: Can confirm I am an idiot, after re-reading your post I feel really really stupid hahaha.

EDIT2: I applied the fix and have also fixed my RollLeft and RollRight functions as I was casting to types uint8 instead of int32, hence why I was getting the zeros in my earlier question of decrypting the shanda encryption. Now the login packet comes back with opcode 0x01 :)
 
Last edited:
Custom Title Activated
Loyal Member
Joined
Mar 14, 2010
Messages
5,363
Reaction score
1,343
This looks cool, btw

What's Golang?

I have noticed that v40b seems to have packet encryption? Are there any versions that do not have any? If so could someone please upload a localhost for that version? I want to get to grips with networking before I handle the encryption side of things since trying to learn too much all at once won't lead me anywhere. Preferably any version before 0.35 would be good.

My complete v28 and v40b are both in one src. o-o I don't see how there is a different packet encryption
 
Newbie Spellweaver
Joined
Jan 23, 2010
Messages
17
Reaction score
6
I was asking albeit very badly if there were any versions of the client that did not have any of the aes packet encryption, as I am new to network programming and don't want to bite off more than I can chew at this stage.

Golang - is a language developed by google.
 
Joined
Apr 10, 2008
Messages
4,087
Reaction score
1,264
I was asking albeit very badly if there were any versions of the client that did not have any of the aes packet encryption, as I am new to network programming and don't want to bite off more than I can chew at this stage.

Golang - is a language developed by google.

Sadly, not. I'm also not sure how complex it will be to remove it. You already got past the encryption, so you shouldn't worry about it. MapleStory Global's encryption is one of the easiest. Go figure out Indonesia/Korean's.
 
Custom Title Activated
Loyal Member
Joined
Mar 14, 2010
Messages
5,363
Reaction score
1,343
I was asking albeit very badly if there were any versions of the client that did not have any of the aes packet encryption, as I am new to network programming and don't want to bite off more than I can chew at this stage.

Golang - is a language developed by google.

V40b doesn't have the aes encryption along with v28 as you already know
 
Everything is possible~
Loyal Member
Joined
Jan 9, 2008
Messages
818
Reaction score
847
Sadly, not. I'm also not sure how complex it will be to remove it. You already got past the encryption, so you shouldn't worry about it. MapleStory Global's encryption is one of the easiest. Go figure out Indonesia/Korean's.

Removing the crypto in a localhost is just changing a jump not equal to a jump.
 
Newbie Spellweaver
Joined
Jan 23, 2010
Messages
17
Reaction score
6
V40b doesn't have the aes encryption along with v28 as you already know

Didn't realise that v40b had no aes ecryption. Thanks for letting me know. Once finished with this I might go back and make a 40b server as well.

Removing the crypto in a localhost is just changing a jump not equal to a jump.

Do you know of any good resources for learning asm/reverse engineering?
 
Everything is possible~
Loyal Member
Joined
Jan 9, 2008
Messages
818
Reaction score
847
Didn't realise that v40b had no aes ecryption. Thanks for letting me know. Once finished with this I might go back and make a 40b server as well.



Do you know of any good resources for learning asm/reverse engineering?

IA-86 ASM is pretty straightforward actually.
MOV A, B = Move B into A
JMP = Jump to address or offset
CMP = Compare values
CALL = Call function
 
Newbie Spellweaver
Joined
Jan 23, 2010
Messages
17
Reaction score
6
IA-86 ASM is pretty straightforward actually.
MOV A, B = Move B into A
JMP = Jump to address or offset
CMP = Compare values
CALL = Call function

How do you go about relating these to what the program is actually doing? Does it just come from experience and trial and error?
 
Custom Title Activated
Loyal Member
Joined
Mar 14, 2010
Messages
5,363
Reaction score
1,343
Didn't realise that v40b had no aes ecryption. Thanks for letting me know. Once finished with this I might go back and make a 40b server as well.



Do you know of any good resources for learning asm/reverse engineering?

1) There isn't much difference between v40b and v28 to be honest, some differences in packets/ obv bigger/more opcodes but in general it's similar. good luck!

I know it wasn't directed at me but :D
2) I'm sure you could probably find one on tuts4you
 
Newbie Spellweaver
Joined
Jan 23, 2010
Messages
17
Reaction score
6
1) There isn't much difference between v40b and v28 to be honest, some differences in packets/ obv bigger/more opcodes but in general it's similar. good luck!

I know it wasn't directed at me but :D
2) I'm sure you could probably find one on tuts4you

Cheers. Unfortunately I am out of the country for 5 days to a week and so will have to stop my work on the server until I get back. If anyone is interested I am keeping the codebase updated on github - . To be honest I am not happy with it as I am having trouble separating my game server logic with network code. So this will slow me down as I try resolve this.
 
Newbie Spellweaver
Joined
Oct 17, 2008
Messages
16
Reaction score
0
I am also trying to understand Shanda among other things. I will be updating my thread regularly with questions I have. I think this will be a good resource for you too Hucaru.
 
Newbie Spellweaver
Joined
Apr 22, 2009
Messages
62
Reaction score
54
It's nice to see someone developing a server emulator in Golang Hucaru !
I'm making one as well, so far I've managed to handle all of the loginserver logic plus some basic in-game stuff and wz xml map loading.

Kagami (the server emulator I'm developing):
My golang maplelib (contains tools for encryption and packets that you can reuse on your own server / tools):
 
Back
Top