Refresh patches
Sophie Brun
4 years ago
0 | Description: Add a script to manage configuration during upgrade | |
1 | During a upgrade we have to install the new configuration files in | |
2 | ~/.config/OSRFramework: | |
3 | - Update configuration.py to create the missing directory "data" | |
4 | only if it doesn't exist. | |
5 | - Add a script (which is called in postinst when it's an upgrade) to | |
6 | remove config directories "default", "plugins", "server", "transforms", | |
7 | and install the new directories and files provided by the package. | |
8 | Author: Sophie Brun <[email protected]> | |
0 | From: Sophie Brun <[email protected]> | |
1 | Date: Thu, 23 Jan 2020 10:21:00 +0100 | |
2 | Subject: Add a script to manage configuration during upgrade | |
3 | ||
9 | 4 | Origin: vendor |
10 | 5 | Last-Update: 2018-01-24 |
6 | ||
7 | During a upgrade we have to install the new configuration files in | |
8 | ~/.config/OSRFramework: | |
9 | - Update configuration.py to create the missing directory "data" | |
10 | only if it doesn't exist. | |
11 | - Add a script (which is called in postinst when it's an upgrade) to | |
12 | remove config directories "default", "plugins", "server", "transforms", | |
13 | and install the new directories and files provided by the package. | |
14 | Last-Update: 2018-01-24 | |
11 | 15 | --- |
12 | This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ | |
16 | osrframework/utils/configuration.py | 6 ++++-- | |
17 | osrframework/utils/upgrade_config.py | 12 ++++++++++++ | |
18 | 2 files changed, 16 insertions(+), 2 deletions(-) | |
19 | create mode 100644 osrframework/utils/upgrade_config.py | |
20 | ||
21 | diff --git a/osrframework/utils/configuration.py b/osrframework/utils/configuration.py | |
22 | --- a/osrframework/utils/configuration.py | |
23 | +++ b/osrframework/utils/configuration.py | |
24 | @@ -40,8 +40,10 @@ def initialize_config_files(): | |
25 | for dirconf in ["default", "plugins"]: | |
26 | shutil.copytree(os.path.join('/etc/osrframework',dirconf), os.path.join(LOCAL_CONFIG_DIR, dirconf)) | |
27 | ||
28 | - # Create directory data | |
29 | - os.mkdir(getConfigPath()["appPathData"]) | |
30 | + # Create directory data if it doesn't exist (we keep it at the | |
31 | + # upgrade) | |
32 | + if not os.path.exists(getConfigPath()["appPathData"]): | |
33 | + os.mkdir(getConfigPath()["appPathData"]) | |
34 | ||
35 | # Create directory Transforms before copy *.py files | |
36 | # os.mkdir(LOCAL_CONFIG_TRANSFORMS_DIR) | |
37 | diff --git a/osrframework/utils/upgrade_config.py b/osrframework/utils/upgrade_config.py | |
38 | new file mode 100644 | |
39 | index 0000000..6e9c57d | |
13 | 40 | --- /dev/null |
14 | 41 | +++ b/osrframework/utils/upgrade_config.py |
15 | 42 | @@ -0,0 +1,12 @@ |
25 | 52 | + for confdir in ["default", "plugins", "server", "transforms"]: |
26 | 53 | + shutil.rmtree(os.path.join(configuration.getConfigPath()["appPath"], confdir), True) |
27 | 54 | + configuration.initialize_config_files() |
28 | --- a/osrframework/utils/configuration.py | |
29 | +++ b/osrframework/utils/configuration.py | |
30 | @@ -41,8 +41,10 @@ def initialize_config_files(): | |
31 | for dirconf in ["default", "plugins"]: | |
32 | shutil.copytree(os.path.join('/etc/osrframework',dirconf), os.path.join(LOCAL_CONFIG_DIR, dirconf)) | |
33 | ||
34 | - # Create directory data | |
35 | - os.mkdir(getConfigPath()["appPathData"]) | |
36 | + # Create directory data if it doesn't exist (we keep it at the | |
37 | + # upgrade) | |
38 | + if not os.path.exists(getConfigPath()["appPathData"]): | |
39 | + os.mkdir(getConfigPath()["appPathData"]) | |
40 | ||
41 | # Create directory Transforms before copy *.py files | |
42 | # os.mkdir(LOCAL_CONFIG_TRANSFORMS_DIR) |
0 | Description: Cleanup setup.py | |
1 | The setup.py makes changes that should not be done in a setup: | |
2 | - change the bin path: there is no need for Kali | |
3 | - install config files is the home user directory: should be done at | |
4 | first launch | |
5 | - configure maltego: should be done at first launch | |
6 | Author: Sophie Brun <[email protected]> | |
0 | From: Sophie Brun <[email protected]> | |
1 | Date: Thu, 23 Jan 2020 10:21:00 +0100 | |
2 | Subject: Cleanup setup.py | |
3 | ||
4 | Last-Update: 2017-09-04 | |
5 | ||
6 | The setup.py makes changes that should not be done in a setup: | |
7 | - change the bin path: there is no need for Kali | |
8 | - install config files is the home user directory: should be done at | |
9 | first launch | |
10 | - configure maltego: should be done at first launch | |
7 | 11 | Last-Update: 2017-09-04 |
8 | 12 | --- |
9 | This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ | |
13 | setup.py | 90 ++++++++++++++++++++++++++++++++-------------------------------- | |
14 | 1 file changed, 45 insertions(+), 45 deletions(-) | |
15 | ||
16 | diff --git a/setup.py b/setup.py | |
17 | index 0f05c1c..8ed4965 100644 | |
10 | 18 | --- a/setup.py |
11 | 19 | +++ b/setup.py |
12 | @@ -37,15 +37,15 @@ NEW_VERSION = osrframework.__version__ | |
13 | import osrframework.utils.configuration as configuration | |
14 | ||
15 | # Depending on the place in which the project is going to be upgraded | |
16 | -try: | |
17 | - raise Exception('Trying to load the markdown manually!') | |
18 | - from pypandoc import convert | |
19 | - read_md = lambda f: convert(f, 'rst') | |
20 | -except ImportError: | |
21 | - print("[!] pypandoc module not found, could not convert Markdown to RST") | |
22 | - read_md = lambda f: open(f, 'r').read() | |
23 | -except Exception: | |
24 | - read_md = lambda f: open(f, 'r').read() | |
25 | +#try: | |
26 | +# raise Exception('Trying to load the markdown manually!') | |
27 | +# from pypandoc import convert | |
28 | +# read_md = lambda f: convert(f, 'rst') | |
29 | +#except ImportError: | |
30 | +# print("[!] pypandoc module not found, could not convert Markdown to RST") | |
31 | +# read_md = lambda f: open(f, 'r').read() | |
32 | +#except Exception: | |
33 | +# read_md = lambda f: open(f, 'r').read() | |
34 | ||
35 | # Reading the .md file | |
36 | try: | |
37 | @@ -149,49 +149,49 @@ setup( | |
20 | @@ -113,52 +113,52 @@ setup( | |
38 | 21 | ############################ |
39 | 22 | ### Creating other files ### |
40 | 23 | ############################ |
41 | -print("[*] Changing permissions of the user folders...") | |
24 | -print("[*] OSRFramework > Changing permissions of the user folders...") | |
42 | 25 | -try: |
43 | - configuration.changePermissionsRecursively(paths["appPath"], int(os.getenv('SUDO_UID')), int(os.getenv('SUDO_GID'))) | |
26 | - configuration.change_permissions_recursively(paths["appPath"], int(os.getenv('SUDO_UID')), int(os.getenv('SUDO_GID'))) | |
44 | 27 | -except: |
45 | +#print("[*] Changing permissions of the user folders...") | |
28 | +#print("[*] OSRFramework > Changing permissions of the user folders...") | |
46 | 29 | +#try: |
47 | +# configuration.changePermissionsRecursively(paths["appPath"], int(os.getenv('SUDO_UID')), int(os.getenv('SUDO_GID'))) | |
30 | +# configuration.change_permissions_recursively(paths["appPath"], int(os.getenv('SUDO_UID')), int(os.getenv('SUDO_GID'))) | |
48 | 31 | +#except: |
49 | 32 | # Something happened with the permissions... We omit this. |
50 | 33 | - pass |
51 | +# pass | |
52 | ||
53 | -print("[*] Copying relevant files...") | |
34 | - | |
35 | -print("[*] OSRFramework > Population OSRFramework's configuration folder...") | |
54 | 36 | -files_to_copy= { |
55 | 37 | - paths["appPath"] : [ |
56 | 38 | - os.path.join("config", "browser.cfg"), |
64 | 46 | - ], |
65 | 47 | - paths["appPathWrappers"] : [ |
66 | 48 | - os.path.join("config", "plugins", "wrapper.py.sample"), |
67 | - ], | |
68 | - paths["appPathPatterns"] : [ | |
69 | - os.path.join("config", "plugins", "pattern.py.sample"), | |
49 | - os.path.join("config", "plugins", "wrapper_v2.py.sample"), | |
70 | 50 | - ] |
71 | 51 | -} |
72 | +#print("[*] Copying relevant files...") | |
52 | +# pass | |
53 | + | |
54 | +#print("[*] OSRFramework > Population OSRFramework's configuration folder...") | |
73 | 55 | +#files_to_copy= { |
74 | 56 | +# paths["appPath"] : [ |
75 | 57 | +# os.path.join("config", "browser.cfg"), |
83 | 65 | +# ], |
84 | 66 | +# paths["appPathWrappers"] : [ |
85 | 67 | +# os.path.join("config", "plugins", "wrapper.py.sample"), |
86 | +# ], | |
87 | +# paths["appPathPatterns"] : [ | |
88 | +# os.path.join("config", "plugins", "pattern.py.sample"), | |
68 | +# os.path.join("config", "plugins", "wrapper_v2.py.sample"), | |
89 | 69 | +# ] |
90 | 70 | +#} |
91 | 71 | |
92 | 72 | # Iterating through all destinations to write the info |
93 | 73 | -for destiny in files_to_copy.keys(): |
94 | - # Grabbing each source file to be moved | |
95 | - for sourceFile in files_to_copy[destiny]: | |
96 | - fileToMove = os.path.join(HERE,sourceFile) | |
97 | - | |
74 | +#for destiny in files_to_copy.keys(): | |
75 | # Grabbing each source file to be moved | |
76 | - for source_file in files_to_copy[destiny]: | |
77 | - file_to_move = os.path.join(HERE, source_file) | |
98 | 78 | - cmd = "" |
99 | 79 | - # Choosing the command depending on the SO |
100 | 80 | - if sys.platform == 'win32': |
101 | - if os.path.isdir(fileToMove): | |
102 | - cmd = "echo d | xcopy \"" + fileToMove + "\" \"" + destiny + "\" /s /e" | |
81 | - if os.path.isdir(file_to_move): | |
82 | - cmd = "echo d | xcopy \"" + file_to_move + "\" \"" + destiny + "\" /s /e" | |
103 | 83 | - else: |
104 | - cmd = "copy \"" + fileToMove + "\" \"" + destiny + "\"" | |
105 | - elif sys.platform == 'linux2' or sys.platform == 'darwin': | |
84 | - cmd = "copy \"" + file_to_move + "\" \"" + destiny + "\"" | |
85 | - elif sys.platform == 'linux' or sys.platform == 'darwin': | |
106 | 86 | - if not os.geteuid() == 0: |
107 | - cmd = "cp -r -- \"" + fileToMove + "\" \"" + destiny + "\"" | |
87 | - cmd = "cp -r -- \"" + file_to_move + "\" \"" + destiny + "\"" | |
108 | 88 | - else: |
109 | - cmd = "sudo cp -r -- \"" + fileToMove + "\" \"" + destiny + "\"" | |
89 | - cmd = "sudo cp -r -- \"" + file_to_move + "\" \"" + destiny + "\"" | |
90 | - else: | |
91 | - print("File '{file_to_move}' could not be copied in a {sys.platform.title()} system.") | |
92 | - continue | |
93 | - print(f"\t> {cmd}") | |
110 | 94 | - output = os.popen(cmd).read() |
111 | +#for destiny in files_to_copy.keys(): | |
112 | +# # Grabbing each source file to be moved | |
113 | +# for sourceFile in files_to_copy[destiny]: | |
114 | +# fileToMove = os.path.join(HERE,sourceFile) | |
115 | +# | |
95 | - | |
96 | -print("[*] OSRFramework > Installation ended. If you don't know where to start, run `osrf` to start working on it.") | |
97 | +# for source_file in files_to_copy[destiny]: | |
98 | +# file_to_move = os.path.join(HERE, source_file) | |
116 | 99 | +# cmd = "" |
117 | 100 | +# # Choosing the command depending on the SO |
118 | 101 | +# if sys.platform == 'win32': |
119 | +# if os.path.isdir(fileToMove): | |
120 | +# cmd = "echo d | xcopy \"" + fileToMove + "\" \"" + destiny + "\" /s /e" | |
102 | +# if os.path.isdir(file_to_move): | |
103 | +# cmd = "echo d | xcopy \"" + file_to_move + "\" \"" + destiny + "\" /s /e" | |
121 | 104 | +# else: |
122 | +# cmd = "copy \"" + fileToMove + "\" \"" + destiny + "\"" | |
123 | +# elif sys.platform == 'linux2' or sys.platform == 'darwin': | |
105 | +# cmd = "copy \"" + file_to_move + "\" \"" + destiny + "\"" | |
106 | +# elif sys.platform == 'linux' or sys.platform == 'darwin': | |
124 | 107 | +# if not os.geteuid() == 0: |
125 | +# cmd = "cp -r -- \"" + fileToMove + "\" \"" + destiny + "\"" | |
108 | +# cmd = "cp -r -- \"" + file_to_move + "\" \"" + destiny + "\"" | |
126 | 109 | +# else: |
127 | +# cmd = "sudo cp -r -- \"" + fileToMove + "\" \"" + destiny + "\"" | |
110 | +# cmd = "sudo cp -r -- \"" + file_to_move + "\" \"" + destiny + "\"" | |
111 | +# else: | |
112 | +# print("File '{file_to_move}' could not be copied in a {sys.platform.title()} system.") | |
113 | +# continue | |
114 | +# print(f"\t> {cmd}") | |
128 | 115 | +# output = os.popen(cmd).read() |
116 | +# | |
117 | +#print("[*] OSRFramework > Installation ended. If you don't know where to start, run `osrf` to start working on it.") |
0 | Description: Drop import validate_email | |
1 | The module validate_email is only mandatory for windows because module | |
2 | emailahoy doesn't work correctly. Drop the import validate_email in Kali | |
3 | package. | |
4 | Author: Sophie Brun <[email protected]> | |
5 | Last-Update: 2017-08-25 | |
6 | --- | |
7 | This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ | |
8 | --- a/osrframework/mailfy.py | |
9 | +++ b/osrframework/mailfy.py | |
10 | @@ -33,7 +33,7 @@ import sys | |
11 | ||
12 | # Email verification libraries | |
13 | import emailahoy | |
14 | -import validate_email | |
15 | +#import validate_email | |
16 | ||
17 | import osrframework | |
18 | import osrframework.thirdparties.haveibeenpwned_com.hibp as hibp | |
19 | --- a/setup.py | |
20 | +++ b/setup.py | |
21 | @@ -125,7 +125,7 @@ setup( | |
22 | "tweepy", | |
23 | "networkx", | |
24 | "decorator", | |
25 | - "validate_email", | |
26 | +# "validate_email", | |
27 | "pydns", | |
28 | "tabulate", | |
29 | "oauthlib>=1.0.0", |
0 | Description: Drop depends on importlib | |
1 | We don't need to explicitly add importlib to Depends as it's a backport | |
2 | of python2.7 and we already have Python 2.7 | |
3 | Author: Sophie Brun <[email protected]> | |
4 | Last-Update: 2017-08-25 | |
5 | --- | |
6 | This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ | |
7 | --- a/setup.py | |
8 | +++ b/setup.py | |
9 | @@ -130,7 +130,7 @@ setup( | |
10 | "tabulate", | |
11 | "oauthlib>=1.0.0", | |
12 | # Added to dinamically import wrappers: | |
13 | - "importlib", | |
14 | +# "importlib", | |
15 | #"inspect", | |
16 | #"pkgutil", | |
17 | # Adding dependencies to avoid the InsecurePlatformWarning when calling Twitter API dealing with SSL: <http://stackoverflow.com/a/29202163>. Other options would require the user to upgrade to Python 2.7.9. |
0 | Description: Initialize the config directory and files | |
1 | Upstream creates and initializes the ~/.config/OSRFramework in the | |
2 | setup.py. We disable this for Kali and create a function | |
3 | initialize_config_files to manage the creation and installation of all | |
4 | the required files. | |
5 | Author: Sophie Brun <[email protected]> | |
0 | From: Sophie Brun <[email protected]> | |
1 | Date: Thu, 23 Jan 2020 10:21:00 +0100 | |
2 | Subject: Initialize the config directory and files | |
3 | ||
4 | Last-Update: 2017-09-18 | |
5 | ||
6 | Upstream creates and initializes the ~/.config/OSRFramework in the | |
7 | setup.py. We disable this for Kali and create a function | |
8 | initialize_config_files to manage the creation and installation of all | |
9 | the required files. | |
6 | 10 | Last-Update: 2017-09-18 |
7 | 11 | --- |
8 | This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ | |
12 | osrframework/utils/configuration.py | 41 ++++++++++++++++++++++++++++++++++--- | |
13 | 1 file changed, 38 insertions(+), 3 deletions(-) | |
14 | ||
15 | diff --git a/osrframework/utils/configuration.py b/osrframework/utils/configuration.py | |
9 | 16 | --- a/osrframework/utils/configuration.py |
10 | 17 | +++ b/osrframework/utils/configuration.py |
11 | @@ -23,9 +23,40 @@ | |
12 | import ConfigParser | |
18 | @@ -19,12 +19,44 @@ | |
19 | ||
13 | 20 | import os |
14 | 21 | import sys |
15 | 22 | +import shutil |
16 | 23 | +import glob |
24 | ||
25 | from configparser import ConfigParser | |
26 | ||
17 | 27 | import osrframework.utils.errors as errors |
18 | 28 | |
19 | 29 | |
22 | 32 | + Function to create and initialize the configuration files and |
23 | 33 | + directories. |
24 | 34 | + """ |
25 | + LOCAL_CONFIG_DIR = getConfigPath()["appPath"] | |
26 | +# LOCAL_CONFIG_TRANSFORMS_DIR = getConfigPath()["appPathTransforms"] | |
27 | + INSTALL_PATH = '/usr/lib/python2.7/dist-packages/osrframework' | |
35 | + LOCAL_CONFIG_DIR = get_config_path()["appPath"] | |
36 | +# LOCAL_CONFIG_TRANSFORMS_DIR = get_config_path()["appPathTransforms"] | |
37 | + INSTALL_PATH = '/usr/lib/python3/dist-packages/osrframework' | |
28 | 38 | + |
29 | 39 | + # Copy default config file into osrframework local config |
30 | 40 | + for dirconf in ["default", "plugins"]: |
46 | 56 | + for f in ["browser.cfg", "general.cfg"]: |
47 | 57 | + shutil.copy((os.path.join(getConfigPath()["appPathDefaults"], f)),LOCAL_CONFIG_DIR) |
48 | 58 | + |
49 | def changePermissionsRecursively(path, uid, gid): | |
50 | """ | |
51 | Function to recursively change the user id and group id. | |
52 | @@ -92,9 +123,10 @@ def getConfigPath(configFileName = None) | |
59 | + | |
60 | def change_permissions_recursively(path, uid, gid): | |
61 | """Function to recursively change the user id and group id | |
62 | ||
63 | @@ -86,9 +118,10 @@ def get_config_path(config_file_name=None): | |
53 | 64 | } |
54 | 65 | |
55 | 66 | # Creating them if they don't exist |
63 | 74 | |
64 | 75 | return paths |
65 | 76 | |
66 | @@ -117,6 +149,8 @@ def returnListOfConfigurationValues(util | |
77 | @@ -105,6 +138,8 @@ def get_configuration_values_for(util): | |
67 | 78 | """ |
68 | 79 | |
69 | 80 | VALUES = {} |
71 | 82 | + initialize_config_files() |
72 | 83 | |
73 | 84 | # If a api_keys.cfg has not been found, creating it by copying from default |
74 | configPath = os.path.join(getConfigPath()["appPath"], "general.cfg") | |
85 | configPath = os.path.join(get_config_path()["appPath"], "general.cfg") |
0 | use-bs4-by-default.patch | |
1 | 0 | cleanup-setup.patch |
2 | dont-use-validate-email.patch | |
3 | drop-explicit-need-of-importlib.patch | |
4 | 1 | upgrade-installation.patch |
5 | 2 | initalize-config.patch |
6 | 3 | add-script-config-upgrade.patch |
0 | Description: Improve installation | |
1 | Upstream installs configuration files directly in the home user directory | |
2 | but we can't / don't do that in packages. | |
3 | Add a data_files in setup to manage the installation of config files in | |
4 | /etc/osrframework. These files will be copied in the user directory at the | |
5 | first launch. | |
6 | Author: Sophie Brun <[email protected]> | |
7 | Last-Update: 2017-09-04 | |
0 | From: Sophie Brun <[email protected]> | |
1 | Date: Thu, 23 Jan 2020 10:21:00 +0100 | |
2 | Subject: Improve installation | |
3 | ||
4 | Last-Update: 2020-01-23 | |
5 | ||
6 | Upstream installs configuration files directly in the home user directory | |
7 | but we can't / don't do that in packages. | |
8 | Add a data_files in setup to manage the installation of config files in | |
9 | /etc/osrframework. These files will be copied in the user directory at the | |
10 | first launch. | |
8 | 11 | --- |
9 | This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ | |
12 | setup.py | 7 ++++++- | |
13 | 1 file changed, 6 insertions(+), 1 deletion(-) | |
14 | ||
15 | diff --git a/setup.py b/setup.py | |
16 | index 8ed4965..716a9f5 100644 | |
10 | 17 | --- a/setup.py |
11 | 18 | +++ b/setup.py |
12 | @@ -23,6 +23,7 @@ | |
19 | @@ -20,7 +20,7 @@ | |
13 | 20 | |
14 | 21 | import os |
15 | 22 | import sys |
23 | - | |
16 | 24 | +import glob |
17 | 25 | from setuptools import setup, find_packages |
18 | import shutil | |
19 | import site | |
20 | @@ -109,6 +110,11 @@ setup( | |
21 | 'Topic :: Text Processing :: Markup :: HTML' | |
22 | ], | |
23 | packages=find_packages(), | |
26 | ||
27 | try: | |
28 | @@ -108,6 +108,11 @@ setup( | |
29 | long_description=read('README.md'), | |
30 | long_description_content_type="text/markdown", | |
31 | install_requires=requirements, | |
24 | 32 | + data_files=[ |
25 | 33 | + ("/etc/osrframework/default", glob.glob("config/*.cfg")), |
26 | + ("/etc/osrframework/plugins/patterns", ["config/plugins/pattern.py.sample"]), | |
27 | + ("/etc/osrframework/plugins/wrappers", ["config/plugins/wrapper.py.sample"]), | |
34 | + ("/etc/osrframework/plugins/patterns", ["config/plugins/wrapper.py.sample"]), | |
35 | + ("/etc/osrframework/plugins/wrappers", ["config/plugins/wrapper_v2.py.sample"]), | |
28 | 36 | + ], |
29 | long_description=long_description, | |
30 | install_requires=[ | |
31 | "setuptools", | |
37 | ) | |
38 | ||
39 | ############################ |
0 | Description: Use bs4 by default | |
1 | Mention beautifulsoup4 in setup so that pybuild generates a dependency on | |
2 | bs4 and not on obsolete beautifulsoup | |
3 | Author: Sophie Brun <[email protected]> | |
4 | Last-Update: 2018-10-18 | |
5 | --- | |
6 | This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ | |
7 | --- a/setup.py | |
8 | +++ b/setup.py | |
9 | @@ -115,7 +115,7 @@ setup( | |
10 | "mechanize", | |
11 | "requests", | |
12 | "python-emailahoy", | |
13 | - "BeautifulSoup", | |
14 | + "beautifulsoup4", | |
15 | "pyexcel==0.2.1", | |
16 | "pyexcel_ods==0.1.1", | |
17 | "pyexcel_xls==0.1.0", |