bot connection/packets

11/26/2011 00:14 kibbles18#1
i'm tryin to send a packet to sro to make my character sit, and its not working.
i know that the packet is sent when i moniter it with a packet sniffer but sro dosen't do anything with it.
Code:
#define silk_IP "121.128.133.59" //64
#define silk_PORT 15779
Code:
	char buffer[256];
	/*-------------------some first shit nonsense---------*/
	WSADATA wsaData;
	if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
	fprintf(stderr, "WSAStartup fail");
	exit(1);
	}
	/*----------------------now the bot--------------------*/
	SOCKET nuconnector;	
	struct sockaddr_in silkroad;
	nuconnector = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);  //making the socket  //maybe raw
	if (nuconnector < 0)
	{
		timestamp();
		printf("cannot establish connection socket creation error");
		cin.get();
		return nuconnector;
	}
	else
	{
		timestamp();
		printf("socket created");
	}
	silkroad.sin_family = AF_INET;
	silkroad.sin_port = htons (silk_PORT);
	silkroad.sin_addr.s_addr = inet_addr(silk_IP);
	memset(silkroad.sin_zero, '\0', sizeof(silkroad.sin_zero));
	int chk = connect(nuconnector,(struct sockaddr *)&silkroad,sizeof silkroad);
	if(chk == -1)
	{
		timestamp();
		printf("connection fail");
		cin.get();
		return chk;
	}
	timestamp();
	printf("connection successful");
	ZeroMemory(buffer, 256);
	strcpy(buffer, "01 00 4F 70 F9 89 04");
	send(nuconnector, buffer, strlen(buffer), 0);
	timestamp();
	printf("test packet sent");
11/26/2011 03:12 theoneofgod#2
Sit opcode is 704F (for vSRO110 based servers)
You should only send byte "0x04" to sit.
11/26/2011 11:34 Schickl#3
You're sending it as a String
01 00 4F 70 F9 89 04 this are byte values in hex

Code:
BYTE pack[7] = {
    0x01, 0x00,  //packet length
    0x4F, 0x70,  //opcode
    0x20, 0x00,  //I didn't use nuconnector for quite some time now so make sure that this is the right direction to send it to
    0x04    //Packet data
};

send(nuconnector, pack, sizeof(pack), 0);
If the opcode you wrote is right and I used the right direction(else just replace the 2 bytes) it should work with the code i wrote above

Note: NEVER send the packets as a string(char array).
The only time you'll see strings in packets is when text is sent.
everything else are raw values(meaning that when you e.g. want to send an int value you really need to send the bytes of an int variable)

Oh and BYTE is defined as unsigned char

EDIT: Looks like you don't use nuconnector
You must connect to it and not to the Silkroad server(IP isn't even right i guess)
If you want to write a program that is similar to nuconnector you'll need some more time
Security Bytes aren't static as far as i know and packets are encrypted(you won't be able to decrypt it w/o knowing the blowfish key)

It's best you just use nuconnector or srproxy
11/27/2011 20:36 kibbles18#4
FIXED
close please
11/28/2011 08:32 Nezekan#5
Here it's seen as a part of the 'ettiquete' that you actually thank peoples post if they helped you. If nobody helped you in this thread, then please share your solution. If everybody would keep things to themselves there wouldn't be a point in having this forum, would it?
11/29/2011 03:07 kibbles18#6
solution: connecting to nuconnector port rather then sro (22581) at localhost
06/25/2012 22:19 dragonsword1#7
can u send me the cpp file plz ?? coz i made kinda the same code and it doesnt work and when i use the pack BYTE array thing it tells me cant convert from byte to unsinged char*