Cryptography Interface signature:
Code:
public interface Icrypto
{
void Decrypt(ref byte[] data, bool IsRemServer);
void Encrypt(ref byte[] data, bool IsRemServer);
}
Code:
private void myProxy_NewConnectionEvent(object sender, int sessionid)
{
//Initialized the encryptor here
CrypImplementer cryptImp = new CrypImplementer();
myProxy.SetCryptImp((object)cryptImp, sessionid);
}
private class CrypImplementer : connection.Icrypto
{
public CrypImplementer() { }
public void Decrypt(ref byte[] data, bool IsRemServer)
{
/*Define your Decryption here
* IrRemServer is true when the data is coming from server
* otherwise it is false
*/
}
public void Encrypt(ref byte[] data, bool IsRemServer)
{
/*Define your Encryption here
* IrRemServer is true when the data is coming from server
* otherwise it is false
*/
}
}
Code:
private void myProxy_DataArrivalEvent(
object sender,
object data,
int sessionid,
Boolean IsRemServer)
{
connection conn = (connection)sender;
if (IsRemServer)
{
// You can add packet handler here
conn.SendPC(data);
}
else
{
// You can add packet handler here
conn.SendPS(data);
}
}
Code:
connection tmpcon=myProxy.GetConn(sessionid); tmpcon.SendPC((object) byte); // send data from proxy to client for connection id= sessionid tmpcon.SendPS((object) byte); // send data from proxy to remote host for connection id= sessionid
General Implementation of the library:
Importing the library
Code:
using xmenproxy;
Code:
/* * If you have more proxy listening at different port then you can defined different instance for it */ ProxyServer myProxy = new ProxyServer(); //ProxyServer myProxy2 = new ProxyServer(); //ProxyServer myProxy3 = new ProxyServer(); //etc
Code:
myProxy.RemoteIP = "remotehostip";
myProxy.RemotePort = 9960;
myProxy.LocalPort = 9960;
myProxy.LocalIP = "localhost";
myProxy.DataArrivalEvent += new ProxyServer.DataArrival(myProxy_DataArrivalEvent);
myProxy.NewConnectionEvent += new ProxyServer.NewConnection(myProxy_NewConnectionEvent);
myProxy.StartServer();
Code:
private void myProxy_NewConnectionEvent(object sender, int sessionid)
{
//Initialized the encryptor here
CrypImplementer cryptImp = new CrypImplementer();
myProxy.SetCryptImp((object)cryptImp, sessionid);
}
private void myProxy_DataArrivalEvent(
object sender,
object data,
int sessionid,
Boolean IsRemServer)
{
connection conn = (connection)sender;
if (IsRemServer)
{
conn.SendPC(data);
}
else
{
conn.SendPS(data);
}
}






