From 89de19b87845e107c549d905e1fa1887e5e5f88e Mon Sep 17 00:00:00 2001 From: Fabian Martinez Portantier Date: Mon, 23 Apr 2018 00:50:10 -0300 Subject: [PATCH] show categories --- habu/lib/webid.py | 32 ++++++-------------------------- setup.py | 2 +- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/habu/lib/webid.py b/habu/lib/webid.py index 5f7baa3..65c4378 100644 --- a/habu/lib/webid.py +++ b/habu/lib/webid.py @@ -27,29 +27,12 @@ def webid(url, no_cache=False, verbose=False): logging.error(e) return False - #with (DATADIR / 'apps.json').open() as f: - # data = json.load(f) - with (DATADIR / 'apps-habu.json').open() as f: data = json.load(f) apps = data['apps'] categories = data['categories'] - #apps.update(data_custom['apps']) - #categories.update(data_custom['categories']) - - # convertir los strings a listas, para que siempre los valores sean listas - #for app in apps: - # for field in ['url', 'html', 'env', 'script', 'implies', 'excludes']: - # - # if field in apps[app]: - # if not isinstance(apps[app][field], list): - # apps[app][field] = [apps[app][field]] - - #with (DATADIR / 'apps-habu.json').open('w') as f: - # f.write(json.dumps({'apps':apps, 'categories': categories}, indent=4)) #data_custom = json.load(f) - content = r.text soup = BeautifulSoup(content, "lxml") tech = {} @@ -159,25 +142,22 @@ def webid(url, no_cache=False, verbose=False): logging.info("{imply} detected because implied by {t}".format(imply=imply, t=t)) tech[imply] = apps[imply] - for t in list(tech.keys()): - try: - tech[t]['category'] = categories[tech[t]['cats'][0]]['name'] - except KeyError: - pass - for t in list(tech.keys()): for exclude in tech[t].get('excludes', []): logging.info("removing {exlude} because its excluded by {t}".format(exlude=exclude, t=t)) del(tech[t]) response = {} + for t in sorted(tech): + response[t] = {'categories':[]} if 'version' in tech[t]: - response[t] = version #version.append('{app} {version}'.format(app=t, version=version)) - else: - response[t] = None #.append('{app}'.format(app=t)) + response[t]['version'] = version + for category in tech[t]['cats']: + response[t]['categories'].append(categories[str(category)]['name']) return response if __name__ == '__main__': print(webid('https://www.woocommerce.com')) + diff --git a/setup.py b/setup.py index 8c385f2..664d900 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='habu', - version='0.0.59', + version='0.0.60', description='Python Network Hacking Toolkit', long_description=readme, author='Fabian Martinez Portantier',