Esempio n. 1
0
def show_all():
    """show all plugin, --all/-a option."""
    logger.info('show all plugin introduction')
    table_lst = [('framework name', 'tags')]
    for plugin_info in all_plugin():
        tags = ', '.join(plugin_info.get('alias'))
        table_lst.append((plugin_info.get('framework'), tags))
    table = AsciiTable(table_lst)
    show_output(table.table)
Esempio n. 2
0
def make_version_test():
    logger.warning('make_version_test start!')
    import ext.err_hunter as err_hunter
    from test_data import target_tmp_hash_map3 as target_tmp_hash_map
    from observer.version import make_version
    django = search('django')
    logger.critical(
        'make_version return: %s',
        make_version(target_tmp_hash_map, django.get('fingerprint')))
    logger.critical(
        'make_version return: %s',
        make_version(target_tmp_hash_map, django.get('reverse_fingerprint'),
                     False))
    logger.info('make_version_test pass!')
Esempio n. 3
0
def static_hash_map_test():
    logger.warning('static_hash_map_test start!')
    django = search('django')
    distri = file_distribute(django)
    logger.info('file_distribute end.')
    target_website = 'http://127.0.0.1:8000/'
    map_ = static_hash_map(target_website, distri, depth=0)
    logger.info(json.dumps(map_, indent=4, sort_keys=True))
    logger.info('static_hash_map_test pass!')
Esempio n. 4
0
 def make_result(self):
     """Make info_result."""
     framework_name = self.framework_name
     logger.info('functions has done. init the result and set the name and alias.')
     self.info_result['framework'] = framework_name
     self.add_alias(framework_name)
     logger.info('set the all versions.')
     self.set_versions()
     logger.info('diff the file version by version and get the info of different file.')
     self.forward_diff()
     self.reverse_diff()
Esempio n. 5
0
def run():
    """main function."""
    args = call_parser()
    check_run_options(args)
    depend = args.depend
    logger.info('searching %s fingerprint infomation.....', depend)
    plugin_info = search(depend)
    if not plugin_info:
        logger.error('%s can not find a fingerprint of %s', APPNAME, depend)
        logger.info('your can use --all to print all fingerprint supported.')
        # TODO: show the request fingerprint url in github
        sys.exit()
    logger.info('already found %s fingerprint.', depend)
    distri = file_distribute(plugin_info)
    logger.info('start to request hash map on %s in depth %d.', args.url,
                args.depth)
    hash_map = static_hash_map(args.url, distri, args.depth)
    logger.verbose('show the hash map: %s',
                   json.dumps(hash_map, indent=4, sort_keys=True))
    logger.info('let\'s observer which version of %s.', depend)
    version_set = make_all(hash_map, plugin_info)
    cond_lst = [
        VersionCond.from_str(''.join(comp)) for comp in calc(version_set)
    ]
    logger.info('show the possible versions of %s on %s', depend, args.url)
    result_lst = [('possible version', )]
    for version_str in plugin_info.get('versions'):
        if all((cond.match(version_str) for cond in cond_lst)):
            info = '{} v{}'.format(depend, version_str)
            logger.verbose(info)
            result_lst.append((info, ))
    show_output(AsciiTable(result_lst).table)
    sys.exit(0)
Esempio n. 6
0
def file_distribute_test():
    """
    Return like:
    {1: {'/static/admin/admin/js/vendor/jquery/LICENSE-JQUERY.txt'},
    2: {'/static/admin/admin/img/sorting-icons.gif',
    '/static/admin/admin/img/tooltag-add.svg',
    '/static/admin/admin/js/vendor/select2/i18n/gl.js',
    '/static/admin/admin/js/vendor/select2/i18n/ru.js',
    '/static/admin/admin/img/LICENSE',
    '/static/admin/admin/js/vendor/select2/i18n/km.js',
    '/static/admin/admin/img/tool-left.gif',
    '/static/admin/admin/js/vendor/select2/i18n/da.js',
    '/static/admin/admin/img/tooltag-add.png',
    '/static/admin/admin/js/vendor/select2/i18n/sv.js',
    '/static/admin/admin/img/icon-changelink.svg',
    '/static/admin/admin/fonts/Roboto-Bold-webfont.woff',
    '/static/admin/admin/img/gis/move_vertex_off.svg',
    '/static/admin/admin/img/icon_deletelink.gif',
    '/static/admin/admin/img/gis/move_vertex_on.svg',
    '/static/admin/admin/img/tooltag-add.gif',
    '/static/admin/admin/js/vendor/select2/i18n/es.js',
    '/static/admin/admin/js/vendor/select2/i18n/pt.js',
    '/static/admin/admin/img/icon-no.gif',
    '/static/admin/admin/js/autocomplete.js',
    '/static/admin/admin/img/icon_error.gif',
    '/static/admin/admin/js/vendor/select2/i18n/pt-BR.js',
    '/static/admin/admin/img/chooser_stacked-bg.gif',
    '/static/admin/admin/img/icon-unknown.svg',
    '/static/admin/admin/js/vendor/select2/select2.full.js',
    '/static/admin/admin/js/vendor/select2/LICENSE-SELECT2.md',
    '/static/admin/admin/js/vendor/select2/i18n/hi.js',
    '/static/admin/admin/img/sorting-icons.svg',
    '/static/admin/admin/img/chooser-bg.gif',
    '/static/admin/admin/js/getElementsBySelector.js',
    '/static/admin/admin/js/vendor/select2/i18n/zh-TW.js',
    '/static/admin/admin/img/selector-icons.svg',
    '/static/admin/admin/img/tooltag-arrowright.svg',
    '/static/admin/admin/js/vendor/select2/i18n/hu.js',
    '/static/admin/admin/js/vendor/select2/i18n/sr.js',
    '/static/admin/admin/img/icon_clock.gif',
    '/static/admin/admin/css/responsive_rtl.css',
    '/static/admin/admin/js/vendor/select2/i18n/lv.js',
    '/static/admin/admin/img/search.svg',
    '/static/admin/admin/img/icon-clock.svg',
    '/static/admin/admin/img/deleted-overlay.gif',
    '/static/admin/admin/js/vendor/select2/i18n/vi.js',
    '/static/admin/admin/js/vendor/select2/i18n/ar.js',
    '/static/admin/admin/js/cancel.js',
    '/static/admin/admin/css/responsive.css',
    '/static/admin/admin/img/tooltag-arrowright.gif',
    '/static/admin/admin/js/vendor/select2/i18n/ja.js',
    '/static/admin/admin/js/popup_response.js',
    '/static/admin/admin/js/vendor/select2/i18n/eu.js',
    '/static/admin/admin/css/fonts.css',
    '/static/admin/admin/js/vendor/select2/i18n/he.js',
    '/static/admin/admin/js/vendor/select2/i18n/ko.js',
    '/static/admin/admin/fonts/Roboto-Light-webfont.woff',
    '/static/admin/admin/js/vendor/select2/i18n/pl.js',
    '/static/admin/admin/js/vendor/jquery/jquery.js',
    '/static/admin/admin/img/gis/move_vertex_on.png',
    '/static/admin/admin/js/vendor/select2/i18n/ms.js',
    '/static/admin/admin/img/icon_calendar.gif',
    '/static/admin/admin/img/tooltag-add_over.gif',
    '/static/admin/admin/js/vendor/select2/i18n/tr.js',
    '/static/admin/admin/js/admin/ordering.js',
    '/static/admin/admin/js/vendor/select2/i18n/th.js',
    '/static/admin/admin/js/vendor/xregexp/xregexp.min.js',
    '/static/admin/admin/css/autocomplete.css',
    '/static/admin/admin/img/tool-right.gif',
    '/static/admin/admin/js/vendor/select2/i18n/lt.js',
    '/static/admin/admin/js/vendor/select2/i18n/az.js',
    '/static/admin/admin/img/icon-addlink.svg',
    '/static/admin/admin/js/vendor/xregexp/xregexp.js',
    '/static/admin/admin/js/LICENSE-JQUERY.txt',
    '/static/admin/admin/img/changelist-bg_rtl.gif',
    '/static/admin/admin/img/icon-alert.svg',
    '/static/admin/admin/fonts/Roboto-Regular-webfont.woff',
    '/static/admin/admin/js/vendor/select2/i18n/id.js',
    '/static/admin/admin/img/nav-bg-selected.gif',
    '/static/admin/admin/js/vendor/select2/i18n/fi.js',
    '/static/admin/admin/css/vendor/select2/LICENSE-SELECT2.md',
    '/static/admin/admin/js/vendor/select2/i18n/sr-Cyrl.js',
    '/static/admin/admin/img/tool-left_over.gif',
    '/static/admin/admin/js/vendor/select2/i18n/it.js',
    '/static/admin/admin/img/icon-unknown.gif',
    '/static/admin/admin/js/compress.py',
    '/static/admin/admin/js/vendor/select2/i18n/cs.js',
    '/static/admin/admin/img/icon-deletelink.svg',
    '/static/admin/admin/img/tool-right_over.gif',
    '/static/admin/admin/js/vendor/select2/i18n/ro.js',
    '/static/admin/admin/js/vendor/select2/i18n/fa.js',
    '/static/admin/admin/img/icon-no.svg',
    '/static/admin/admin/js/vendor/select2/i18n/ca.js',
    '/static/admin/admin/img/icon_success.gif',
    '/static/admin/admin/css/vendor/select2/select2.min.css',
    '/static/admin/admin/js/vendor/select2/i18n/bg.js',
    '/static/admin/admin/js/vendor/xregexp/LICENSE-XREGEXP.txt',
    '/static/admin/admin/img/icon-yes.svg',
    '/static/admin/admin/js/vendor/select2/i18n/hr.js',
    '/static/admin/admin/js/vendor/select2/i18n/zh-CN.js',
    '/static/admin/admin/img/selector-search.gif',
    '/static/admin/admin/img/icon-unknown-alt.svg',
    '/static/admin/admin/js/vendor/select2/i18n/en.js',
    '/static/admin/admin/js/vendor/select2/i18n/nb.js',
    '/static/admin/admin/img/nav-bg-grabber.gif',
    '/static/admin/admin/js/vendor/select2/i18n/mk.js',
    '/static/admin/admin/img/README.txt',
    '/static/admin/admin/js/vendor/select2/i18n/sk.js',
    '/static/admin/admin/img/gis/move_vertex_off.png',
    '/static/admin/admin/img/selector-icons.gif',
    '/static/admin/admin/js/vendor/select2/select2.full.min.js',
    '/static/admin/admin/img/icon-yes.gif',
    '/static/admin/admin/js/prepopulate_init.js',
    '/static/admin/admin/js/vendor/select2/i18n/el.js',
    '/static/admin/admin/img/icon_addlink.gif',
    '/static/admin/admin/img/tooltag-arrowright.png',
    '/static/admin/admin/img/calendar-icons.svg',
    '/static/admin/admin/js/vendor/select2/i18n/fr.js',
    '/static/admin/admin/js/vendor/select2/i18n/uk.js',
    '/static/admin/admin/img/tooltag-arrowright_over.gif',
    '/static/admin/admin/js/related-widget-wrapper.js',
    '/static/admin/admin/img/icon-calendar.svg',
    '/static/admin/admin/img/icon_alert.gif',
    '/static/admin/admin/css/vendor/select2/select2.css',
    '/static/admin/admin/img/inline-delete.svg',
    '/static/admin/admin/js/vendor/select2/i18n/is.js',
    '/static/admin/admin/js/vendor/select2/i18n/de.js',
    '/static/admin/admin/fonts/README.txt',
    '/static/admin/admin/js/vendor/select2/i18n/et.js',
    '/static/admin/admin/js/vendor/select2/i18n/nl.js',
    '/static/admin/admin/img/icon_changelink.gif'},
    3: {'/static/admin/admin/img/inline-delete.png',
    '/static/admin/admin/js/vendor/jquery/jquery.min.js',
    '/static/admin/admin/fonts/LICENSE.txt',
    '/static/admin/admin/img/inline-restore-8bit.png',
    '/static/admin/admin/js/change_form.js',
    '/static/admin/admin/img/changelist-bg.gif',
    '/static/admin/admin/img/icon_searchbox.png',
    '/static/admin/admin/css/ie.css',
    '/static/admin/admin/img/default-bg.gif',
    '/static/admin/admin/js/timeparse.js',
    '/static/admin/admin/img/inline-restore.png',
    '/static/admin/admin/img/inline-delete-8bit.png',
    '/static/admin/admin/img/inline-splitter-bg.gif',
    '/static/admin/admin/img/nav-bg.gif',
    '/static/admin/admin/img/default-bg-reverse.gif',
    '/static/admin/admin/img/nav-bg-reverse.gif'},
    4: {'/static/admin/admin/js/jquery.init.js',
    '/static/admin/admin/css/login.css',
    '/static/admin/admin/css/dashboard.css',
    '/static/admin/admin/js/prepopulate.js',
    '/static/admin/admin/js/jquery.js',
    '/static/admin/admin/js/collapse.js',
    '/static/admin/admin/js/jquery.min.js'},
    5: {'/static/admin/admin/js/prepopulate.min.js',
    '/static/admin/admin/js/SelectBox.js'},
    6: {'/static/admin/admin/css/changelists.css',
    '/static/admin/admin/css/rtl.css',
    '/static/admin/admin/js/urlify.js'},
    7: {'/static/admin/admin/js/collapse.min.js',
    '/static/admin/admin/js/calendar.js'},
    8: {'/static/admin/admin/js/actions.min.js',
    '/static/admin/admin/js/actions.js',
    '/static/admin/admin/js/inlines.js'},
    9: {'/static/admin/admin/js/SelectFilter2.js',
    '/static/admin/admin/js/inlines.min.js',
    '/static/admin/admin/css/forms.css'},
    10: {'/static/admin/admin/css/widgets.css',
    '/static/admin/admin/js/core.js',
    '/static/admin/admin/css/base.css'},
    11: {'/static/admin/admin/js/admin/DateTimeShortcuts.js'},
    14: {'/static/admin/admin/js/admin/RelatedObjectLookups.js'}}
    """
    django = search('django')
    distri = file_distribute(django)
    logger.info(distri)
Esempio n. 7
0
def mdf_of_file_and_byte_content_test():
    logger.warning('mdf_of_file_and_byte_content_test start!')
    filepath = './observer.py'
    fbyte = open(filepath, 'rb').read()
    assert (file_md5(filepath) == byte_md5(fbyte)) is True
    logger.info('mdf_of_file_and_byte_content_test pass!')