The following FixUp is required to use this Pit.

import zlib
from Peach.fixup import Fixup

class Crc32LowOrdFixup(Fixup):
 
        '''
        Standard CRC32 as defined by ISO 3309.  Used by PNG, zip, etc.
        '''
 
        def __init__(self, ref):
                Fixup.__init__(self)
                self.ref = ref
 
        def fixup(self):
                self.context.defaultValue = "0"
                stuff = self._findDataElementByName(self.ref).getValue()
                if stuff == None:
                        raise Exception("Error: Crc32Fixup was unable to locate [%s]" % self.ref)
 
                crc = zlib.crc32(stuff)
                crc = crc & 0xffff
                if crc < 0:
                        crc = ~crc ^ 0xffffffff
 
                return crc

<?xml version="1.0" encoding="utf-8"?>
<Peach version="1.0" author="Jason Kratzer" site="http://www.flinkd.org">
  <!-- Custom Fixup -->
  <PythonPath path="c:\svn-peach\"/>
  <Import import="custom" />
  <Include ns="default" src="file:defaults.xml"/>
  <!-- http://ams.cern.ch/AMS/amsexch/arch/rar/technote.txt -->

  <DataModel name="RarFileFormat">
    <Choice maxOccurs="1000">
    <!-- Marker block ( MARK_HEAD ) -->
      <Block name="MarkerBlock">
        <String name="MarkHeadCRC32" valueType="hex" value="5261" token="true" mutable="false">
          <Hint name="NumericalString" value="true"/>
        </String>
        <Number name="MarkHeadType" size="8" endian="little" signed="false" value="114" token="true" mutable="false"/>
        <String name="MarkHeadFlags" valueType="hex" value="211A" token="true">
          <Hint name="NumericalString" value="true"/>
        </String>
        <Number name="MarkHeadSize" size="16" endian="little" signed="false" value="7"/>
      </Block>

      <!--  Archive header ( MAIN_HEAD ) -->
        <Block name="ArchiveHeader">
        <Number name="ArchiveHeadCRC16" size="16" endian="little" signed="false" mutable="false">
          <Fixup class="custom.Crc32LowOrdFixup">
            <Param name="ref" value="ArchiveHeaderData"/>
          </Fixup>
        </Number>
        <Block name="ArchiveHeaderData">
          <String name="ArchiveHeadType" valueType="hex" value="73" token="true" mutable="false">
            <Hint name="NumericalString" value="true"/>
          </String>
          <Flags name="HeadFlags" size="16">
            <Flag name="VolumeAttribute" position="0" size="1"/> <!-- 0x0001 -->
            <Flag name="ArchiveLockAttribute" position="2" size="1"/> <!-- 0x0004 -->
            <Flag name="SolidAttribute" position="3" size="1"/> <!-- 0x0008 -->
            <Flag name="VolumeNamingScheme" position="4" size="1"/> <!-- 0x0010 -->
            <Flag name="AuthenticityInformation" position="5" size="1"/> <!-- 0x0020 -->
            <Flag name="RecoveryRecord" position="6" size="1"/> <!-- 0x0040 -->
            <Flag name="EncryptedBlockHeaders" position="7" size="1"/> <!-- 0x0080 -->
            <Flag name="FirstVolume" position="7" size="1"/> <!-- 0x0100 -->
            <Flag name="Internal1" position="9" size="1" /> <!-- Internal Use Only -->
            <Flag name="Internal2" position="10" size="1" /> <!-- Internal Use Only -->
            <Flag name="Internal3" position="11" size="1" /> <!-- Internal Use Only -->
            <Flag name="Internal4" position="12" size="1" /> <!-- Internal Use Only -->
            <Flag name="Internal5" position="13" size="1" /> <!-- Internal Use Only -->
            <Flag name="Internal6" position="14" size="1" /> <!-- Internal Use Only -->
            <Flag name="Internal7" position="15" size="1" /> <!-- Internal Use Only -->
            </Flags>
            <Number name="HeadSize" size="16" endian="little" signed="false">
              <Relation type="size" of="ArchiveHeader"/>
            </Number>
            <Number name="Reserved1" size="16" endian="little" signed="false"/>
            <Number name="Reserved2" size="32" endian="little" signed="false"/>
          </Block>
        </Block>

      <!-- File header (File in archive) -->
        <Block name="FileHeader">
          <Number name="FileHeadCRC32" size="16" endian="little" signed="false" mutable="false">
            <Fixup class="custom.Crc32LowOrdFixup">
              <Param name="ref" value="FileHeaderData"/>
            </Fixup>
          </Number>
          <Block name="FileHeaderData">
            <String name="HeadType" valueType="hex" value="74" token="true" mutable="false">
              <Hint name="NumericalString" value="true"/>
            </String>
            <Flags name="FileHeadFlags" size="16">
              <Flag name="FileContinuedPrevVol" position="0" size="1"/> <!-- 0x0001 -->
              <Flag name="FileContinuedNextVol" position="1" size="1"/> <!-- 0x0002 -->
              <Flag name="FileEncrypted" position="2" size="1"/> <!-- 0x0004 -->
              <Flag name="FileComment" position="3" size="1"/> <!-- 0x0008 -->
              <Flag name="InformationFromPrev" position="4" size="1"/> <!-- 0x0010 -->
              <Flag name="Dictionary" position="5" size="3"/>
              <Flag name="HighPackHighUNPSize" position="8" size="1"/> <!-- 0x0100 -->
              <Flag name="FileName" position="9" size="1"/> <!-- 0x0200 -->
              <Flag name="EncryptionSalt" position="10" size="1"/> <!-- 0x0400 -->
              <Flag name="VersionFlag" position="11" size="1"/> <!-- 0x0800 -->
              <Flag name="ExtendedTimeField" position="12" size="1" /> <!-- 0x1000 -->
              <Flag name="Reserved" position="13" size="1" />
              <Flag name="OldVersionIgnore" position="14" size="1" />
              <Flag name="AddSizePresent" position="15" size="1" /> <!-- 0x8000 -->
            </Flags>
            <Number name="FileHeadSize" size="16" endian="little" signed="false">
              <!-- <Relation type="size" of="FileHeader"/> This should be fixed -->
            </Number>
            <Number name="CompressedSize" size="32" endian="little" signed="false">
              <Relation type="size" of="RawData"/>
            </Number>
            <Number name="UncompressedSize" size="32" endian="little" signed="false"/>
            <Number name="FileHostOS" size="8" endian="little" signed="false"/>
            <Number name="FileCRC" size="32" endian="little" signed="true" mutable="false"/> <!-- CRC of decompressed file -->
            <Number name="FileTime" size="16" endian="little" signed="false"/>
            <Number name="FileDate" size="16" endian="little" signed="false"/>
            <Number name="FileUnpackedVer" size="8" endian="little" signed="false"/>
            <Number name="FileMethod" size="8" endian="little" signed="false"/>
            <Number name="FileNameSize" size="16" endian="little" signed="false">
              <Relation type="size" of="FileName" isOutputOnly="true"/>
            </Number>
            <Number name="FileAttributes" size="32" endian="little" signed="false"/>
            <Block name="OptionalPackSize" minOccurs="0" maxOccurs="2">
              <!-- Enabled if HeadFlags 0x100 != 0 -->
              <Relation type="when" when="self.find('HighPackHighUNPSize').getInternalValue() != 0"/>
              <Number name="FileHighPackedSize" size="32" endian="little" signed="false"/>
              <Number name="FileHighUnpackedSize" size="32" endian="little" signed="false"/>
            </Block>
            <String name="FileName"/>
            <Block minOccurs="0" maxOccurs="1">
              <!-- Enabled if HeadFlags 0x400 != 0 -->
              <Relation type="when" when="self.find('EncryptionSalt').getInternalValue() != 0"/>
              <Number name="FileSalt" size="64" endian="little" signed="false"/>
            </Block>
            <Block name="OptionalFileExtTime" minOccurs="0" maxOccurs="1">
              <!-- Enabled if HeadFlags 0x1000 != 0 -->
              <Relation type="when" when="self.find('ExtendedTimeField').getInternalValue() != 0"/>
              <!--<Number name="FileExtTime" endian="little" signed="false"/>--> <!-- Element size undocumented -->
              <String name="FileExtTime" length="5"/>
            </Block>
          </Block>
          <Blob name="RawData"/>
        </Block>

      <!-- Old Style Comment Block -->
        <Block name="CommentBlock">
          <Number name="CommentBlockHeadCRC32" size="16" endian="little" signed="false" mutable="false">
            <Fixup class="custom.Crc32LowOrdFixup">
              <Param name="ref" value="CommentData"/>
            </Fixup>
          </Number>
          <Block name="CommentData">
            <String name="HeadType" valueType="hex" value="75" token="true" mutable="false">
              <Hint name="NumericalString" value="true"/>
            </String>
            <Number name="CommentHeadFlags" size="16" endian="little" signed="false"/>
            <Number name="CommentHeadSize" size="16" endian="little" signed="false">
              <Relation type="size" of="CommentBlock"/>
            </Number>
            <Number name="CommentUnpSize" size="16" endian="little" signed="false"/>
            <Number name="CommentUnpVersion" size="8" endian="little" signed="false"/>
            <Number name="CommentUnpMethod" size="8" endian="little" signed="false"/>
            <Number name="CommentCRC" size="16" endian="little" signed="false"/>
            <Blob name="CommentData"/>
          </Block>
        </Block>

      <!-- Old Style Authenticity Block -->
        <Block name="ExtraInfoBlock"><Relation type="size" of="ExtraInfoHeadSize"/>
          <Number name="ExtraInfoHeadCRC32" size="16" endian="little" signed="false" mutable="false">
            <Fixup class="custom.Crc32LowOrdFixup">
              <Param name="ref" value="ExtraInfoData"/>
            </Fixup>
          </Number>
          <Block name="ExtraInfoData">
            <Number name="ExtraInfoHeadType" size="8" endian="little" signed="false" value="118" token="true"/>
            <Number name="ExtraInfoHeadFlags" size="16" endian="little" signed="false"/>
            <Number name="ExtraInfoHeadSize" size="16" endian="little" signed="false"/>
            <Blob name="ExtraInfoData"/>
          </Block>
        </Block>

      <!-- Old Style Sub-Block -->
        <Block name="OldSubBlock"><Relation type="size" of="OldSubBlockHeadSize"/>
          <Number name="OldSubBlockHeadCRC32" size="16" endian="little" signed="false" mutable="false">
            <Fixup class="custom.Crc32LowOrdFixup">
              <Param name="ref" value="OldSubBlockData"/>
            </Fixup>
          </Number>
          <Block name="OldSubBlockData">
            <Number name="OldSubBlockHeadType" size="8" endian="little" signed="false" value="119" token="true"/>
            <Number name="OldSubBlockHeadFlags" size="16" endian="little" signed="false"/>
            <Number name="OldSubBlockHeadSize" size="16" endian="little" signed="false"/>
          </Block>
        </Block> 

      <!-- Sub-Block -->
        <Block name="SubBlock">
          <Block name="SubBlockHeader">
            <Number name="SubBlockHeadCRC32" size="16" endian="little" signed="false" mutable="false">
              <Fixup class="custom.Crc32LowOrdFixup">
                <Param name="ref" value="SubBlockData"/>
              </Fixup>
            </Number>
            <Block name="SubBlockData">
              <String name="SubBlockHeadType" valueType="hex" value="7A" token="true">
                <Hint name="NumericalString" value="true"/>
              </String>
              <Number name="SubBlockHeadFlags" size="16" endian="little" signed="false"/>
              <Number name="SubBlockHeadSize" size="16" endian="little" signed="false">
                <Relation type="size" of="SubBlockFoo" expressionGet="size-11" expressionSet="size+11"/>
              </Number>
              <Number name="SubBlockRawDataSize" size="32" endian="little" signed="false">
                <Relation type="size" of="SubBlockBar"/> <!-- Add named relation -->
              </Number>
              <Blob name="SubBlockFoo"/> <!-- Fix this -->
            </Block>
          </Block>
          <Blob name="SubBlockBar"/>
        </Block>

      <!-- End of File Block -->
        <Block name="EndOfFile">
          <Number name="EoFHeadCRC32" size="16" endian="little" signed="false" mutable="false">
            <Fixup class="custom.Crc32LowOrdFixup">
              <Param name="ref" value="EoFData"/>
            </Fixup>
          </Number>
          <Block name="EoFData">
            <Number name="EoFHeadType" size="8" endian="little" signed="false" value="123" token="true"/>
            <Number name="EoFHeadFlags" size="16" endian="little" signed="false"/>
            <Number name="EoFHeadSize" size="16" endian="little" signed="false" value="7" token="true">
              <Relation type="size" of="EndOfFile" />
            </Number>
          </Block>
        </Block>
      </Choice>
    </DataModel>

    <DataModel name="Param">
      <String name="Value" isStatic="true"/>
    </DataModel>
    <StateModel name="TheState" initialState="Initial">
      <State name="Initial">
        <Action type="output">
          <DataModel ref="RarFileFormat"/>
          <Data name="data" fileName="C:\test.rar"/>
        </Action>
        <Action type="close"/>
        <Action type="call" method="ScoobySnacks"/>
      </State>
    </StateModel>
    <Agent name="LocalAgent">
      <Monitor class="debugger.WindowsDebugEngine">
        <Param name="CommandLine" value="C:\Program Files\WinRAR\WinRAR.exe fuzzed.rar"/>
        <Param name="StartOnCall" value="ScoobySnacks"/>
      </Monitor>
      <Monitor class="process.PageHeap">
        <Param name="Executable" value="WinRAR.exe"/>
      </Monitor>
    </Agent>

    <Test name="TheTest">
      <!--<Strategy class="rand.RandomMutationStrategy" switchCount="1500" maxFieldsToMutate="7"/>-->
      <Agent ref="LocalAgent"/>
      <StateModel ref="TheState"/>
      <Publisher class="file.FileWriterLauncherGui">
        <Param name="fileName" value="fuzzed.rar"/>
        <Param name="windowName" value="fuzzeds.rar - WinRAR"/>
        <Param name="debugger" value="true"/>
      </Publisher>
    </Test>
    <Run name="DefaultRun">
      <Test ref="TheTest"/>
      <Logger class="logger.Filesystem">
        <Param name="path" value="C:\svn-peach\logs\winrar\"/>
      </Logger>
    </Run>
</Peach>