public byte[] ToByteArray() { using (var rtqName = new FlashWriter()) { rtqName.Write7BitEncodedInt(ObjNameIndex); return rtqName.ToArray(); } }
public byte[] ToByteArray() { using (var multinameL = new FlashWriter()) { multinameL.Write7BitEncodedInt(NamespaceSetIndex); return multinameL.ToArray(); } }
public byte[] ToByteArray() { using (var trait = new FlashWriter()) { trait.Write7BitEncodedInt(DispId); trait.Write7BitEncodedInt(MethodIndex); return trait.ToArray(); } }
public byte[] ToByteArray() { using (var trait = new FlashWriter()) { trait.Write7BitEncodedInt(SlotId); trait.Write7BitEncodedInt(FunctionIndex); return trait.ToArray(); } }
public byte[] ToByteArray() { using (var asNamespace = new FlashWriter()) { asNamespace.Write((byte)NamespaceType); asNamespace.Write7BitEncodedInt(ObjNameIndex); return asNamespace.ToArray(); } }
protected override byte[] OnConstruct() { using (var tag = new FlashWriter(4)) { tag.Write(MaxRecursionDepth); tag.Write(ScriptTimeoutSeconds); return tag.ToArray(); } }
protected override byte[] OnConstruct() { using (var tag = new FlashWriter()) { tag.Write(Flags); tag.WriteNullTerminatedString(Name); tag.Write(ABC.ToByteArray()); return tag.ToArray(); } }
protected override byte[] OnConstruct() { using (var tag = new FlashWriter()) { tag.Write(FontId); tag.WriteNullTerminatedString(FontName); tag.WriteNullTerminatedString(FontCopyright); return tag.ToArray(); } }
public byte[] ToByteArray() { using (var asNamespaceSet = new FlashWriter()) { asNamespaceSet.Write7BitEncodedInt(NamespaceIndices.Count); foreach (int namespaceIndex in NamespaceIndices) asNamespaceSet.Write7BitEncodedInt(namespaceIndex); return asNamespaceSet.ToArray(); } }
protected override byte[] OnConstruct() { using (var tag = new FlashWriter(6 + BinaryData.Length)) { tag.Write(CharacterId); tag.Position += 4; tag.Write(BinaryData); return tag.ToArray(); } }
public byte[] ToByteArray() { using (var asException = new FlashWriter()) { asException.Write7BitEncodedInt(From); asException.Write7BitEncodedInt(To); asException.Write7BitEncodedInt(Target); asException.Write7BitEncodedInt(ExceptionTypeIndex); asException.Write7BitEncodedInt(VariableNameIndex); return asException.ToArray(); } }
protected override byte[] OnConstruct() { using (var tag = new FlashWriter()) { tag.Write((ushort)Assets.Count); foreach (KeyValuePair<ushort, string> pair in Assets) { tag.Write(pair.Key); tag.WriteNullTerminatedString(pair.Value); } return tag.ToArray(); } }
public byte[] ToByteArray() { using (var asClass = new FlashWriter()) { asClass.Write7BitEncodedInt(ConstructorIndex); asClass.Write7BitEncodedInt(Traits.Count); foreach (ASTrait trait in Traits) asClass.Write(trait.ToByteArray()); return asClass.ToArray(); } }
public byte[] ToByteArray() { using (var asScript = new FlashWriter()) { asScript.Write7BitEncodedInt(FunctionIndex); asScript.Write7BitEncodedInt(Traits.Count); foreach (ASTrait trait in Traits) asScript.Write(trait.ToByteArray()); return asScript.ToArray(); } }
public byte[] ToByteArray() { using (var typename = new FlashWriter()) { typename.Write7BitEncodedInt(TypeIndex); typename.Write7BitEncodedInt(ParameterTypeIndices.Count); foreach (int multinameParameterIndex in ParameterTypeIndices) typename.Write7BitEncodedInt(multinameParameterIndex); return typename.ToArray(); } }
public byte[] ToByteArray() { using (var trait = new FlashWriter()) { trait.Write7BitEncodedInt(SlotId); trait.Write7BitEncodedInt(TypeIndex); trait.Write7BitEncodedInt(ValueIndex); if (ValueIndex != 0) trait.Write((byte)ValueType); return trait.ToArray(); } }
public byte[] ToByteArray() { using (var asMetadata = new FlashWriter()) { asMetadata.Write7BitEncodedInt(ObjNameIndex); asMetadata.Write7BitEncodedInt(Elements.Count); foreach (Tuple<int, int> element in Elements) { asMetadata.Write7BitEncodedInt(element.Item1); asMetadata.Write7BitEncodedInt(element.Item2); } return asMetadata.ToArray(); } }
protected override byte[] OnConstruct() { using (var tag = new FlashWriter(26)) { tag.Write((uint)ProductId); tag.Write((uint)Edition); tag.Write(MajorVersion); tag.Write(MinorVersion); tag.Write(BuildLow); tag.Write(BuildHigh); tag.Write((ulong)( (CompilationDate - _epoch).TotalMilliseconds)); return tag.ToArray(); } }
public byte[] ToByteArray() { using (var asMethod = new FlashWriter()) { asMethod.Write7BitEncodedInt(Parameters.Count); asMethod.Write7BitEncodedInt(ReturnTypeIndex); foreach (ASParameter parameter in Parameters) asMethod.Write7BitEncodedInt(parameter.TypeIndex); asMethod.Write7BitEncodedInt(NameIndex); asMethod.Write7BitEncodedInt((byte)MethodInfo); if ((MethodInfo & MethodFlags.HasOptional) != 0) { int optionalParamCount = 0; byte[] optionalParamData = null; using (var opParam = new FlashWriter()) { for (int i = 0; i < Parameters.Count; i++) { if (!Parameters[i].IsOptional) continue; optionalParamCount++; opParam.Write7BitEncodedInt(Parameters[i].ValueIndex); opParam.Write((byte)Parameters[i].ValueType); } optionalParamData = opParam.ToArray(); } asMethod.Write7BitEncodedInt(optionalParamCount); asMethod.Write(optionalParamData); } if ((MethodInfo & MethodFlags.HasParamNames) != 0) { foreach (ASParameter parameter in Parameters) asMethod.Write7BitEncodedInt(parameter.ObjNameIndex); } return asMethod.ToArray(); } }
protected override byte[] OnConstruct() { using (var tag = new FlashWriter()) { tag.Position = 2; ushort symbolCount = 0; foreach (KeyValuePair<ushort, string> symbol in Symbols) { string[] symbolNames = symbol.Value.Split(','); foreach (string symbolName in symbolNames) { symbolCount++; tag.Write(symbol.Key); tag.WriteNullTerminatedString(symbol.Value); } } tag.Position = 0; tag.Write(symbolCount); return tag.ToArray(); } }
public byte[] ToByteArray() { using (var asInstance = new FlashWriter()) { asInstance.Write7BitEncodedInt(TypeIndex); asInstance.Write7BitEncodedInt(SuperTypeIndex); asInstance.Write7BitEncodedInt((byte)ClassInfo); if ((ClassInfo & ClassFlags.ProtectedNamespace) != 0) asInstance.Write7BitEncodedInt(ProtectedNamespaceIndex); asInstance.Write7BitEncodedInt(InterfaceIndices.Count); foreach (int index in InterfaceIndices) asInstance.Write7BitEncodedInt(index); asInstance.Write7BitEncodedInt(ConstructorIndex); asInstance.Write7BitEncodedInt(Traits.Count); foreach (ASTrait trait in Traits) asInstance.Write(trait.ToByteArray()); return asInstance.ToArray(); } }
protected override byte[] OnConstruct() { if (_compressedBitmapData == null) { _compressedBitmapData = ZlibStream.CompressBuffer(_bitmapData); } using (var tag = new FlashWriter(7 + _compressedBitmapData.Length)) { tag.Write(CharacterId); tag.Write(BitmapFormat); tag.Write(BitmapWidth); tag.Write(BitmapHeight); tag.Write(_compressedBitmapData); return tag.ToArray(); } }
public byte[] ToByteArray() { using (var asMultiname = new FlashWriter()) { asMultiname.Write((byte)MultinameType); asMultiname.Write(Data.ToByteArray()); return asMultiname.ToArray(); } }
/// <summary> /// Reconstructs the Shockwave Flash(SWF) file using the tags from <see cref="Tags"/>. /// </summary> public byte[] Reconstruct() { using (var flash = new FlashWriter()) { flash.WriteUTF8SimpleString("FWS"); flash.Write(Version); flash.Position += 4; flash.Write(_frameData); foreach (FlashTag tag in Tags) flash.Write(tag.ToArray()); flash.Position = 4; flash.Write(flash.Length); _flashData = flash.ToArray(); Reader.ResetBuffer(_flashData); return _flashData; } }
public byte[] ToByteArray() { using (var asTrait = new FlashWriter()) { var trueKind = (byte)(( (byte)Attributes << 4) + (byte)TraitType); asTrait.Write7BitEncodedInt(TypeIndex); asTrait.Write(trueKind); asTrait.Write(Data.ToByteArray()); if ((Attributes & TraitAttributes.Metadata) != 0) { asTrait.Write7BitEncodedInt(MetadataIndices.Count); foreach (int index in MetadataIndices) asTrait.Write7BitEncodedInt(index); } return asTrait.ToArray(); } }
public bool BypassRemoteHostCheck() { ABCFile abc = ABCFiles[2]; ASInstance commManager = abc.FindInstanceByName("HabboCommunicationManager"); if (commManager == null) return false; // The "host" value is always the first slot, for now. string hostValueSlotName = commManager.FindTraits<SlotConstantTrait>(TraitType.Slot) .Where(t => t.Type.ObjName == "String").ToArray()[0].ObjName; ASMethod initComponent = commManager.FindMethod("initComponent", "void").Method; if (initComponent == null) return false; using (var inCode = new FlashReader(initComponent.Body.Bytecode)) using (var outCode = new FlashWriter(inCode.Length)) { int hostSlotIndex = abc.Constants.IndexOfMultiname(hostValueSlotName); while (inCode.Position != inCode.Length) { OPCode op = inCode.ReadOP(); outCode.WriteOP(op); if (op != OPCode.GetLocal_0) continue; op = inCode.ReadOP(); outCode.WriteOP(op); if (op != OPCode.CallPropVoid) continue; int callPropVoidIndex = inCode.Read7BitEncodedInt(); outCode.Write7BitEncodedInt(callPropVoidIndex); int callPropVoidArgCount = inCode.Read7BitEncodedInt(); outCode.Write7BitEncodedInt(callPropVoidArgCount); if (callPropVoidArgCount != 0) continue; int getPropertyNameIndex = abc.Constants .IndexOfMultiname("getProperty"); outCode.WriteOP(OPCode.GetLocal_0); outCode.WriteOP(OPCode.FindPropStrict); outCode.Write7BitEncodedInt(getPropertyNameIndex); outCode.WriteOP(OPCode.PushString); outCode.Write7BitEncodedInt(abc.Constants.AddString("connection.info.host")); outCode.WriteOP(OPCode.CallProperty); outCode.Write7BitEncodedInt(getPropertyNameIndex); outCode.Write7BitEncodedInt(1); outCode.WriteOP(OPCode.InitProperty); outCode.Write7BitEncodedInt(hostSlotIndex); outCode.Write(inCode.ToArray(), inCode.Position, inCode.Length - inCode.Position); do op = inCode.ReadOP(); while (op != OPCode.CallPropVoid); callPropVoidIndex = inCode.Read7BitEncodedInt(); ASMultiname callPropVoidName = abc.Constants.Multinames[callPropVoidIndex]; ASMethod connectMethod = commManager.FindMethod(callPropVoidName.ObjName, "void").Method; RemoveHostSuffix(abc, connectMethod); initComponent.Body.Bytecode = outCode.ToArray(); return true; } } return false; }
protected void RemoveDeadFalseConditions(ASMethodBody body) { using (var inCode = new FlashReader(body.Bytecode)) using (var outCode = new FlashWriter(inCode.Length)) { while (inCode.Position != inCode.Length) { OPCode op = inCode.ReadOP(); if (op != OPCode.PushFalse) { outCode.WriteOP(op); continue; } op = inCode.ReadOP(); if (op != OPCode.PushFalse) { outCode.WriteOP(OPCode.PushFalse); outCode.WriteOP(op); continue; } op = inCode.ReadOP(); if (op != OPCode.IfNe) { outCode.WriteOP(OPCode.PushFalse); outCode.WriteOP(OPCode.PushFalse); outCode.WriteOP(op); continue; } else inCode.ReadS24(); } body.Bytecode = outCode.ToArray(); } }
public bool ReplaceRSA(int exponent, string modulus) { ABCFile abc = ABCFiles[2]; int modulusIndex = abc.Constants.AddString(modulus); int exponentIndex = abc.Constants .AddString(exponent.ToString("x")); int rsaStart = 0; ASInstance commClass = abc.FindInstanceByName("HabboCommunicationDemo"); ASMethod verifier = FindVerifyMethod(commClass, abc, out rsaStart); using (var inCode = new FlashReader(verifier.Body.Bytecode)) using (var outCode = new FlashWriter(inCode.Length)) { bool searchingKeys = true; inCode.Position = rsaStart; outCode.Write(inCode.ToArray(), 0, rsaStart); while (inCode.Position != inCode.Length) { byte codeByte = inCode.ReadByte(); outCode.Write(codeByte); if (!searchingKeys) { outCode.Write(inCode.ToArray(), inCode.Position, inCode.Length - inCode.Position); break; } switch ((OPCode)codeByte) { case OPCode.GetLex: { outCode.Position--; outCode.WriteOP(OPCode.PushString); int typeIndex = inCode.Read7BitEncodedInt(); ASMultiname type = abc.Constants.Multinames[typeIndex]; inCode.ReadOP(); inCode.Read7BitEncodedInt(); inCode.Read7BitEncodedInt(); if (modulusIndex > 0) { outCode.Write7BitEncodedInt(modulusIndex); modulusIndex = -1; } else if (searchingKeys) { outCode.Write7BitEncodedInt(exponentIndex); searchingKeys = false; } break; } case OPCode.PushString: { int stringIndex = inCode.Read7BitEncodedInt(); string value = abc.Constants.Strings[stringIndex]; if (string.IsNullOrWhiteSpace(Modulus)) { Modulus = value; outCode.Write7BitEncodedInt(modulusIndex); } else if (string.IsNullOrWhiteSpace(Exponent)) { Exponent = value; outCode.Write7BitEncodedInt(exponentIndex); searchingKeys = false; } break; } default: continue; } } verifier.Body.Bytecode = outCode.ToArray(); if (!searchingKeys) return true; } return false; }
public bool DisableExpirationDateCheck() { ABCFile abc = ABCFiles[2]; ASInstance windowContext = abc.FindInstanceByName("WindowContext"); if (windowContext == null) return false; using (var inCode = new FlashReader(windowContext.Constructor.Body.Bytecode)) using (var outCode = new FlashWriter()) { int setLocal11Itterations = 0; while (inCode.Position != inCode.Length) { OPCode op = inCode.ReadOP(); outCode.WriteOP(op); if (op != OPCode.SetLocal) continue; int setLocalIndex = inCode.Read7BitEncodedInt(); outCode.Write7BitEncodedInt(setLocalIndex); if (setLocalIndex != 11 || (++setLocal11Itterations != 2)) continue; outCode.WriteOP(OPCode.ReturnVoid); outCode.Write(inCode.ToArray(), inCode.Position, inCode.Length - inCode.Position); windowContext.Constructor.Body.Bytecode = outCode.ToArray(); return true; } } return false; }
protected void RemoveHostSuffix(ABCFile abc, ASMethod connectMethod) { using (var inCode = new FlashReader(connectMethod.Body.Bytecode)) using (var outCode = new FlashWriter(inCode.Length)) { int ifNeCount = 0; while (inCode.Position != inCode.Length) { OPCode op = inCode.ReadOP(); outCode.WriteOP(op); if (op == OPCode.IfNe && ++ifNeCount == 2) { var iFNeJumpCount = (int)inCode.ReadS24(); outCode.WriteS24(iFNeJumpCount + 6); continue; } else if (op != OPCode.PushInt) continue; int pushIntIndex = inCode.Read7BitEncodedInt(); int integerValue = abc.Constants.Integers[pushIntIndex]; switch (integerValue) { case 65244: case 65185: case 65191: case 65189: case 65188: case 65174: case 65238: case 65184: case 65171: case 65172: { pushIntIndex = abc.Constants.AddInteger(65290); break; } } outCode.Write7BitEncodedInt(pushIntIndex); } connectMethod.Body.Bytecode = outCode.ToArray(); } RemoveDeadFalseConditions(connectMethod.Body); }