• Stars
    star
    148
  • Rank 249,928 (Top 5 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created about 10 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Melkor is a very intuitive and easy-to-use ELF file format fuzzer to find functional and security bugs in ELF parsers.
 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
|                        -- DESCRIPTION --                        |
 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~

Melkor - An ELF File Format Fuzzer

Melkor, a fictional character from J. R. R. Tolkien's Middle-earth 
legendarium, was the first Dark Lord and master of Sauron. He's 
mentioned briefly in The Lord of the Rings and is known for:

"... Melkor had captured a number of ELVES before the Valar 
attacked him, and he tortured and corrupted them, breeding the 
first Orcs." (http://en.wikipedia.org/wiki/Morgoth)

"... Melkor was cunning and more filled with malice than ever. 
Seeing the bliss of the ELVES and remembering that it was for their 
sake that he was overthrown, Melkor desired above all things to 
corrupt them." (http://lotr.wikia.com/wiki/Melkor)

"Orcs...This has been so from the day they were bred by Melkor from 
corrupted, tortured and mutilated ELVES that may also have been 
forced to breed with other unnatural abominations in the dominion 
of the Dark Powers." (http://lotr.wikia.com/wiki/Orcs)

To honor his name, this piece of code takes an ELF, corrupts it and
creates as much Orcs as you want.

Melkor is a hybrid fuzzer (mutation-based and generation-based).
It mutates the existing data in an ELF sample given to create orcs
(malformed ELFs), however, it doesn't change values randomly (dumb 
fuzzing), instead, it fuzzes certain metadata with semi-valid values
through the use of fuzzing rules (knowledge base). Written in C, 
Melkor is a very intuitive and easy-to-use fuzzer to find functional
(and security) bugs in ELF parsers.

The fuzzing rules were designed with the following inputs in mind:
- ELF Specification violations
  * TIS ELF Specification 1.2 (May, 1995)
  * ELF-64 Object File Format 1.5 (May 1998)
- Misc ideas & considerations
- Parsing patterns in ELF software

You will find the fuzzing rules in detail and some other schematics
in the docs/ directory.



 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
|                        -- REQUIREMENTS --                       |
 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~

- make
- gcc



 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
|                  -- COMPILATION & USAGE --                      |
 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
The compilation is very straightforward, just type:
$make

It will create the file 'melkor', which is the fuzzer itself, and
some other ELF files inside the templates/ folder, including normal
ELF files such as a normal ELF executable, some shared libraries, 
an static ELF (standalone executable) and some others.

By running melkor, a list of options will be shown and you will
realize that it's very intuitive and easy-to-use. All you have to
supply is the name of an ELF to be used as a template, which could
be any of the ones inside the templates/ dir.

Depending on what kind of software you want to test, you have to
choose which metadata you want to fuzz. For example, if you want
to test an OS loader, you probably might want to fuzz only the
Program Header Table (-P) and/or the Dynamic Section (-D). On the
other hand, perhaps you might want to fuzz the Section Header
Table and the ELF Header to test any antivirus engine or debugger.
Fuzzing the Symbols Tables (-s) and/or Relocations Tables (-R) on
relocatable files (.o) or shared libraries (.so) to test compilers
and/or linkers. The String Tables could be fuzzed as well (-Z).
It's up to you to decide how badly you want to corrupt an ELF }:-)

Once the orcs have been created inside the orcs_*/ dir, it's time
to test them with the help of test_fuzzed.sh, where you can simply
specify the name of the folder with the orcs to be run (OS loader
testing) or add an extra parameter to specify which program (and
its parameters) you'd like to test against every malformed ELF 
within the orcs folder. This script has the option to fuzz some
environment variables (defined as fuzzing rules as well).
Showing logs with #dmesg after running the script could be useful
to identify which program/library crashed and where that crash was.
Some examples are shown running the script without parameters.

If you want test the malformed ELFs (orcs) automatically on Windows
environment, there is included a batch script (win_test_fuzzed.bat)
with almost the same functionality of the script for *NIX.

Happy Fuzzing !


 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
|                           -- DIRS --                            |
 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~

- docs/      Contains related documentation such as the detailed
             list of fuzzing rules as well as the list of ELF
             metadata dependencies.

- templates/ It has some ELF files compiled at the same time than
             melkor and could be used to feed melkor:
             foo.c    -> foo.o (ELF object)-> foo (ELF executable)
             foo.c    -> foo_static (ELF static executable)
             libfoo.c -> libfoo.so (ELF shared object)
             and some others. Type "$make templ" to see in detail
             which other ELF templates are created.

- orcs_*/    Will contain the malformed ELF files (based on the 
             given template file) created after the fuzzing process.

- src/       Melkor source code.



 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
|                           -- BUGS --                            |
 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~

Please read BUGS.txt



 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
|                          -- CONTACT --                          |
 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~

Name:      Alejandro Hernandez H. [nitr0us]
Twitter:   http://twitter.com/nitr0usmx
Email:     nitrousenador [at] gmail [dot] com
Website:   http://www.brainoverflow.org
Blog:      http://chatsubo-labs.blogspot.com



 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
|                        -- IN MEMORIAL --                        |
 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~

This project is dedicated to the memory of one of my best friends,
Aaron Alba.



 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
|                          -- LICENSE --                          |
 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~

Melkor - An ELF File Format Fuzzer
Copyright (C) 2014 Alejandro Hernandez H. (nitr0us)

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/>.

More Repositories

1

jdwp-shellifier

Python
815
star
2

XDiFF

Extended Differential Fuzzing Framework
Python
320
star
3

RepoSsessed

A project designed to parse public source code repositories and find various types of vulnerabilities.
Shell
188
star
4

laf

This project intends to provide a series of tools to craft, parse, send, analyze and crack a set of LoRaWAN packets in order to audit or pentest the security of a LoraWAN infrastructure.
Python
167
star
5

Platbox

UEFI and SMM Assessment Tool
Python
161
star
6

I-know-where-your-page-lives

I Know Where Your Page Lives: Derandomizing the latest Windows 10 Kernel - ZeroNights 2016
C++
157
star
7

FuzzNDIS

A Fuzzer for Windows NDIS Drivers OID Handlers
C
91
star
8

kmdf_re

Helper idapython code for reversing kmdf drivers
C
66
star
9

BlueCrawl

Frida (Android) Script for extracting bluetooth information
JavaScript
59
star
10

FileFormatFuzzing

C
39
star
11

AOSP-DownloadProviderDbDumperSQLiWhere

PoC Exploiting SQL Injection in Android's Download Provider in Selection Parameter (CVE-2019-2198)
Java
32
star
12

AOSP-ExploitUserDictionary

PoC Exploit for AOSP UserDictionary Content Provider (CVE-2018-9375)
Java
21
star
13

SearchAndCollect

search and collect windows files from multiple locations on machine and store in one centralized directory
C
20
star
14

AOSP-DownloadProviderHijacker

PoC Exploiting Permission Bypass in Android's Download Provider (CVE-2018-9468)
Java
18
star
15

AutoGadgetFS

USB testing framework
Python
15
star
16

BurpJDSer-ng

Allows you to deserialize java objects to XML and lets you dynamically load classes/jars as needed
Java
15
star
17

uefi_research

A repository with UEFI research stuff
13
star
18

Embedded-Defense

Sample embedded defense code for applications written in .NET, Java, PHP and Python.
JavaScript
11
star
19

PinguCrew

Python
9
star
20

Paddo

Framework for auditing and conducting "padding oracle" attacks
Python
8
star
21

AOSP-DownloadProviderDbDumper

PoC Exploiting SQL Injection in Android's Download Provider (CVE-2018-9493)
Java
7
star
22

BlackHat_2017

Materials for "Go Nuclear: Breaking Radiation Monitoring Devices"
C
6
star
23

AOSP-DownloadProviderHeadersDumper

PoC Exploiting Headers Disclosure in Android's Download Provider (CVE-2018-9546)
Java
6
star
24

NexusTacos

A vulnerability in the SNMP module of NX-OS could allow an unauthenticated, remote attacker to disclose potentially sensitive information.
Python
5
star
25

FileSquattingExample

FileSquatting Exploitation by Example
C
5
star
26

HL7-Fuzzer

An HL7 message fuzzer ( client and server )
Python
4
star
27

rubenBlackHat2018

Last Call For Satcom Security Materials
C
3
star
28

AOSP-DownloadProviderDbDumperSQLiLimit

PoC Exploiting SQL Injection in Android's Download Provider in Sort Parameter (CVE-2019-2196)
Java
2
star