Description: Initialize the config directory and files
Upstream creates and initializes the ~/.config/OSRFramework in the
setup.py. We disable this for Kali and create a function
initialize_config_files to manage the creation and installation of all
the required files.
Author: Sophie Brun <[email protected]>
Last-Update: 2017-09-18
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/osrframework/utils/configuration.py
+++ b/osrframework/utils/configuration.py
@@ -23,9 +23,40 @@
import ConfigParser
import os
import sys
+import shutil
+import glob
import osrframework.utils.errors as errors
+def initialize_config_files():
+ """
+ Function to create and initialize the configuration files and
+ directories.
+ """
+ LOCAL_CONFIG_DIR = getConfigPath()["appPath"]
+# LOCAL_CONFIG_TRANSFORMS_DIR = getConfigPath()["appPathTransforms"]
+ INSTALL_PATH = '/usr/lib/python2.7/dist-packages/osrframework'
+
+ # Copy default config file into osrframework local config
+ for dirconf in ["default", "plugins"]:
+ shutil.copytree(os.path.join('/etc/osrframework',dirconf), os.path.join(LOCAL_CONFIG_DIR, dirconf))
+
+ # Create directory data
+ os.mkdir(getConfigPath()["appPathData"])
+
+ # Create directory Transforms before copy *.py files
+# os.mkdir(LOCAL_CONFIG_TRANSFORMS_DIR)
+
+ # Copy *.py files in transforms directory
+# for f in glob.glob(os.path.join(INSTALL_PATH, "transforms/[a-z]*.py")):
+# shutil.copy(f, LOCAL_CONFIG_TRANSFORMS_DIR)
+# for f in ["alias_generator.py", "entify.py", "phonefy.py", "searchfy.py", "mailfy.py", "usufy.py", "domainfy.py", "enumerate-profiles.py"]:
+# shutil.copy((os.path.join(INSTALL_PATH, f)), LOCAL_CONFIG_TRANSFORMS_DIR)
+
+ # Copy default config files for the user
+ for f in ["browser.cfg", "general.cfg"]:
+ shutil.copy((os.path.join(getConfigPath()["appPathDefaults"], f)),LOCAL_CONFIG_DIR)
+
def changePermissionsRecursively(path, uid, gid):
"""
Function to recursively change the user id and group id.
@@ -92,9 +123,10 @@ def getConfigPath(configFileName = None)
}
# Creating them if they don't exist
- for path in paths.keys():
- if not os.path.exists(paths[path]):
- os.makedirs(paths[path])
+#Don't create them in Kali: initialize_config_files() will create them
+# for path in paths.keys():
+# if not os.path.exists(paths[path]):
+# os.makedirs(paths[path])
return paths
@@ -117,6 +149,8 @@ def returnListOfConfigurationValues(util
"""
VALUES = {}
+ if not os.path.exists(getConfigPath()["appPath"]):
+ initialize_config_files()
# If a api_keys.cfg has not been found, creating it by copying from default
configPath = os.path.join(getConfigPath()["appPath"], "general.cfg")