Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/example.py
Views: 11766
#!/usr/bin/env python31# -*- coding: utf-8 -*-23# standard modules4import logging56# extra modules7dependencies_missing = False8try:9import requests10except ImportError:11dependencies_missing = True1213from metasploit import module141516metadata = {17'name': 'Python Module Example',18'description': '''19Python communication with msfconsole.20''',21'authors': [22'Jacob Robles'23],24'date': '2018-03-22',25'license': 'MSF_LICENSE',26'references': [27{'type': 'url', 'ref': 'https://www.rapid7.com/blog/post/2017/12/28/regifting-python-in-metasploit/'},28{'type': 'aka', 'ref': 'Coldstone'}29],30'type': 'single_scanner',31'options': {32'targeturi': {'type': 'string', 'description': 'The base path', 'required': True, 'default': '/'},33'rhost': {'type': 'address', 'description': 'Target address', 'required': True, 'default': None}34}35}363738def run(args):39module.LogHandler.setup(msg_prefix='{} - '.format(args['rhost']))40if dependencies_missing:41logging.error('Module dependency (requests) is missing, cannot continue')42return4344# Your code here45try:46r = requests.get('https://{}/{}'.format(args['rhost'], args['targeturi']), verify=False)47except requests.exceptions.RequestException as e:48logging.error('{}'.format(e))49return5051logging.info('{}...'.format(r.text[0:50]))525354if __name__ == '__main__':55module.run(metadata, run)565758