Esempio n. 1
0
        public List <VirusDataSet> GetViruses(string signature, int position)
        {
            List <VirusDataSet> viruses    = new List <VirusDataSet>();
            SqliteConnection    connection = GetConnection();

            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())
                {
                    VirusDataSet virus = new VirusDataSet(
                        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();
            //connections.Enqueue(connection);
            return(viruses);
        }
Esempio n. 2
0
        protected bool CheckSignatureFullMatch(VirusDataSet virus, byte[] data, int offset)
        {
            string signature = GetStringOfBytes(data, offset, virus.Signature.Length / 2);

            //TODO && offset + virus.Signature.Length < virus.OffsetEnd
            if (signature.Equals(virus.Signature) && offset + virus.Signature.Length < virus.OffsetEnd)
            {
                return(true);
            }
            return(false);
        }