Generally malwares are defined as security threat for computing systems and computer networks. Today's common and most used method for detecting malwares is signature-based method. There is also another way that focuses on file behavior. More over, recent researches used data mining and machine learning and other heuristic solutions for malware detection. In the current research, new method based on opcode sequences extraction has been introduced. Markov Blanket Algorithm has been used as a feature selection method to reduce the number of features. Using Markov Blanket reduced features size about 99%. Finally, a Hidden Markov Model has been trained based on the best features. Experimental results revealed that the trained model detects malwares with about 99% precision and 98% sensitivity.