Hi all, Is there a command to send and receive TCP messages

Discuss, ask for help, share ideas, give suggestions, read tutorials, and tell us about bugs you have found with MicroMacro in here.

Do not post RoM-Bot stuff here. There is a subforum for that.
Forum rules
This is a sub-forum for things specific to MicroMacro.

This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
Message
Author
runner01
Posts: 11
Joined: Wed Mar 21, 2012 10:43 pm

Hi all, Is there a command to send and receive TCP messages

#1 Post by runner01 » Wed Mar 21, 2012 10:58 pm

Hi, all.

First of all, I would like to say hi. I'm new to the forum. I am also very new to Lua based scripting. Now that with the introductions done, here's my question. I used another macro program which is not Lua based. The code is as follows:

Code: Select all

 Begin
     // Set this to the IP of the client where the bot is running
     Variable.Set("BotIP1", "10.0.0.7")
     Variable.Set("BotIP2", "10.0.0.8")
     Function.Execute("loop")
 end

function("loop")
     begin loop("")
          Keyboard.Wait for one of the following keys to be pressed("{<F9>}{<F10>}", "Command")
          Function.Execute("{Command}")
     end
function

function("{<f9>}")
     begin
          Variable.Evaluate (Text)("DNGEnter","Command")
          Network.Send message (TCP)("{BotIP1}", "{Command}")
          Network.Send message (TCP)("{BotIP2}", "{Command}")
     end
function

function("{<f10>}")
     begin
          Variable.Evaluate (Text)("DNGExit","Command")
          Network.Send message (TCP)("{BotIP1}", "{Command}")
          Network.Send message (TCP)("{BotIP2}", "{Command}")
     end
function

What it was doing is, when I press F9 on the main PC, it sends a TCP message to my botting PC telling it to Enter a Dungeon. And when F10 is pressed, it tells it to exit. So my question is, does MicroMacro has a similar function? Something to send TCP command and receive TCP commands?

Regards,
-Runner

User avatar
MiesterMan
Posts: 543
Joined: Tue Jul 06, 2010 9:15 pm
Location: Between the Second and Third Circles of Hell

Re: Hi all, Is there a command to send and receive TCP messa

#2 Post by MiesterMan » Thu Mar 22, 2012 7:22 am

If you are using this for runes of magic I believe there are a lot of work arounds for this already. I know MM has some network functionality but I've never worked with it myself.

This is the link to the "Network Functions" section of the micromacro manual, if it helps:
http://www.solarstrike.net/wiki/index.p ... _Functions

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Hi all, Is there a command to send and receive TCP messa

#3 Post by Administrator » Thu Mar 22, 2012 10:51 am

Additionally, you may use an addon like LuaSocket if you want to send and receive raw TCP/UDP packets. MicroMacro's built-in networking takes care of a lot of fuss for you such as (de-)serialization and encryption.

runner01
Posts: 11
Joined: Wed Mar 21, 2012 10:43 pm

Re: Hi all, Is there a command to send and receive TCP messa

#4 Post by runner01 » Thu Mar 22, 2012 11:51 am

First of all, I would like to thank you on the expedient respond. Actually, I myself and a partner are trying to "rebuild" a couple of bots we have created for a game called Eden Eternal. The original scripting was done using a different tool, sadly that tool is being detected by the game. So we are migrating over to a Luabased script. But thanks for the input. I'll look into the examples provided.

Regards,
Runner

User avatar
MiesterMan
Posts: 543
Joined: Tue Jul 06, 2010 9:15 pm
Location: Between the Second and Third Circles of Hell

Re: Hi all, Is there a command to send and receive TCP messa

#5 Post by MiesterMan » Thu Mar 22, 2012 5:34 pm

Always looking for new games to play. What exactly changed about the game? Is it free to play? Did they add some crapshield like gameguard or punkbuster to go with it?

And what language was the script in? Autoit scripts can almost directly be converted into lua to work with micromacro without all the addon setup.

runner01
Posts: 11
Joined: Wed Mar 21, 2012 10:43 pm

Re: Hi all, Is there a command to send and receive TCP messa

#6 Post by runner01 » Fri Mar 23, 2012 1:41 am

The game is f2p, their protection is like strap. But done server side. The tool we used was Blue eye macro. The virtual driver is being detected.

runner01
Posts: 11
Joined: Wed Mar 21, 2012 10:43 pm

Re: Hi all, Is there a command to send and receive TCP messa

#7 Post by runner01 » Tue Mar 27, 2012 12:22 pm

another quick question, what is the default tcp port that micromacro uses?

User avatar
MiesterMan
Posts: 543
Joined: Tue Jul 06, 2010 9:15 pm
Location: Between the Second and Third Circles of Hell

Re: Hi all, Is there a command to send and receive TCP messa

#8 Post by MiesterMan » Tue Mar 27, 2012 12:54 pm

Sorry, forgot about this thread. So I downloaded the game, a couple of times. After I finally got the install to go through it won't go past the loading screen. I tried turning down all settings but it had the same result.

Afraid I won't be able to help with this.

runner01
Posts: 11
Joined: Wed Mar 21, 2012 10:43 pm

Re: Hi all, Is there a command to send and receive TCP messa

#9 Post by runner01 » Wed Mar 28, 2012 4:45 am

Yeah they are picky about their video drivers/cards.

runner01
Posts: 11
Joined: Wed Mar 21, 2012 10:43 pm

Re: Hi all, Is there a command to send and receive TCP messa

#10 Post by runner01 » Wed Mar 28, 2012 4:51 am

ok maybe another question about writing to memory.
I'm trying to write these 2 chunks into memory:
the below is the code: But the game crashes... On the memory editor, everything is fine.
What am I doing wrong?

Code: Select all

addHPPoke = 0x0070BE0F;
dataHPPoke = {0xE9, 0xFB, 0x3F, 0x6, 0x00, 0x90};

addHP = 0x00DEFE0F;
dataHP = {0x8B, 0x58, 0x04, 0x89, 0x1D, 0x10, 0xEF, 0xDD, 0x00, 0x8B, 0x58, 0x4C, 0x89, 0x1D, 0x14, 0xEF, 0xDD, 0x00, 0x8B, 0x58, 0x08, 0x89, 0x1D, 0x18, 0xEF, 0xDD, 0x00, 0x8B, 0x58, 0x50, 0x89, 0x1D, 0x1C, 0xEF, 0xDD, 0x00, 0xEB, 0xDA, 0xE9, 0xDA, 0xBF, 0x91, 0xFF};

function memoryWriteCC(proc, address, msg)
local l_msg_len = table.getn(msg);
local l_char = nil;
for i=1, (l_msg_len) do
-- l_char = msg:byte(i)
printf("address: %x; value: %s\n", address + i - 1, msg[i]);
memoryWriteByte(proc, address + i - 1, msg[i])
end
-- memoryWriteByte(proc, address + l_msg_len, 0)
end

Code: Select all

memoryWriteCC(processName, addHPPoke, dataHPPoke);
memoryWriteCC(processName, addHP, dataHP);
Attachments
Memory chunk.png

User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: Hi all, Is there a command to send and receive TCP messa

#11 Post by botje » Wed Mar 28, 2012 9:57 am

MiesterMan wrote:Always looking for new games to play. What exactly changed about the game? Is it free to play? Did they add some crapshield like gameguard or punkbuster to go with it?

And what language was the script in? Autoit scripts can almost directly be converted into lua to work with micromacro without all the addon setup.
your welcome to help with my AION bot anytime man :P

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Hi all, Is there a command to send and receive TCP messa

#12 Post by Administrator » Wed Mar 28, 2012 1:30 pm

runner01 wrote:another quick question, what is the default tcp port that micromacro uses?
You should set the port with netOpenCon. The first argument should look like "0.0.0.0:1234".

vIndie
Posts: 9
Joined: Thu Mar 29, 2012 12:35 am

Re: Hi all, Is there a command to send and receive TCP messa

#13 Post by vIndie » Fri Mar 30, 2012 3:03 pm

So I'm trying to create a client/server with MicroMacro but I'm not getting a connection. I've disable windows Firewall so I don't believe that is the problem. The netserver says waiting for connection and the netclient says attempting connection..

Here is the network server code:

Code: Select all

CNetworkServer = class(
	function (self)
		netPushKey("encryptionKey", "12345");
	end
);

function CNetworkServer:start()
	listen = netOpenCon("0.0.0.0", "default");
	
	if( netListen(listen) ~= 0 ) then
	  printf("Error making connection.\n");
	end	
	
	print("Waiting for a client...");
	 
	-- Lets wait until a client joins our server.
	netcon = netPollListen(listen);
	while(netcon == nil) do
	print("Waiting for a client...");
	  netcon = netPollListen(listen);
	  rest(100);
	end
	
	while(netPollMessages(netcon)) do
		-- remember, in our example, we sent: 12, "Hello my name is John Doe."
		local message = netGetMessage(netcon);
		local messId = message[1];

		printf("Received message: %s\n", messId);

		if (messId == 1) then
			--enterDNG();
		elseif (messId == 2) then
			--exitDNG();
		end	
	end
end

function netStart()
	netServer = CNetworkServer();
	if (netServer) then
		netServer:start();
	end
end

startMacro(netStart);
and here is the network client code:

Code: Select all

CNetworkClient = class(
	function (self)
		netPushKey("encryptionKey", "12345");
	end
);
	
function CNetworkClient:connect(ip)

	netcon = netOpenCon("encryptionKey");
	if( netConnect(netcon, ip) == 0 ) then
		print("Attempting connection...");

		-- We wait until our connection status is either an error, or a successful connection
		status = netConnectStatus(netcon);
		while( status == 0 ) do
			status = netConnectStatus(netcon);
		end
		if( status > 0 )then
			print("Connection success!");
			return true;
		else
			print("Connection failed!");
			return false;
		end
	else
		print("Error initializing connection.");
		return false;
	end

end

function CNetworkClient:sendNetMessage(messId)
    if (netcon ~= nil) then
      printf("Message (%i) sent to %s: %b\n", messID, ip, (netSendMessage(netcon, messId) == 0));
    end
end


function EnterDNG()
  sendNetMessage(1);
end

function ExitDNG()
  sendNetMessage(2);
end

function main()
	client = CNetworkClient();
	client:connect("128.0.0.1:62751");
	EnterDNG();
end

startMacro(main);


User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Hi all, Is there a command to send and receive TCP messa

#14 Post by Administrator » Fri Mar 30, 2012 3:41 pm

client:connect("128.0.0.1:62751");
I think that's your problem there. I think you meant 127.0.0.1. You should also specify the listen port in the server so you can be sure that you are attempting to connect to the right port.

vIndie
Posts: 9
Joined: Thu Mar 29, 2012 12:35 am

Re: Hi all, Is there a command to send and receive TCP messa

#15 Post by vIndie » Fri Mar 30, 2012 3:45 pm

Administrator wrote:
client:connect("128.0.0.1:62751");
I think that's your problem there. I think you meant 127.0.0.1. You should also specify the listen port in the server so you can be sure that you are attempting to connect to the right port.
Thanks, that was a quick typo because I didnt want to paste my actual IP address. for the server it would just be 0.0.0.0:62751?

Would it be possible to use LuaSocket with MicroMacro?

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Hi all, Is there a command to send and receive TCP messa

#16 Post by Administrator » Fri Mar 30, 2012 3:46 pm

Yes, that looks right, and yes, you can use LuaSocket. Just put the main LuaSocket DLL in the plugins directory while any other dependencies (if available) will be placed in the MicroMacro root directory.

vIndie
Posts: 9
Joined: Thu Mar 29, 2012 12:35 am

Re: Hi all, Is there a command to send and receive TCP messa

#17 Post by vIndie » Fri Mar 30, 2012 3:51 pm

and I'm an idiot...

Code: Select all

listen = netOpenCon("0.0.0.0", "default");
should have been

Code: Select all

listen = netOpenCon("0.0.0.0", "encryptionKey");
does the network provide any kind of error so that I would have known that it was the wrong encryption key?

vIndie
Posts: 9
Joined: Thu Mar 29, 2012 12:35 am

Re: Hi all, Is there a command to send and receive TCP messa

#18 Post by vIndie » Fri Mar 30, 2012 4:11 pm

very basic but it works.

Code: Select all

CNetworkServer = class(
	function (self)
		netPushKey("encryptionKey", "12345");
	end
);

function CNetworkServer:start()
	listen = netOpenCon("0.0.0.0:62751", "encryptionKey");
	
	if( netListen(listen) ~= 0 ) then
	  printf("Error making connection.\n");
	end	
	while (1) do
		printf("Waiting for a client...");
		 
		-- Lets wait until a client joins our server.
		netcon = netPollListen(listen);
		while(netcon == nil) do
			printf(".");
			netcon = netPollListen(listen);
			rest(100);
		end
		printf("Connection success!\n");
	
		local messId = nil;
		while(netPollMessages(netcon)) do
			-- remember, in our example, we sent: 12, "Hello my name is John Doe."
			local message = netGetMessage(netcon);
			messId = message[1];

			printf("Received message: %s\n", messId);
		end
		
		if (messId == 1) then
			--enterDNG();
		elseif (messId == 2) then
			--exitDNG();
		elseif (messId == 3) then
			return;
		end	
	end
end

function netStart()
	netServer = CNetworkServer();
	if (netServer) then
		netServer:start();
	end
end

startMacro(netStart);

Code: Select all

CNetworkClient = class(
	function (self)
		self.ip = 0;
		self.netcon = 0;
		netPushKey("encryptionKey", "12345");
	end
);
	
function CNetworkClient:connect(ip)

	self.netcon = netOpenCon("encryptionKey");
	if( netConnect(self.netcon, ip) == 0 ) then
		printf("Attempting connection...");

		-- We wait until our connection status is either an error, or a successful connection
		status = netConnectStatus(self.netcon);
		while( status == 0 ) do
			printf(".");
			status = netConnectStatus(self.netcon);
		end
		if( status > 0 )then
			printf("Connection success!\n");
			self.ip = ip;
			return true;
		else
			printf("Connection failed!\n");
			return false;
		end
	else
		printf("Error initializing connection.\n");
		return false;
	end

end

function CNetworkClient:sendNetMessage(messId)
    if (self.netcon ~= nil) then
		printf("Message (%i) sent to %s: %s\n", messId, self.ip, (netSendMessage(self.netcon, messId) == 0));
		-- netSendMessage(self.netcon, messId);
    end
end

function CNetworkClient:close()
	netCloseCon(self.netcon);
end

function EnterDNG()
  client:sendNetMessage(1);
end

function ExitDNG()
  client:sendNetMessage(2);
end

function main()
	client = CNetworkClient();
	client:connect("127.0.0.1:62751");
	EnterDNG();
	client:close();
end

startMacro(main);


User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Hi all, Is there a command to send and receive TCP messa

#19 Post by Administrator » Fri Mar 30, 2012 5:20 pm

vIndie wrote:does the network provide any kind of error so that I would have known that it was the wrong encryption key?
Not really, no. "default" is always available, so that would be a "valid" encryption key. In the case that you used two different encryption keys, it would just result in a loss of data/malformed packets, but you should* be able to connect.

*I'm not entirely sure about this. I expect that the connection should open, but transmitting data wouldn't work.

Code: Select all

CNetworkServer = class(
   function (self)
      netPushKey("encryptionKey", "12345");
   end
);
This wouldn't work. Unless I made some changes that I forgot about, that is. netPushKey needs to be called from lib/net.lua. You should add an entry there instead, and make sure that this key exists (and is the same) on both the client and server side. The reason that this is a requirement is for your safety. This prevents someone from sneaking in some code that would send potentially sensitive information (username/password pairs or something) to the exploiter, as they wouldn't be able to use a valid encryption key to open the connection with (your default key is randomly generated user-side when MicroMacro is opened and the key does not exist).

vIndie
Posts: 9
Joined: Thu Mar 29, 2012 12:35 am

Re: Hi all, Is there a command to send and receive TCP messa

#20 Post by vIndie » Fri Mar 30, 2012 5:29 pm

Administrator wrote:Not really, no. "default" is always available, so that would be a "valid" encryption key. In the case that you used two different encryption keys, it would just result in a loss of data/malformed packets, but you should* be able to connect.

*I'm not entirely sure about this. I expect that the connection should open, but transmitting data wouldn't work.
Nope, I wasn't even getting a connection past the netConnectionStatus.
Administrator wrote:

Code: Select all

CNetworkServer = class(
   function (self)
      netPushKey("encryptionKey", "12345");
   end
);
This wouldn't work. Unless I made some changes that I forgot about, that is. netPushKey needs to be called from lib/net.lua. You should add an entry there instead, and make sure that this key exists (and is the same) on both the client and server side. The reason that this is a requirement is for your safety. This prevents someone from sneaking in some code that would send potentially sensitive information (username/password pairs or something) to the exploiter, as they wouldn't be able to use a valid encryption key to open the connection with (your default key is randomly generated user-side when MicroMacro is opened and the key does not exist).
Was working fine and sending/recieving data.

I've gotten LuaSocket working so I may use that instead, a bit more flexibility but no encryption built in. =\

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests