Giter Club home page Giter Club logo

badmoodle's Introduction

badmoodle

badmoodle

Moodle community-based vulnerability scanner

Description

badmoodle is an unofficial community-based vulnerability scanner for moodle that scans for canonical and non-canonical Moodle vulnerabilities.

badmoodle's purpose is to help penetration testers, bug hunters and security researchers find more vulnerabilities on moodle instances.

Since badmoodle is community-based, it will scan for two different kind of vulnerabilities:

  • Official vulnerabilities: The canonical ones published in Moodle security advisory blog;

  • Community vulnerabilities: The non-canonical ones that are not present in Moodle security advisory blog.

The community vulnerability scan can run in two modes:

  • Check mode: Only checks if the host is vulnerable or not;

  • Exploit mode: If the host is vulnerable, exploit the vulnerabilities.

If not specified, the scan will run in check mode.

Installation

Installing badmoodle is very simple, it can be performed in just a few steps:

  • Clone the repository:

    git clone https://github.com/cyberaz0r/badmoodle
  • Dive into "badmoodle" directory:

    cd badmoodle
  • Install requirements for Python:

    pip3 install -r requirements.txt
  • Give execution permissions to "badmoodle.py":

    chmod +x badmoodle.py
  • Run "badmoodle.py":

    ./badmoodle.py

If you see the badmoodle logo and help with no errors you are good to go :)

Usage

Using badmoodle is also very simple. Once installed you can run it with the following options:

  • -h, --help

    Show logo and help with options and their descriptions, then exit

  • -u TARGET_URL, --url TARGET_URL

    Moodle target URL (required)

  • -a USERNAME:PASSWORD, --auth USERNAME:PASSWORD

    Moodle username and password separated by ":" (default: none)

  • -p PROXY_ADDRESS:PORT, --proxy PROXY_ADDRESS:PORT

    Proxy used for connecting to moodle (default: none)

  • -H HEADER, --header HEADER

    Headers used for HTTP connections

  • -l LEVEL, --level LEVEL

    Level of tests to perform (default: 1):

    • Level 1: simple version check by parsing 404 page (MAJOR.MINOR)

    • Level 2: simple and specific version check by parsing 404 page and confronting pages hash (MAJOR.MINOR.PATCH)

    • Level 3: all of the above and plugin/themes enumeration

  • -v VERBOSITY, --verbose VERBOSITY

    Verbosity level (default: 1)

  • -r, --random-agent

    Use a random User Agent for HTTP requests (default: Chrome Win10)

  • -e, --exploit

    Enable exploit mode (default: check mode)

  • -s, --scrape

    Scraping mode: scrape all the pages from moodle and save the result in a JSON file (default: disabled)

  • -o OUTFILE, --outfile OUTFILE

    Save scan results to a JSON file

  • -m, --list-modules

    Option to list all the community vulnerability modules and check which ones are enabled

  • -U, --update

    Update badmoodle official vulnerability database by scraping Moodle security blog, update plugin and themes list by using Moodle API and retrieve new community modules from GitHub repository

Community Vulnerability Modules

Since Moodle is so strict about their vulnerability disclosure program, a lot of vulnerabilities that security researchers discover and share with Moodle end up rejected or put on hold forever.

All these vulnerabilities will never see the light, they will be left unfixed and forgotten by Moodle... but not by badmoodle ;)

You can just add a community vulnerability module with your exploit code and badmoodle will execute it for you :)

badmoodle is modular, which means that you can add a community vulnerability module that will be executed by badmoodle without interfering with the rest of the code.

Adding a community vulnerability module is very simple: just create a .py file inside the "vulns" directory and badmoodle will execute it alongside the other modules.

badmoodle needs only 2 requirements to make your module work:

  • It must have a boolean variable enabled and a string variable name.

    The enabled boolean variable is used to determine wether badmoodle should run the module or not. This allows to enable or disable modules by simply editing this variable without removing it from the "vulns" folder.

    The name string variable is just the vulnerability name, that will be printed in the core.

  • It must have the functions check(args, sess, version) and exploit(args, sess, version)

    These are the main functions of the module, the ones badmoodle will call in the core. Through these functions badmoodle will pass to the module the script arguments, the request session object of the script (useful for authenticated sessions) and moodle version.

    The check function is a boolean function that only checks whether the host is vulnerable or not, the exploit function instead will exploit that vulnerability.

    If in check mode badmoodle will call only the check function to only determine whether the host is vulnerable or not, if in exploit mode badmoodle will also call the exploit function for exploiting the vulnerability.

You are also free to include all the logging and output functions you need by using from utils.output import * for colored output functions and from utils.logging import * for logging functions.

There follows a template for a badmoodle community vulnerability module:

'''
@Title:
MODULE_TITLE

@Author:
MODULE_AUTHOR

@Description:
MODULE_DESCRIPTION
'''

from utils.output import *
from utils.logging import *


name = 'VULNERABILITY_NAME'
enabled = True


def check(args, sess, version):
	#YOUR_CHECK_CODE_HERE
	#return True if the host is vulnerable, False otherwise


def exploit(args, sess, version):
	#YOUR_EXPLOIT_CODE_HERE

badmoodle comes with 2 community vulnerability modules built-in:

  • A module for a Dashboard Stored XSS vulnerability

  • A module for an Atto Editor Stored XSS vulnerability

Contribute

If you wrote a community vulnerability module for badmoodle and want to share it with the community, you can contribute to the badmoodle project.

Pull requests with new community vulnerability modules are very welcome :)

Also, if you want to report a bug, feel free to open an issue or contact me via mail at [email protected]

To do

Currently these are the features that are planned to be implemented in badmoodle:

  • Event logging
  • More granular version check
  • Multithreading mode (for instance for plugin/themes enumeration)
  • Getting vulnerabilities from snyk.io
  • Packaging (Makefile, PKGBUILD)
  • Releases for debian-based and arch-based distribution (.deb and .tar.xz packages)

Credits

badmoodle is coded by Michele 'cyberaz0r' Di Bonaventura.

A special thanks to Panfilo Salutari for the idea of the concept of the tool.

Thanks to moodlescan (https://github.com/inc0d3/moodlescan) for the specific version check technique and its version database.

Changelog

Changelog is available here

badmoodle's People

Contributors

cyberaz0r 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

Watchers

 avatar  avatar

badmoodle's Issues

Feature Request: colors

It would be nice to add colored output to distinguish the various phases of execution and quality of results

Update problem 'All previous versions' cannot be processed

Nice script. Founds properly vulnerabilities on some testing older 3.9 Moodle instance.

Anyway when I use "--update" it shows an exception. Seems like string 'All previous versions' cannot be processed.

[+] Moodle version: v3.9

[*] Checking for official vulnerabilities from vulnerability database
Traceback (most recent call last):
  File "./badmoodle.py", line 235, in <module>
    main()
  File "./badmoodle.py", line 228, in main
    check_official_vulnerabilities(version)
  File "./badmoodle.py", line 86, in check_official_vulnerabilities
    vulnerabilities_found = list_vulnerabilities(version[1:].split('-')[0])
  File "/root/badmoodle/utils/version.py", line 76, in list_vulnerabilities
    if check_in_range(ver, vuln_ver):
  File "/root/badmoodle/utils/version.py", line 61, in check_in_range
    ver_from = int(''.join([str(x).zfill(2) for x in vuln_ver['from'].split('.')]))
ValueError: invalid literal for int() with base 10: 'All previous versions'


Error when updating

Command:

python badmoodle.py -U

Result:

[*] Updating badmoodle
[*] Updating vulnerability database by scraping Moodle official security advisory blog
[X] Update failed: error encountered while updating vulnerability database
Traceback (most recent call last):
  File "D:\badmoodle-main\badmoodle-main\badmoodle.py", line 30, in update
    update_vulnerability_database(verbosity)
  File "D:\badmoodle-main\badmoodle-main\lib\update.py", line 174, in update_vulnerability_database
    title = advisory.find('h3', class_='h4').get_text()
AttributeError: 'NoneType' object has no attribute 'get_text'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\badmoodle-main\badmoodle-main\badmoodle.py", line 351, in <module>
    main()
  File "D:\badmoodle-main\badmoodle-main\badmoodle.py", line 230, in main
    update(args.verbosity)
  File "D:\badmoodle-main\badmoodle-main\badmoodle.py", line 37, in update
    print_info('Details of the error are reported in "{}"'.format(exception_logfile()))
TypeError: exception_logfile() missing 1 required positional argument: 'exception'

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.