{ "info": { "author": "Gulshan Singh", "author_email": "gsingh2011@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# libafl [![PyPI](https://img.shields.io/pypi/v/libafl.svg?maxAge=2592000)]()\n\nA library for compiling binaries and running them from python code. This library is not for fuzzing python code. This library is still in development, expect bugs and breaking API changes.\n\n## Installation\n\n```\npip install libafl\n```\n\n## Usage\n\nFirst define a `Target`. A target has three methods, `init` for downloading/extracting/patching a package, `build` for building it, and `run` for running it. All three are optional. There is a special target for AFL targets call `AflTarget`.\n\n``` python\nclass LibfooAflTarget(libafl.AflTarget):\n # The root directory for our fuzzing project. In this case, the location of\n # this script\n root_path = os.path.dirname(os.path.realpath(__file__))\n\n # The directory our target's source code will be located in\n src_dir = 'libfoo-afl'\n\n # Pass any constructor arguments to the super class\n def __init__(self, *args, **kwargs):\n super(LibarchiveAflTarget, self).__init__(*args, **kwargs)\n\n # Extract the included tar file and move to the directory with the correct\n # name\n def init(self):\n if not os.path.isdir(self.src_dir):\n subprocess.check_output(['tar', '-xf', 'libfoo-0.0.1.tar.gz'])\n shutil.move('libfoo-0.0.1', self.src_dir)\n\n # Build both the library and a test program with AFL instrumentation\n def build(self):\n # AflTarget provides this method and includes other options as well\n envs = self.set_afl_envs(cc='afl-gcc')\n env = dict(os.environ, **envs)\n subprocess.check_output(\n './configure && make',\n shell=True,\n env=env,\n )\n os.chdir(self.root_path);\n subprocess.check_output(\n ('afl-gcc libfootest.c -I %s/include -L %s/libs -o libfootest-afl') %\n (self.src_dir, self.src_dir),\n shell=True,\n env=env,\n )\n```\n\nCreate a new `AflProject` and register all targets:\n\n``` python\nclass LibfooProject(libafl.AflProject):\n def __init__(self, wrapper=None):\n super(LibarchiveProject, self).__init__(wrapper)\n\n self.addTarget('afl', LibarchiveAflTarget('input', 'output', './libfootest-afl', '@@'))\n```\n\nNow you can run functions manually:\n\n``` python\nproject = LibfooProject()\nproject.build('afl') # or project.build_all() to build all targets\nproject.run('afl')\n```\n\nOr use the builtin command line interface:\n\n``` python\nlibafl.handle_args(LibfooProject(libafl.TmuxWrapper()))\n```\n\nNote in this example we used the `TmuxWrapper`, which will launch fuzzers in new `tmux` windows. You can write your own wrappers for other programs (like `screen`).\n\nThe command line interface provides the following options:\n\n```\nvagrant@vagrant-ubuntu-trusty-64:/vagrant/libafl/libarchive$ ./libarchive-afl.py -h\nusage: libarchive-afl.py [-h] {init,init_all,build,build_all,run,list} ...\n\npositional arguments:\n {init,init_all,build,build_all,run,list}\n init initialize a target\n init_all initialize all targets\n build build a target\n build_all build all targets\n run run a target\n list list all targets\n\noptional arguments:\n -h, --help show this help message and exit\n```\n\nMore examples can be seen in my [afl-scripts](https://github.com/gsingh93/afl-scripts) repo. See the source for full function signatures and all available methods.\n\n## Why\n\nI kept rewriting scripts for compiling/running binaries with AFL, and the number of configurations I wanted to compile with kept increasing (32 bit/64 bit versions, ASAN/no ASAN, gcov instrumentation, no AFL instrumentation, etc.).\n\nThis library is an attempt to remove the boiler plate from writing AFL fuzzing scripts, which will make it easier to test different configurations, and save these configurations for later use, or for sharing with others.", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/gsingh93/libafl/tarball/master", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/gsingh93/libafl", "keywords": "afl,fuzz", "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "libafl", "package_url": "https://pypi.org/project/libafl/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/libafl/", "project_urls": { "Download": "https://github.com/gsingh93/libafl/tarball/master", "Homepage": "https://github.com/gsingh93/libafl" }, "release_url": "https://pypi.org/project/libafl/0.0.2/", "requires_dist": null, "requires_python": null, "summary": "A library for using AFL from python", "version": "0.0.2" }, "last_serial": 2241597, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "759ba7bce3a9383f0aeec151ef51b7f2", "sha256": "5831cd6104ecf45e06a1cc474edebc8def5e5989b3b818437e59fe5b0081af48" }, "downloads": -1, "filename": "libafl-0.0.1.tar.gz", "has_sig": false, "md5_digest": "759ba7bce3a9383f0aeec151ef51b7f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4242, "upload_time": "2016-07-25T03:38:19", "url": "https://files.pythonhosted.org/packages/c4/6a/c0d85c58b5e8b39f2085d2b1c30f6672b791afc04728bd7bab5040cc6347/libafl-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "8544f936721554fee16952dff348f436", "sha256": "c36dab7a3acde9e354bdb3b972fdfa20dc93adc5c598cede1e669978892fca93" }, "downloads": -1, "filename": "libafl-0.0.2.tar.gz", "has_sig": false, "md5_digest": "8544f936721554fee16952dff348f436", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5233, "upload_time": "2016-07-25T04:10:13", "url": "https://files.pythonhosted.org/packages/ca/01/d72462be9271dbfe1c62179d5a9d33a2505acbc532a953d917665c719d06/libafl-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8544f936721554fee16952dff348f436", "sha256": "c36dab7a3acde9e354bdb3b972fdfa20dc93adc5c598cede1e669978892fca93" }, "downloads": -1, "filename": "libafl-0.0.2.tar.gz", "has_sig": false, "md5_digest": "8544f936721554fee16952dff348f436", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5233, "upload_time": "2016-07-25T04:10:13", "url": "https://files.pythonhosted.org/packages/ca/01/d72462be9271dbfe1c62179d5a9d33a2505acbc532a953d917665c719d06/libafl-0.0.2.tar.gz" } ] }