securing / DumpsterDiver

Tool to search secrets in various filetypes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error while running

nikhilgeo opened this issue · comments

I'm hit with below error when running in Ubuntu, python 2.7

python DumpsterDiver.py -p ~/src/sourcedir -s --bad-expressions "test" > result.txt
Traceback (most recent call last):
  File "DumpsterDiver.py", line 143, in <module>
    core.start_the_hunt()
  File "/home/user/Downloads/DumpsterDiver-master/core.py", line 275, in start_the_hunt
    save_output()
  File "/home/user/Downloads/DumpsterDiver-master/core.py", line 326, in save_output
    logger.error("while trying to write to " + str(_file) + " file. Details:\n" + str(e))
NameError: global name '_file' is not defined

Hi @nikhilgeo !
DumpsterDiver requires using Python 3. Please let me know if you have any further comments.

If it requires Python 3, why does the hashbang say python? Many Linux distributions are still keeping /usr/bin/python -> Python 2 for compatibility reasons, and it will be a while until this changes. Better be explicit and say python3.

Also, the hash-bang won't always work well, because env is usually installed in /usr/bin, not /bin on Linux (although the latter can be a symlink to the former in some cases).

I recommend the following patch:

diff --git a/DumpsterDiver.py b/DumpsterDiver.py
old mode 100644
new mode 100755
index 272702f..847e2c5
--- a/DumpsterDiver.py
+++ b/DumpsterDiver.py
@@ -1,4 +1,4 @@
-#!/bin/env python
+#!/usr/bin/env python3
 
 import advancedSearch
 import core
diff --git a/advancedSearch.py b/advancedSearch.py
index 84f0530..612e742 100644
--- a/advancedSearch.py
+++ b/advancedSearch.py
@@ -1,4 +1,4 @@
-#!/bin/env python
+#!/usr/bin/env python3
 
 import core
 import fnmatch
diff --git a/core.py b/core.py
index 69eefc1..a568232 100644
--- a/core.py
+++ b/core.py
@@ -1,4 +1,4 @@
-#!/bin/env python
+#!/usr/bin/env python3
 
 import advancedSearch
 import fnmatch
diff --git a/entropy.py b/entropy.py
index befe393..7ac5286 100644
--- a/entropy.py
+++ b/entropy.py
@@ -1,4 +1,4 @@
-#!/bin/env python
+#!/usr/bin/env python3
 
 import math
 import sys

Oh, and since that would make the scripts executable, I suggest giving the DumpsterDiver execute permissions as well:

chmod +x DumpsterDiver.py

Hi @onitake ! Thanks for your suggestions. The changes have been just applied.