/// <summary> /// Identifying method for JFIF/JPEG/JPG /// </summary> /// <param name="filename">fiel name</param> /// <returns>identified sig</returns> public static FASignature IdentifyJPEG(string filename) { string buffer = File.ReadAllText(filename); int index = BoyerMooreString.IndexOf(buffer, "JFIF");//jfif files have a section with an ASCII JFIF\0 that will identify it. //most JPGs conform to the JFIF standard if (index != -1) { Console.WriteLine(index); return(new FASignature("FF D8 FF E0", "JFIF", 0, "JPEG File Interchange Format is an image file format standard")); } return(new FASignature("FF D8 FF E0", "JPEG", 0, "JPEG/JPG Image Format")); }
/// <summary> /// primitive scanner using boyer moore to identify something. /// </summary> /// <param name="filename"></param> /// <returns></returns> private static bool TestTSQL(string filename) { string[] tsql_keywords = { "SELECT", "FROM", "WHERE", "ORDER BY", "GROUP BY", "HAVING" }; //simple example of keywords string text = File.ReadAllText(filename); int count = 0, threshold = 6; foreach (string keyword in tsql_keywords) { if (BoyerMooreString.IndexOf(text, keyword) > -1) { count++; } } if (count > threshold) { Console.WriteLine("Possible TSQL File!"); return(true); } return(false); }