Skip to content

Commit

Permalink
2.0.1
Browse files Browse the repository at this point in the history
See release notes for full updates
  • Loading branch information
ex0dus-0x committed Sep 19, 2022
1 parent 2b57cb4 commit 2a81a52
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 29 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ jobs:
pypi-pkg-upload:
runs-on: ubuntu-20.04
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}

publish-doc-site:
runs-on: ubuntu-20.04
Expand Down
29 changes: 20 additions & 9 deletions fuzzable/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def analyze(
if debug:
log.setLevel(logging.DEBUG)

if not target.is_file() or target.is_dir():
error(f"Target path `{target}` does not exist.")

try:
mode = AnalysisMode[mode.upper()]
except KeyError:
Expand Down Expand Up @@ -91,11 +94,7 @@ def analyze(
if target.is_file():
run_on_file(target, mode, score_weights, export, list_ignored, skip_stripped)
elif target.is_dir():
run_on_workspace(
target, mode, score_weights, export, list_ignored, skip_stripped
)
else:
error(f"Target path `{target}` does not exist")
run_on_workspace(target, mode, score_weights, export, list_ignored)


def run_on_file(
Expand All @@ -117,21 +116,27 @@ def run_on_file(
# Prioritize loading binja as a backend, this may not
# work if the license is personal/student.
try:
import sys

sys.tracebacklimit = 0

from binaryninja.binaryview import BinaryViewType
from fuzzable.analysis.binja import BinjaAnalysis

bv = BinaryViewType.get_view_of_file(target)
bv.update_analysis_and_wait()

from fuzzable.analysis.binja import BinjaAnalysis

analyzer = BinjaAnalysis(
bv,
mode,
score_weights=score_weights,
skip_stripped=True,
skip_stripped=skip_stripped,
headless=True,
)

# didn't work, try to load angr as a fallback instead
except (ModuleNotFoundError, RuntimeError):
except (RuntimeError, ModuleNotFoundError, ImportError):
log.warning(
f"Cannot load Binary Ninja as a backend. Attempting to load angr instead."
)
Expand Down Expand Up @@ -160,7 +165,6 @@ def run_on_workspace(
score_weights: t.List[float],
export: t.Optional[Path],
list_ignored: bool,
skip_stripped: bool,
) -> None:
"""
Given a workspace, recursively iterate and parse out all of the source code files
Expand Down Expand Up @@ -202,8 +206,15 @@ def create_harness(
out_harness: t.Optional[Path] = typer.Option(
None, help="Specify to set output harness template file path."
),
debug: bool = typer.Option(
False,
help="If set, will be verbose and output debug information.",
),
):
"""Synthesize a AFL++/libFuzzer harness for a given symbol in a target."""
if debug:
log.setLevel(logging.DEBUG)

if not symbol_name:
error("No --symbol-name specified.")

Expand Down
2 changes: 1 addition & 1 deletion fuzzable/analysis/angr.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
angr.py
Fallback disassembly backend, most likely for headless analysis.
Fallback disassembly backend with angr, most likely for headless analysis.
"""
import typing as t

Expand Down
2 changes: 1 addition & 1 deletion fuzzable/analysis/ast.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
ast.py
Fuzzable analysis support for C/C++ code by through query on top of pycparser ASTs.
Fuzzable analysis support for C/C++ code by through query on top of tree-sitter ASTs.
"""
import os
Expand Down
5 changes: 2 additions & 3 deletions fuzzable/analysis/binja.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""
binja.py
Fuzzable analysis support for the Binary Ninja disassembler.
Can be invoked both through registered plugin handlers, and through
a headless standalone CLI.
Fuzzable analysis support for the Binary Ninja disassembler. Can be invoked both through
registered plugin handlers, and through a headless standalone CLI.
"""
import os
Expand Down
18 changes: 9 additions & 9 deletions fuzzable/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import typer
import typing as t

from rich import print
from rich import print as rprint
from rich.console import Console
from rich.table import Table

Expand Down Expand Up @@ -44,7 +44,7 @@ def error(string: str) -> None:
string,
fg=typer.colors.RED,
)
print(f"{ERROR_START} {exception}")
typer.echo(f"{ERROR_START} {exception}")
sys.exit(1)


Expand Down Expand Up @@ -74,16 +74,16 @@ def print_table(
console = Console()
console.print(table)

print("\n[bold red]ADDITIONAL METADATA[/bold red]\n")
print(f"[underline]Number of Symbols Analyzed[/underline]: \t\t{len(fuzzability)}")
print(f"[underline]Number of Symbols Skipped[/underline]: \t\t{len(skipped)}")
print(f"[underline]Top Fuzzing Contender[/underline]: \t\t{fuzzability[0].name}\n")
rprint("\n[bold red]ADDITIONAL METADATA[/bold red]\n")
rprint(f"[underline]Number of Symbols Analyzed[/underline]: \t\t{len(fuzzability)}")
rprint(f"[underline]Number of Symbols Skipped[/underline]: \t\t{len(skipped)}")
rprint(f"[underline]Top Fuzzing Contender[/underline]: \t\t{fuzzability[0].name}\n")

if list_ignored:
print("\n[bold red]SKIPPED SYMBOLS[/bold red]\n")
rprint("\n[bold red]SKIPPED SYMBOLS[/bold red]\n")
for name, loc in skipped.items():
print(f"{name}\t\t{loc}")
print("\n")
rprint(f"{name}\t\t{loc}")
rprint("\n")


def export_results(export, results) -> None:
Expand Down
3 changes: 1 addition & 2 deletions fuzzable/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

FORMAT = "%(message)s"
logging.basicConfig(
level="NOTSET", format=FORMAT, datefmt="[%X]", handlers=[RichHandler()]
level=logging.INFO, format=FORMAT, datefmt="[%X]", handlers=[RichHandler()]
)
log = logging.getLogger("fuzzable")
log.setLevel(logging.INFO)
14 changes: 13 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fuzzable"
version = "2.0.0"
version = "2.0.1"
description = "Framework for Automating Fuzzable Target Discovery with Static Analysis"
authors = [
"ex0dus <[email protected]>"
Expand All @@ -22,6 +22,7 @@ prettytable = "^3.3.0"
lief = "^0.12.1"
tree-sitter = "^0.20.0"
scikit-criteria = "^0.7"
pypcode = "^1.0.7"

[tool.poetry.dev-dependencies]
pytest = "^7.1.2"
Expand Down Expand Up @@ -50,9 +51,11 @@ exclude = '''
| \.mypy_cache
| \.tox
| \.venv
| \.github
| _build
| buck-out
| build
| docs
| dist
)/
| foo.py # also separately exclude a file named foo.py in
Expand Down

0 comments on commit 2a81a52

Please sign in to comment.