Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError 'hash' / 'Value' whle running `snare --port 8080 --page-dir "some site name" #201

Open
ADI10HERO opened this issue Mar 30, 2019 · 10 comments

Comments

@ADI10HERO
Copy link

Hello i sucessully set up snare (example.com) worked but then cloning twitter,gmail and then my college website gave errors.
Twitter and Gmail were not clonned to begin with but the college website (http) was cloned but when i tried to run the above mentioned command it gave the following error :

"""
Traceback (most recent call last):
File "/usr/local/bin/snare", line 4, in
import('pkg_resources').run_script('Snare==0.3.0', 'snare')
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 658, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 1445, in run_script
exec(script_code, namespace, namespace)
File "/usr/local/lib/python3.6/dist-packages/Snare-0.3.0-py3.6.egg/EGG-INFO/scripts/snare", line 200, in
File "/usr/lib/python3.6/asyncio/base_events.py", line 473, in run_until_complete
return future.result()
File "/usr/local/lib/python3.6/dist-packages/Snare-0.3.0-py3.6.egg/snare/server.py", line 91, in start
KeyError: 'hash'
you are running the latest version
""""
Help wanted :)

@rnehra01
Copy link
Collaborator

Can you provide the link your college website?

@ADI10HERO
Copy link
Author

Yes sure, well my college official website is bad (sorry) This is another website giving same error i think this will do?
http://www.kjscecodecell.com/

@rnehra01
Copy link
Collaborator

rnehra01 commented Apr 2, 2019

It is working fine for me. Can you show the commands you run?

@erwanlr
Copy link

erwanlr commented Dec 31, 2019

I have the same issue. Cloned a local site with sudo clone --target http://wp.lab/

Then ran sudo snare --port 8080 --page-dir wp.lab which resulted in:

Traceback (most recent call last):
  File "/usr/local/bin/snare", line 4, in <module>
    __import__('pkg_resources').run_script('Snare==0.3.0', 'snare')
  File "/Users/xxxx/Library/Python/3.7/lib/python/site-packages/pkg_resources/__init__.py", line 666, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/Users/xxxx/Library/Python/3.7/lib/python/site-packages/pkg_resources/__init__.py", line 1453, in run_script
    exec(script_code, namespace, namespace)
  File "/usr/local/lib/python3.7/site-packages/Snare-0.3.0-py3.7.egg/EGG-INFO/scripts/snare", line 180, in <module>
KeyError: 'hash'

@Parth1811
Copy link
Contributor

Is there any solution to this problem? I'm a facing the same issue

@afeena
Copy link
Collaborator

afeena commented Feb 26, 2020

@Parth1811 guess it might be connected #215

@Parth1811
Copy link
Contributor

@Parth1811 guess it might be connected #215

@afeena I somehow got this fixed. But I'm unable to replicate it now.
I don't think it's related #215, it may be an issue related to dependencies.
Is there any way to reproduce it?

@afeena
Copy link
Collaborator

afeena commented Mar 4, 2020

@Parth1811 how you reproduce that for the first time? I could give it a try

@steve7158
Copy link
Contributor

steve7158 commented Apr 19, 2020

Hi @Parth1811 were you able replicate the error.
In my case the cloner and the snare are working perfectly.
if the issue is related to '/' at the end of url, can you try this solution :)

pattern=re.compile(r'(http://|https://)?(www\.)?(\w+)(\.\w+)(/\S+)*(/)')
match = re.search(pattern, url)
        if match:
            new_url=pattern.sub(r'\1\2\3\4\5',url)

@lordlabuckdas
Copy link
Contributor

The KeyError: 'hash' most likely occurs at a call like meta_info[args.index_page]['hash'].

Both in Snare and Cloner, we set the default index page to index.html without checking if it exists, but index.html is not the default index file for some websites, like how sites that use PHP and thus Wordpress sites have index.php as their default index page. This way, this issue is related to #215.

One solution to solve this issue could be to iterate through a list of common index pages from various languages and frameworks in the exact same order that a server would and check the status code of the corresponding site for success.

For example, index_page_list = ['index.html', 'index.htm', 'index.shtml', 'index.xhtml', 'index.php'].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants