Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Windows support. #104

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions recon/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def _write_local_file(self, path, content):
dirpath = os.path.sep.join(path.split(os.path.sep)[:-1])
if not os.path.exists(dirpath):
os.makedirs(dirpath)
with open(path, 'w') as outfile:
with open(path, 'w', encoding='UTF-8') as outfile:
outfile.write(content)

def _remove_empty_dirs(self, base_path):
Expand Down Expand Up @@ -374,7 +374,7 @@ def _update_module_index(self):
# load module index from local copy
path = os.path.join(self.home_path, 'modules.yml')
if os.path.exists(path):
with open(path, 'r') as infile:
with open(path, 'r', encoding='UTF-8') as infile:
self._module_index = yaml.safe_load(infile)
# add status to index for each module
for module in self._module_index:
Expand Down Expand Up @@ -424,7 +424,7 @@ def _install_module(self, path):
except:
self.error(f"Module installation failed: {path}")
raise
abs_path = os.path.join(self.mod_path, rel_path)
abs_path = os.path.normpath(os.path.join(self.mod_path, rel_path))
downloads[abs_path] = resp.text
# install the module
for abs_path, content in downloads.items():
Expand All @@ -434,7 +434,7 @@ def _install_module(self, path):
def _remove_module(self, path):
# remove the module
rel_path = '.'.join([path, 'py'])
abs_path = os.path.join(self.mod_path, rel_path)
abs_path = os.path.normpath(os.path.join(self.mod_path, rel_path))
os.remove(abs_path)
# remove supporting data files
files = self._get_module_from_index(path).get('files', [])
Expand Down Expand Up @@ -462,11 +462,11 @@ def _load_modules(self):

def _load_module(self, dirpath, filename):
mod_name = filename.split('.')[0]
mod_category = re.search('/modules/([^/]*)', dirpath).group(1)
mod_dispname = '/'.join(re.split('/modules/', dirpath)[-1].split('/') + [mod_name])
mod_category = re.search('/modules/([^/]*)', dirpath.replace('\\','/')).group(1)
mod_dispname = '/'.join(re.split('/modules/', dirpath.replace('\\','/'))[-1].split('/') + [mod_name])
mod_loadname = mod_dispname.replace('/', '_')
mod_loadpath = os.path.join(dirpath, filename)
mod_file = open(mod_loadpath)
mod_file = open(mod_loadpath, encoding='UTF-8')
try:
# import the module into memory
mod = imp.load_source(mod_loadname, mod_loadpath, mod_file)
Expand Down Expand Up @@ -528,7 +528,7 @@ def do_index(self, params):
print(markup)
# write to file if index name provided
if file_name:
with open(file_name, 'w') as outfile:
with open(file_name, 'w', encoding='UTF-8') as outfile:
outfile.write(markup)
self.output('Module index created.')
else:
Expand Down
6 changes: 3 additions & 3 deletions recon/core/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _merge_dicts(self, x, y):
def _parse_frontmatter(self):
rel_path = '.'.join([self._modulename, 'py'])
abs_path = os.path.join(self.mod_path, rel_path)
with open(abs_path) as fp:
with open(abs_path, encoding='UTF-8') as fp:
state = False
yaml_src = ''
for line in fp:
Expand All @@ -81,7 +81,7 @@ def _migrate_key(self, key):
key_path = os.path.join(self.home_path, 'keys.dat')
if os.path.exists(key_path):
try:
key_data = json.loads(open(key_path, 'rb').read())
key_data = json.loads(open(key_path, 'rb', encoding='UTF-8').read())
if key_data.get(key):
self.add_key(key, key_data.get(key))
except:
Expand Down Expand Up @@ -171,7 +171,7 @@ def _get_source(self, params, query=None):
else:
sources = [x[0] for x in results]
elif os.path.exists(params):
sources = open(params).read().split()
sources = open(params, encoding='UTF-8').read().split()
else:
sources = [params]
if not sources:
Expand Down