Skip to content

Use sqlmap as a library #2083

Description

@jetz

Hi @stamparm:

I want to embed sqlmap into my project as a library (not subporcess call), but found it's difficult, so I have to write a wrapper to call sqlmap.main() and retrive the result from session.sqlite, just as the following snippet (should be placed in sqlmap dir, it raises exception if use pip-installed sqlmap). Is there a simpler way to do it (eg. just call an entrypoint callable and get the json result)?

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import pprint
import sqlmap
from lib.core.enums import HASHDB_KEYS
from lib.core.common import hashDBRetrieve


def patch_exit(x):
    pass
os._exit = patch_exit


def p(data):
    pprint.pprint(r)

if __name__ == "__main__":
    sqlmap.main()
    try:
        r = hashDBRetrieve(HASHDB_KEYS.KB_INJECTIONS, True)
        p(r)
    except Exception as e:
        print(e)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions