A virus detection system (VDS) based on artificial immune system (AIS) is proposed in this paper. VDS at first generates the detector set from virus files in the dataset, negative selection and clonal selection are applied to the detector set to eliminate autoimmunity detectors and increase the diversity of the detector set in the non-self space respectively. Two novel hybrid distances called hamming-max and shift r bit-continuous distance are proposed to calculate the affinity vectors of each file using the detector set. The affinity vectors of the training set and the testing set are used to train and test classifiers respectively. VDS compares the detection rates using three classifiers, knearest neighbor (KNN), RBF networks and SVM when the length of detectors is 32 - and 64 - . The experimental results show that the proposed VDS has a strong detection ability and good generalization performance.