public void setUp() { parser = new PEParser(); trueSentence = (Sentence)parser.parse("true"); falseSentence = (Sentence)parser.parse("false"); andSentence = (Sentence)parser.parse("(P AND Q)"); orSentence = (Sentence)parser.parse("(P OR Q)"); impliedSentence = (Sentence)parser.parse("(P => Q)"); biConditionalSentence = (Sentence)parser.parse("(P <=> Q)"); m = new Model(); }
private static void Dump(PEParser parser) { Console.WriteLine("File Header:"); WriteObject(parser.FileHeader); Console.WriteLine(); Console.WriteLine("Optional Header:"); WriteObject(parser.OptionalHeader); Console.WriteLine(); Console.WriteLine("Exports:"); var exports = parser.GetExports(); if (exports != null) { foreach (var export in exports) { if (export.ForwardName != null) { Console.WriteLine($"Forward name: {export.ForwardName}"); } else { Console.WriteLine($"{export.Name} {export.Ordinal} 0x{export.Address:X}"); } } } Console.WriteLine(); Console.WriteLine("Imports:"); var imports = parser.GetImports(); if (imports != null) { foreach (var import in imports) { Console.WriteLine($"{import.LibraryName}"); foreach (var imp in import.Symbols) { Console.WriteLine($"\t{imp.Name}"); } } } Console.WriteLine(); Console.WriteLine("Debug Information:"); var debug = parser.GetDebugInformation(); if (debug != null) { WriteObject(debug); } }
static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Usage: dumppe [options] <filename>"); } try { var parser = new PEParser(args.Last()); Dump(parser); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } }
public void setUp() { classifier = new SymbolClassifier(); parser = new PEParser(); }
public void setUp() { parser = new PEParser(); gatherer = new CNFClauseGatherer(); }
public KnowledgeBase() { this.Sentences = new List <Sentence>(); parser = new PEParser(); }
public void setUp() { parser = new PEParser(); dpll = new DPLL(); }
public KnowledgeBase() { sentences = new ArrayList(); parser = new PEParser(); }
public void setUp() { parser = new PEParser(); collector = new SymbolCollector(); }
public void setUp() { parser = new PEParser(); }
public void setUp() { resolution = new PLResolution(); parser = new PEParser(); }
public static void Main(string[] args) { int i; byte[] buf = null; bool parsedExeName = false; string inFileName = null, reportFileName = null; FileStream inFileStream = null; BinaryReader inFileReader = null; string[] fileList = null; //char[] counter = new char[2]{(char)0, '\0'}; // initializes the string counter used to obfuscate strings char[] counter = new char[2] { (char)0x2F, '\0' }; // initializes the string counter used to obfuscate strings ArrayList mdInfoList = new ArrayList(); // this list stores all the MetaData section of all modules in this assembly if (args.Length == 0) { Usage(); Exit(RETURN_FAIL + RETURN_BAD_ARGUMENT); } for (i = 0; i < args.Length; i++) { ParseArguments(0, ref parsedExeName, args[i], ref inFileName, ref reportFileName); } if (!m_NoLogoFlag) { Console.WriteLine(Environment.NewLine + "OBFUS - .NET Assembly Obfuscation Utility. Version " + Util.Version.VersionString); Console.WriteLine("Copyright (C) Microsoft Corporation. 2000-2002. All rights reserved." + Environment.NewLine); } if (m_HelpFlag) { Usage(); Exit(RETURN_PASS); } if (m_errno != 0) // we have encountered an error while parsing the arguments { Console.WriteLine(m_errmsg); Exit(m_errno); } if (inFileName == null) { Console.WriteLine(" ERROR: Input binary CIL file is not specified."); Exit(RETURN_FAIL + RETURN_CANNOT_OPEN_FILE); } try // this try is only responsible for opening the input file { inFileStream = File.Open(inFileName, FileMode.Open, FileAccess.Read, FileShare.Read); } catch (Exception e) { Console.WriteLine(" ERROR: " + e.Message); Exit(RETURN_FAIL + RETURN_CANNOT_OPEN_FILE); } // TODO : There is a problem with System.dll. If we have not closed the stream and if DEBUG is defined, then // when the obfuscator needs to load the System.Diagnostic.Debug class, it fails. However, we cannot // really close the stream, because we are still accessing the file in the method ParsePEFile. // The workaround is to copy System.dll, obfuscate the copy, and then replace the original one with the // obfuscated version. try // this try is responsbile for parsing the headers of the input file { inFileReader = new BinaryReader(inFileStream); buf = PEParser.ParsePEFile(ref inFileReader); // parse the input file } catch (EndOfStreamException) { // We have to change the error message for this type of exception. The original message says // "Unable to read beyond the end of the stream". Console.WriteLine(" ERROR: Invalid CIL binary file format."); Exit(RETURN_FAIL + RETURN_BAD_FILE_FORMAT); } catch (Exception e) { Console.WriteLine(" ERROR: " + e.Message); Exit(RETURN_FAIL + RETURN_BAD_FILE_FORMAT); } try // this try is responsible for creating the output directory if necessary { if (!Directory.Exists(m_outFilePath)) { Directory.CreateDirectory(m_outFilePath); } if (m_outFilePath[m_outFilePath.Length - 1] != '\\') { m_outFilePath = String.Concat(m_outFilePath, "\\"); } } catch (Exception e) { Console.WriteLine(" ERROR: " + e.Message); Exit(RETURN_FAIL + RETURN_CANNOT_CREATE_DIR); } try // do the obfuscation { m_mdSection = new MetaData(ref buf); m_obfuscator = new Obfus(ref m_mdSection, ref counter, inFileName, ref mdInfoList, ref fileList, true); m_obfuscator.Initialize(); m_obfuscator.FinishInitialization(); m_obfuscator.ObfuscateAllModules(); } catch (InvalidFileFormat) { Console.WriteLine(" ERROR: Invalid CIL binary file format."); Exit(RETURN_FAIL + RETURN_BAD_FILE_FORMAT); // we need to give the correct error code here } catch (NotEnoughSpace) { Console.WriteLine(" UNSUCCESSFUL: There is not enough space in the string heap to finish obfuscation."); Exit(RETURN_FAIL + RETURN_NOT_ENOUGH_SPACE); // we need to give the correct error code here } catch (Exception e) { Console.WriteLine(" ERROR: " + e.Message); Exit(RETURN_FAIL); } if (!m_SuppressFlag) // suppress warning messages if this flag is set { // Give a warning for each class which is in the exclude list but does not actually exist in the assembly. for (IDictionaryEnumerator excludeEnum = m_excludeTypeNames.GetEnumerator(); excludeEnum.MoveNext();) { if (!(bool)excludeEnum.Value) { Console.WriteLine(" WARNING: Class " + ((Obfus.NameSpaceAndName)excludeEnum.Key).nameSpace.Trim('\0') + "." + ((Obfus.NameSpaceAndName)excludeEnum.Key).name.Trim('\0') + " does not exist."); } } } if (m_VerboseFlag) { PrintStats(reportFileName); // print the statistics if necessary } // This call also closes the underlying stream. Moreover, this call is delayed until the end so that the input // file will not be overwritten. inFileReader.Close(); Exit(RETURN_PASS); }