public Request(Method _method, string _uri, Payloads _payload = null, Dictionary <string, string> _pathParams = null) { this.method = _method; this.uri = _uri; this.payload = _payload; this.pathParams = _pathParams; }
public static string SerializePostData(Payloads payload) { fsData data; serializer.TrySerialize(payload.GetType(), payload, out data).AssertSuccessWithoutWarnings(); return(data.ToString()); }
private void HandleGetServers(GetServers payload, PayloadWriter writer) { if (!ServerUpdateReceivers.TryAdd(Connection, Account.Id)) { StatusMsg resultPayload1 = Payloads.CreatePayload <StatusMsg>(); resultPayload1.Errorcode = 3; resultPayload1.Errormsg = "Can not get server list"; resultPayload1.TicketId = payload.TicketId; SendReply(writer, resultPayload1); return; } List <Server> servers = Program.Servers.GetServers(); uint ticketId = payload.TicketId; foreach (Server server in servers) { ServerInfo resultPayload1 = CreateServerInfoPayload(server, ticketId); SendReply(writer, resultPayload1); } StatusMsg resultPayload2 = Payloads.CreatePayload <StatusMsg>(); resultPayload2.Errorcode = 0; resultPayload2.Errormsg = null; resultPayload2.TicketId = payload.TicketId; SendReply(writer, resultPayload2); }
/// <summary> /// Emits WiX XML. /// </summary> /// <returns></returns> public override XContainer[] ToXml() { var root = new XElement("ExePackage"); root.SetAttribute("Name", Name); //will respect null if (this.IsIdSet()) { root.SetAttribute("Id", Id); } root.AddAttributes(this.Attributes) .Add(this.MapToXmlAttributes()); if (Payloads.Any()) { Payloads.ForEach(p => root.Add(new XElement("Payload", new XAttribute("SourceFile", p)))); } foreach (var exitCode in ExitCodes) { root.Add(exitCode.ToXElement()); } return(new[] { root }); }
private void HandleGetCdKeys(GetCDKeys payload, PayloadWriter writer) { uint accountId = payload.UserId; if (accountId != Account.Id) { StatusMsg resultPayload1 = Payloads.CreatePayload <StatusMsg>(); resultPayload1.Errorcode = 1; resultPayload1.Errormsg = "Incorrect account"; resultPayload1.TicketId = payload.TicketId; SendReply(writer, resultPayload1); return; } SendCDKey resultPayload2 = Payloads.CreatePayload <SendCDKey>(); resultPayload2.UserId = accountId; resultPayload2.CdKey = "0000000000000000"; resultPayload2.Keypool = 1; resultPayload2.TicketId = payload.TicketId; SendReply(writer, resultPayload2); StatusMsg resultPayload3 = Payloads.CreatePayload <StatusMsg>(); resultPayload3.Errorcode = 0; resultPayload3.Errormsg = null; resultPayload3.TicketId = payload.TicketId; SendReply(writer, resultPayload3); }
/// <summary> /// Automatically generates required sources files for building the Bootstrapper. It is /// used to automatically generate the files which, can be generated automatically without /// user involvement (e.g. BootstrapperCore.config). /// </summary> /// <param name="outDir">The output directory.</param> public override void AutoGenerateSources(string outDir) { //NOTE: while it is tempting, AutoGenerateSources cannot be called during initialization as it is too early. //The call must be triggered by Compiler.Build* calls. rawAppAssembly = AppAssembly; if (rawAppAssembly.EndsWith("%this%")) { rawAppAssembly = Compiler.ResolveClientAsm(outDir); //NOTE: if a new file is generated then the Compiler takes care for cleaning any temps if (Payloads.FirstOrDefault(x => x.SourceFile == "%this%") is Payload payload_this) { payload_this.SourceFile = rawAppAssembly; } } string asmName = Path.GetFileNameWithoutExtension(Utils.OriginalAssemblyFile(rawAppAssembly)); var suppliedConfig = Payloads.Select(x => x.SourceFile).FirstOrDefault(x => Path.GetFileName(x).SameAs("BootstrapperCore.config", true)); bootstrapperCoreConfig = suppliedConfig; if (bootstrapperCoreConfig == null) { bootstrapperCoreConfig = Path.Combine(outDir, "BootstrapperCore.config"); sys.File.WriteAllText(bootstrapperCoreConfig, DefaultBootstrapperCoreConfigContent.Replace("{asmName}", asmName)); Compiler.TempFiles.Add(bootstrapperCoreConfig); } }
private void HandleRegisterNickname(RegisterNickname payload, PayloadWriter writer) { uint accountId = payload.OwnerId; string nickname = payload.Name; if (accountId != 0) { StatusWithId resultPayload1 = Payloads.CreatePayload <StatusWithId>(); resultPayload1.Errorcode = 1; resultPayload1.Errormsg = "Incorrect account"; resultPayload1.Id = payload.OwnerId; resultPayload1.TicketId = payload.TicketId; SendReply(writer, resultPayload1); return; } Program.Accounts.SetNickname(Database.Connection, Account.Id, nickname); Account.PlayerName = nickname; StatusWithId resultPayload2 = Payloads.CreatePayload <StatusWithId>(); resultPayload2.Errorcode = 0; resultPayload2.Errormsg = null; resultPayload2.Id = Account.Id; resultPayload2.TicketId = payload.TicketId; SendReply(writer, resultPayload2); }
/// <summary> /// Emits WiX XML. /// </summary> /// <returns></returns> public override XContainer[] ToXml() { string winInstaller = typeof(Session).Assembly.Location; var root = new XElement("BootstrapperApplicationRef"); root.SetAttribute("Id", "ManagedBootstrapperApplicationHost"); var files = new List <Payload> { rawAppAssembly.ToPayload(), bootstrapperCoreConfig.ToPayload() }; files.AddRange(Payloads.DistinctBy(x => x.SourceFile)); //note %this% it already resolved at this stage into an absolute path if (!Payloads.Any(x => Path.GetFileName(x.SourceFile).SameAs(Path.GetFileName(winInstaller)))) { files.Add(winInstaller.ToPayload()); } if (files.Any()) { files.DistinctBy(x => x.SourceFile).ForEach(p => root.Add(p.ToXElement("Payload"))); } return(new[] { root }); }
private void HandleUpdateServerInfo(UpdateServerInfo payload, PayloadWriter writer) { if (_server == null) { StatusMsg resultPayload1 = Payloads.CreatePayload <StatusMsg>(); resultPayload1.Errorcode = 3; resultPayload1.Errormsg = "No server"; resultPayload1.TicketId = payload.TicketId; SendReply(writer, resultPayload1); return; } _server.Name = payload.Name; _server.Description = payload.Description; _server.MaxPlayers = payload.MaxPlayers; _server.RoomId = payload.RoomId; _server.Level = payload.Level; _server.GameMode = payload.GameMode; _server.Hardcore = payload.Hardcore; _server.Running = payload.Running; _server.LockedConfig = payload.LockedConfig; _server.Data = payload.Data; SendServerUpdates(); StatusMsg resultPayload2 = Payloads.CreatePayload <StatusMsg>(); resultPayload2.Errorcode = 0; resultPayload2.Errormsg = null; resultPayload2.TicketId = payload.TicketId; SendReply(writer, resultPayload2); }
/// <summary> /// Emits WiX XML. /// </summary> /// <returns></returns> public override XContainer[] ToXml() { var root = new XElement("MsiPackage"); root.SetAttribute("Name", Name); //will respect null if (this.IsIdSet()) { root.SetAttribute("Id", Id); } root.AddAttributes(this.Attributes) .Add(this.MapToXmlAttributes()); if (Payloads.Any()) { Payloads.ForEach(p => root.Add(new XElement("Payload", new XAttribute("SourceFile", p)))); } string props = MsiProperties + ";" + DefaultMsiProperties; props.ToDictionary().ForEach(p => { root.Add(new XElement("MsiProperty").AddAttributes("Name={0};Value={1}".FormatWith(p.Key, p.Value))); }); return(new[] { root }); }
private string GetPayload() { if (Rb_Multi.Checked) { return(__MultidAttack.Payload); } else if (rbCust.Checked) { return(__CustomAttack.Payload); } if (RBCookie.Checked) { return(__CookieAttack.Payload); } if (RB_X_Forwarded_For.Checked) { return(__XfrwrdAttack.Payload); } if (RB_Referer.Checked) { return(__RefererAttack.Payload); } if (rbUserAgent.Checked) { return(__UserAgentAttack.Payload); } else { return(Payloads.GetPayload(Payload_.string_)); } }
/// <summary> /// Emits WiX XML. /// </summary> /// <returns></returns> public override XContainer[] ToXml() { var root = new XElement("MsuPackage"); root.SetAttribute("Name", Name); //will respect null if (this.IsIdSet()) { root.SetAttribute("Id", Id); } root.AddAttributes(this.Attributes) .Add(this.MapToXmlAttributes()); if (Payloads.Any()) { Payloads.ForEach(p => root.Add(p.ToXElement("Payload"))); } if (RemotePayloads.Any()) { RemotePayloads.ForEach(p => root.Add(p.ToXElement("RemotePayload"))); } return(new[] { root }); }
private static ServerInfo CreateServerInfoPayload(Server server, uint ticketId) { ServerInfo resultPayload1 = Payloads.CreatePayload <ServerInfo>(); resultPayload1.ServerId = server.Id; resultPayload1.Name = server.Name; resultPayload1.OwnerId = server.OwnerId; resultPayload1.Description = server.Description; resultPayload1.Ip = server.Ip; resultPayload1.Port = server.Port; resultPayload1.PasswordRequired = false; resultPayload1.ServerType = server.Type; resultPayload1.ServerSubtype = server.SubType; resultPayload1.Version = "1.1"; resultPayload1.MaxPlayers = server.MaxPlayers; resultPayload1.CurPlayers = 0; resultPayload1.MaxSpectators = 0; resultPayload1.CurSpectators = 0; resultPayload1.AiPlayers = 0; resultPayload1.RoomId = server.RoomId; resultPayload1.Level = server.Level; resultPayload1.GameMode = server.GameMode; resultPayload1.Hardcore = server.Hardcore; resultPayload1.Map = null; resultPayload1.Running = server.Running; resultPayload1.LockedConfig = server.LockedConfig; resultPayload1.Data = server.Data; // Crypto.BytesFromHexString("25000000785e63607264d26567c00f001041007a"); resultPayload1.TicketId = ticketId; return(resultPayload1); }
public FCgManager_Process() : base() { for (int i = 0; i < PAYLOAD_COUNT; ++i) { Payloads.Add(new FCgProcessPayload()); } }
private void HandleGetWelcomeMsg(GetWelcomeMsg payload, PayloadWriter writer) { SendWelcomeMsg resultPayload = Payloads.CreatePayload <SendWelcomeMsg>(); resultPayload.Txt = $"Welcome to Sacred 2, {Account.PlayerName}"; resultPayload.TicketId = payload.TicketId; SendReply(writer, resultPayload); }
private void HandleLoginChat(LoginChat payload, PayloadWriter writer) { LoginChatReply resultPayload = Payloads.CreatePayload <LoginChatReply>(); resultPayload.Nonce = Crypto.CreateNonce(); resultPayload.TicketId = payload.TicketId; SendReply(writer, resultPayload); }
public override int GetHashCode() { int hash = 1; if (Timestamp != 0L) { hash ^= Timestamp.GetHashCode(); } if (GlobalTxId.Length != 0) { hash ^= GlobalTxId.GetHashCode(); } if (LocalTxId.Length != 0) { hash ^= LocalTxId.GetHashCode(); } if (ParentTxId.Length != 0) { hash ^= ParentTxId.GetHashCode(); } if (Type.Length != 0) { hash ^= Type.GetHashCode(); } if (CompensationMethod.Length != 0) { hash ^= CompensationMethod.GetHashCode(); } if (Payloads.Length != 0) { hash ^= Payloads.GetHashCode(); } if (ServiceName.Length != 0) { hash ^= ServiceName.GetHashCode(); } if (InstanceId.Length != 0) { hash ^= InstanceId.GetHashCode(); } if (Timeout != 0) { hash ^= Timeout.GetHashCode(); } if (Retries != 0) { hash ^= Retries.GetHashCode(); } if (RetryMethod.Length != 0) { hash ^= RetryMethod.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private void HandleRegisterServer(RegisterServer payload, PayloadWriter writer) { string name = payload.Name; uint serverId = Program.Servers.Register(name); if (serverId == 0) { StatusWithId resultPayload1 = Payloads.CreatePayload <StatusWithId>(); resultPayload1.Errorcode = 3; resultPayload1.Errormsg = "Can not register server"; resultPayload1.Id = 0; resultPayload1.TicketId = payload.TicketId; SendReply(writer, resultPayload1); return; } _server = Program.Servers.Get(serverId); if (_server == null) { Program.Servers.Remove(serverId); StatusWithId resultPayload1 = Payloads.CreatePayload <StatusWithId>(); resultPayload1.Errorcode = 3; resultPayload1.Errormsg = "Can not register server"; resultPayload1.Id = 0; resultPayload1.TicketId = payload.TicketId; SendReply(writer, resultPayload1); return; } _server.ConnectionId = Connection; _server.OwnerId = Account.Id; _server.Description = payload.Description; _server.Ip = payload.Ip ?? Program.Ip; _server.Port = payload.Port; _server.Type = payload.ServerType; _server.SubType = payload.ServerSubtype; _server.MaxPlayers = payload.MaxPlayers; _server.RoomId = payload.RoomId; _server.Level = payload.Level; _server.GameMode = payload.GameMode; _server.Hardcore = payload.Hardcore; _server.Running = payload.Running; _server.LockedConfig = payload.LockedConfig; _server.Data = payload.Data; SendServerUpdates(); StatusWithId resultPayload2 = Payloads.CreatePayload <StatusWithId>(); resultPayload2.Errorcode = 0; resultPayload2.Errormsg = null; resultPayload2.Id = _server.Id; resultPayload2.TicketId = payload.TicketId; SendReply(writer, resultPayload2); }
private void HandlePayload157(Payload157 payload, PayloadWriter writer) { StatusMsg resultPayload = Payloads.CreatePayload <StatusMsg>(); resultPayload.Errorcode = 0; resultPayload.Errormsg = null; resultPayload.TicketId = payload.TicketId; SendReply(writer, resultPayload); }
public void TestLoadPayloads() { var accessControlAllowMethodsDetector = new AccessControlAllowMethodsDetector(); // load the payloads IPayloads payloads = new Payloads(Library.Constants.PayloadsQuickDataFolder); payloads.LoadPayloads(accessControlAllowMethodsDetector.GetType().Name).ShouldNotBeNull(); }
private void _____ATTACK___(AttackDetails _Atk_details, ref Label L_statue, ref Label L_code, ref LinkLabel L_source, ref Label hint, string attacker = "") { Notify(_Atk_details.Target + " Attacking "); L_statue.Text = L_code.Text = "..."; __HTTTPAttack_ at = new __HTTTPAttack_(); at.Payload = _Atk_details.Payload; at._Url = _Atk_details.URL; at.SetTargetHeader(_Atk_details.Target); at.Attack_Current_Header(); at.owner = _Atk_details.Owner; if (at.Succeeded) { if (at.IsCurrentHeaderVulnerable()) { L_statue.Text = "Vulnerable " + Payloads.Percent(at.Payload); } else { L_statue.Text = "Not Vulnerable"; } } else { L_statue.Text = "Error "; } L_code.Text = at.statueCode; AddAttackToList(at); L_code.Visible = true; switch (attacker.ToLower().Trim()) { case "cus": __CustomAttack = __HTTTPAttack_.Copy(at); break; case "xf": case "x-forwarded-for": __XfrwrdAttack = __HTTTPAttack_.Copy(at); break; case "c*k": case "cookie": __CookieAttack = __HTTTPAttack_.Copy(at); break; case "ua": case "useragent": case "user-agent": __UserAgentAttack = __HTTTPAttack_.Copy(at); break; case "ref": case "referer": __RefererAttack = __HTTTPAttack_.Copy(at); break; case "mul": case "multi": __MultidAttack = __HTTTPAttack_.Copy(at); break; } hint.Text = at.Message; hint.Visible = true; this.Notify(at.Summary(), 3000); }
private void HandleVerifyChatLogin(VerifyChatLogin payload, PayloadWriter writer) { StatusWithId resultPayload = Payloads.CreatePayload <StatusWithId>(); resultPayload.Errorcode = 0; resultPayload.Errormsg = null; resultPayload.Id = 0; resultPayload.TicketId = payload.TicketId; SendReply(writer, resultPayload); }
public void DisplayMatching(TimeSpan position) { var matching = Payloads.Where((pld) => { return(pld.TimeStamp <= position); }).ToList(); foreach (var pld in matching) { DisplayPayloads.Insert(0, pld); Payloads.Remove(pld); } }
private void HandleGetChatServer(GetChatServer payload, PayloadWriter writer) { SendChatServerInfo resultPayload = Payloads.CreatePayload <SendChatServerInfo>(); resultPayload.ServerId = 1; resultPayload.Ip = Program.Ip; resultPayload.Port = Program.ChatPort; resultPayload.ServerType = payload.ServerType; resultPayload.Version = null; resultPayload.Data = null; resultPayload.TicketId = payload.TicketId; SendReply(writer, resultPayload); }
private void HandleLogin(Login payload, PayloadWriter writer) { byte[] loginKey = payload.Key; _sharedSecret = Crypto.CreateSecretKey(); byte[] result = Crypto.HandleKey(loginKey, _sharedSecret); LoginReply resultPayload = Payloads.CreatePayload <LoginReply>(); resultPayload.Cipher = result; resultPayload.TicketId = payload.TicketId; SendReply(writer, resultPayload); }
private void HandleStopServerUpdates(StopServerUpdates payload, PayloadWriter writer) { uint accountId; ServerUpdateReceivers.TryRemove(Connection, out accountId); StatusMsg resultPayload = Payloads.CreatePayload <StatusMsg>(); resultPayload.Errorcode = 0; resultPayload.Errormsg = null; resultPayload.TicketId = payload.TicketId; SendReply(writer, resultPayload); }
public override string ToString() { return(Type + "{" + "globalTxId='" + GlobalTxId + '\'' + ", localTxId='" + LocalTxId + '\'' + ", parentTxId='" + ParentTxId + '\'' + ", compensationMethod='" + CompensationMethod + '\'' + ", timeout=" + Timeout + ", retryMethod='" + RetryMethod + '\'' + ", retries=" + Retries + ", payloads=" + string.Join(",", Payloads.Select(x => x.ToString()).ToArray()) + '}'); }
protected sealed override void HandleMessage(BinaryReader reader, BinaryWriter writer) { reader.BaseStream.Seek(0, SeekOrigin.Begin); PayloadReader payloadReader = new PayloadReader(reader); PayloadWriter payloadWriter = new PayloadWriter(writer); PayloadPrefix prefix = new PayloadPrefix(); prefix.Serialize(payloadReader); if (prefix.Magic == PayloadPrefix.PayloadMagic) { if (prefix.Type1 != prefix.Type2) { Program.Log($" Corrupt payload type, first is {prefix.Type1:X04} but second is {prefix.Type2:X04}"); } Payloads.Types payloadType = (Payloads.Types)prefix.Type2; PayloadPrefix payload = Payloads.CreatePayload(payloadType); reader.BaseStream.Seek(0, SeekOrigin.Begin); payload.Serialize(payloadReader); HandlePayloadType(payloadType, payload, payloadWriter); } else if (prefix.Magic == ChatPayloadPrefix.PayloadMagic) { if (prefix.Type1 != 0) { Program.Log($" Corrupt payload chatTypes, is {prefix.Type1:X04} but expected 0"); } ChatPayloads.ChatTypes chatPayloadType = (ChatPayloads.ChatTypes)prefix.Type2; ChatPayloadPrefix chatPayload = ChatPayloads.CreateChatPayload(chatPayloadType); reader.BaseStream.Seek(0, SeekOrigin.Begin); chatPayload.Serialize(payloadReader); HandleChatPayloadType(chatPayloadType, chatPayload, payloadWriter); } else { Program.Log($" Incorrect payload magic, is {prefix.Magic:X04} but should be {PayloadPrefix.PayloadMagic:X04}"); } }
/// <summary> /// Automatically generates required sources files for building the Bootstrapper. It is /// used to automatically generate the files which, can be generated automatically without /// user involvement (e.g. BootstrapperCore.config). /// </summary> /// <param name="outDir">The output directory.</param> public override void AutoGenerateSources(string outDir) { //NOTE: while it is tempting, AutoGenerateSources cannot be called during initialization as it is too early. //The call must be triggered by Compiler.Build* calls. rawAppAssembly = AppAssembly; if (rawAppAssembly.EndsWith("%this%")) { rawAppAssembly = Compiler.ResolveClientAsm(outDir); //NOTE: if a new file is generated then the Compiler takes care for cleaning any temps if (Payloads.FirstOrDefault(x => x.SourceFile == "%this%") is Payload payload_this) { payload_this.SourceFile = rawAppAssembly; } } string asmName = Path.GetFileNameWithoutExtension(Utils.OriginalAssemblyFile(rawAppAssembly)); var suppliedConfig = Payloads.Select(x => x.SourceFile).FirstOrDefault(x => Path.GetFileName(x).SameAs("BootstrapperCore.config", true)); bootstrapperCoreConfig = suppliedConfig; if (bootstrapperCoreConfig == null) { bootstrapperCoreConfig = Path.Combine(outDir, "BootstrapperCore.config"); sys.File.WriteAllText(bootstrapperCoreConfig, DefaultBootstrapperCoreConfigContent.Replace("{asmName}", asmName)); Compiler.TempFiles.Add(bootstrapperCoreConfig); } // WiX does not check the validity of the BootstrapperCore.config so we need to do it try { var expectedAssemblyName = XDocument.Load(bootstrapperCoreConfig) .FindFirst("host") .Attribute("assemblyName") .Value; if (asmName != expectedAssemblyName) { Compiler.OutputWriteLine( $"WARNING: It looks like your configured BA assembly name (<host assemblyName=\"{expectedAssemblyName}\">) " + $"from `BootstrapperCore.config` file is not matching the actual assembly name (\"{asmName}\")."); } } catch { } }
/// <summary> /// Automatically generates required sources files for building the Bootstrapper. It is /// used to automatically generate the files which, can be generated automatically without /// user involvement (e.g. BootstrapperCore.config). /// </summary> /// <param name="outDir">The output directory.</param> public override void AutoGenerateSources(string outDir) { //NOTE: while it is tempting, AutoGenerateSources cannot be called during initialization as it is too early. //The call must be triggered by Compiler.Build* calls. rawAppAssembly = AppAssembly; if (rawAppAssembly.EndsWith("%this%")) { rawAppAssembly = Compiler.ResolveClientAsm(outDir); //NOTE: if a new file is generated then the Compiler takes care for cleaning any temps if (Payloads.FirstOrDefault(x => x.SourceFile == "%this%") is Payload payload_this) { payload_this.SourceFile = rawAppAssembly; } } string asmName = Path.GetFileNameWithoutExtension(Utils.OriginalAssemblyFile(rawAppAssembly)); var suppliedConfig = Payloads.Select(x => x.SourceFile).FirstOrDefault(x => Path.GetFileName(x).SameAs("BootstrapperCore.config", true)); bootstrapperCoreConfig = suppliedConfig; if (bootstrapperCoreConfig == null) { bootstrapperCoreConfig = Path.Combine(outDir, "BootstrapperCore.config"); sys.File.WriteAllText(bootstrapperCoreConfig, @"<?xml version=""1.0"" encoding=""utf-8"" ?> <configuration> <configSections> <sectionGroup name=""wix.bootstrapper"" type=""Microsoft.Tools.WindowsInstallerXml.Bootstrapper.BootstrapperSectionGroup, BootstrapperCore""> <section name=""host"" type=""Microsoft.Tools.WindowsInstallerXml.Bootstrapper.HostSection, BootstrapperCore"" /> </sectionGroup> </configSections> <startup useLegacyV2RuntimeActivationPolicy=""true""> <supportedRuntime version=""v4.0"" /> </startup> <wix.bootstrapper> <host assemblyName=""" + asmName + @"""> <supportedFramework version=""v4\Full"" /> <supportedFramework version=""v4\Client"" /> </host> </wix.bootstrapper> </configuration> "); Compiler.TempFiles.Add(bootstrapperCoreConfig); } }
public virtual void OnPayload(Payloads.Payload payload) { }