Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Technical Support » Win32 FDS » RenRem protocol
RenRem protocol [message #351553] Sun, 21 September 2008 04:15 Go to next message
jindrak2 is currently offline  jindrak2
Messages: 4
Registered: September 2007
Karma: 0
Recruit
Hey guys,

Im scripting a bot in Java for my server.

For the moment, i use the FDSTalk.dll file to communicate to FDS (with JNI technology) and i used SSGM DDE as well. But i want to use pure java code to communicate to FDS and for that i need to know how RenRem does it.


If someone can help me it would be great Big Grin

Re: RenRem protocol [message #351902 is a reply to message #351553] Tue, 23 September 2008 16:06 Go to previous messageGo to next message
jindrak2 is currently offline  jindrak2
Messages: 4
Registered: September 2007
Karma: 0
Recruit
I made my java file alone. It talks directly to RenegadeFDS Big Grin without renrem, fdstalk ,...

I had fun with the java bytes ^^
Re: RenRem protocol [message #351926 is a reply to message #351553] Tue, 23 September 2008 23:48 Go to previous messageGo to next message
Goztow is currently offline  Goztow
Messages: 9737
Registered: March 2005
Location: Belgium
Karma: 13
General (5 Stars)
Goztoe
Very nice Smile. Will you release it?

You can find me in The KOSs2 (TK2) discord while I'm playing. Feel free to come and say hi! TK2 discord
Re: RenRem protocol [message #351929 is a reply to message #351926] Wed, 24 September 2008 01:21 Go to previous messageGo to next message
jindrak2 is currently offline  jindrak2
Messages: 4
Registered: September 2007
Karma: 0
Recruit
I will see.

I need to optimize the code and make a real java class before releasing the code.
Re: RenRem protocol [message #395095 is a reply to message #351929] Wed, 15 July 2009 14:05 Go to previous messageGo to next message
snazy2000 is currently offline  snazy2000
Messages: 67
Registered: December 2007
Karma: 0
Recruit
i no im opening an old topic but ages ago i found this somewere

import java.io.*;
import java.net.*;

class JavaFDS {

byte[] message5 = new byte[20];

private String password;
private byte[] result;
private byte[] receiveData;
private String message;
private DatagramSocket clientSocket;
private	InetAddress IPAdress;
private int port;
private DatagramPacket sendPacket,receivePacket;
	
	public void connectFDS(String password, int port) throws Exception
	{
		this.password = password;
		message = password;
		this.port = port;
		encrypt2();
		
		clientSocket = new DatagramSocket();
		IPAdress = InetAddress.getByName("loopback");
		receiveData = new byte[1024];
		
		sendPacket = new DatagramPacket(result,result.length,IPAdress,port);
		clientSocket.send(sendPacket);
		//receivePacket = new DatagramPacket(receiveData,receiveData.length);
		//clientSocket.receive(receivePacket);
		//decrypt2();
		//Connection1.sendMsg("PRIVMSG " + Connection1.chan + " " + message);
		//System.out.println(byteToInt(receiveData[1]));
		return;
	}
	public void sendMsg(String message) throws Exception
	{
		this.message = message;
		encrypt2();
		
		receiveData = new byte[1024];
		sendPacket = new DatagramPacket(result,result.length,IPAdress,port);
		clientSocket.send(sendPacket);
		//receivePacket = new DatagramPacket(receiveData,receiveData.length);
		//clientSocket.receive(receivePacket);
		//modifiedSentence = new String(receivePacket.getData());
		//System.out.println(byteToInt(receiveData[1]));
		//decrypt2();
		//decrypt2();
		//shutdown();
		//return this.message;
		return;
	}
	public void shutdown() throws Exception
	{
		clientSocket.close();
	}


// ****************
// Internal functions
// ****************
	

// Encrypt the variable "message" and stock the encryption into the variable "result"

private void decrypt2() throws Exception {
	int l=1023;
	while(byteToInt(receiveData[l])==0)
		l--;
	//System.out.println(l);
	while (l%4 != 0)
			l++;
	byte[] dmessage = new byte[l+1];
	for(int i=0;i<l+1;i++)
		dmessage[i] = receiveData[i];
	
	//System.out.println(dmessage[0]);
	
	byte ESI;
		byte[] ECX = {(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00};
		byte[] EDX = {(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00};
		byte[] EBX = {(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x01};
		byte[] EAX = {(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00};
		
		String shortpass;
		if (password.length()>=8)
			shortpass = password.substring(0,8);
		else 
			return;
		byte[] bpass = new byte[8];
		bpass = shortpass.getBytes();
	
	for(int i=4;i<l+1;i++)
	{
		EDX[3] = dmessage[i];
		mov(ECX,EAX);
		ECX[3] = (byte) (ECX[3] & (byte)0x07);
		ECX[0]=(byte)0x00;
		ECX[1]=(byte)0x00;
		ECX[2]=(byte)0x00;
		ESI = ECX[3];
		ECX[3] = bpass[byteToInt(ECX[3])];
		ECX[3] = (byte)(ECX[3] ^ EDX[3]);
		EDX[3] = ECX[3];
		bpass[(int)ESI] = ECX[3];
		EDX[3] = (byte)(EDX[3] + ~EAX[3] + (byte)0x01);
		EDX[3] = (byte)(EDX[3] + (byte)0x32);
		dmessage[i] = EDX[3];
		add(EAX,EBX);		
	}
	
	for(int i=0;i<l+1;i++)
	{
		if(byteToInt(dmessage[i]) == 10)
			dmessage[i]=(byte)0x20;
			}
		
	byte[] dmessage2 = new byte[l+1-8];
	for(int i=0;i<l+1-8;i++)
		dmessage2[i] = dmessage[i+8];
		
	byte[] dmessage3 = new byte[l+1-11];
	for(int i=0;i<l+1-11;i++)
		dmessage3[i] = dmessage2[i];
	String tze = new String( dmessage3 , "Cp1252" );
	this.message=tze;
	//System.out.println(message);
	
	
}

private void encrypt2() throws Exception
	{
		int l = this.message.length();
		byte[] bmessage = new byte[l];
		bmessage = this.message.getBytes();
		
		String shortpass;
		if (password.length()>=8)
			shortpass = password.substring(0,8);
		else 
			return;
		byte[] bpass = new byte[8];
		bpass = shortpass.getBytes();
		
		l=l+9;
		while (l%4 != 0)
			l++;
		result = new byte[l];
		
		// Initialisation
		
		for(int i=0;i<l;i++)
		{
			if(i<8)
			{
				result[i]=(byte)0x00;
			}
			else if(i>7 && i<8+this.message.length())
			{
				result[i]=bmessage[i-8];
			}
			else
			{
				result[i] = (byte)0x00;
			}
		}
		
		// Encryption
		
		byte ESI;
		byte[] ECX = {(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00};
		byte[] EDX = {(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00};
		byte[] EBX = {(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x01};
		byte[] EAX = {(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00};
		
		for(int i=4;i<this.message.length()+9;i++)
		{
			EAX[3] = result[i];
			mov(EDX,ECX);
			EDX[3] = (byte) (EDX[3] & (byte)0x07);
			EDX[0]=(byte)0x00;
			EDX[1]=(byte)0x00;
			EDX[2]=(byte)0x00;
			add(EAX,ECX);
			EAX[3] = (byte)(EAX[3] + ~(byte)0x32 + (byte)0x01);
			ESI = EDX[3];
			EDX[3] = bpass[(int)EDX[3]];
			EAX[3] = (byte)(EAX[3] ^ EDX[3]);
			result[i] = EAX[3];
			EDX[3] = (byte)(EDX[3] ^ EAX[3]);
			bpass[(int)ESI] = EDX[3];
			add(ECX,EBX);	
		}
		
		
		int rrr;
		if((this.message.length()+4+1)%4 == 0)
			rrr = (this.message.length()+4+1)/4;
			else
			rrr = (this.message.length()+4+1)/4+1;
		//if((this.message.length())%4 != 0)
		//rrr--;
		for(int i=0;i<rrr;i++)
		{
			ECX[0] = result[3];
			ECX[1] = result[2];
			ECX[2] = result[1];
			ECX[3] = result[0];
			
			mov(EAX,ECX);
			
			EAX[3] = (byte)((byte)(EAX[0] >> 7) & (byte)0x00 + 1);
			EAX[0] = (byte)0x00;
			EAX[1] = (byte)0x00;
			EAX[2] = (byte)0x00;
						
			shl(ECX);
		
			add(EAX,ECX);		
			
			ECX[0] = result[4*i+7];
			ECX[1] = result[4*i+6];
			ECX[2] = result[4*i+5];
			ECX[3] = result[4*i+4];
			
			add(EAX,ECX);
			
			result[3] = EAX[0];
			result[2] = EAX[1];
			result[1] = EAX[2];
			result[0] = EAX[3];	
		}
	}
	
// Convert a signed byte to an integer.
	
private int byteToInt(byte bIn){
if((bIn > 127) || (bIn < -128))
	return 0;
else
{
	if(bIn >= 0)
		return (int)bIn;
	else{
		return (-(-(int)bIn) & 0xff);
	}
}
}

// Replace the first registry by the second one.

private void mov(byte[] reg1, byte[] reg2)
{
	reg1[0] = reg2[0];
	reg1[1] = reg2[1];
	reg1[2] = reg2[2];
	reg1[3] = reg2[3];
}

// Add the second registry to the first one and stock the result into the first registry.

private void add(byte[] reg1, byte[] reg2)
{
	byte temp = (byte)0x00;
	byte temp2 = (byte)0x00;
			
	if(byteToInt(reg1[3])+byteToInt(reg2[3]) > 255)
		temp = (byte)0x01;
	reg1[3] = (byte)(reg1[3] + reg2[3]);
	
	if(byteToInt(reg1[2])+byteToInt(reg2[2])+temp > 255)
		temp2 = (byte)0x01;
	reg1[2] = (byte)(reg1[2] + reg2[2] + temp);
	
	if(byteToInt(reg1[1])+byteToInt(reg2[1])+temp2 > 255)
		temp = (byte)0x01;
	else
		temp = (byte)0x00;
	reg1[1] = (byte)(reg1[1] + reg2[1] +temp2);
	reg1[0] = (byte)(reg1[0] + reg2[0] +temp);
}

// Multiply the registry by 2.

private void shl(byte []reg)
{
	byte temp = (byte)0x00;
	byte temp2 = (byte)0x00;
			
	if((int)reg[3] < 0)
		temp = (byte)0x01;
	reg[3] = (byte)(reg[3] << 1);
	
	if((int)reg[2] < 0)
		temp2 = (byte)0x01;
	reg[2] = (byte)(reg[2] << 1);
	reg[2] = (byte)(reg[2] + temp);
	
	if((int)reg[1] < 0)
		temp = (byte)0x01;
	else
		temp= (byte)0x00;
	reg[1] = (byte)(reg[1] << 1);
	reg[1] = (byte)(reg[1] + temp2);
	reg[0] = (byte)(reg[0] << 1);
	reg[0] = (byte)(reg[0] + temp);
}
 	
}



Dont no if that can help any 1 Smile
Re: RenRem protocol [message #395133 is a reply to message #351553] Wed, 15 July 2009 19:26 Go to previous messageGo to next message
HTT-Bird is currently offline  HTT-Bird
Messages: 11
Registered: June 2009
Karma: 0
Recruit
RenRem is a bit of a security hole, tbh (unless your firewall blocks RenRem traffic Wink

The best approach for an external application is to use the Windows APIs AttachConsole & WriteConsoleInput to push console commands directly into the FDS buffer (the latter takes a few gymnastics to call and and the former is only available on Windows XP or later, but when you combine the two, you get a one-way pty that is vastly better than DDE or RenRem); you can use jonwil's RenLogMon feature to see the console output coming back to you.

BTW: You can't pipe FDS I/O on Windows due to the fact the FDS uses the W32 low-level console API.

Re: RenRem protocol [message #396086 is a reply to message #351553] Fri, 24 July 2009 05:29 Go to previous messageGo to next message
CarrierII is currently offline  CarrierII
Messages: 3804
Registered: February 2006
Location: England
Karma: 0
General (3 Stars)

RenRem's perfectly secure if you set the remote admin IP to 127.0.0.1, right?


Renguard is a wonderful initiative
Toggle Spoiler
Re: RenRem protocol [message #396154 is a reply to message #396086] Fri, 24 July 2009 22:31 Go to previous messageGo to next message
Genesis2001
Messages: 1397
Registered: August 2006
Karma: 0
General (1 Star)
CarrierII wrote on Fri, 24 July 2009 05:29

RenRem's perfectly secure if you set the remote admin IP to 127.0.0.1, right?



RenRem's protocol, last I checked, wasn't supposed to be released as it's a security risk perhaps? or am I just thinking of FDSTalk.dll...?
Re: RenRem protocol [message #397189 is a reply to message #396154] Thu, 06 August 2009 10:22 Go to previous messageGo to next message
Ethenal is currently offline  Ethenal
Messages: 2532
Registered: January 2007
Location: US of A
Karma: 0
General (2 Stars)

Zack wrote on Sat, 25 July 2009 00:31

CarrierII wrote on Fri, 24 July 2009 05:29

RenRem's perfectly secure if you set the remote admin IP to 127.0.0.1, right?



RenRem's protocol, last I checked, wasn't supposed to be released as it's a security risk perhaps? or am I just thinking of FDSTalk.dll...?

Technically, FDSTalk.dll wasn't supposed to be released for security purposes, but this however, is obviously not FDSTalk so I don't think that applies. Somebody might remove it anyway, though.


-TLS-DJ-EYE-K wrote on Mon, 18 March 2013 07:29

Instead of showing us that u aren't more inteligent than a Toast, maybe you should start becomming good in renegade Thumbs Up

Re: RenRem protocol [message #397389 is a reply to message #351553] Sun, 09 August 2009 05:26 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
Why is it a security risk? Anyone who wants the protocol could just open BRenBot and get it that way anyway...

http://steamsignature.com/card/1/76561197975867233.png
Re: RenRem protocol [message #397467 is a reply to message #397389] Sun, 09 August 2009 23:54 Go to previous message
Ethenal is currently offline  Ethenal
Messages: 2532
Registered: January 2007
Location: US of A
Karma: 0
General (2 Stars)

danpaul88 wrote on Sun, 09 August 2009 07:26

Why is it a security risk? Anyone who wants the protocol could just open BRenBot and get it that way anyway...

lol, I thought you wouldn't like it if I said that, but that is exactly what I had in mind when I read this thread. People have always been tinfoil hat about it for some reason, even though it's almost always used locally and is a shitty protocol to begin with.


-TLS-DJ-EYE-K wrote on Mon, 18 March 2013 07:29

Instead of showing us that u aren't more inteligent than a Toast, maybe you should start becomming good in renegade Thumbs Up

Previous Topic: error creating game channel
Next Topic: Again a really anoying problem
Goto Forum:
  


Current Time: Sat Nov 02 08:53:58 MST 2024

Total time taken to generate the page: 0.00831 seconds