-------------------------------------------------------------------------------------------------
FEATURES
-------------------------------------------------------------------------------------------------

From the proposal:
- Listing all EFI drivers loaded into memory and dumping them to a specified disk - DONE
- Probing entire memory range, scanning for executable files and dumping them when they are found - DONE
- Monitoring all newly loaded drivers until operating system starts and dumping them if they are found - DONE
- Listing and scanning EFI BOOT SERVICES and EFI RUNTIME SERVICES for modified function pointers. Detecting 
redirections and displaying the module to which they point to - DONE
- Displaying memory map and dumping all suitable regions. - DONE
- Continually monitoring EFI BOOT SERVICES and EFI RUNTIME SERVICES while operating system is being loaded. Logging all changes to a log file. - DONE
- Listing and monitoring EVENT callbacks that can be used by rootkits/malware. Initial support for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE. - DONE + EXTENDED TO ALL EVENTS
- Storing output to a console and a log file, e.g. USB thumb drive or external storage. - DONE
- Working in a standalone mode without the EFI shell - DONE

EXTRA FEATURES:
- context functions/context dump
- idt/gdt functions/dump
- serial (com) output
- detecting modifications to drivers and their code sections (checksums)
- screen apis + splash logo
- scanning boot services and runtime services pointers in images
- configuration file
- hook detection for selected runtime/boot time services plus displaying
where the hook points to

- some gEventSignalQueueAddr resolver for mac mini and asrock mobo
(maybe it should be cut from this version and put into the next milestone?)
- same goes for the memory map patch for mac mini

-------------------------------------------------------------------------------------------------
FILES
-------------------------------------------------------------------------------------------------

- EfiScannerPkg\EfiScannerDxe					-	framework source code and scanner in one (DXE driver)
- EfiScannerPkg\EfiScannerLib					-	just an .inf file to generate library
- EfiScannerPkg\EfiScannerIncludes				-   	main include file (copied from EfiScannerDxe)
- EfiScannerPkg\EfiScannerApp					-	shows sample attacks

- EfiScannerClientPkg\EfiScannerClientApp			- 	sample application which is using framework APIs

-------------------------------------------------------------------------------------------------
DOCUMENTATION
-------------------------------------------------------------------------------------------------

Generated by doxygen based on the comments in the source files. 
Check "html/index.html"


-------------------------------------------------------------------------------------------------
PROBLEMS AND OBSERVATIONS
-------------------------------------------------------------------------------------------------

- It is better to use the "Display and dump memory map (skip Reserved and MemoryMappedIO mem)"
option instead of the normal memory map dump because sometimes after accessing MemoryMappedIO
the media controller may stop responding and the EFI will return error EFI_DEVICE_ERROR.
Additionally all future file operations will be cancelled (you need to reset the machine).
Same goes for probing the memory while searching for PE files. EFI support for
FAT32 seems to be often unstable - no idea why this happens maybe it is related to the
huge amounts of data we are writing or to reading some "sensitive" parts of physical
memory. Another theory is that appending to my observations following issues
are always happening after dumping huge files to the disk. Even though the FAT32
limitation per single file is 4GB (max volume is 2TB) it appears that often 
after dumping more than 4GB data to the disk weird things start to happen.  



- On Asrock the EFI firmware seems to be completely ignoring the File->Flush() operation.
Meaning the data will be flushed to file only after successful File->Close(). So when your system
freezes before this happens your log may be empty. Potential solution to this issue would be to
Open-Write-Close the log file after every call to LogFullAscii however this would decrease the
performance. Another solution (if you are working with EFI shell) is to type "edit log.txt".

- do not use AllocatePages on mac apple firmware. It will fault when GetMemoryMap will be executed
with memory from AllocatePages as a parameter (fixed)

- on mac miniQueryCapsuleCapabilities/CreateEventEx functions are unavailable so checking such
invalid areas for call/jmp opcodes will end up with system crash (fixed)

- in conf.txt you can describe the range that would be excluded from the brute PE scan.


-------------------------------------------------------------------------------------------------
COMPILING
-------------------------------------------------------------------------------------------------

Platform prerequisites:
- Microsoft Windows 7 (x86/x64)
- Microsoft Visual Studio 2008 with SP1

Prerequisites for RDFU source code compilation:
- 7zip
- TortoiseSVN
- EDK 2

Installing EDK 2:
- Install TortoiseSVN (x86/x64)
- Create a new folder named EDK under X:\
  Or any other drive letter, X is just an example
- Right click inside the EDK folder in Explorer and select SVN Checkout
- Enter the following URL: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2
- Select [OK]

Compiling RDFU:
- Open CMD and change folder to X:\EDK
- Type: edksetup.bat
- Extract RDFU\src with 7zip to X:\EDK
  Folders EfiScannerClientPkg and EfiScannerPkg should be in X:\EDK
- Type: notepad Conf\target.txt
- Edit the following items:
  ACTIVE_PLATFORM			=  EfiScannerPkg/EfiScannerPkg.dsc 
  TARGET				=  RELEASE	
  TARGET_ARCH				=  X64 # IA32 is for x86
  TOOL_CHAIN_TAG			=  VS2008
    Or VS2008x86 if you have Windows 7 x64
- Type: build
- After the compilation finishes files are located in X:\EDK\Build
  You can repeat the process for IA32 but since you need to install VM for both x86 and x64 its simpler to test just x64.
- Type: notepad Conf\target.txt
- Edit the following items:
  ACTIVE_PLATFORM  =  EfiScannerClientPkg/EfiScannerClientPkg.dsc
- Type: build
- After the compilation finishes files are located in X:\EDK\Build
  You can repeat the process for IA32 but since you need to install VM for both x86 and x64 its simpler to test just x64.


-------------------------------------------------------------------------------------------------
VMWARE INSTALLATION
-------------------------------------------------------------------------------------------------

Make sure your vmware is configured to use EFI firmware -> in your virtual machine configuration
file (.vmx) you should have following line:

firmware = "efi"


Also guestOS variable should be set correctly depending on the architecture you want to use for example:
guestOS = "windows8-64"		


You also need to either add a physical USB device to your machine or to add a sample hard drive.
Both USB and hard drive must be formatted with FAT32 file system. You will need to mount
the hard drive to windows to copy our EFI files there. Make sure they have at least
4GB free space.


(this is automated for USB installation)
For vmware you can just copy files from "copy_to_vmware_disk"
to your vmware drive.

(check the attached video)


Put the selecting files to the USB/hard drive:
- EfiScannerDxe.efi		- main RDFU scanner driver
- EfiTestApp.efi		- sample app for testing few attacks
- EfiScannerClientApp.efi	- sample app that is using framework functions


You also need to create following directories 
- dump				- all dumped images will be placed here
- mdump				- dumped memory regions will be placed here
- sdump				- dumped images from image sniffer will be placed here
- bdump				- dumped images gathered from brute-force memory scan will be placed here



Now run the virtual machine and boot to EFI Shell.
In the efi shell write enter the current drive by for example putting:
fs0:
ls		-> you should see your files here

if not try doing the same thing with different drive
fs1:
ls

fsX:
ls


to load the RDFU scanner type:
load EfiScannerDxe.efi
(the log file is log.txt you can also follow the output on the screen or through
serial port just add one in vmware)


to run other apps type:
EfiTestApp.efi 
EfiScannerClientApp.efi


-------------------------------------------------------------------------------------------------
USB INSTALL
-------------------------------------------------------------------------------------------------

To install on USB you need to format the USB thumb drive, set an active partition and copy
all the necessary files. the "INSTALL_USB_NEEDADMIN.bat" will do it for you. 


-------------------------------------------------------------------------------------------------
References
-------------------------------------------------------------------------------------------------
- http://www.uefi.org/specs/download/UEFI_Specification_2_and_Errata_Sept16_08.pdf
- ftp://byosoft.com.cn/UEFI/UEFI%20Overview.pdf
- http://voxel.dl.sourceforge.net/project/edk2/General%20Documentation/EDKII%20Module%20Writer_s%20Guide_0_7.pdf
- edk 2
- refit/refind
- http://wiki.phoenix.com
