Skip to content
Permalink
Browse files

dirsearch: Breaks if ~/.dirsearch/ does not exist (#512)

  • Loading branch information...
linxon committed Oct 10, 2019
1 parent d2939d0 commit cca98884187370d9788eafe62d864fc1d1601bcb
@@ -3,10 +3,10 @@

EAPI=7

PYTHON_COMPAT=( python3_{5,6} )
PYTHON_COMPAT=( python3_{5,6,7} )
PYTHON_REQ_USE="threads"

inherit eutils python-r1
inherit eutils python-single-r1

DESCRIPTION="A simple command line tool designed to brute force dirs and files in websites"
HOMEPAGE="https://github.com/maurosoria/dirsearch"
@@ -17,41 +17,35 @@ LICENSE="GPL-2"
SLOT=0
IUSE=""

RDEPEND="${PYTHON_DEPS}"
DEPEND="${PYTHON_DEPS}"
RDEPEND=""

pkg_setup() {
python_setup
python-single-r1_pkg_setup
}

src_prepare() {
eapply "${FILESDIR}/add_homedir_support.patch"
# run it without fucking root!
eapply "${FILESDIR}/add_homedir_support-r1.patch"

mv *.md "${T}" || die
python_fix_shebang -q "${S}"

python_fix_shebang "${S}"
default
}

src_install() {
insinto "/usr/share/${PN}"
for x in db \
lib \
thirdparty \
dirsearch.py \
default.conf
do
doins -r "$x"
done
doins -r *

python_optimize "${D}/usr/share/${PN}"

make_wrapper $PN \
"python3 /usr/share/${PN}/dirsearch.py"

dodoc \
CHANGELOG.md \
README.md
dodoc "${T}"/*.md
}

pkg_postinst() {
elog "\nExample: https://infosectoughguy.blogspot.com/2016/10/lazy-directory-searching-for-pentesters.html\n"
elog "Please create the following folder: mkdir -p ~/.dirsearch/"
}
@@ -0,0 +1,53 @@
diff -ur a/lib/controller/Controller.py b/lib/controller/Controller.py
--- a/lib/controller/Controller.py 2017-07-25 08:03:31.000000000 +0300
+++ b/lib/controller/Controller.py 2019-10-10 17:31:38.082321707 +0300
@@ -51,7 +51,7 @@
self.exit = False
self.arguments = arguments
self.output = output
- self.savePath = self.script_path
+ self.savePath = FileUtils.buildPath(os.path.expanduser('~'), ".dirsearch")
if self.arguments.saveHome:
savePath = self.getSavePath()
if not FileUtils.exists(savePath):
@@ -180,7 +180,12 @@

def setupErrorLogs(self):
fileName = "errors-{0}.log".format(time.strftime('%y-%m-%d_%H-%M-%S'))
- self.errorLogPath = FileUtils.buildPath(FileUtils.buildPath(self.savePath, "logs", fileName))
+ logs = FileUtils.buildPath(self.savePath, "logs")
+
+ if not FileUtils.exists(logs):
+ FileUtils.createDirectory(logs)
+
+ self.errorLogPath = FileUtils.buildPath(logs, fileName)
self.errorLog = open(self.errorLogPath, "w")

def setupBatchReports(self):
diff -ur a/lib/core/ArgumentParser.py b/lib/core/ArgumentParser.py
--- a/lib/core/ArgumentParser.py 2017-07-25 08:03:31.000000000 +0300
+++ b/lib/core/ArgumentParser.py 2019-10-10 17:23:30.377578430 +0300
@@ -16,6 +16,9 @@
#
# Author: Mauro Soria

+import os
+import shutil
+
from optparse import OptionParser, OptionGroup

from lib.utils.FileUtils import File
@@ -135,7 +138,12 @@

def parseConfig(self):
config = DefaultConfigParser()
- configPath = FileUtils.buildPath(self.script_path, "default.conf")
+ configPath = FileUtils.buildPath(os.path.expanduser('~'), ".dirsearch", "dirsearch.conf")
+
+ if not FileUtils.exists(configPath):
+ os.makedirs(os.path.dirname(configPath), exist_ok=True)
+ shutil.copyfile(FileUtils.buildPath(self.script_path, 'default.conf'), configPath)
+
config.read(configPath)

# General

This file was deleted.

0 comments on commit cca9888

Please sign in to comment.
You can’t perform that action at this time.