I've noticed that sending packets to silkroad is not a thing only a few people can do. I'm interested in sending the sitting packet to the silkroad server with the help of nuconnector (using C#). How can this be achieved? I understand that the hard work is done by the nuconnector, but how to connect to it and how to send the packet?
Not experienced programmer, so a working code would be really appreciated.
Trying to learn this stuff, but I really don´t know how. Right now, I'm learning from TCP networking tutorials and C# ebooks.
Connect to the proxy via a tcp socket. Sniff the correct packet. Send the previously sniffed packet. Done.
Thank you for the answer, I'll look into that. Although connecting to the proxy is my main concern, there are no guides available, yet so many people here seem to know how to do it.
Thanks for the code. I partly understood it, I have to create TCP client in C# and connect it to the nuconnector with the right IP and PORT. How do you know the right ones?
Thirdly, you use a function TCPSend(mainsocket, data). How can I do this in C#? I think I have to get a stream, create a binarywriter and then send the data, how would it look like?
EDIT: Do I have to patch my client in order for this to work? And does nuconnector say something like bot connected, if you connect to it?
That's the point, everyone says: "Oh, it's easy, just connect to the nuconnector and send the packet." Could you provide a working example please?
It might be easy for an experienced programmer, but it's quite complicated for a beginner.
I never used C# so I can't really give you an example
I looked something up, though:
Code:
TcpClient tcpClient = new TcpClient ();
tcpClient.Connect ("127.0.0.1", 22580);
Not sure if it really is what you're looking for, but it really looks like it
Quote:
Thanks for the code. I partly understood it, I have to create TCP client in C# and connect it to the nuconnector with the right IP and PORT. How do you know the right ones?
IP is the localhost(because it's running on your PC) and Port is 22580
That's just a random port the creator of nuconnector used
Oh and remote connections don't work(I think; I remember it listening on localhost only; not sure though)
Quote:
EDIT: Do I have to patch my client in order for this to work? And does nuconnector say something like bot connected, if you connect to it?
Yes you have to.
The client has to connect to localhost as well(port is the original one, Joymax uses)
And yes nuconnector notifies you when you connect to it
It waits for the bot to connect and then for the client
I never used C# so I can't really give you an example
I looked something up, though:
Code:
TcpClient tcpClient = new TcpClient ();
tcpClient.Connect ("127.0.0.1", 22580);
Used the exact same thing in my code. But didn't really progress before, because the nuconnector didn't say anything and I don't have the knowledge send anything.
EDIT: Phconnector (now nuconnector too) says, that I'm connected to the proxy(used the same method), now, how to send the packet?
EDIT2: Now I got a code like this, but it's not working:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;
namespace Connecting_to_nuconnector
{
class Program
{
/*Found it on MSDN: http://msdn.microsoft.com/en-us/library/ms145128.aspx needed for socket.beginconnect*/
public static void ConnectCallback1(IAsyncResult ar)
{
allDone.Set();
Socket socketclient = (Socket)ar.AsyncState;
socketclient.EndConnect(ar);
}
public static ManualResetEvent allDone = new ManualResetEvent(false);
static void Main(string[] args)
{
//Create the array to get the size of the data
byte[] array = new byte[200];
BinaryWriter bw = new BinaryWriter(new MemoryStream(array));
bw.Write((byte)0x04);
ushort size = (ushort)array.Length;
bw.Close();
//Create second array to send
byte[] array2 = new byte[200];
BinaryWriter bw2 = new BinaryWriter(new MemoryStream(array2));
bw2.Write((ushort)size); /size
bw2.Write((ushort)0x704F); /opcode
bw2.Write((ushort)0x0100); /direction
bw2.Write((ushort)0x04); /data
bw2.Close();
//Create a socket
Socket socketclient = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
IPAddress ipAddress = IPAddress.Parse("127.0.0.1");
IPEndPoint remoteEP = new IPEndPoint(ipAddress, 22580);
socketclient.BeginConnect("127.0.0.1", 22580, new AsyncCallback(ConnectCallback1), socketclient);
allDone.WaitOne();
while (true)
{
socketclient.Send(array2);
Console.WriteLine("Array sent");
Console.ReadLine();
}
}
}
}
EDIT3: qkuh fixed it for me. EDIT4: Sit part still not working.
you should post your final source. so we can see how its done
Don't worry, I will post it here(want others to learn from this thread as well), but still working on that with qkuh (he said he'll show me mistakes, but coded almost everything ). He made me a code which receives packets from the server, and if you press enter, it exits. It works without the media patcher and it can be launched during the game, as long as proxy is connected.
The problem right now is, that the sit packet isn't working(which was the whole point of this thread). When he can, he'll show me what's wrong with my code. Does anyone else know what's wrong? Wanted to make it as simple as possible to understand sending a sit packet, but I think here is some unnecessary parts that I plan to remove, so that other beginners can understand.
Doesn't make the character sit, so any help on sending the sitting packet still appreciated!
As of now, the code is:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading; /*Some librarys probably not needed, gonna remove them*/
namespace Sending_a_packet
{
class Program
{
private static ManualResetEvent connectDone = new ManualResetEvent(false);
private static Socket socketclient = null;
/*Found it on MSDN: http://msdn.microsoft.com/en-us/library/ms145128.aspx needed for socket.beginconnect*/
public static void ConnectCallback(IAsyncResult ar)
{
connectDone.Set();
Socket socketclient = (Socket)ar.AsyncState;
if (socketclient.Connected)
{
Console.WriteLine("Connected");
//Create the array to get the size of the data
byte[] array = new byte[200];
BinaryWriter bw = new BinaryWriter(new MemoryStream(array));
bw.Write((byte)0x04);
ushort size = (ushort)bw.BaseStream.Position;
bw.Close();
//Create second array to send
byte[] array2 = new byte[200];
BinaryWriter bw2 = new BinaryWriter(new MemoryStream(array2));
bw2.Write((ushort)size); //size
bw2.Write((ushort)0x704F); //opcode
bw2.Write((ushort)0x0100); //direction
bw2.Write((ushort)0x04); //data
int position = (int)bw2.BaseStream.Position;
bw2.Close();
socketclient.Send(array2, position - 2, 0);
Console.WriteLine("SENT");
Receive();
}
else
{
Console.WriteLine("Cannot connect");
}
socketclient.EndConnect(ar);
}
static void Main(string[] args)
{
//Create a socket
socketclient = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
socketclient.BeginConnect("127.0.0.1", 23580, new AsyncCallback(ConnectCallback), socketclient);
connectDone.WaitOne();
Console.WriteLine("Press enter again");
Console.ReadLine();
}
static void Receive()
{
StateObject obj = new StateObject();
obj.workSocket = socketclient;
socketclient.BeginReceive(obj.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(ReceiveCallback), obj);
}
static void ReceiveCallback(IAsyncResult ar)
{
StateObject obj = (StateObject)ar.AsyncState;
socketclient = obj.workSocket;
int bytesRead = socketclient.EndReceive(ar);
if(bytesRead > 0)
{
Console.WriteLine(bytesRead + " bytes received!");
String hexString = BitConverter.ToString(obj.buffer, 0, bytesRead).Replace("-", "");
Console.WriteLine("[PACKET] " + hexString);
}
socketclient.BeginReceive(obj.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(ReceiveCallback), obj);
}
}
public class StateObject
{
// Client socket.
public Socket workSocket = null;
// Size of receive buffer.
public const int BufferSize = 256;
// Receive buffer.
public byte[] buffer = new byte[BufferSize];
// Received data string.
public StringBuilder sb = new StringBuilder();
}
}
Probably going post what I learned in the first post once I get it working and understand it. EDIT: The mistake was in the direction byte, it has to be 0x0001, not 0x0100!! Left the mistake in so you can see it.
You casted it as ushort, but it has to be a byte
This shouldn't affect anything, though
This part of the code is useless:
Code:
//Create the array to get the size of the data
byte[] array = new byte[200];
BinaryWriter bw = new BinaryWriter(new MemoryStream(array));
bw.Write((byte)0x04);
ushort size = (ushort)bw.BaseStream.Position;
bw.Close();
You can make the size static(works for your example program)
In case you need a dynamic one some time, you should make your own class for Packets
In there you would modify the size every time you add something(seek to the beginning and overwrite the size, or keep it in a variable and write it in your array when you send the packet)
I would make it this way:
Code:
public static void ConnectCallback(IAsyncResult ar)
{
connectDone.Set();
Socket socketclient = (Socket)ar.AsyncState;
if (socketclient.Connected)
{
Console.WriteLine("Connected");
//Changed the size to the one you really need. Be sure to increase it, if you use bigger packets
byte[] array2 = new byte[7];
BinaryWriter bw2 = new BinaryWriter(new MemoryStream(array2));
//making it static is so much easier right now
bw2.Write((ushort)1); //size
bw2.Write((ushort)0x704F); //opcode
bw2.Write((ushort)0x0100); //direction
bw2.Write((byte)0x04); //data
//I'm assuming that BinaryWriter.BaseStream.Position is zero based, I'm not sure, though, because I can't find shit about it on the MSDN page(It only says that it's possible to get the position from it, but not if it's zero based or not)
int position = (int)bw2.BaseStream.Position;
bw2.Close();
socketclient.Send(array2, position, 0);
Console.WriteLine("SENT");
Receive();
}
else
{
Console.WriteLine("Cannot connect");
}
socketclient.EndConnect(ar);
}
GUIDE:HOW TO SEND A PACKET WITH THE HELP OF PHCONNECTOR AND EDXLOADER
In order to make a packet sender to work, we need to send the connection through a proxy, which will take care of the encryption and decryption of the packets(the security basically, except the hackshield, that’s why you can’t use it on isro). And in order to make the proxy work, we need to use a loader(edx loader in the example) which will redirect all the traffic through the proxy.
*This is an example, we will cover setting the ports and selecting the server you like.
To send a packet to silkroad server with phconnector/nuconnector(going to use phconnector in examples, but there shouldn't be any difference), we need to set the configuration files of the phconnector, so it knows where the data is coming from and where to send it to.
To do that we need to know the IP address and PORT of the server. To get the IP and the PORT, we need to open up edxLoader and add the sro_client to it. After that the edxloader should display the IP address and the port of the server. While the edxloader is still open go ahead and tick “Multiclient” and “Redirect Gateway Server” and set the port to 18000(will cover why we did this). Our edxLoader should look something like this now:
Open up the phconnector configuration file and you should see something like this:
Place your private server's (silkroad europe private server in my example) IP address and port into the config file. You may also enter a host name, or convert the host name into an ip address(google: convert host name into IP address).
Now we need to tell the phconnector, which port the exloader will redirect all the traffic, so the phconnector can listen and accept all the packets. For that we use ListenPort. You can set it to your liking as longs as you have set the edxloader to redirect the traffic to the same port.
Next, we need to set the port that the phconnector will listen and accept a bot connection(and later exchange data). For that we need to configure the BotPort. You can also set it to your liking, because this will be the port that the bot has to connect to, and when you code your own bot, you can tell it which port it needs to connect to. Finally our example configuration file should look like this:
Note: Bot->phconnector and Client(loader)->phconnector communication is done through localhost (127.0.0.1), and that's the reason, why we only set the ip for the private server and not for the bot and edxloader.
Next, we need to understand the basics of Socket programming and sro packet structure. A packet is an array of bytes, which in the case of sro consists of:
size(of the data only) (2bytes)
opcode (2bytes)
direction(some say security byte) (2bytes)
data (x bytes)
And you'll have to place those bytes in the array accordingly: size->opcode->direction->data.
For example, the sit packet:
size 00 01 (because the data is 04)
opcode 70 4f
direction 00 01 (0001 represents client to server (c->s) unencrypted(you can send encrypted packets too)*)
data 04
Which in byte array looks like 00 01 70 4f 00 01 04 . That is what we are going to send to the phconnector. Once we send it, phconnector encrypts it, sends to the server, and makes our character sit.
*Note: Security byte can be either 1,2,3 or 4, but most of the time, you want to use 1.
0x0001 Unencrypted to the Server
0x0002 Unencrypted to the Client
0x0003 Encrypted to the Server
0x0004 Encrypted to the Client
To send the array you need to establish a connection to the phconnector through the localhost and port(which in this example is set to 23580). Then use the Socket.Send method to send the packet. I can't explain any further, because this is the limit of my knowledge. To fully understand this you need to examine the source code provided by qkuh (2 posts up) and become familiar with socket programming.
GOOD ARTICLES ABOUT ASYNCHRONOUS SOCKET CONNECTION:
If you want to know how to sniff the packets, let me know(hint: it can be done with phAnalyzer). Report my mistakes too, please.
c# sending packet 11/22/2011 - .NET Languages - 0 Replies i enter an online flash game from my app webbrowser tho i cant find out how to send packets trougth it :S.
i managed to send packets trought WPE PRO tho i want to code it into my proggy.
i dont think i need to hook my own app am i?
Need help sending a packet ! 02/28/2010 - Kal Online - 1 Replies i've got a Question and i hope some1 can help me
there is an item at a NPC that u can buy 1 only each time .. and i need to buy 1000000 of it
so i need to send the packet to buy this item 1000000 times
when i try to sniff the packet to buy this item i got :
Packet type : 0x18
format : m
arguments : (unknown character)
so ... how can i send that (unknown character) as an argument ??
in the code that (unknown character) is displayed from "(DWORD)va_arg(args,DWORD)"
when i tried to save...
sending packet at WPe 07/18/2008 - Dekaron - 10 Replies after sending some packet at WPE my connection to 2moons always got disconnect the moment I send the packet
can someone help me regargding this
packet sending 03/31/2008 - RF Online - 4 Replies now i know how to bypass rf online and now i can run WPE PRO w/o getting detected by fireguard.any1 can help me w/ this packet sniffing?coz i get confused on what packet to capture and send to the server.thanks
sending a packet 11/26/2007 - Conquer Online 2 - 3 Replies I've captured a packet that I'd like to re-send to do a specific function, but I don't know how to do that. I know it involves 4 encryption keys and a packet id number. My best guess is to send the packet to a proxy that hopefully will forward it to the server properly. Anyone want to offer some tips on what to use?