Exemplo n.º 1
0
        public List <VirusDS> getViruses(string signature, int position)
        {
            List <VirusDS> viruses = new List <VirusDS>();

            connection.Open();
            var command = connection.CreateCommand();

            command.CommandText = $@"
                SELECT * FROM viruses 
                    WHERE Signature Like '{signature}%' 
                                AND OffsetBegin <= {position} 
                                AND OffsetEnd >= {position}
            ";

            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    VirusDS virus = new VirusDS(
                        Int32.Parse(reader.GetString(0)),
                        reader.GetString(1),
                        reader.GetString(2),
                        Int32.Parse(reader.GetString(3)),
                        Int32.Parse(reader.GetString(4))
                        );
                    viruses.Add(virus);
                }
            }
            connection.Close();
            return(viruses);
        }
Exemplo n.º 2
0
        private bool signatureOnFullMatch(VirusDS virus, byte[] data, int offset)
        {
            string signature        = this.getStringOfBytes(data, offset, virus.signature.Length / 2);
            bool   signatureInFrame = (offset + virus.signature.Length) < virus.offsetEnd;

            if (signature.Equals(virus.signature) && signatureInFrame)
            {
                return(true);
            }
            return(false);
        }