Skip to content

Commit

Permalink
Merge pull request #306 from DarkRelay-Security-Labs/DarkRelayLabs-AF…
Browse files Browse the repository at this point in the history
…L-feature

Implemented AFL Fuzzing
  • Loading branch information
michaelrsweet committed Mar 6, 2024
2 parents c07a57e + c841bec commit 83e9b0a
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,12 @@ testmxml-vg: $(LIBOBJS) testmxml.o

testmxml.o: mxml.h

# Fuzz-test the library <>
.PHONY: afl
afl:
$(MAKE) -$(MAKEFLAGS) CC="afl-clang-fast" COMMONFLAGS="-g" clean all
test afl-output || rm -rf afl-output
afl-fuzz -x xml.dict -i afl-input -o afl-output -V 600 -e xml -t 5000 ./testmxml @@ temps.xml

#
# Analyze code with the Clang static analyzer <https://clang-analyzer.llvm.org>
Expand Down
29 changes: 29 additions & 0 deletions afl-input/test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<group>
<option>
<keyword type="opaque">InputSlot</keyword>
<default type="opaque">Auto</default>
<text>Media Source</text>
<order type="real">10.000000</order>
<choice>
<keyword type="opaque">Auto</keyword>
<text>Auto Tray Selection</text>
<code type="opaque" />
</choice>
<choice>
<keyword type="opaque">Upper</keyword>
<text>Tray 1</text>
<code type="opaque">&lt;&lt;/MediaPosition 0&gt;&gt;setpagedevice</code>
</choice>
<choice>
<keyword type="opaque">Lower</keyword>
<text>Tray 2</text>
<code type="opaque">&lt;&lt;/MediaPosition 1&gt;&gt;setpagedevice</code>
</choice>
</option>
<integer>123</integer>
<string>Now is the time for all good men to come to the aid of their
country.</string>
<!-- this is a comment -->
<![CDATA[this is CDATA 0123456789ABCDEF]]>
</group>
72 changes: 72 additions & 0 deletions xml.dict
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#
# AFL dictionary for XML
# ----------------------
#
# Several basic syntax elements and attributes, modeled on libxml2.
#
# Created by Michal Zalewski <[email protected]>
#

attr_encoding=" encoding=\"1\""
attr_generic=" a=\"1\""
attr_href=" href=\"1\""
attr_standalone=" standalone=\"no\""
attr_version=" version=\"1\""
attr_xml_base=" xml:base=\"1\""
attr_xml_id=" xml:id=\"1\""
attr_xml_lang=" xml:lang=\"1\""
attr_xml_space=" xml:space=\"1\""
attr_xmlns=" xmlns=\"1\""

entity_builtin="&lt;"
entity_decimal="&#1;"
entity_external="&a;"
entity_hex="&#x1;"

string_any="ANY"
string_brackets="[]"
string_cdata="CDATA"
string_col_fallback=":fallback"
string_col_generic=":a"
string_col_include=":include"
string_dashes="--"
string_empty="EMPTY"
string_empty_dblquotes="\"\""
string_empty_quotes="''"
string_entities="ENTITIES"
string_entity="ENTITY"
string_fixed="#FIXED"
string_id="ID"
string_idref="IDREF"
string_idrefs="IDREFS"
string_implied="#IMPLIED"
string_nmtoken="NMTOKEN"
string_nmtokens="NMTOKENS"
string_notation="NOTATION"
string_parentheses="()"
string_pcdata="#PCDATA"
string_percent="%a"
string_public="PUBLIC"
string_required="#REQUIRED"
string_schema=":schema"
string_system="SYSTEM"
string_ucs4="UCS-4"
string_utf16="UTF-16"
string_utf8="UTF-8"
string_xmlns="xmlns:"

tag_attlist="<!ATTLIST"
tag_cdata="<![CDATA["
tag_close="</a>"
tag_doctype="<!DOCTYPE"
tag_element="<!ELEMENT"
tag_entity="<!ENTITY"
tag_ignore="<![IGNORE["
tag_include="<![INCLUDE["
tag_notation="<!NOTATION"
tag_open="<a>"
tag_open_close="<a />"
tag_open_exclamation="<!"
tag_open_q="<?"
tag_sq2_close="]]>"
tag_xml_q="<?xml?>"

0 comments on commit 83e9b0a

Please sign in to comment.