Flinkd!

fuzzing, reverse engineering, exploit development, pure gibberish

  • Home
  • Projects
    • Advisories
    • Exploits
    • Code
    • Peach Pits
      • ZIP File Format
      • RAR File Format
      • ASF File Format
      • AVI File Format
      • MOV/MP4 File Format
      • CAB File Format
    • Research
  • About
12
Jul/11

Fuzzing with Peach – Part 1

by pyoor under Fuzzing
file format, fuzzer, peach, tutorial, zip

35 Comments for this entry

  • Nicolas
    July 21st, 2011 on 6:45 am

    Excellent post, it’s the most complete information on building a Peach pit and using Peach fuzzer to it’s full extend.

  • Red
    July 21st, 2011 on 12:39 pm

    Very good article! Do you mind if I translate it into Russian and will publish on its website?

    • pyoor
      July 21st, 2011 on 2:31 pm

      Certainly. Please don’t modify the content or remove references to the original source.

  • white
    August 3rd, 2011 on 10:17 am

    hi, i’m run peach 2.3.9 but get an error at rand.py on line 59. Did you fix that in peach?
    Can you share me the way you fix?
    Regards,
    Sorry for my bad english !

    • pyoor
      August 4th, 2011 on 10:08 am

      Could you provide me with a bit more detail on the error?

  • xssww2
    August 12th, 2011 on 6:01 pm

    do you sure that the second block of the element will be generated? I think that the only first block will be output.

    see:
    http://groups.google.com/group/peachfuzz/browse_thread/thread/ee2f3429856df70d/10f904c8fd3b9d90?lnk=gst&q=choice#10f904c8fd3b9d90

    • xssww2
      August 12th, 2011 on 6:01 pm

      element: Choice

      • pyoor
        August 12th, 2011 on 8:06 pm

        xssww2: Short answer, yes. If you’re referring to the “dd_chooser” choice element, it’ll first begin cracking the “dd_64” block. If the constraint fails, Peach will discard this block and select the “dd_32.” If this fails as well neither block will be chosen and Peach will move to the next major block in the list. If you’re seeing otherwise please let me know.

  • mushu
    August 29th, 2011 on 4:50 am

    ] Peach 2.3.9 DEV Runtime
    ] Copyright (c) Michael Eddington

    [*] Optmizing DataModel for cracking: ‘ZipFileFormat’
    [*] Cracking data from C:\fuzz\test.zip into ZipFileFormat
    [*] Total time to crack data: 0.08
    [*] Building relation cache
    Traceback (most recent call last):
    File “C:\Peach\\peach.py”, line 393, in
    parser.asParser(args[0])
    File “C:\Peach\Peach\Analyzers\pit.py”, line 57, in asParser
    return parser.parse(uri)
    File “C:\Peach\Peach\Engine\parser.py”, line 161, in parse
    obj = self.HandleDocument(doc, uri)
    File “C:\Peach\Peach\Engine\parser.py”, line 364, in HandleDocument
    tests = self.HandleTest(child, None)
    File “C:\Peach\Peach\Engine\parser.py”, line 2464, in HandleTest
    test.mutator = self.HandleFuzzingStrategy(child, test)
    File “C:\Peach\Peach\Engine\parser.py”, line 2511, in HandleFuzzingStrategy
    exec(“strategy = PeachXml_%s(node, parent)” % cls)
    File “”, line 1, in
    File “C:\Peach\Peach\MutateStrategies\rand.py”, line 59, in __init__
    RandomMutationStrategy.SEED = Engine.context.SEED
    AttributeError: ‘NoneType’ object has no attribute ‘SEED’

    • pyoor
      August 30th, 2011 on 2:12 am

      Without the syntax that caused this error I can’t be certain but I imagine you’re seeing this error when running”peach.bat -t zip.xml”. I’m not sure why but Peach will throw an error when running the syntax test with the random mutation strategy enabled in the PIT. To run a syntax check, simply comment out the “Strategy” element within your test model. To use it during fuzzing remove the comment.

      • mushu
        August 30th, 2011 on 1:24 pm

        thanks,pyoor,it works now

  • Jinghao
    November 29th, 2011 on 1:39 am

    Hi, nice guide.
    From my understanding, this process will fuzz the test.zip, and check by cutezip. Am I right?

    If I just want to fuzz the test.zip file, and save the fuzzed zip file to some place. No need to monitor and check, just need the fuzzed result. What should I do?

    Thanks.

    • pyoor
      November 29th, 2011 on 4:49 am

      Jinghao,

      Yes, you are correct.

      Also, have a look at the following:
      http://peachfuzzer.com/HowDoI#Generate_All_Fuzzed_Files

      This will generate all fuzzed files and write them to disk.

      • Jinghao
        December 6th, 2011 on 5:52 am

        When I use this xml to fuzz, the CPU usage will grow up quickly. Then the whole system will be hang. It is very strange.

        Thanks,
        -Jinghao

        • pyoor
          December 7th, 2011 on 12:59 am

          Jinghao,

          This is more than likely dependent on the application you’ve chosen to fuzz. Once the sample file has been cracked, Peach uses very little resources for the actual fuzz process. Try looking at alternative monitors available in Peach as this may cause the application to spike in CPU usage.

          • Jinghao
            December 12th, 2011 on 2:31 am

            Thanks for your reply.
            Actually, I don’t use any monitor. I just generated the fuzzed files. And after remove the random Strategy, it will be OK. I don’t know why. Thanks.

  • Steven John
    February 2nd, 2012 on 12:30 pm

    Hi pyoor,
    Excellent writeup. Thanks for your patience.
    I tried to generate fuzz files using your datamodel. I am receiving the following error while executing “peach.bat zip.xml”. I didnt receive syntax errors by the way. Any help would be appreciated. Thanks

    ] Peach 2.3.8 Runtime
    ] Copyright (c) Michael Eddington

    [*] Starting run “DefaultRun”
    [-] Test: “TheTest” (None)
    [1:?:?] Element: N/A
    Mutator: N/A

    ‘PK\x01\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
    x00\x00\x00\x00\x00\x00\x00’

    ”

    ‘PK\x01\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
    x00\x00\x00\x00\x00\x00\x00’
    (, AttributeError(“ExpressionFixup instance ha
    s no attribute ‘getRoot'”,), )
    [1:?:?] Caught error on receave, ignoring [None]
    Traceback (most recent call last):
    File “peach.py”, line 516, in
    File “Peach\Engine\engine.pyo”, line 471, in Run
    File “Peach\Engine\engine.pyo”, line 678, in _runTest
    File “Peach\Engine\state.pyo”, line 136, in run
    File “Peach\Engine\state.pyo”, line 253, in _runState
    File “Peach\Engine\dom.pyo”, line 2851, in getValue
    File “Peach\Engine\dom.pyo”, line 2363, in getValue
    File “Peach\Engine\dom.pyo”, line 2976, in getRawValue
    File “Peach\Engine\dom.pyo”, line 2918, in getInternalValue
    File “Peach\Engine\dom.pyo”, line 2363, in getValue
    File “Peach\Engine\dom.pyo”, line 3402, in getRawValue
    File “Peach\Engine\dom.pyo”, line 3334, in getInternalValue
    File “Peach\Engine\dom.pyo”, line 2363, in getValue
    File “Peach\Engine\dom.pyo”, line 3402, in getRawValue
    File “Peach\Engine\dom.pyo”, line 3334, in getInternalValue
    File “Peach\Engine\dom.pyo”, line 2363, in getValue
    File “Peach\Engine\dom.pyo”, line 3626, in getRawValue
    File “Peach\Engine\dom.pyo”, line 3539, in getInternalValue
    File “Peach\Engine\dom.pyo”, line 2233, in getRelationValue
    File “Peach\Engine\dom.pyo”, line 2313, in getSize
    File “Peach\Engine\dom.pyo”, line 2363, in getValue
    File “Peach\Engine\dom.pyo”, line 4123, in getRawValue
    File “Peach\Engine\dom.pyo”, line 4100, in getInternalValue
    File “Peach\fixup.pyo”, line 60, in dofixup
    File “Peach\Fixups\checksums.pyo”, line 58, in fixup
    File “Peach\Engine\common.pyo”, line 190, in evalEvent
    File “Peach\Engine\common.pyo”, line 111, in buildImports
    AttributeError: ExpressionFixup instance has no attribute ‘getRoot’

    • pyoor
      February 13th, 2012 on 4:56 pm

      Steven,

      Are you running the latest svn of Peach? Some of the features included in those pits are only available via svn. If you’re still having issues let me know.

  • Chris
    July 11th, 2012 on 12:52 pm

    I’m trying to use your PeachPit file, but I get the following error. Do you know what I’m doing wrong?

    C:\peach\zip>c:\peach\peach -t zip.xml

    ] Peach 2.3.8 Runtime
    ] Copyright (c) Michael Eddington

    [*] Optmizing DataModel for cracking: ‘ZipFileFormat’
    [*] Cracking data from C:\peach\samples\MPlayer-mingw32-1.0pre8.zip into ZipFile
    Format
    Traceback (most recent call last):
    File “peach.py”, line 392, in
    File “Peach\Analyzers\pit.pyo”, line 57, in asParser
    File “Peach\Engine\parser.pyo”, line 161, in parse
    File “Peach\Engine\parser.pyo”, line 351, in HandleDocument
    File “Peach\Engine\parser.pyo”, line 2885, in HandleStateMachine
    File “Peach\Engine\parser.pyo”, line 2907, in HandleState
    File “Peach\Engine\parser.pyo”, line 3043, in HandleAction
    File “Peach\Engine\dom.pyo”, line 1245, in setDefaults
    File “Peach\Engine\incoming.pyo”, line 171, in crackData
    File “Peach\Engine\incoming.pyo”, line 1020, in _handleNode
    File “Peach\Engine\incoming.pyo”, line 1733, in _handleBlock
    File “Peach\Engine\incoming.pyo”, line 858, in _handleNode
    File “Peach\Engine\incoming.pyo”, line 728, in _handleArray
    File “Peach\Engine\dom.pyo”, line 825, in __delitem__
    KeyError: ‘LocalFileHeader’
    C:\peach\zip>

    • pyoor
      July 13th, 2012 on 3:35 pm

      Chris,

      The zip.xml pit requires the latest version of PIT (2.3.9 DEV). You can pull it down using the following SVN resource:

      svn co https://peachfuzz.svn.sourceforge.net/svnroot/peachfuzz/branches/Peach2.3/ peach2.3

      • Chris
        July 23rd, 2012 on 7:50 am

        Thanks! I pulled down the latest version, but I still get an error:

        C:\Peach2.3>peach -t zip\zip.xml

        ] Peach 2.3.9 DEV Runtime
        ] Copyright (c) Michael Eddington

        [*] Optmizing DataModel for cracking: ‘ZipFileFormat’
        [*] Cracking data from C:\Peach2.3\samples\samples.zip into ZipFileFormat
        [*] Total time to crack data: 0.15
        [*] Building relation cache
        Traceback (most recent call last):
        File “C:\Peach2.3\\peach.py”, line 393, in
        parser.asParser(args[0])
        File “C:\Peach2.3\Peach\Analyzers\pit.py”, line 57, in asParser
        return parser.parse(uri)
        File “C:\Peach2.3\Peach\Engine\parser.py”, line 161, in parse
        obj = self.HandleDocument(doc, uri)
        File “C:\Peach2.3\Peach\Engine\parser.py”, line 364, in HandleDocument
        tests = self.HandleTest(child, None)
        File “C:\Peach2.3\Peach\Engine\parser.py”, line 2464, in HandleTest
        test.mutator = self.HandleFuzzingStrategy(child, test)
        File “C:\Peach2.3\Peach\Engine\parser.py”, line 2511, in HandleFuzzingStrategy

        exec(“strategy = PeachXml_%s(node, parent)” % cls)
        File “”, line 1, in
        File “C:\Peach2.3\Peach\MutateStrategies\rand.py”, line 59, in __init__
        RandomMutationStrategy.SEED = Engine.context.SEED
        AttributeError: ‘NoneType’ object has no attribute ‘SEED’

        • Chris
          July 23rd, 2012 on 8:49 am

          Sorry, I didn’t read the other comments. It works now!

  • Chris
    July 23rd, 2012 on 12:56 pm

    Hello again,

    Now I’ve been trying to use minset for a while, but I get this error:

    C:\Peach2.3\tools\minset>minset -s zip\*.zip -m minset “C:\Program Files\7-Zip\7
    z.exe” %s

    ] Peach Minset Finder v0.10
    ] Copyright (c) Michael Eddington

    [*] Performing code coverage traces with 12 files
    [*] Determining coverage with [zip\bzip2.zip]
    E: Failed to allocate Injector, Error = INJECTOR_ERR_NO_ACTIVE_SERVER
    E:Pin is exiting due to fatal error
    Traceback (most recent call last):
    File “minset.py”, line 468, in
    options.needsKilling)
    File “minset.py”, line 356, in runCoverage
    (sampleFileMostCoverage, sampleFileMostCoverageCount ) = self.runTraces(comm
    and, sampleFiles, None, needsKilling)
    File “minset.py”, line 323, in runTraces
    bbl = self.getCoverage(cmd, sampleFile)
    File “minset.py”, line 282, in getCoverage
    cmd)
    File “C:\Python27\lib\os.py”, line 608, in spawnl
    return spawnv(mode, file, args)
    OSError: [Errno 0] Error

    Do you know what I’m doing wrong here?

    • pyoor
      July 24th, 2012 on 3:40 pm

      Hrmm. No not entirely sure but I’d try wrapping %s in quotes (“%s”).

  • jeffball55
    October 21st, 2012 on 6:19 pm

    FYI:
    The linked CuteZip appears to be corrupted (Installing in Windows 7 fails). However, I was able to download a copy from archive.org that installed and I was able to verify that it has the example vulnerability.

    Link: http://archive.org/details/tucows_312509_CuteZIP

  • mehdi
    December 8th, 2013 on 2:44 pm

    What version of Peach you used for this tutorial?

    I’m using windows xp sp3 and peach 2.3.9 but got this error :

    http://pastebin.com/8SFjwHyc

    what’s wrong?

    following command not work too :
    peach.bat samples\DebuggerWindows.xml

    but i have peach 3 installed and when use peach.bat with DebuggerWindows.xml works well but not work with zip.xml

    • pyoor
      December 10th, 2013 on 2:03 pm

      Mehdi,

      You’re missing the ‘win32process’ module. Also, the zip.xml Peach pit will not work under Peach 3 without modifying it first. Peach 3 has significantly changed the pit format.

  • GetGoing
    December 10th, 2013 on 1:25 pm

    Hi Pyoor,
    Thanks for this wonderful website!

    I am new to Peach and learning it everyday. I have a bit of confusion related with Size Relation:


    As size of “lfh_FileNameLen” would be derived from “lfh_FileName”, whats the use of defining size in below line:
    <Number name="lfh_FileNameLen" size=”16″ endian=”little” signed=”false”>

    Could you please help me understand this.

    G.

    • pyoor
      December 10th, 2013 on 2:08 pm

      GetGoing,

      The Zip specification requires a field which identifies the size in characters of the filename length. The reason we specify a size relation here is that if Peach manipulates either the lfh_FileNameLen or lfh_FileName elements, it can then update the corresponding fields accordingly. For instance, if Peach mutates the lfh_Filename field to “AAAAAAAAAA”, it can then update the lfh_FileNameLen to 10. The caveat here is that may or may not happen depending on the mutation strategy in use.

      • GetGoing
        December 10th, 2013 on 5:06 pm

        Thanks a lot the clarifies 🙂

        • GetGoing
          December 10th, 2013 on 5:08 pm

          Sorry for typo…Thanks a lot that answers my query

  • GetGoing
    December 10th, 2013 on 5:11 pm

    Hi Pyoor,

    I have a query on load from file in peach:

    Wondering if you have used it
    My sample data is in .pcap format (network packet), do I just need to change the extension of my .pcap files to .bin or is there a different approach here?

    Thanks,
    G.

  • sulley
    January 19th, 2015 on 1:14 pm

    Im close to five years late. I hope its not a problem. This is still the most detailed zip format implementation of the internet. Im running into the following error. What do you think my problem is.
    C:\Peach2.3.9>peach.bat -t samples\zip.xml

    ] Peach 2.3.9 DEV Runtime
    ] Copyright (c) Michael Eddington

    [*] Optmizing DataModel for cracking: ‘ZipFileFormat’
    [*] Cracking data from C:\fuzz\zip\150.zip into ZipFileFormat
    [*] Total time to crack data: 0.00
    [*] Building relation cache
    eocd_OffsetToCenDir
    Parent:
    DataRoot:
    DataRoot.parent:
    Fullname: ZipFileFormat.EndOfCentralDirectoryRecord.eocd_OffsetToCenDir.Named_4

    Couldn’t locate [LocalFileHeader] size
    template: ZipFileFormat: parent
    block: ArchiveExtraDataRecord: parent
    string: aedr_Sig: parent
    number: aedr_ExtFldLen: parent
    blob: aedr_ExtFld: parent
    block: CentralDirectoryStructure: parent
    block: FileHeader: parent
    string: cfh_Signature: parent
    number: cfh_Ver: parent
    number: cfh_VerReq: parent
    flags: cfh_BitFlag: parent
    flag: cfh_bf_Encrypted: parent
    flag: cfh_bf_CompMethod1: parent
    flag: cfh_bf_CompMethod2: parent
    flag: cfh_bf_Zeroed: parent
    flag: cfh_bf_Deflate: parent
    flag: cfh_bf_Patched: parent
    flag: cfh_bf_Strong: parent
    flag: cfh_bf_Unused1: parent
    flag: cfh_bf_Unused2: parent
    flag: cfh_bf_Unused3: parent
    flag: cfh_bf_Unused4: parent
    flag: cfh_bf_EFS: parent
    flag: cfh_bf_Reserved1: parent
    flag: cfh_bf_Enc_Cd: parent
    flag: cfh_bf_Reserved2: parent
    flag: cfh_bf_Reserved3: parent
    number: cfh_CompMethod: parent
    number: cfh_LastModTime: parent
    number: cfh_LastModDate: parent
    number: cfh_CRC32: parent
    number: cfh_CompSize: parent
    number: cfh_DecompSize: parent
    number: cfh_FileNameLen: parent
    number: cfh_ExtraFldLen: parent
    number: cfh_FileCommLen: parent
    number: cfh_DiskNumStart: parent
    number: cfh_IntFileAttrib: parent
    number: cfh_ExtFileAttrib: parent
    number: cfh_RelOffsetLFH: parent
    string: cfh_FileName: parent
    string: cfh_FldName: parent
    string: cfh_FileComment: parent
    block: CDSDigitalSignature: parent
    string: cdsds_Signature: parent
    number: cdsds_DataSize: parent
    blob: cdsds_Data: parent
    block: Zip64EndOfCentralDirectoryRecord: parent
    string: z64eocd_Signature: parent
    number: z64eocd_SizeOfRecord: parent
    block: CentralDirectoryRecord: parent
    number: z64eocd_VerMadeBy: parent
    number: z64eocd_VerNeeded: parent
    number: z64eocd_ThisDiskNum: parent
    number: z64eocd_SofCDDiskNum: parent
    number: z64eocd_CDOnDisk: parent
    number: z64eocd_TotNumEntries: parent
    number: z64eocd_SizeOfCenDir: parent
    number: z64eocd_OffsetToCenDir: parent
    block: z64eocd_Z64ExtensDS: parent
    number: z64eocd_ExtensDs_Header: parent
    number: z64eocd_ExtensDs_Size: parent
    blob: z64eocd_ExtensDs_Data: parent
    block: Zip64EndOfCentralDirectoryLocator: parent
    string: eocdl_Signature: parent
    number: eocdl_NumOfDisk: parent
    number: eocdl_RelOffsetofZ64: parent
    number: eocdl_TotNumDisk: parent
    block: EndOfCentralDirectoryRecord: parent
    string: eocd_Signature: parent
    number: eocd_NumOfDisk: parent
    number: eocd_NumOfDiskWCD: parent
    number: eocd_TotNumEntriesOD: parent
    number: eocd_TotNumEntriesICD: parent
    number: eocd_SizeOfCenDir: parent
    number: eocd_OffsetToCenDir: parent
    block: ZipFileCommentBlock: parent
    number: eocd_CommLen: parent
    blob: eocd_Comment: parent
    Traceback (most recent call last):
    File “C:\Peach2.3.9\\peach.py”, line 393, in
    parser.asParser(args[0])
    File “C:\Peach2.3.9\Peach\Analyzers\pit.py”, line 57, in asParser
    return parser.parse(uri)
    File “C:\Peach2.3.9\Peach\Engine\parser.py”, line 161, in parse
    obj = self.HandleDocument(doc, uri)
    File “C:\Peach2.3.9\Peach\Engine\parser.py”, line 351, in HandleDocument
    stateMachine = self.HandleStateMachine(child, peach)
    File “C:\Peach2.3.9\Peach\Engine\parser.py”, line 2888, in HandleStateMachine
    state = self.HandleState(child, stateMachine)
    File “C:\Peach2.3.9\Peach\Engine\parser.py”, line 2910, in HandleState
    action = self.HandleAction(child, state)
    File “C:\Peach2.3.9\Peach\Engine\parser.py”, line 3046, in HandleAction
    action.template.setDefaults(action.data, self.dontCrack, True)
    File “C:\Peach2.3.9\Peach\Engine\dom.py”, line 1304, in setDefaults
    self.BuildRelationCache()
    File “C:\Peach2.3.9\Peach\Engine\dom.py”, line 1518, in BuildRelationCache
    ofStr = r.getOfElement().getFullnameInDataModel()
    File “C:\Peach2.3.9\Peach\Engine\dom.py”, line 5133, in getOfElement
    raise Exception(“Couldn’t locate [%s]” % self.of)
    Exception: Couldn’t locate [LocalFileHeader]

    • pyoor
      January 22nd, 2015 on 2:53 pm

      It has been a while since I’ve looked at this. Are you sure the sample you’re loading is a valid ZIP file? Based on the error, it looks like Peach can’t identify the LocalFileHeader, specifically – lfh_Signature. Also, are you running the latest development release of 2.3.9.x?

      Also, if you need help it’s typically quicker to reach me on twitter at @pyoor_

  • Gh05t
    February 4th, 2016 on 2:18 pm

    Man this article is awesome!! Thanks for pulling this together.

    Gh05t

4 Trackbacks / Pingbacks for this entry

  • » Giving Automated Fuzzing a Trial Run with Peach - Grant Curell
    August 31st, 2013 on 5:12 pm

    […] Fuzzing with Peach – Part 1 […]

  • Use all the fuzzers! | Joel's SPQR Research
    October 2nd, 2013 on 6:34 pm

    […] order to generate and mutate fuzzing inputs. http://peachfuzzer.com/ Example file format fuzzing: http://www.flinkd.org/2011/07/fuzzing-with-peach-part-1/ Network fuzzing (more interesting): […]

  • Fuzzing: FastStone Image Viewer & CVE-2021-26236 – YLabs
    March 18th, 2021 on 4:27 pm

    […] regarding the Peach’s Pit file structure. For the below explanation I’ve heavily relied on the Peach Fuzzing: Getting Started & Peach Fuzzer: Data Modelling […]

  • Fuzzing: FastStone Image Viewer & CVE-2021-26236 - VoidSec
    January 14th, 2022 on 8:01 am

    […] regarding the Peach’s Pit file structure. For the below explanation I’ve heavily relied on the Peach Fuzzing: Getting Started & Peach Fuzzer: Data Modelling […]

RSS feed for this post (comments)
  • Categories

    • Android
    • App-Sec
    • Burp
    • Exploits
    • Fuzzing
    • iOS
    • Metasploit
    • Uncategorized
  • Blogroll

    • 0Entropy
    • Corelan Team
    • Nullthreat Security
    • Phed
  • Copyright © 1996-2010 Flinkd!. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress