XNU Image Fuzzer 1.8.2
Documentation for XNU Image Fuzzer
|
XNU Image Fuzzer. More...
import <Foundation/Foundation.h>
import <UIKit/UIKit.h>
import <CoreGraphics/CoreGraphics.h>
import "AppDelegate.h"
import <os/log.h>
import <os/signpost.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <math.h>
#include <stdbool.h>
#include <float.h>
#include <string.h>
#include <stdint.h>
#include <sys/sysctl.h>
import <ImageIO/ImageIO.h>
import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
Go to the source code of this file.
Macros | |
#define | ALL -1 |
Defines constants for general application configuration. | |
#define | MAX_PERMUTATION 12 |
#define | COMM_PAGE64_BASE_ADDRESS (0x0000000FFFFFC000ULL) |
#define | COMM_PAGE_CPU_CAPABILITIES64 (COMM_PAGE64_BASE_ADDRESS + 0x010) |
#define | MAX_PERMUTATION 12 |
#define | COMM_PAGE_VERSION (COMM_PAGE64_BASE_ADDRESS + 0x01E) |
#define | COMM_PAGE_NCPUS (COMM_PAGE64_BASE_ADDRESS + 0x022) |
#define | COMM_PAGE_CACHE_LINESIZE (COMM_PAGE64_BASE_ADDRESS + 0x026) |
#define | COMM_PAGE_SCHED_GEN (COMM_PAGE64_BASE_ADDRESS + 0x028) |
#define | COMM_PAGE_MEMORY_PRESSURE (COMM_PAGE64_BASE_ADDRESS + 0x02c) |
#define | COMM_PAGE_SPIN_COUNT (COMM_PAGE64_BASE_ADDRESS + 0x030) |
#define | COMM_PAGE_KDEBUG_ENABLE (COMM_PAGE64_BASE_ADDRESS + 0x044) |
#define | COMM_PAGE_ATM_DIAGNOSTIC_CONFIG (COMM_PAGE64_BASE_ADDRESS + 0x048) |
#define | COMM_PAGE_BOOTTIME_USEC (COMM_PAGE64_BASE_ADDRESS + 0x0C8) |
#define | COMM_PAGE_ACTIVE_CPUS (COMM_PAGE64_BASE_ADDRESS + 0x034) |
#define | COMM_PAGE_PHYSICAL_CPUS (COMM_PAGE64_BASE_ADDRESS + 0x035) |
#define | COMM_PAGE_LOGICAL_CPUS (COMM_PAGE64_BASE_ADDRESS + 0x036) |
#define | COMM_PAGE_MEMORY_SIZE (COMM_PAGE64_BASE_ADDRESS + 0x038) |
#define | COMM_PAGE_CPUFAMILY (COMM_PAGE64_BASE_ADDRESS + 0x040) |
#define | COMM_PAGE_CPU_CAPABILITIES64 (COMM_PAGE64_BASE_ADDRESS + 0x010) |
#define | _XOPEN_SOURCE |
Provides ANSI color codes for enhancing console output readability. | |
#define | MAG(string) "\x1b[0;35m" string RESET_COLOR |
#define | BLUE(string) "\x1b[34m" string RESET_COLOR |
#define | RED(string) "\x1b[31m" string RESET_COLOR |
#define | WHT(string) "\x1b[0;37m" string RESET_COLOR |
#define | GRN(string) "\x1b[0;32m" string RESET_COLOR |
#define | YEL(string) "\x1b[0;33m" string RESET_COLOR |
#define | CYN(string) "\x1b[0;36m" string RESET_COLOR |
#define | HWHT(string) "\x1b[0;97m" string RESET_COLOR |
#define | NORMAL_COLOR(string) "\x1B[0m" string RESET_COLOR |
#define | RESET_COLOR "\x1b[0m" |
#define | INJECT_STRING_1 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" |
Configures robust strings for security testing within the application. | |
#define | INJECT_STRING_2 "<script>console.error('XNU Image Fuzzer');</script>" |
#define | INJECT_STRING_3 "' OR ''='" |
#define | INJECT_STRING_4 "%d %s %d %s" |
#define | INJECT_STRING_5 "XNU Image Fuzzer" |
#define | INJECT_STRING_6 "123456; DROP TABLE users" |
#define | INJECT_STRING_7 "!@#$%^&*()_+=" |
#define | INJECT_STRING_8 "..//..//..//win" |
#define | INJECT_STRING_9 "\0\0\0" |
#define | INJECT_STRING_10 "<?xml version=\"1.0\"?><!DOCTYPE replace [<!ENTITY example \"XNUImageFuzzer\"> ]><userInfo><firstName>XNUImageFuzzer<&example;></firstName></userInfo>" |
#define | NUMBER_OF_STRINGS 10 |
#define | DebugLog(...) |
Provides macros for enhanced logging and assertions during development. | |
#define | AssertWithMessage(condition, message, ...) |
#define | READ_COMM_PAGE_VALUE(type, address) (*((type *)(address))) |
Dumps key communication page details for diagnostic purposes. | |
Functions | |
NSString * | formattedCurrentDateTime (void) |
char * | signature (void) |
void | dumpDeviceInfo (void) |
Logs comprehensive information about the current device. | |
void | dumpMacDeviceInfo (void) |
Logs system information for macOS devices. | |
void | dump_comm_page (void) |
void | printColored (const char *color, const char *message) |
Prints a message with specified ANSI color to the console. | |
BOOL | isValidImagePath (NSString *path) |
Prototypes for utility functions used in image processing. | |
unsigned long | hashString (const char *str) |
Computes a hash value for a given string. | |
UIImage * | loadImageFromFile (NSString *imageName) |
Loads an image from the application bundle into a UIImage object. | |
NSData * | UIImageGIFRepresentation (UIImage *image) |
Creates a GIF representation of a UIImage. This custom function handles the conversion of a UIImage to GIF data using the Image I/O framework. | |
NSData * | generateFuzzedImageData (size_t width, size_t height, CFStringRef imageType) |
Generates a random image for fuzzing. | |
void | processImage (UIImage *image, int permutation) |
Processes an image using various bitmap context configurations. | |
void | addAdditiveNoise (float *pixel) |
void | applyMultiplicativeNoise (float *pixel) |
void | invertColor (float *pixel) |
void | applyExtremeValues (float *pixel) |
void | assignSpecialFloatValues (float *pixel) |
void | applyColorShift (unsigned char *data, size_t index) |
Applies a color shift to a specific pixel within the image data. | |
void | applyPixelScramble (unsigned char *data, size_t index) |
Randomly scrambles the RGB values of a pixel. | |
void | createBitmapContextStandardRGB (CGImageRef cgImg, int permutation) |
Creates a bitmap context with standard RGB settings, applies a fuzzing process to alter the image, and saves the fuzzed image. Useful for testing image processing functionalities or creating varied visual effects. | |
void | createBitmapContextPremultipliedFirstAlpha (CGImageRef cgImg) |
Creates a bitmap context with Premultiplied First Alpha settings and applies image processing. | |
void | createBitmapContextNonPremultipliedAlpha (CGImageRef cgImg) |
Creates a bitmap graphics context with Non-Premultiplied Alpha settings for processing a CGImage. | |
void | createBitmapContext16BitDepth (CGImageRef cgImg) |
Creates a bitmap graphics context for 16-bit depth per channel processing. | |
void | createBitmapContextGrayscale (CGImageRef cgImg) |
void | createBitmapContextHDRFloatComponents (CGImageRef cgImg) |
Initializes a bitmap context for HDR content with floating-point components. | |
void | createBitmapContextAlphaOnly (CGImageRef cgImg) |
Creates a bitmap context for alpha channel manipulation of a CGImageRef. | |
void | createBitmapContext1BitMonochrome (CGImageRef cgImg) |
Creates a bitmap context for 1-bit monochrome image processing. | |
void | createBitmapContextBigEndian (CGImageRef cgImg) |
Creates a bitmap context with Big Endian byte ordering for image data processing. | |
void | createBitmapContextLittleEndian (CGImageRef cgImg) |
Initializes a bitmap context with Little Endian settings for image data processing. | |
void | createBitmapContext8BitInvertedColors (CGImageRef cgImg) |
Transforms the color representation of an image by inverting its colors and applying an 8-bit color depth. | |
void | createBitmapContext32BitFloat4Component (CGImageRef cgImg) |
Creates a bitmap context with standard RGB settings, applies a fuzzing process to alter the image, and saves the fuzzed image. Useful for testing image processing functionalities or creating varied visual effects. | |
void | applyFuzzingToBitmapContext (unsigned char *rawData, size_t width, size_t height) |
Applies fuzzing to the RGB components of each pixel in a bitmap context. | |
void | applyEnhancedFuzzingToBitmapContext (unsigned char *rawData, size_t width, size_t height, BOOL verboseLogging) |
Applies enhanced fuzzing techniques to bitmap data. | |
void | logPixelData (unsigned char *rawData, size_t width, size_t height, const char *message, BOOL verboseLogging) |
Logs information about a random set of pixels from an image's raw data. | |
void | convertTo1BitMonochrome (unsigned char *rawData, size_t width, size_t height) |
Converts image data to 1-bit monochrome using a simple thresholding technique. | |
void | saveMonochromeImage (UIImage *image, NSString *identifier) |
Saves a monochrome UIImage with a specified identifier to the documents directory. | |
void | saveFuzzedImage (UIImage *image, NSString *contextDescription) |
Saves a modified (fuzzed) UIImage to the documents directory. | |
NSString * | createUniqueDirectoryForSavingImages (void) |
Creates a unique directory for saving images within the documents directory. | |
void | LogRandomPixelData (unsigned char *rawData, size_t width, size_t height, const char *message) |
Logs information about a random set of pixels from an image's raw data. | |
void | applyEnhancedFuzzingToBitmapContextWithFloats (float *rawData, size_t width, size_t height, BOOL verboseLogging) |
Applies enhanced fuzzing techniques to bitmap data using 32-bit floating-point precision. | |
void | applyEnhancedFuzzingToBitmapContextAlphaOnly (unsigned char *alphaData, size_t width, size_t height, BOOL verboseLogging) |
Applies enhanced fuzzing techniques to the alpha channel of bitmap pixel data. | |
void | debugMemoryHandling (void) |
Allocates and deallocates memory chunks using mmap and munmap for debugging. | |
void | performAllImagePermutations (void) |
Generates a random image and processes it with all permutation strategies. | |
int | main (int argc, const char *argv[]) |
Entry point of the application, handling initialization, argument parsing, and image processing. | |
Variables | |
static int | verboseLogging = 0 |
Core and external libraries necessary for the fuzzer functionality. | |
char * | injectStrings [10] |
const char * | cpu_cap_strings [] |
Identifies the CPU's supported capabilities. | |
XNU Image Fuzzer.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file xnuimagefuzzer.m.
#define _XOPEN_SOURCE |
Provides ANSI color codes for enhancing console output readability.
Use these definitions to add color to console logs, improving the distinction between different types of messages. Each macro wraps a given string with the ANSI code for a specific color and automatically resets the color to default after the string. This ensures that only the intended text is colored, without affecting subsequent console output.
MAG(string)
: Magenta colored text.BLUE(string)
: Blue colored text.RED(string)
: Red colored text for errors or warnings.WHT(string)
: White colored text.GRN(string)
: Green colored text for success messages.YEL(string)
: Yellow colored text for cautionary messages.CYN(string)
: Cyan colored text for informational messages.HWHT(string)
: High-intensity white colored text.NORMAL_COLOR(string)
: Resets text color to default console color.RESET_COLOR
: ANSI code to reset text color to default.Definition at line 143 of file xnuimagefuzzer.m.
#define ALL -1 |
Defines constants for general application configuration.
This section includes definitions for constants used throughout the application to control its behavior and configuration. These constants are pivotal for ensuring the application operates within defined parameters and accesses system resources correctly.
ALL
: A special flag used to indicate an operation applies to all items or states. Useful for functions that require a broad application of their logic.MAX_PERMUTATION
: Defines the upper limit on the number of permutations that can be applied in image processing tasks. This constant helps in preventing excessive processing time and resource consumption.COMM_PAGE64_BASE_ADDRESS
: The base memory address for the comm page, which is a reserved area of memory used by the system to store variables that are accessed frequently.COMM_PAGE_CPU_CAPABILITIES64
: An offset from COMM_PAGE64_BASE_ADDRESS
that points to the CPU capabilities. Useful for quickly determining the hardware capabilities of the system.Definition at line 89 of file xnuimagefuzzer.m.
#define AssertWithMessage | ( | condition, | |
message, | |||
... ) |
Definition at line 243 of file xnuimagefuzzer.m.
#define BLUE | ( | string | ) | "\x1b[34m" string RESET_COLOR |
Definition at line 145 of file xnuimagefuzzer.m.
#define COMM_PAGE64_BASE_ADDRESS (0x0000000FFFFFC000ULL) |
Definition at line 91 of file xnuimagefuzzer.m.
Referenced by dump_comm_page(), and signature().
#define COMM_PAGE_ACTIVE_CPUS (COMM_PAGE64_BASE_ADDRESS + 0x034) |
Definition at line 110 of file xnuimagefuzzer.m.
#define COMM_PAGE_ATM_DIAGNOSTIC_CONFIG (COMM_PAGE64_BASE_ADDRESS + 0x048) |
Definition at line 108 of file xnuimagefuzzer.m.
#define COMM_PAGE_BOOTTIME_USEC (COMM_PAGE64_BASE_ADDRESS + 0x0C8) |
Definition at line 109 of file xnuimagefuzzer.m.
#define COMM_PAGE_CACHE_LINESIZE (COMM_PAGE64_BASE_ADDRESS + 0x026) |
Definition at line 103 of file xnuimagefuzzer.m.
#define COMM_PAGE_CPU_CAPABILITIES64 (COMM_PAGE64_BASE_ADDRESS + 0x010) |
Definition at line 92 of file xnuimagefuzzer.m.
Referenced by dump_comm_page().
#define COMM_PAGE_CPU_CAPABILITIES64 (COMM_PAGE64_BASE_ADDRESS + 0x010) |
Definition at line 92 of file xnuimagefuzzer.m.
#define COMM_PAGE_CPUFAMILY (COMM_PAGE64_BASE_ADDRESS + 0x040) |
Definition at line 114 of file xnuimagefuzzer.m.
#define COMM_PAGE_KDEBUG_ENABLE (COMM_PAGE64_BASE_ADDRESS + 0x044) |
Definition at line 107 of file xnuimagefuzzer.m.
#define COMM_PAGE_LOGICAL_CPUS (COMM_PAGE64_BASE_ADDRESS + 0x036) |
Definition at line 112 of file xnuimagefuzzer.m.
#define COMM_PAGE_MEMORY_PRESSURE (COMM_PAGE64_BASE_ADDRESS + 0x02c) |
Definition at line 105 of file xnuimagefuzzer.m.
#define COMM_PAGE_MEMORY_SIZE (COMM_PAGE64_BASE_ADDRESS + 0x038) |
Definition at line 113 of file xnuimagefuzzer.m.
#define COMM_PAGE_NCPUS (COMM_PAGE64_BASE_ADDRESS + 0x022) |
Definition at line 102 of file xnuimagefuzzer.m.
#define COMM_PAGE_PHYSICAL_CPUS (COMM_PAGE64_BASE_ADDRESS + 0x035) |
Definition at line 111 of file xnuimagefuzzer.m.
#define COMM_PAGE_SCHED_GEN (COMM_PAGE64_BASE_ADDRESS + 0x028) |
Definition at line 104 of file xnuimagefuzzer.m.
#define COMM_PAGE_SPIN_COUNT (COMM_PAGE64_BASE_ADDRESS + 0x030) |
Definition at line 106 of file xnuimagefuzzer.m.
#define COMM_PAGE_VERSION (COMM_PAGE64_BASE_ADDRESS + 0x01E) |
Definition at line 101 of file xnuimagefuzzer.m.
#define CYN | ( | string | ) | "\x1b[0;36m" string RESET_COLOR |
Definition at line 150 of file xnuimagefuzzer.m.
#define DebugLog | ( | ... | ) |
Provides macros for enhanced logging and assertions during development.
This section defines two key macros designed to assist in the debugging process, ensuring that developers can log detailed information and perform assertions with customized messages. These macros are especially useful in DEBUG builds, where additional context can significantly aid in diagnosing issues.
DebugLog
: This macro is used for logging detailed debug information, including the name of the current function and the line number from where it's called. It's instrumental in tracing the execution flow or pinpointing the location of specific events or states in the code.AssertWithMessage
: This macro allows for the execution of assertions that, upon failure, log a custom message. It's valuable for validating assumptions within the code and providing immediate feedback if those assumptions are violated.Use the DebugLog
macro to log messages with additional context, such as the function name and line number. This macro is only active in DEBUG builds, helping to avoid the potential exposure of sensitive information in release builds.
Definition at line 226 of file xnuimagefuzzer.m.
#define GRN | ( | string | ) | "\x1b[0;32m" string RESET_COLOR |
Definition at line 148 of file xnuimagefuzzer.m.
#define HWHT | ( | string | ) | "\x1b[0;97m" string RESET_COLOR |
Definition at line 151 of file xnuimagefuzzer.m.
#define INJECT_STRING_1 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" |
Configures robust strings for security testing within the application.
These strings are tailored to simulate a variety of inputs aimed at testing the application's resilience against common and uncommon vulnerabilities. They include tests for SQL injections, XSS, buffer overflows, and more.
INJECT_STRING_1
to INJECT_STRING_10
: Each string targets different aspects of security handling, from special character processing to injection attacks.NUMBER_OF_STRINGS
: Denotes the total number of defined injection strings, aiding in their application across varied test scenarios.
Definition at line 177 of file xnuimagefuzzer.m.
#define INJECT_STRING_10 "<?xml version=\"1.0\"?><!DOCTYPE replace [<!ENTITY example \"XNUImageFuzzer\"> ]><userInfo><firstName>XNUImageFuzzer<&example;></firstName></userInfo>" |
Definition at line 186 of file xnuimagefuzzer.m.
#define INJECT_STRING_2 "<script>console.error('XNU Image Fuzzer');</script>" |
Definition at line 178 of file xnuimagefuzzer.m.
#define INJECT_STRING_3 "' OR ''='" |
Definition at line 179 of file xnuimagefuzzer.m.
#define INJECT_STRING_4 "%d %s %d %s" |
Definition at line 180 of file xnuimagefuzzer.m.
#define INJECT_STRING_5 "XNU Image Fuzzer" |
Definition at line 181 of file xnuimagefuzzer.m.
#define INJECT_STRING_6 "123456; DROP TABLE users" |
Definition at line 182 of file xnuimagefuzzer.m.
#define INJECT_STRING_7 "!@#$%^&*()_+=" |
Definition at line 183 of file xnuimagefuzzer.m.
#define INJECT_STRING_8 "..//..//..//win" |
Definition at line 184 of file xnuimagefuzzer.m.
#define INJECT_STRING_9 "\0\0\0" |
Definition at line 185 of file xnuimagefuzzer.m.
#define MAG | ( | string | ) | "\x1b[0;35m" string RESET_COLOR |
Definition at line 144 of file xnuimagefuzzer.m.
#define MAX_PERMUTATION 12 |
Definition at line 90 of file xnuimagefuzzer.m.
#define MAX_PERMUTATION 12 |
Definition at line 90 of file xnuimagefuzzer.m.
#define NORMAL_COLOR | ( | string | ) | "\x1B[0m" string RESET_COLOR |
Definition at line 152 of file xnuimagefuzzer.m.
#define NUMBER_OF_STRINGS 10 |
Definition at line 187 of file xnuimagefuzzer.m.
Referenced by applyEnhancedFuzzingToBitmapContext(), applyEnhancedFuzzingToBitmapContextWithFloats(), applyFuzzingToBitmapContext(), and createBitmapContextHDRFloatComponents().
#define READ_COMM_PAGE_VALUE | ( | type, | |
address ) (*((type *)(address))) |
Dumps key communication page details for diagnostic purposes.
This function extracts and logs essential details from the system's communication page, such as the signature, version, and number of CPUs, along with CPU capabilities. It utilizes the READ_COMM_PAGE_VALUE
macro to read values directly from specified memory addresses, facilitating a low-level inspection of system configurations and capabilities.
COMM_PAGE_CPU_CAPABILITIES64
address. Each capability is checked and logged, indicating whether it is supported.This function does not take any parameters.
This function does not return a value.
[*] COMM_PAGE_SIGNATURE: <signature_value>
or [*] COMM_PAGE_SIGNATURE: Error reading signature.
[*] COMM_PAGE_VERSION: <version_number>
[*] COMM_PAGE_NCPUS: <cpu_count>
READ_COMM_PAGE_VALUE
macro is crucial for the function's operation, casting the specified address to the appropriate type before dereferencing.READ_COMM_PAGE_VALUE
macro for how memory addresses are read.Definition at line 500 of file xnuimagefuzzer.m.
Referenced by dump_comm_page().
#define RED | ( | string | ) | "\x1b[31m" string RESET_COLOR |
Definition at line 146 of file xnuimagefuzzer.m.
#define RESET_COLOR "\x1b[0m" |
Definition at line 153 of file xnuimagefuzzer.m.
Referenced by printColored().
#define WHT | ( | string | ) | "\x1b[0;37m" string RESET_COLOR |
Definition at line 147 of file xnuimagefuzzer.m.
#define YEL | ( | string | ) | "\x1b[0;33m" string RESET_COLOR |
Definition at line 149 of file xnuimagefuzzer.m.
void addAdditiveNoise | ( | float * | pixel | ) |
void applyColorShift | ( | unsigned char * | data, |
size_t | index ) |
Applies a color shift to a specific pixel within the image data.
This method modifies the RGB values of the specified pixel by randomly increasing or decreasing these values, which can simulate color distortion effects useful in fuzzing tests.
data | The raw image data array. |
index | The index of the pixel within the data array where the color shift will be applied. |
Definition at line 942 of file xnuimagefuzzer.m.
Referenced by applyEnhancedFuzzingToBitmapContext().
void applyEnhancedFuzzingToBitmapContext | ( | unsigned char * | rawData, |
size_t | width, | ||
size_t | height, | ||
BOOL | verboseLogging ) |
Applies enhanced fuzzing techniques to bitmap data.
This function targets the robustness of image processing routines by applying a comprehensive set of fuzzing techniques directly to the raw pixel data of a bitmap. Techniques include string injections to simulate security testing scenarios, visual distortions such as inversion, noise addition, random color adjustments, pixel value shifts, contrast modifications, and color swapping under predefined conditions. The goal is to simulate a variety of real-world inputs, both benign and malicious, thereby uncovering potential vulnerabilities and ensuring the image processing system can handle unexpected inputs gracefully.
rawData | Pointer to the raw pixel data of the bitmap, which is modified in place. This data should be in RGBA format, where each pixel is represented by four bytes for red, green, blue, and alpha components. |
width | The width of the bitmap in pixels, used to navigate the pixel data array. |
height | The height of the bitmap in pixels, indicating the total number of pixel rows in the rawData. |
verboseLogging | If enabled (true), the function logs detailed information about each fuzzing action and its effect on the pixel data, facilitating debugging and providing insights into the impact of different fuzzing techniques on the bitmap. |
Definition at line 980 of file xnuimagefuzzer.m.
References applyColorShift(), applyPixelScramble(), injectStrings, NUMBER_OF_STRINGS, and verboseLogging.
Referenced by createBitmapContext16BitDepth(), createBitmapContext8BitInvertedColors(), createBitmapContextBigEndian(), createBitmapContextLittleEndian(), createBitmapContextNonPremultipliedAlpha(), createBitmapContextPremultipliedFirstAlpha(), and createBitmapContextStandardRGB().
void applyEnhancedFuzzingToBitmapContextAlphaOnly | ( | unsigned char * | alphaData, |
size_t | width, | ||
size_t | height, | ||
BOOL | verboseLogging ) |
Applies enhanced fuzzing techniques to the alpha channel of bitmap pixel data.
This function focuses on testing and improving the resilience of image processing routines to handle unusual or extreme alpha values effectively. By manipulating the alpha transparency data in various ways, it simulates edge cases or malicious inputs that could occur in real-world applications. The function employs several fuzzing methods, including alpha inversion, setting random transparency extremes, and introducing noise, to challenge and enhance the robustness of image processing algorithms.
alphaData | Pointer to the alpha channel data of the bitmap context. This buffer contains only the alpha (transparency) values for each pixel, represented by one byte per pixel. |
width | The width of the bitmap in pixels, defining the row length in the alpha data array. |
height | The height of the bitmap in pixels, indicating the total number of rows in the alpha data. |
verboseLogging | When YES, enables detailed logging of each fuzzing operation and its impact on the alpha channel, aiding in debugging and analysis of the fuzzing effects. |
alphaData
buffer to reflect these changes. It includes initial validity checks to ensure that operations are conducted on valid data with positive dimensions, and logs a message before aborting if parameters are found to be invalid. The goal is to ensure that image processing systems are capable of handling a wide range of transparency variations, thereby enhancing both the visual quality and security of applications that rely on such routines. Definition at line 1223 of file xnuimagefuzzer.m.
References verboseLogging.
Referenced by createBitmapContextAlphaOnly().
void applyEnhancedFuzzingToBitmapContextWithFloats | ( | float * | rawData, |
size_t | width, | ||
size_t | height, | ||
BOOL | verboseLogging ) |
Applies enhanced fuzzing techniques to bitmap data using 32-bit floating-point precision.
This function is designed to test the robustness of image processing algorithms by applying a variety of fuzzing techniques to the raw pixel data of a bitmap. It iterates through a predefined set of strings, each dictating a specific fuzzing method based on its hash value. Techniques include additive and multiplicative noise, color inversion, setting extreme values, and applying special floating-point values such as NaN or Infinity. The function aims to uncover potential vulnerabilities by simulating real-world inputs and ensuring that the image processing system can gracefully handle unexpected or malicious inputs.
rawData | Pointer to the raw pixel data of the bitmap, which is modified in place. The data is assumed to be in RGBA format, with each pixel represented by four 32-bit floating-point values for red, green, blue, and alpha components. |
width | The width of the bitmap in pixels, used to calculate the location of each pixel in the rawData array. |
height | The height of the bitmap in pixels, used along with the width to navigate through the rawData array. |
verboseLogging | A boolean value that, when set to YES, enables detailed logging of each fuzzing action and its effects on the pixel data. This facilitates debugging and provides insights into how different fuzzing techniques impact the bitmap. |
Definition at line 1139 of file xnuimagefuzzer.m.
References hashString(), injectStrings, NUMBER_OF_STRINGS, and verboseLogging.
Referenced by createBitmapContext32BitFloat4Component(), and createBitmapContextHDRFloatComponents().
void applyExtremeValues | ( | float * | pixel | ) |
void applyFuzzingToBitmapContext | ( | unsigned char * | rawData, |
size_t | width, | ||
size_t | height ) |
Applies fuzzing to the RGB components of each pixel in a bitmap context.
This function introduces small, random variations to the RGB values of each pixel to test the resilience of image processing algorithms to input data variations. The fuzzing process adjusts the R, G, and B components of each pixel within a specified range, while optionally encoding additional data into the alpha channel of the first row of pixels. This method is useful for evaluating how image processing systems handle slight inconsistencies or errors in visual data.
rawData | Pointer to the bitmap's raw pixel data, modified in-place. Assumes RGBA format, with 4 bytes per pixel. RGB components are randomly adjusted, and the alpha channel of certain pixels may encode additional data. |
width | The width of the bitmap in pixels, determining the row length in the data array. |
height | The height of the bitmap in pixels, indicating the total number of rows. |
arc4random_uniform
for a uniform distribution of fuzz factors, avoiding biases.rawData
, requiring users to back up original data if preservation is needed.Definition at line 1281 of file xnuimagefuzzer.m.
References injectStrings, and NUMBER_OF_STRINGS.
void applyMultiplicativeNoise | ( | float * | pixel | ) |
void applyPixelScramble | ( | unsigned char * | data, |
size_t | index ) |
Randomly scrambles the RGB values of a pixel.
This method swaps the values of two RGB channels at the given pixel index, which can help in uncovering issues related to incorrect channel processing or assumptions in color models.
data | The raw image data. |
index | The index of the pixel where the RGB channels will be scrambled. |
Definition at line 958 of file xnuimagefuzzer.m.
Referenced by applyEnhancedFuzzingToBitmapContext().
void assignSpecialFloatValues | ( | float * | pixel | ) |
void convertTo1BitMonochrome | ( | unsigned char * | rawData, |
size_t | width, | ||
size_t | height ) |
Converts image data to 1-bit monochrome using a simple thresholding technique.
This function iterates over each pixel in the input image data, applying a fixed threshold to determine if a pixel should be black or white in the resulting monochrome image. This is a basic form of binarization, suitable for simplifying images or preparing them for certain types of processing where color is not needed.
rawData | Pointer to the image data. |
width | The width of the image in pixels. |
height | The height of the image in pixels. |
Definition at line 759 of file xnuimagefuzzer.m.
Referenced by createBitmapContext1BitMonochrome().
void createBitmapContext16BitDepth | ( | CGImageRef | cgImg | ) |
Creates a bitmap graphics context for 16-bit depth per channel processing.
This function is tailored for scenarios requiring high color fidelity, utilizing 16-bit depth per channel to enhance color range and reduce artifacts. It's ideal for high-quality image processing and editing, ensuring the highest fidelity in color information. The process involves validating the source image, allocating a memory buffer with adequate depth, setting up a suitable color space, configuring and rendering into the bitmap context, applying custom image processing, and managing resources efficiently.
cgImg | The CGImageRef representing the source image for processing in the 16-bit depth bitmap context. |
CGImageRef
for nullity, logging any errors encountered.Definition at line 2152 of file xnuimagefuzzer.m.
References applyEnhancedFuzzingToBitmapContext(), and saveFuzzedImage().
Referenced by processImage().
void createBitmapContext1BitMonochrome | ( | CGImageRef | cgImg | ) |
Creates a bitmap context for 1-bit monochrome image processing.
This function is crafted for applications that convert color or grayscale images to monochrome using a 1-bit per pixel format. It's particularly suited for environments where reducing data size is crucial, such as in low-bandwidth or memory-constrained situations, or to achieve a certain aesthetic. The function covers the process from validating the input image, through creating a monochrome bitmap context, to finalizing and releasing resources.
cgImg | The CGImageRef representing the source image to be converted to 1-bit monochrome. |
CGImageRef
is valid and non-null.Definition at line 2503 of file xnuimagefuzzer.m.
References convertTo1BitMonochrome(), and saveMonochromeImage().
Referenced by processImage().
void createBitmapContext32BitFloat4Component | ( | CGImageRef | cgImg | ) |
Creates a bitmap context with standard RGB settings, applies a fuzzing process to alter the image, and saves the fuzzed image. Useful for testing image processing functionalities or creating varied visual effects.
This function demonstrates how to create a bitmap context, manipulate image pixel data through a fuzzing process, and save the modified image. It covers validating input images, creating bitmap contexts with specific configurations, and applying image processing algorithms to explore and enhance image processing techniques.
cgImg | The source image from which to create the bitmap context, represented as a CGImageRef . |
debugMemoryHandling
to illustrate potential insertion points for memory diagnostics.permutation
parameter demonstrates the function's potential to apply various fuzzing types based on input parameters, enhancing modularity and maintainability.NSLog
for debugging purposes. A more sophisticated logging framework is recommended for production code.applyEnhancedFuzzingToBitmapContext
function, promoting code modularity and maintainability.CGImageRef
input to ensure a source image is provided.CGColorSpaceRef
in the device RGB color space.CGImageRef
from the bitmap context, converts it to UIImage
, and saves the result.Definition at line 2833 of file xnuimagefuzzer.m.
References applyEnhancedFuzzingToBitmapContextWithFloats(), and saveFuzzedImage().
Referenced by processImage().
void createBitmapContext8BitInvertedColors | ( | CGImageRef | cgImg | ) |
Transforms the color representation of an image by inverting its colors and applying an 8-bit color depth.
This function is designed for manipulating a bitmap graphics context to invert the RGB values of each pixel in a given CGImageRef, while keeping the alpha channel unchanged. It applies an "enhanced fuzzing logic" to the modified pixel data, making it suitable for creating visual negatives, enhancing image contrast, or evaluating the robustness of image processing algorithms. The color inversion process creates complementary colors for each pixel, offering a straightforward method for achieving visual effects or testing.
The setup includes configuring a bitmap context optimized for color inversion and specifying byte order and alpha channel handling. It involves iterating over raw pixel data for manual color inversion and integrating enhanced fuzzing routines for further pixel manipulation. The function concludes by generating a new CGImage that encapsulates all modifications, which is then saved with a unique identifier.
Resource management is a key aspect, ensuring efficient memory use and necessitating the implementation of fuzzing and saving routines elsewhere within the application's codebase.
cgImg | The CGImageRef representing the source image to be transformed. This parameter must not be NULL to ensure proper function execution. |
Definition at line 2735 of file xnuimagefuzzer.m.
References applyEnhancedFuzzingToBitmapContext(), and saveFuzzedImage().
Referenced by processImage().
void createBitmapContextAlphaOnly | ( | CGImageRef | cgImg | ) |
Creates a bitmap context for alpha channel manipulation of a CGImageRef.
This function is specifically designed for scenarios requiring isolated handling of image transparency, excluding color data. It supports applications in graphics editing, custom rendering, and transparency management by focusing exclusively on the alpha channel. The function validates the source image, configures a dedicated bitmap context for alpha data, applies custom modifications to transparency levels, and manages resource cleanup effectively.
cgImg | The CGImageRef representing the source image from which the alpha channel will be extracted and processed. |
Implementation Notes:
applyEnhancedFuzzingToBitmapContextAlphaOnly
function for specific alpha data manipulation, aimed at testing or enhancing transparency effects.debugMemoryHandling
to facilitate memory management diagnostics, crucial for optimizing resource use in constrained environments.CGImageRef
is suitable for transparency extraction and processing.Definition at line 2406 of file xnuimagefuzzer.m.
References applyEnhancedFuzzingToBitmapContextAlphaOnly(), and saveFuzzedImage().
Referenced by processImage().
void createBitmapContextBigEndian | ( | CGImageRef | cgImg | ) |
Creates a bitmap context with Big Endian byte ordering for image data processing.
This function is designed for scenarios where Big Endian representation is crucial for the consistency of pixel color data in memory, particularly in systems or applications expecting this byte order. It validates the input image, establishes an appropriate RGB color space, configures a bitmap context for Big Endian processing, applies an "enhanced fuzzing logic" to the pixel data for testing or artistic purposes, and finalizes the process by releasing resources and saving the modified image.
cgImg | The CGImageRef representing the original image for processing. It is essential that this image is not null to proceed with the transformation. |
CGImageRef
provided is valid and not null.Definition at line 2578 of file xnuimagefuzzer.m.
References applyEnhancedFuzzingToBitmapContext(), and saveFuzzedImage().
Referenced by processImage().
void createBitmapContextGrayscale | ( | CGImageRef | cgImg | ) |
Definition at line 2251 of file xnuimagefuzzer.m.
void createBitmapContextHDRFloatComponents | ( | CGImageRef | cgImg | ) |
Initializes a bitmap context for HDR content with floating-point components.
This function is pivotal for handling High Dynamic Range (HDR) images, enabling the precise manipulation of extended color and brightness ranges. By employing floating-point components and an HDR-compatible color space, it facilitates the processing of images with significantly broader luminance and color gamut than traditional 8-bit or 16-bit formats allow. The function outlines steps for validating the source image, allocating memory for HDR data, setting up an HDR-compatible color space and bitmap context, and applying custom image processing.
cgImg | The CGImageRef representing the source image for processing in the HDR bitmap context. |
CGImageRef
is valid and not null.kCGColorSpaceExtendedLinearSRGB
) to accurately handle HDR images' expanded gamut and luminance.Definition at line 2284 of file xnuimagefuzzer.m.
References applyEnhancedFuzzingToBitmapContextWithFloats(), NUMBER_OF_STRINGS, and saveFuzzedImage().
Referenced by processImage().
void createBitmapContextLittleEndian | ( | CGImageRef | cgImg | ) |
Initializes a bitmap context with Little Endian settings for image data processing.
This function focuses on preparing and manipulating a bitmap graphics context optimized for Little Endian byte ordering, suitable for systems and applications that require the least significant byte to be stored first. It involves creating an RGB color space, setting up the bitmap context for Little Endian processing, applying predefined fuzzing algorithms to pixel data, and finalizing the modified image. The process is aimed at testing image processing capabilities, creating visual effects, or introducing distortions through direct pixel manipulation.
cgImg | The CGImageRef representing the image to be processed, which must not be null to ensure successful transformation. |
CGImageRef
is valid and non-null.Definition at line 2655 of file xnuimagefuzzer.m.
References applyEnhancedFuzzingToBitmapContext(), and saveFuzzedImage().
Referenced by processImage().
void createBitmapContextNonPremultipliedAlpha | ( | CGImageRef | cgImg | ) |
Creates a bitmap graphics context with Non-Premultiplied Alpha settings for processing a CGImage.
Tailored for scenarios where non-premultiplied alpha handling is crucial, this function facilitates precise control over the alpha channel during image processing. It's particularly useful where premultiplication could obscure details or degrade quality. The function outlines a structured approach to creating a bitmap context that maintains the integrity of the alpha channel, applying modifications through an "enhanced fuzzing" process, and concluding with the saving of the altered image.
The procedure includes validating the CGImageRef, memory allocation for pixel data, setting up a Device RGB color space, configuring bitmap context parameters for non-premultiplied alpha, image rendering, applying custom processing logic, and resource cleanup.
cgImg | The CGImageRef representing the image to be processed, used as the source for the bitmap context. |
CGImageRef
is non-null and valid for processing.Definition at line 2035 of file xnuimagefuzzer.m.
References applyEnhancedFuzzingToBitmapContext(), and saveFuzzedImage().
Referenced by processImage().
void createBitmapContextPremultipliedFirstAlpha | ( | CGImageRef | cgImg | ) |
Creates a bitmap context with Premultiplied First Alpha settings and applies image processing.
This function initializes a bitmap context optimized for image processing with premultiplied first alpha settings, drawing a provided CGImage into this context. It fills the allocated memory with a 0x41 pattern to facilitate debugging and security analysis by identifying unused or inefficiently managed memory regions. After processing the image, it checks for any unchanged memory areas and logs their locations, offering insights into memory utilization.
cgImg | A CGImageRef representing the source image to be transformed. Must not be NULL. |
Utilizing a 0x41 pattern fill and subsequent check, this function aids in debugging memory handling and potentially identifying security vulnerabilities related to buffer overflow or improper memory management. It's designed for enhanced debugging and should be used with consideration for its performance impact in production environments.
CGImageRef
provided to this function is valid. The function logs detailed information about its operation, especially detecting unchanged memory areas after processing, which can be instrumental in identifying inefficiencies or vulnerabilities. Definition at line 1919 of file xnuimagefuzzer.m.
References applyEnhancedFuzzingToBitmapContext(), and saveFuzzedImage().
Referenced by processImage().
void createBitmapContextStandardRGB | ( | CGImageRef | cgImg, |
int | permutation ) |
Creates a bitmap context with standard RGB settings, applies a fuzzing process to alter the image, and saves the fuzzed image. Useful for testing image processing functionalities or creating varied visual effects.
This function demonstrates how to create a bitmap context, manipulate image pixel data through a fuzzing process, and save the modified image. It covers validating input images, creating bitmap contexts with specific configurations, and applying image processing algorithms to explore and enhance image processing techniques.
cgImg | The source image from which to create the bitmap context, represented as a CGImageRef . |
permutation | An integer representing the type or level of fuzzing to apply. Though not utilized in this simplified example, it is designed to dictate different fuzzing algorithms or intensities. |
debugMemoryHandling
to illustrate potential insertion points for memory diagnostics.permutation
parameter demonstrates the function's potential to apply various fuzzing types based on input parameters, enhancing modularity and maintainability.NSLog
for debugging purposes. A more sophisticated logging framework is recommended for production code.applyEnhancedFuzzingToBitmapContext
function, promoting code modularity and maintainability.CGImageRef
input to ensure a source image is provided.CGColorSpaceRef
in the device RGB color space.CGImageRef
from the bitmap context, converts it to UIImage
, and saves the result.Definition at line 1813 of file xnuimagefuzzer.m.
References applyEnhancedFuzzingToBitmapContext(), saveFuzzedImage(), and verboseLogging.
Referenced by processImage().
NSString * createUniqueDirectoryForSavingImages | ( | void | ) |
Creates a unique directory for saving images within the documents directory.
Generates a unique directory name by combining the current date-time stamp and a random component, ensuring uniqueness. This directory is created within the application's documents directory, intended for storing processed images. Useful in scenarios requiring organized storage without naming conflicts, maintaining chronological order. The inclusion of a random component further ensures directory name uniqueness, even when created in rapid succession.
Definition at line 817 of file xnuimagefuzzer.m.
void debugMemoryHandling | ( | void | ) |
Allocates and deallocates memory chunks using mmap and munmap for debugging.
This function facilitates memory handling debugging by allocating and then deallocating a predetermined number of memory chunks. It utilizes the mmap and munmap system calls, offering a lower-level look at memory management beyond what high-level languages typically provide. This approach is useful for examining application behavior under various memory conditions and demonstrating memory mapping techniques.
Definition at line 1333 of file xnuimagefuzzer.m.
void dump_comm_page | ( | void | ) |
Definition at line 502 of file xnuimagefuzzer.m.
References COMM_PAGE64_BASE_ADDRESS, COMM_PAGE_CPU_CAPABILITIES64, cpu_cap_strings, READ_COMM_PAGE_VALUE, and signature().
Referenced by main().
void dumpDeviceInfo | ( | void | ) |
Logs comprehensive information about the current device.
This utility function leverages the UIDevice
class to access and log a wide range of information about the device on which the application is running. It covers basic device identifiers, operating system details, and battery status, providing a holistic view of the device's configuration and state.
The function temporarily enables battery monitoring to retrieve the current battery level and state, supplementing the device information with power status. This could be particularly useful for applications that need to adjust their behavior or performance based on the device's power status.
This example demonstrates how to call dumpDeviceInfo to log device information. This can be particularly useful during development and debugging to understand the environment in which the application is operating.
Definition at line 344 of file xnuimagefuzzer.m.
Referenced by main().
void dumpMacDeviceInfo | ( | void | ) |
Logs system information for macOS devices.
This function is specifically designed to fetch and log key pieces of system information for macOS devices, utilizing the sysctl
interface. It provides insights into the kernel version, hardware model, and CPU type, among others, offering a clear snapshot of the underlying hardware and operating system specifics.
This function is tailor-made for macOS environments and can be invoked directly to log the system information to the console:
Example Output:
Definition at line 407 of file xnuimagefuzzer.m.
Referenced by main().
NSString * formattedCurrentDateTime | ( | void | ) |
Definition at line 266 of file xnuimagefuzzer.m.
Referenced by main().
NSData * generateFuzzedImageData | ( | size_t | width, |
size_t | height, | ||
CFStringRef | imageType ) |
Generates a random image for fuzzing.
This function creates a random image with specified width, height, and type, fills it with random data, and returns the generated image data.
width | The width of the generated image. |
height | The height of the generated image. |
imageType | The type of the generated image. |
Definition at line 1446 of file xnuimagefuzzer.m.
Referenced by performAllImagePermutations().
unsigned long hashString | ( | const char * | str | ) |
Computes a hash value for a given string.
This function implements the djb2 algorithm, a simple and effective hash function for strings. The algorithm iterates over each character in the input string, combining the previous hash value and the current character to produce a new hash. This method is known for its simplicity and decent distribution properties, making it suitable for a variety of hashing needs where extreme cryptographic security is not required.
str | Pointer to the input string to be hashed. The string is assumed to be null-terminated. |
Definition at line 1371 of file xnuimagefuzzer.m.
Referenced by applyEnhancedFuzzingToBitmapContextWithFloats().
void invertColor | ( | float * | pixel | ) |
BOOL isValidImagePath | ( | NSString * | path | ) |
Prototypes for utility functions used in image processing.
Validates the existence of a file at a specified path.
This section declares functions essential for the image processing pipeline, ranging from path validation to image manipulation and utility operations. These functions facilitate tasks such as validating image paths, loading images from files, applying various image processing permutations, and managing output directories and string hashing.
isValidImagePath
: Validates the specified image path.loadImageFromFile
: Loads an image from the given file path.processImage
: Processes the image with a specified permutation algorithm.processImage
, might modify the input image directly.Checks if an image file exists at a given path, essential for applications that require the presence of a file before performing further operations. Utilizes NSFileManager
's fileExistsAtPath:
to assess file presence, ensuring the path's validity for subsequent processing or operations. This function is crucial in contexts where the accuracy of file paths directly impacts application behavior or user experience.
path | NSString representing the file path to validate. |
NSFileManager
for reliable file existence checks. Logs the outcome to provide clear feedback on path validity.Definition at line 1574 of file xnuimagefuzzer.m.
UIImage * loadImageFromFile | ( | NSString * | imageName | ) |
Loads an image from the application bundle into a UIImage object.
Essential for iOS applications, this function loads images stored within the app's resources, facilitating the display or processing of those images. It abstracts filesystem complexities, allowing developers to concentrate on resource utilization.
imageName | NSString representing the file name (including its extension) of the image to load. |
UIImage
object initialized with the specified image file's contents or nil if the image could not be loaded.NSBundle
's pathForResource:ofType:
to locate the image file, simplifying access to app resources.NSData
, a format compatible with UIImage
's imageWithData:
initializer.UIImage
from NSData
. On success, logs image details like dimensions and scale for debugging or information.Definition at line 1605 of file xnuimagefuzzer.m.
Referenced by main().
void logPixelData | ( | unsigned char * | rawData, |
size_t | width, | ||
size_t | height, | ||
const char * | message, | ||
BOOL | verboseLogging ) |
Logs information about a random set of pixels from an image's raw data.
Selects a random set of pixels from the provided image data and logs their RGBA components. If verbose logging is enabled, it decodes and logs character data embedded within the pixel values, providing insights into the image's content or image processing results. Assumes RGBA format for pixel data.
rawData | The raw pixel data of the image. |
width | The width of the image in pixels. |
height | The height of the image in pixels. |
message | A contextual message or identifier for the log. |
verboseLogging | Enables detailed information logging, including decoded data, when set to true. |
Definition at line 863 of file xnuimagefuzzer.m.
References verboseLogging.
void LogRandomPixelData | ( | unsigned char * | rawData, |
size_t | width, | ||
size_t | height, | ||
const char * | message ) |
Logs information about a random set of pixels from an image's raw data.
This function is designed to offer a quick diagnostic look at the content of an image by logging the color values of a randomly selected set of pixels. It's particularly useful for debugging and for verifying the effects of image processing algorithms. By providing a message or identifier, developers can contextualize the log output, making it easier to track logs related to specific images or operations. The function provides a high-level overview of pixel data without detailed analysis or decoding.
rawData | The raw pixel data of the image. This should be a pointer to the start of the pixel data array. |
width | The width of the image in pixels. This is used to calculate the position of pixels within the raw data array. |
height | The height of the image in pixels. Along with width, this determines the total number of pixels that can be logged. |
message | A message or identifier to include in the log for context. This helps to identify the log output related to specific images or processing steps. |
Definition at line 908 of file xnuimagefuzzer.m.
int main | ( | int | argc, |
const char * | argv[] ) |
Entry point of the application, handling initialization, argument parsing, and image processing.
Sets up the application environment, parses command-line arguments for image loading and processing, and manages resources efficiently. Demonstrates a command-line utility pattern in Objective-C, integrating C and Objective-C elements for image processing tasks.
argc | Count of command-line arguments. |
argv | Array of command-line arguments. |
@autoreleasepool
for efficient memory management. The initial environment variable configurations are for debugging and may need adjustment depending on deployment. Definition at line 1497 of file xnuimagefuzzer.m.
References dump_comm_page(), dumpDeviceInfo(), dumpMacDeviceInfo(), formattedCurrentDateTime(), loadImageFromFile(), performAllImagePermutations(), and processImage().
void performAllImagePermutations | ( | void | ) |
Generates a random image and processes it with all permutation strategies.
This function defines the dimensions and image type for a generated image, creates the image data, writes it to a temporary file, loads the image, and processes it with permutation -1, indicating all permutations.
Definition at line 1402 of file xnuimagefuzzer.m.
References generateFuzzedImageData(), and processImage().
Referenced by main().
void printColored | ( | const char * | color, |
const char * | message ) |
Prints a message with specified ANSI color to the console.
This utility function enhances console log visibility by allowing messages to be printed in different colors. It wraps a provided message with the specified ANSI color code, ensuring the message stands out in the console output. After printing the message, it resets the console color back to its default, maintaining the terminal's readability for subsequent outputs.
color | The ANSI color code that dictates the color of the message. This parameter expects a string representation of ANSI color codes (e.g., "\033[31m" for red). |
message | The text message to be printed. This string is the content that will be displayed in the specified color in the console. |
This example demonstrates how to use the printColored function to print an error message in red, making it more noticeable in the console output.
See Also: ANSI color codes documentation for more information on how colors are represented in terminals.
Definition at line 552 of file xnuimagefuzzer.m.
References RESET_COLOR.
void processImage | ( | UIImage * | image, |
int | permutation ) |
Processes an image using various bitmap context configurations.
Central to testing different bitmap context configurations, this function allows for the exploration and application of a wide range of image processing techniques. Configurations vary by color space, alpha settings, bit depth, and pixel format, enabling comprehensive testing across different image processing scenarios.
image | The UIImage object to be processed, which must contain a valid CGImage . |
permutation | An integer specifying the bitmap context configuration to apply. A value of -1 applies all configurations in a loop, while any other value selects a specific configuration. |
CGImage
from the UIImage
. Logs an error and exits if this step fails.Definition at line 1655 of file xnuimagefuzzer.m.
References createBitmapContext16BitDepth(), createBitmapContext1BitMonochrome(), createBitmapContext32BitFloat4Component(), createBitmapContext8BitInvertedColors(), createBitmapContextAlphaOnly(), createBitmapContextBigEndian(), createBitmapContextHDRFloatComponents(), createBitmapContextLittleEndian(), createBitmapContextNonPremultipliedAlpha(), createBitmapContextPremultipliedFirstAlpha(), and createBitmapContextStandardRGB().
Referenced by main(), and performAllImagePermutations().
void saveFuzzedImage | ( | UIImage * | image, |
NSString * | contextDescription ) |
Saves a modified (fuzzed) UIImage to the documents directory.
This function takes a UIImage object that has undergone modifications (e.g., fuzzing) and saves it to the documents directory with a unique filename derived from a provided context description. It's designed to facilitate the persistence of images altered through security testing, experimental modifications, or user interactions within an application. The process includes validation of input parameters, generation of a unique filename, and the actual saving of the image in specified formats including PNG, JPEG, and GIF.
image | The modified UIImage object to be saved. |
contextDescription | A description of the context in which the image was modified, used to generate a unique file name. |
contextDescription
for validity to avoid file path issues.NSSearchPathForDirectoriesInDomains
to find the documents directory, ensuring iOS compatibility.Definition at line 642 of file xnuimagefuzzer.m.
References UIImageGIFRepresentation().
Referenced by createBitmapContext16BitDepth(), createBitmapContext32BitFloat4Component(), createBitmapContext8BitInvertedColors(), createBitmapContextAlphaOnly(), createBitmapContextBigEndian(), createBitmapContextHDRFloatComponents(), createBitmapContextLittleEndian(), createBitmapContextNonPremultipliedAlpha(), createBitmapContextPremultipliedFirstAlpha(), and createBitmapContextStandardRGB().
void saveMonochromeImage | ( | UIImage * | image, |
NSString * | identifier ) |
Saves a monochrome UIImage with a specified identifier to the documents directory.
This function saves the provided UIImage object as a PNG file in the application's documents directory, using the specified identifier as part of the file name. It's useful for persisting processed images for later retrieval, sharing, or comparison.
image | The UIImage to save. |
identifier | A unique identifier for the image file. |
Definition at line 791 of file xnuimagefuzzer.m.
Referenced by createBitmapContext1BitMonochrome().
char * signature | ( | void | ) |
Definition at line 301 of file xnuimagefuzzer.m.
References COMM_PAGE64_BASE_ADDRESS, and signature().
Referenced by dump_comm_page(), and signature().
NSData * UIImageGIFRepresentation | ( | UIImage * | image | ) |
Creates a GIF representation of a UIImage. This custom function handles the conversion of a UIImage to GIF data using the Image I/O framework.
image | The UIImage to be converted. |
Definition at line 701 of file xnuimagefuzzer.m.
Referenced by saveFuzzedImage().
const char* cpu_cap_strings[] |
Identifies the CPU's supported capabilities.
This section enumerates various CPU capabilities and instruction sets that modern processors might support. These capabilities enhance the processor's performance and security features. Identifiers for these capabilities are used to represent specific hardware features and instruction sets, such as Multimedia Extensions, Streaming SIMD Extensions, Advanced Encryption Standard instruction sets, and others.
The identifiers provided are used to map the CPU capability bits to human-readable strings. This mapping aids developers and system administrators in understanding the features supported by the CPU on a given device, facilitating optimizations and security enhancements.
MMX
: Refers to Multimedia Extensions that enhance multimedia and communication tasks.SSE
, SSE2
, SSE3
, SSE4_1
, SSE4_2
: Streaming SIMD Extensions and their versions, improving performance on floating point and integer operations.AES
: Denotes support for the Advanced Encryption Standard instruction set, crucial for fast and secure data encryption.AVX1_0
, AVX2_0
: Advanced Vector Extensions that improve performance for applications requiring high computational throughput.BMI1
, BMI2
: Bit Manipulation Instruction Sets, enhancing the efficiency of certain data processing tasks.RTM
: Restricted Transactional Memory, supporting transactional memory synchronization.HLE
: Hardware Lock Elision, aimed at improving the performance of lock-based concurrent algorithms.ADX
: Multi-Precision Add-Carry Instruction Extensions, useful in cryptographic algorithms.RDSEED
, MPX
, SGX
: Various security and protection extensions, including random number generation, memory protection, and trusted execution.The availability and support for these capabilities are highly dependent on the CPU model and the architecture of the device's processor. Detection and utilization of these features typically require querying through system-specific interfaces or leveraging instruction sets designed for this purpose.
Definition at line 455 of file xnuimagefuzzer.m.
Referenced by dump_comm_page().
char* injectStrings[10] |
Definition at line 190 of file xnuimagefuzzer.m.
Referenced by applyEnhancedFuzzingToBitmapContext(), applyEnhancedFuzzingToBitmapContextWithFloats(), and applyFuzzingToBitmapContext().
|
static |
Core and external libraries necessary for the fuzzer functionality.
This section includes the necessary headers for the Foundation framework, UIKit, Core Graphics, standard input/output, standard library, memory management, mathematical functions, Boolean type, floating-point limits, and string functions. These libraries support image processing, UI interaction, and basic C operations essential for the application.
Definition at line 62 of file xnuimagefuzzer.m.
Referenced by applyEnhancedFuzzingToBitmapContext(), applyEnhancedFuzzingToBitmapContextAlphaOnly(), applyEnhancedFuzzingToBitmapContextWithFloats(), createBitmapContextStandardRGB(), and logPixelData().