Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Simple Swift Fuzzer

Sometimes we want to test a Function to see how… robust it is. This is a small example fuzzing function to input randomly generated characters that get passed to another function. It just uses randomBytes so much more logic could easily be added to constrain what’s being passed to whatever type it’s being passed to… but this satisfies my need.

import Foundation

func fuzz(function: () -> Void) {
// Generate a random input to pass to the function we are fuzzing
let input = Data(randomBytes: 1024)

// Call the fuzzed function with the random input
do {
try function()
} catch {
print(error)
}

// Check the fuzzed function to see if it crashed
if ProcessInfo.processInfo.isCrashed {
print("The function crashed")
}
}

The post Simple Swift Fuzzer appeared first on krypted.



This post first appeared on Krypted.com | Tiny Deathstars Of Foulness, please read the originial post: here

Share the post

Simple Swift Fuzzer

×

Subscribe to Krypted.com | Tiny Deathstars Of Foulness

Get updates delivered right to your inbox!

Thank you for your subscription

×