Skip to content
Karsten Hahn edited this page Feb 11, 2023 · 21 revisions

Report Creation

The tools package of PortEx has a ReportCreator, which prints all available file information with a nice formatting, or returns a report string for the information of your interest.

// load the PE file data
PEData data = PELoader.loadPE(new File("myfile"));

// Print report
ReportCreator reporter = new ReportCreator(data);
reporter.printReport();

// Get report parts
String anomalyReport = reporter.anomalyReport();
String importsReport = reporter.importsReport();

Header Information

//load the PE file data
PEData data = PELoader.loadPE(new File(args[0]));
			
// get various data from coff file header and print it
COFFFileHeader coff = data.getCOFFFileHeader();
MachineType machine = coff.getMachineType();
Date date = coff.getTimeDate();
int numberOfSections = coff.getNumberOfSections();
int optionalHeaderSize = coff.getSizeOfOptionalHeader();

System.out.println("machine type: " + machine.getDescription());
System.out.println("number of sections: " + numberOfSections);
System.out.println("size of optional header: " + optionalHeaderSize);
System.out.println("time date stamp: " + date);

List<FileCharacteristic> characteristics = coff.getCharacteristics();
System.out.println("characteristics: ");
for (FileCharacteristic characteristic : characteristics) {
    System.out.println("\t* " + characteristic.getDescription());
}

If printing information is the only purpose the same can be achieved using the report creator.

Clone this wiki locally