Giter Club home page Giter Club logo

lightbulb-framework's Introduction

LightBulb

LightBulb is an open source python framework for auditing web application firewalls and filters.

Synopsis

The framework consists of two main algorithms:

  • GOFA: An active learning algorithm that infers symbolic representations of automata in the standard membership/equivalence query model.

    Active learning algorithms permits the analysis of filter and sanitizer programs remotely, i.e. given only the ability to query the targeted program and observe the output.

  • SFADiff: A black-box differential testing algorithm based on Symbolic Finite Automata (SFA) learning

    Finding differences between programs with similar functionality is an important security problem as such differences can be used for fingerprinting or creating evasion attacks against security software like Web Application Firewalls (WAFs) which are designed to detect malicious inputs to web applications.

Quick Installation

LightBulb is available in BApp Store as an extesion for the Burp Suite. You can directly install LightBulb by navigating at the Burp Extender tab. You can also import latest the standalone version of the extension.

Motivation

Web Applications Firewalls (WAFs) are fundamental building blocks of modern application security. For example, the PCI standard for organizations handling credit card transactions dictates that any application facing the internet should be either protected by a WAF or successfully pass a code review process. Nevertheless, despite their popularity and importance, auditing web application firewalls remains a challenging and complex task. Finding attacks that bypass the firewall usually requires expert domain knowledge for a specific vulnerability class. Thus, penetration testers not armed with this knowledge are left with publicly available lists of attack strings, like the XSS Cheat Sheet, which are usually insufficient for thoroughly evaluating the security of a WAF product.

BlackHat Europe 2016 Presentation

In this presentation we introduce a novel, efficient, approach for bypassing WAFs using automata learning algorithms. We show that automata learning algorithms can be used to obtain useful models of WAFs. Given such a model, we show how to construct, either manually or automatically, a grammar describing the set of possible attacks which are then tested against the obtained model for the firewall. Moreover, if our system fails to find an attack, a regular expression model of the firewall is generated for further analysis. Using this technique we found over 10 previously unknown vulnerabilities in popular WAFs such as Mod-Security, PHPIDS and Expose allowing us to mount SQL Injection and XSS attacks bypassing the firewalls. Finally, we present LightBulb, an open source python framework for auditing web applications firewalls using the techniques described above. In the release we include the set of grammars used to find the vulnerabilities presented.

BHEU16 Presentation

Commands Usage

Main interface commands:

Command Description
core Shows available core modules
utils Shows available query handlers
info <module> Prints module information
library Enters library
modules Shows available application modules
use <module> Enters module
start <moduleA> <moduleB> Initiate algorithm
help Prints help
status Checks and installs required packages
complete Prints bash completion command

Module commands:

Command Description
back Go back to main menu
info Prints current module information
library Enters library
options Shows available options
define <option> <value> Set an option value
start Initiate algoritm
complete Prints bash completion command

Library commands:

Command Description
back Go back to main menu
info <folder\module> Prints requested module information (folder must be located in lightbulb/data/)
cat <folder\module> Prints requested module (folder must be located in lightbulb/data/)
modules <folder> Shows available library modules in the requested folder (folder must be located in lightbulb/data/)
search <keywords> Searches available library modules using comma separated keywords
complete Prints bash completion command

Installation

Prepare your system

First you have to verify that your system supports flex, python dev, pip and build utilities:

For apt platforms (ubuntu, debian...):

    sudo apt-get install flex
	sudo apt-get install python-pip
	sudo apt-get install python-dev
	sudo apt-get install build-essential

(Optional for apt) If you want to add support for MySQL testing:

    sudo apt-get install libmysqlclient-dev

For yum platforms (centos, redhat, fedora...) with already installed the extra packages repo (epel-release):

	sudo yum install -y python-pip
	sudo yum install -y python-devel
	sudo yum install -y wget
	sudo yum groupinstall -y 'Development Tools'

(Optional for yum) If you want to add support for MySQL testing:

	sudo yum install -y mysql-devel 
	sudo yum install -y MySQL-python

Install Lightbulb

In order to use the application without complete package installation:

git clone https://github.com/lightbulb-framework/lightbulb-framework
cd lightbulb-framework
make
lightbulb status

In order to perform complete package installation. You can also install it from pip repository. This requires first to install the latest setuptools version:

pip install setuptools --upgrade
pip install lightbulb-framework
lightbulb status

If you want to use virtualenv:

pip install virtualenv
virtualenv env
source env/bin/activate
pip install lightbulb-framework
lightbulb status

The "lightbulb status" command will guide you to install MySQLdb and OpenFst support. If you use virtualenv in linux, the "sudo" command will be required only for the installation of libmysqlclient-dev package.

It should be noted that the "lightbulb status" command is not necessary if you are going to use the Burp Extension. The reason is that this command installs the "openfst" and "mysql" bindings and the extension by default is using Jython, which does not support C bindings. It is recommended to use the command only if you want to change the Burp extension configuration from the settings and enable the native support.

It is also possible to use a docker instance:

docker pull lightbulb/lightbulb-framework

LightBulb Installation on Debian Linux

Install Burp Extension

If you wish to use the new GUI, you can use the extension for the Burp Suite.

BApp Store

The extension is already available in the BApp Store. You can directly install LightBulb by navigating at the Burp Extender tab.

Manual Installation

You can also use the following steps to install the latest version of the extension from this repository manually in Burp.

First, it is recommended to increase the available memory for Burp using the following command:

java -jar -Xmx2048M /path/to/burpbinary

Also, Lightbulb uses the native binary of flex parser. As a result, it is recommended to install flex before using the tool. In Debian system it can be installed with the following command:

apt install flex

Then, you have to setup a working environment with Burp Proxy and Jython

  • Download the latest Jython from here**
  • Find your local python packages installation folder*
  • Configure Burp Extender to use these values, as shown below*

  • Select the new LightBulb module ("BurpExtension.py") and set the extension type to be "Python"

*You can ignore this step, and install the standalone version which contains all the required python packages included. You can download it here

** The latest Jython 2.7.X is supported. However MySQL Differential Learning may still require an older version (eg. Jython 2.5.X) since the MySQL connector jar cannot be dynamically imported in the classpath.

Examples

Check out the Wiki page for usage examples.

Contributors

  • George Argyros
  • Ioannis Stais
  • Suman Jana
  • Angelos D. Keromytis
  • Aggelos Kiayias

References

  • G. Argyros, I. Stais, S. Jana, A. D. Keromytis, and A. Kiayias. 2016. SFADiff: Automated Evasion Attacks and Fingerprinting Using Black-box Differential Automata Learning. In Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security (CCS '16). ACM, New York, NY, USA, 1690-1701. doi: 10.1145/2976749.2978383
  • G. Argyros, I. Stais, A. Kiayias and A. D. Keromytis, "Back in Black: Towards Formal, Black Box Analysis of Sanitizers and Filters," 2016 IEEE Symposium on Security and Privacy (SP), San Jose, CA, 2016, pp. 91-109. doi: 10.1109/SP.2016.14

Acknowledgements

This research was partly supported by ERC project CODAMODA, #259152.

License

MIT License as described in LICENSE file

lightbulb-framework's People

Contributors

iamaldi avatar istais avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lightbulb-framework's Issues

requirement installation failed

+--------------------------+--------+
| Name | Status |
+--------------------------+--------+
| six | OK |
| stevedore | OK |
| pbr | OK |
| cmd2 | FAIL |
| unicodecsv | FAIL |
| yaml | OK |
| prettytable | FAIL |
| cliff | OK |
| multiprocessing | OK |
| FAdo | OK |
| dateutil | FAIL |
| symautomata | OK |
| sfalearn | OK |
| MySQLdb | OK |
| OpenFST Python Extension | OK |
+--------------------------+--------+

first, I install under my username (not sudo) failed, then I tried install under the sudo, it's also failed.
I tried install standalone by wget, then manual installation, few requirement was detect with OK, some not detect and it's also failed, do you know how to solve?

I am using ubuntu 16.04 (32bit)

BurpExtension error

raceback (most recent call last):
File "/root/WeB-Attack/lightbulb-framework/BurpExtension.py", line 44, in
from lightbulb.api.api import LightBulb
File "/root/WeB-Attack/lightbulb-framework/lightbulb/api/api.py", line 11, in
from cliff.app import App
ImportError: No module named cliff

at org.python.core.Py.ImportError(Py.java:328)
at org.python.core.imp.import_first(imp.java:877)
at org.python.core.imp.import_module_level(imp.java:972)
at org.python.core.imp.importName(imp.java:1062)
at org.python.core.ImportFunction.__call__(__builtin__.java:1280)
at org.python.core.PyObject.__call__(PyObject.java:431)
at org.python.core.__builtin__.__import__(__builtin__.java:1232)
at org.python.core.imp.importFromAs(imp.java:1156)
at org.python.core.imp.importFrom(imp.java:1132)
at lightbulb.api.api$py.f$0(/root/WeB-Attack/lightbulb-framework/lightbulb/api/api.py:33)
at lightbulb.api.api$py.call_function(/root/WeB-Attack/lightbulb-framework/lightbulb/api/api.py)
at org.python.core.PyTableCode.call(PyTableCode.java:167)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.imp.createFromCode(imp.java:436)
at org.python.core.imp.createFromSource(imp.java:396)
at org.python.core.imp.loadFromSource(imp.java:661)
at org.python.core.imp.find_module(imp.java:543)
at org.python.core.PyModule.impAttr(PyModule.java:106)
at org.python.core.imp.import_next(imp.java:842)
at org.python.core.imp.import_logic(imp.java:904)
at org.python.core.imp.import_module_level(imp.java:978)
at org.python.core.imp.importName(imp.java:1062)
at org.python.core.ImportFunction.__call__(__builtin__.java:1280)
at org.python.core.PyObject.__call__(PyObject.java:431)
at org.python.core.__builtin__.__import__(__builtin__.java:1232)
at org.python.core.imp.importFromAs(imp.java:1156)
at org.python.core.imp.importFrom(imp.java:1132)
at org.python.pycode._pyx4.f$0(/root/WeB-Attack/lightbulb-framework/BurpExtension.py:121)
at org.python.pycode._pyx4.call_function(/root/WeB-Attack/lightbulb-framework/BurpExtension.py)
at org.python.core.PyTableCode.call(PyTableCode.java:167)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1386)
at org.python.core.__builtin__.execfile_flags(__builtin__.java:535)
at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:286)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at burp.g8c.<init>(Unknown Source)
at burp.mde.a(Unknown Source)
at burp.q9h.run(Unknown Source)
at java.lang.Thread.run(Thread.java:748)

documentation / howto

Hi,
I managed to install lightbulb but I'm now stuck on how to use it?
Do you have some step-by-step guidelines to setup and scan mod_security for example?

thanks

Flex can't find regex attribute file

Not sure how to interpret this error.

Please connect your Browser at http://localhost:8080
flex: can't open /home/user/lib/python2.7/site-packages/lightbulb_framework-0.0.13-py2.7.egg/lightbulb/data//regex/BROWSER/html_p_attribute.y
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/user/lib/python2.7/site-packages/lightbulb_framework-0.0.13-py2.7.egg/lightbulb/core/operate.py", line 77, in operate_diff_part
initmodule = module(configuration, shared_memory, cross)
File "/home/user/lib/python2.7/site-packages/lightbulb_framework-0.0.13-py2.7.egg/lightbulb/core/modules/sfadiff.py", line 69, in __init__
self.mma = flex_object_m.yyparse(findlibrary(self.seed_file))
File "/home/user/src/symautomata/symautomata/flex2fst.py", line 277, in yyparse
states_num, delta = self._create_delta()
File "/home/user/src/symautomata/symautomata/flex2fst.py", line 240, in _create_delta
states = self._read_transitions()
File "/home/user/src/symautomata/symautomata/flex2fst.py", line 66, in _read_transitions
with open(self.outfile) as flex_file:
IOError: [Errno 2] No such file or directory: '/tmp/V898W_lex.yy.c'

some mistake

after lightbulb status it will notice

sudo apt-get install libmysqlclient-dev sudo: apt-get: command not found
my system is centos 7

Burp Extension Install Not Working

I followed the steps to install lightbulb into burp using the BApp Store. When I send a request to lightbulb from Repeater tab and then select - Learning -> Tests -> Grammar -> query_sql and then right click the request and select Start Filter Learning - it only sends 2 in the campaign screen and then it just hangs. It locks up Burp entirely and I have to force quit.
I am using the latest Burp Pro and running on Mac OSX Ventura 13.6.

In order to rule out OSX issues, I also tried the same using a Kali linux install. I followed the same steps to install lightbulb-framework from the BApp store and same steps and again it hung on 2 requests.

Any ideas why this just hangs?

Error: Exception in thread Thread-8

Hi, when I use your command I got:

Exception in thread Thread-8:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/dist-packages/lightbulb_framework-0.0.9-py2.7.egg/lightbulb/core/operate.py", line 77, in operate_diff_part
initmodule = module(configuration, shared_memory, cross)
File "/usr/local/lib/python2.7/dist-packages/lightbulb_framework-0.0.9-py2.7.egg/lightbulb/core/modules/sfadiff.py", line 38, in init
self.setup(configuration)
File "/usr/local/lib/python2.7/dist-packages/lightbulb_framework-0.0.9-py2.7.egg/lightbulb/core/base.py", line 41, in setup
self.handler = handler_class(handler_configuration)
File "/usr/local/lib/python2.7/dist-packages/lightbulb_framework-0.0.9-py2.7.egg/lightbulb/core/utils/browserhandler.py", line 108, in init
self.host, self.wsport, SocketHandler)
File "/usr/local/lib/python2.7/dist-packages/lightbulb_framework-0.0.9-py2.7.egg/lightbulb/core/utils/SimpleWebSocketServer.py", line 583, in init
self.serversocket.bind((host, port))
File "/usr/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
error: [Errno 98] Address already in use

I use symautomata 0.0.12, but still not works.
very thank you to help me!

[Support] Lightbulb performs only two requests when running the learn_Waf_grammar test

Hi, first: Great work, seems like an incredible tool!

I'm trying to play around with Lightbulb and it's waf learning capabilities.
I've set up a vulnerable application with a sqli in a GET parameter and I'm using the following file

`use HTTPHandler as my_query_handler
define URL http:/localhost:8080/test_app/intSqli?id=1
define PARAM id
define BLOCK Exception
back
use GOFA as my_gofa
define TESTS_FILE <library_absolute_path>/query_sql.y

define TESTS_FILE_TYPE GRAMMAR
define HANDLER my_query_handler
back
start my_gofa
`
In the server's access log I see only the following two requests

194.221.15.16 - - [02/Mar/2017:11:11:17 +0000] "GET /test_app/intSqli?id=1?id= HTTP/1.1" 403 1518
194.221.15.16 - - [02/Mar/2017:11:11:17 +0000] "GET /spiracle/intSqli?id=1?id=z HTTP/1.1" 403 1519

Then lightbulb produces the following output

`httphandler my_query_handler
Entering handler httphandler
Option URL defined as http://localhost:8080/test_app/intSqli?id=1
Option PARAM defined as id
Option BLOCK defined as Exception
Back to main menu
gofa my_gofa
Checking for pywrapfst module: OK
Checking for pythonpda module: OK
Entering core module gofa
Option TESTS_FILE defined as /query_sql.y
Option TESTS_FILE_TYPE defined as GRAMMAR
Option HANDLER defined as my_query_handler
Back to main menu
Starting my_gofa:
Initializing learning procedure.
Generating a closed and consistent observation table.
Generated conjecture machine with 1 states.
start intersection
PDA States: 269
DFA States: 0
end intersection

  • Reduce PDA using DFA BFS (remove unreachable states):
  • Total PDA states after reduction are 1
    No counterexample found. Hypothesis is correct!
    Learning complete.

Statistics:

+-----------------------------+-------+
| Name | Value |
+-----------------------------+-------+
| Bypass | None |
| Membership Queries | 2 |
| Cached Membership Queries | 0 |
| Equivalence Queries | 1 |
| Cached Equivalence Queries | 0 |
+-----------------------------+-------+
`
This seems wrong as in order to learn the grammar more requests should be needed
(Side note: how can one make lightbulb learn a grammar through a POST request? and do you only accept yacc files or is there a way to submit antlr grammars as well?)

Thanks

Burp Extension can't be installed

I've cloned full repository and build it. All missed packages was downloaded, and my jython version is 2.7.0 But despite this I can not install an extension and got following error trace:

Traceback (most recent call last):
  File "/Users/igor/DevelPython/jython/lightBulb/lightbulb-framework/BurpExtension.py", line 44, in <module>
    from lightbulb.api.api import LightBulb
  File "/Users/igor/DevelPython/jython/lightBulb/lightbulb-framework/lightbulb/api/api.py", line 11, in <module>
    from cliff.app import App
ImportError: No module named cliff

	at org.python.core.Py.ImportError(Py.java:328)
	at org.python.core.imp.import_first(imp.java:877)
	at org.python.core.imp.import_module_level(imp.java:972)
	at org.python.core.imp.importName(imp.java:1062)
	at org.python.core.ImportFunction.__call__(__builtin__.java:1280)
	at org.python.core.PyObject.__call__(PyObject.java:431)
	at org.python.core.__builtin__.__import__(__builtin__.java:1232)
	at org.python.core.imp.importFromAs(imp.java:1156)
	at org.python.core.imp.importFrom(imp.java:1132)
	at lightbulb.api.api$py.f$0(/Users/igor/DevelPython/jython/lightBulb/lightbulb-framework/lightbulb/api/api.py:33)
	at lightbulb.api.api$py.call_function(/Users/igor/DevelPython/jython/lightBulb/lightbulb-framework/lightbulb/api/api.py)
	at org.python.core.PyTableCode.call(PyTableCode.java:167)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.imp.createFromCode(imp.java:436)
	at org.python.core.imp.createFromPyClass(imp.java:236)
	at org.python.core.imp.createFromPyClass(imp.java:205)
	at org.python.core.imp.loadFromSource(imp.java:651)
	at org.python.core.imp.find_module(imp.java:543)
	at org.python.core.PyModule.impAttr(PyModule.java:106)
	at org.python.core.imp.import_next(imp.java:842)
	at org.python.core.imp.import_logic(imp.java:904)
	at org.python.core.imp.import_module_level(imp.java:978)
	at org.python.core.imp.importName(imp.java:1062)
	at org.python.core.ImportFunction.__call__(__builtin__.java:1280)
	at org.python.core.PyObject.__call__(PyObject.java:431)
	at org.python.core.__builtin__.__import__(__builtin__.java:1232)
	at org.python.core.imp.importFromAs(imp.java:1156)
	at org.python.core.imp.importFrom(imp.java:1132)
	at org.python.pycode._pyx5.f$0(/Users/igor/DevelPython/jython/lightBulb/lightbulb-framework/BurpExtension.py:121)
	at org.python.pycode._pyx5.call_function(/Users/igor/DevelPython/jython/lightBulb/lightbulb-framework/BurpExtension.py)
	at org.python.core.PyTableCode.call(PyTableCode.java:167)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1386)
	at org.python.core.__builtin__.execfile_flags(__builtin__.java:535)
	at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:286)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at burp.f6e.<init>(Unknown Source)
	at burp.h2e.a(Unknown Source)
	at burp.mzg.run(Unknown Source)
	at java.lang.Thread.run(Thread.java:745)

P.S. i've installed module named cliff manually. It's doesn't solve my problem

Installation using virtualenv

I typically use Python in a per user virtualenv and the install script does not play nicely with this. Is there any way to get lightbulb to work with this type of configuration?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.