예제 #1
0
 public void UpdateCredentialsInVault(PasswordCredential credential)
 {
     MethodCalls.Add(
         new Tuple <string, IList <object> >("UpdateCredentialsInVault", new List <object> {
         credential
     }));
 }
        public override void VisitInvocationExpression(InvocationExpressionSyntax node)
        {
            IEnumerable <IdentifierNameSyntax> objectAndMethod = node.Expression.DescendantNodes()
                                                                 .OfType <IdentifierNameSyntax>()
                                                                 .TakeLast(2);

            if (objectAndMethod.Count() == 2)
            {
                // Assumption: for this analyser, assuming that variables are declared with a type (not var/base class/interface)
                IdentifierNameSyntax classIdentifier = objectAndMethod.First();
                SyntaxNode           declaration     = IdentifierDeclarationFinder.Find(classIdentifier);
                string className = declaration != null
                    ? declaration.ChildNodes().OfType <VariableDeclarationSyntax>().FirstOrDefault()?.Type.ToString()
                                   // no declaration was found, assume static method
                    : classIdentifier.Identifier.Text;

                MethodCalls.Add(new MethodCallHolder(className, node));
            }
            else
            {
                string className = node.Ancestors()
                                   .OfType <ClassDeclarationSyntax>()
                                   .FirstOrDefault()?
                                   .Identifier
                                   .Text;

                MethodCalls.Add(new MethodCallHolder(className, node));
            }

            base.VisitInvocationExpression(node);
        }
예제 #3
0
 internal void MoveCallsFrom(Method other)
 {
     foreach (var methodCall in other.MethodCalls)
     {
         methodCall.Source = this;
         MethodCalls.Add(methodCall);
     }
     other.MethodCalls.Clear();
 }
예제 #4
0
 public void LoadPlaylist(PlaylistItemCollection playlistItemCollection)
 {
     LoadPlaylistCallCount++;
     MethodCalls.Add("LoadPlaylist", playlistItemCollection);
 }
예제 #5
0
        public PasswordCredential GetCredentialsFromVault()
        {
            MethodCalls.Add(new Tuple <string, IList <object> >("GetCredentialsFromVault", new List <object>()));

            return(OnGetCredentialsFromVault != null?OnGetCredentialsFromVault() : new PasswordCredential());
        }
예제 #6
0
        public void Analyse()
        {
            if (IsEmpty)
            {
                return;
            }
            if (Il2CppMethod != null)
            {
                if (!Il2CppMethod.VirtualAddress.HasValue)
                {
                    return;
                }

                X86DisassembleMode      mode         = Owner.AppModel.Image.Arch == "x64" ? X86DisassembleMode.Bit64 : X86DisassembleMode.Bit32;
                CapstoneX86Disassembler disassembler = CapstoneDisassembler.CreateX86Disassembler(mode);
                disassembler.EnableInstructionDetails = true;

                var asm = disassembler.Disassemble(Il2CppMethod.GetMethodBody(), (long)Il2CppMethod.VirtualAddress.Value.Start);
                foreach (X86Instruction ins in asm)
                {
                    if (Dissasembler.ShouldCheckInstruction(ins.Id))
                    {
                        UnitorMethod m = Dissasembler.GetMethodFromInstruction(ins, Owner);
                        if (m != null)
                        {
                            MethodCalls.Add(m);
                            Owner.MethodReferences.AddOrUpdate(m, new List <UnitorMethod>(), (key, references) => { references.Add(this); return(references); });
                        }
                        var s = Dissasembler.GetStringFromInstruction(ins, Owner.StringTable);
                        if (!string.IsNullOrEmpty(s.Item2))
                        {
                            Strings.Add(new KeyValuePair <ulong, string>(s.Item1, s.Item2));
                        }
                    }
                }
                disassembler.Dispose();
            }
            else
            {
                if (!MonoMethod.HasBody)
                {
                    return;
                }

                foreach (Instruction ins in MonoMethod.Body.Instructions)
                {
                    if ((ins.OpCode.Code == Code.Call || ins.OpCode.Code == Code.Calli || ins.OpCode.Code == Code.Callvirt) && ins.Operand is MethodDef calledMethod)
                    {
                        if (Owner.MonoTypeMatches.TryGetValue(calledMethod.DeclaringType, out UnitorType type))
                        {
                            if (type.Methods == null)
                            {
                                continue;
                            }
                            UnitorMethod method = type.Methods.FirstOrDefault(m => calledMethod.Name == m.Name);
                            MethodCalls.Add(method);
                            Owner.MethodReferences.AddOrUpdate(method, new List <UnitorMethod>(), (key, references) => { references.Add(this); return(references); });
                        }
                    }
                    if (ins.OpCode.Code == Code.Ldstr && ins.Operand is string s)
                    {
                        Strings.Add(new KeyValuePair <ulong, string>((ulong)(MonoMethod.RVA + ins.Offset), s));
                    }
                }
            }
        }