sensepost / snoopy-ng

Snoopy v2.0 - modular digital terrestrial tracking framework
Other
429 stars 128 forks source link

Problems creating Drone account on server #37

Closed stevenhorner closed 9 years ago

stevenhorner commented 9 years ago

When I run the following command to create a Drone account I get the error below: snoopy_auth --create myDrone

Traceback (most recent call last): File "/usr/bin/snoopyauth", line 164, in auth = auth('sqlite:////root/snoopy_api/snoopy.db') File "/usr/bin/snoopy_auth", line 30, in init self.metadata.reflect() File "build/bdist.linux-x86_64/egg/sqlalchemy/schema.py", line 2497, in reflect File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py", line 2504, in table_names File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py", line 2490, in contextual_connect File "build/bdist.linux-x86_64/egg/sqlalchemy/pool.py", line 224, in connect File "build/bdist.linux-x86_64/egg/sqlalchemy/pool.py", line 387, in init File "build/bdist.linux-x86_64/egg/sqlalchemy/pool.py", line 802, in _do_get File "build/bdist.linux-x86_64/egg/sqlalchemy/pool.py", line 188, in _create_connection File "build/bdist.linux-x86_64/egg/sqlalchemy/pool.py", line 270, in init File "build/bdist.linux-x86_64/egg/sqlalchemy/pool.py", line 330, in __connect File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/strategies.py", line 80, in connect File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/default.py", line 281, in connect sqlalchemy.exc.OperationalError: (OperationalError) unable to open database file None None

I am now running sqlalchemy 0.7.8 after having problems with a newer version and seeing problems mentioned in the issues. I can start Snoopy as a server but can't create any Drone accounts. I just get the above error.

3arlybird commented 9 years ago

i am not sure but in the previous versions the auth tokens were stored in the /includes folder --> snoopy_creds.db

or maybe its only a typo since the last commit, because there is no /snoopy_api/ folder. No guarantee but just try to change the path in includes/auth_handler.py:

auth_ = auth('sqlite:////root/snoopyapi/snoopy.db') --> auth = auth('sqlite:///snoopy.db')
or auth_ = auth('sqlite:////root/snoopyapi/snoopy.db') --> auth = auth('sqlite:///%s/snoopy_creds.db' % path)

stevenhorner commented 9 years ago

Thanks @mexmustermann that worked.

I changed line 164 in includes/auth_handler.py

auth_ = auth('sqlite:////root/snoopy_api/snoopy.db')

to

auth_ = auth('sqlite:////root/snoopy.db')

It then allows me to create my Drones, it looks like it was an error in the last commit like you mentioned.

stevenhorner commented 9 years ago

I have done a pull request to fix it.

stevenhorner commented 9 years ago

Actually this is a big issue, the change I made enabled me to create a new Drone Key but it saved it in a new snooby.db file in my home folder "root" in this test case. So my credentials were being stored there but when I try to syn anything it was checking a different copy of the snoopy.db file so couldn't find my credentials.

If the intention is to now store the credentials in the main snooby.db file then changing line 24 in auth_handler.py:

from: def init(self,dbms="sqlite:///%s/snoopy_creds.db" % path, rawdb=None): to def init(self,dbms="sqlite:///snoopy.db", rawdb=None):

and line 164 in authhandler.py: from auth = auth('sqlite:////root/snoopyapi/snoopy.db') to auth = auth('sqlite:///snoopy.db')

This may not be the best approach, storing the credentials in the same DB as the rest of your data when it is in clear text but it does work.

I have not yet tested altering those lines to use a separate snoopy_creds.db file which was the case before the last commit.

My earlier pull request is actually no good to fix the whole problem. If someone is able to give some clarification as to whether the creds should now be in the main snoopy.db or a seperate snoopy_creds.db going forward then I will do a new pull request with a fix.

3arlybird commented 9 years ago

After reading the code in auth_handler.py again, all the changes (Maltego shadow key --> mkt, users, ) have to do with the new Commercial launch of Snoopy-ng. So when you don't use the Commercial Service everything should work for you when you change line 164 in authhandler.py from auth = auth('sqlite:////root/snoopyapi/snoopy.db') to auth = auth() then all the credentials are stored in inlcude/snoopy_creds.db

but thats just quick fix, i hope @glennzw can give us some background infos about the changes.

stevenhorner commented 9 years ago

@mexmustermann There are other parts that appear broken too, but will need separate issues raising. I had to disable wpa.py because it crashes snoopy-ng, presumably when it gets a handshake.

When I get more time I will raise issues for the WPA and any other problems I find and hopefully @glennzw can take a look. It does look like a few things were broken with the last commit.

maximcherny commented 9 years ago

@glennzw - please tag the code up until the recent changes as a release so that one could switch to a known working state.

maximcherny commented 9 years ago

To anyone having issues in the meantime - perhaps switch to commit bd7588055fca71f89d7fb782895e807685a76787?

glennzw commented 9 years ago

Thanks for noticing the typo @stevenhorner, update pushed. The other changes shouldn't affect non-commercial users, but let me know if anything goes wrong?

I haven't made any changes to the WPA code in a long while, could you paste the error you're getting in a new issue?