[VB.NET]Use OPCODES

07/26/2011 16:49 lordfeling#1
Hi all :D,

Im a amateur in VB.NET, and I never programmed a tool for Silkroad except a Spammer.
Today, I would like to introduce me to OpCode, in order to make small programs.

But the problem is that I do not know how to write code in VB.NET, for send to server opcodes, how this happens.

So, I've already use edxSilkroadLoader5 for capture OPCODES in game :
Code:
[S -> C][B0BD]
C9 E 04 00
61 05 00 00
67 5F 02 00

This is the code for a Skill fire. So this is 0xB0BD ?
But, I don't know how to use this information in VB.NET for send to the server the Packet.

So, i want to know if anybody can help me to learn how to use OPCODES in Silkroad with VB.NET ?

Thanks :)
07/26/2011 17:28 kevin_owner#2
I'm not int the whole .net world but you need to use a socket to connect to the server. And you could use the binairywriter to build the whole packet. Take a look at some open source emulator projects like csremu or srevolution. It has a packet writer in it and you might want to use that one. It's C# but you can convert C#.net to vb.net.

But yeah the opcode of that packet is 0xB0BD and the data is 3 integers. It's quite a lot to explain in one post so mabye you could try some things and tell me the parts which are unclear. Btw it would also be helpfull to have some basic understanding of the tcp/ip thing.
07/26/2011 21:18 sarkoplata#3
This pakcet is taken by server and sending it may result in dc and wont have effect.
You should capture packets which are Client to Server. [C -> S]
Capture the sit-stand up packet and post it here , i will help about it.
07/26/2011 22:26 lordfeling#4
Quote:
Originally Posted by sarkoplata View Post
This pakcet is taken by server and sending it may result in dc and wont have effect.
You should capture packets which are Client to Server. [C -> S]
Capture the sit-stand up packet and post it here , i will help about it.
Hi, thanks for you responce.

I've captured somes packet :

Code:
Sit-stand up :
[C -> S][704F]
04
Code:
pick gold :
[C -> S][7074]
01                                                
02                                                
01                                                
6E 05 1A 00

I never programmed a tool with packet.
That why I require help for learn how to use Packet.

Thanks.
07/27/2011 17:35 sarkoplata#5
Quote:
Originally Posted by lordfeling View Post
Hi, thanks for you responce.

I've captured somes packet :

Code:
Sit-stand up :
[C -> S][704F]
04
Code:
pick gold :
[C -> S][7074]
01                                                
02                                                
01                                                
6E 05 1A 00

I never programmed a tool with packet.
That why I require help for learn how to use Packet.

Thanks.
Ok, First of all we should import our class.
Just write the top of the class :

PHP Code:
Imports System.Net.Sockets 
Now we are able to use system.net.sockets class.

Lets declare our socket :

PHP Code:
    Public Client As Socket = New Socket(AddressFamily.InterNetworkSocketType.StreamProtocolType.Tcp
Now , we are should connect to our proxy to inject packets.
You can basicly use phConnector for this.
(And you will redirect your ip to 127.0.0.1 : 15778 from loader. )

Lets connect our socket :

PHP Code:
Client.Connect("localhost"xyour phConnector botport 
Now we connected to proxy and we can send packets.
Packets are in raw form at fact , but we convert em to easier structure.

Client.Send("x") will send raw packets.
So we should make our packet raw at first.
Here is my func. to do that. This func. is written by xKraizy.

PHP Code:
Public Sub SendPacket(ByVal OpCode As StringByVal sData As StringByVal Enc As Boolean)
        
Using buffer As New IO.MemoryStream
            Using w 
As New IO.BinaryWriter(buffer)
                
w.Write(CUShort(0))
                
w.Write(CUShort("&H" OpCode))
                If 
Enc True Then
                    w
.Write(CUShort(3))
                Else
                    
w.Write(CUShort(1))
                
End If
                For 
0 To sData.Length 1
                    w
.Write(CByte("&H" sData.Substring(22)))
                
Next

                w
.BaseStream.Position 0
                w
.Write(CUShort(w.BaseStream.Length 6))
                
w.Flush()
                
Client.Send(buffer.ToArray)
            
End Using
        End Using
    End Sub 
You can call this function anywhere you want now.
For example , add client connecting thingy to form_load , and add a button and write this.

PHP Code:
SendPacket("704F","04",False
First parameter is your opcode
Second parameter is your packet data
Third packet is a boolean , if you make it True , you will be able to send encrypted packets.(They are a bit intermediate part.)

And about gold packet ;

I dont really remember but every byte in packet has a meaning.

PHP Code:
[-> S][7074// Opcode
01 // Some Flag                                               
02 // Some Flag                                                      
01 // Some Flag                                                      
6E 05 1A 00  // UniqueID of gold. 
Have fun and ask when you needed !
sarkolata
07/27/2011 18:07 lordfeling#6
Thanks fot you responce.
I will try to do what you posted, but im not sure to understand all.

And im looking for phconnector, but impossible to find it (for download it).

EDIT : I've downloaded phConnector.
10/11/2011 11:32 thegfx3r#7
How could i send a notice using this method.

[C->S] [3026]
0702004869

[C->S] [3026]
48690D0A

I believe the above is the notice info.
10/13/2011 15:29 s2k#8
notice is Server -> Client. not sure about the opcode
10/13/2011 16:14 Kraizy​#9
Quote:
Originally Posted by thegfx3r View Post
How could i send a notice using this method.

[C->S] [3026]
0702004869

[C->S] [3026]
48690D0A

I believe the above is the notice info.
Code:
3026 - Notice (Server -> Client)

3026 //Opcode
02 //Message-Length
68-69 //message: hi
02 //server -> client
10/13/2011 16:45 lesderid#10
Quote:
Originally Posted by xKraizy View Post
Code:
3026 - Notice (Server -> Client)

3026 //Opcode
02 //Message-Length
68-69 //message: hi
02 //server -> client
I'm afraid that's wrong.
This is what I have:

PHP Code:
var packet = new Packet(0x3026);

packet.WriteByte(7); //Chat type
packet.WriteString(valuenoticeutf16true); 
10/13/2011 19:36 Kraizy​#11
@lesderid it worked with my old project..
10/13/2011 20:49 lesderid#12
Quote:
Originally Posted by xKraizy View Post
@lesderid it worked with my old project..
That's strange.
10/14/2011 14:58 Kraizy​#13
Quote:
Originally Posted by lesderid View Post
That's strange.
Maybe there is not only one way to do something like that :)
10/14/2011 16:58 lesderid#14
Quote:
Originally Posted by xKraizy View Post
Maybe there is not only one way to do something like that :)
I doubt that's the case.
Maybe you were just using another version of SRO or something, but this is really what I've been using in my code since ages ago.
10/14/2011 20:46 Schickl#15
Kraizy's packet structure is indeed wrong
Code:
///Chatpacket

1100
2630
0200
05
0400
53657374
0400
5300650073007400

for Type 0x02, 0x04, 0x05 and 0x06:
# of Bytes | Description
-----------|------------------------
2	   | Size of the Data in byte
2	   | Opcode
2	   | Direction 0200 = to client and 0100 = to server
1	   | Type of the Message
2	   | Size of the Name
--	   | As specified before
2	   | Length of the Message. Counting every UNICODE char(2 bytes = 1 char)
--	   | As specified before(UNICODE!!!)
This isn't the exact structure for the notice, but the only thing that is removed is the length of the name and the name
Everything else should be the same
Oh and don't try to use it at normal chat(just sayin')

Security bytes have been replaced in there, because i was using it with nuconnector
[ADDED]
damn
I'd like to read that code, but vb has such a fucked up syntax^^
a/w
Isn't the notice in Unicode?(Didn't try it out for a loooong time)
So phconnector just wants you to specify the opcode at the beginning of the packet and the direction at the end?
Personally I don't like that. It requires you to modify the original packet structure and so you won't be able to use it with other tools easily(and it also makes it quite hard to read imo)
Well, whatever
Just felt like saying it^^

oh I should've added what the message types mean 0x02 = PM, 0x04 = guild, 0x05 = union and 0x06 = academy
The other Types I didn't document:
0x01 = normal chat(Object ID required)
0x03 = should be party(Object ID again?!)
0x07 = notice

edit: well, lol, seems like he deleted his post so most of the things i said are non-sense