Skip to content

Commit

Permalink
Merge pull request #132 from inab/131-errors-in-downloading-from-skul…
Browse files Browse the repository at this point in the history
…lsecurityorg-during-installation

131 errors in downloading from skullsecurityorg during installation
  • Loading branch information
jmfernandez authored Dec 3, 2024
2 parents 812c060 + 25778aa commit 2fd054a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 28 deletions.
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ repository-code: "https://github.com/inab/WfExS-backend"
repository-artifact: "https://github.com/inab/WfExS-backend/pkgs/container/wfexs-backend"
type: software
title: "WfExS-backend"
version: 1.0.0rc1
date-released: "2024-10-16"
version: 1.0.0rc2
date-released: "2024-12-03"
6 changes: 3 additions & 3 deletions WfExS-config-replicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ def loadXLSXParams(paramsFilename: "str") -> "Sequence[Mapping[str, Any]]":
# by latest openpyxl annotations
sheet = cast("Worksheet", sheet_raw) # type: ignore[redundant-cast]
gotHeader = False
headerMap: "MutableMapping[int,str]" = {}
headerMap: "MutableMapping[Optional[int],str]" = {}
for cells_in_row in sheet.iter_rows():
# Either get the header or the data
if gotHeader:
params: "MutableMapping[str, MutableSequence[Any]]" = dict()
for cell in cells_in_row:
headerName = headerMap.get(cell.col_idx)
headerName = headerMap.get(cell.column)
if headerName is not None:
theVal = cell.value
params.setdefault(headerName, []).append(theVal)
Expand All @@ -129,7 +129,7 @@ def loadXLSXParams(paramsFilename: "str") -> "Sequence[Mapping[str, Any]]":
if len(headerName) > 0:
gotHeader = True
# The column index is 1-based
headerMap[cell.col_idx] = headerName
headerMap[cell.column] = headerName

return paramsArray

Expand Down
2 changes: 1 addition & 1 deletion wfexs_backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
__license__ = "Apache 2.0"

# https://www.python.org/dev/peps/pep-0396/
__version__ = "1.0.0rc1"
__version__ = "1.0.0rc2"
__url__ = "https://github.com/inab/WfExS-backend"
__official_name__ = "WfExS-backend"

Expand Down
60 changes: 38 additions & 22 deletions wfexs_backend/utils/passphrase_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
from __future__ import absolute_import

import inspect
import logging
import os
import pathlib
import random
Expand Down Expand Up @@ -77,9 +79,11 @@ class WfExSPassphraseGenerator:
)
],
"cain": [
# Originally
# https://wiki.skullsecurity.org/index.php/Passwords
# and http://downloads.skullsecurity.org/passwords/cain.txt.bz2
RemoteWordlistResource(
"http://downloads.skullsecurity.org/passwords/cain.txt.bz2"
"https://github.com/duyet/bruteforce-database/raw/233b5e59a87b96ec696ddcb33b8a37709ca6aa8a/cain.txt"
),
],
"adjectives": [
Expand Down Expand Up @@ -115,6 +119,12 @@ def __init__(
cacheDir: "Optional[pathlib.Path]" = None,
word_sets: "Mapping[str, Sequence[RemoteWordlistResource]]" = DEFAULT_WORD_SETS,
):
self.logger = logging.getLogger(
dict(inspect.getmembers(self))["__module__"]
+ "::"
+ self.__class__.__name__
)

# The cache is an integral part, as it is where the
# different components are going to be fetched
self.cacheHandler = cacheHandler
Expand Down Expand Up @@ -167,31 +177,37 @@ def _materialize_word_sets(
pass

if indexed_filename is None:
# Time to fetch the wordlist
i_cached_content = self.cacheHandler.fetch(
cast("URIType", word_set_uri),
destdir=self.cacheDir,
offline=False,
)

# Prepare the compressed index
with tempfile.NamedTemporaryFile() as tmp_indexed_filename:
CompressedIndexedText.IndexTextFile(
i_cached_content.path.as_posix(),
tmp_indexed_filename.name,
substart=remote_wordlist.substart,
subend=remote_wordlist.subend,
)
# And inject it in the cache
indexed_filename, _ = self.cacheHandler.inject(
wordlist_internal_uri,
try:
# Time to fetch the wordlist
i_cached_content = self.cacheHandler.fetch(
cast("URIType", word_set_uri),
destdir=self.cacheDir,
tempCachedFilename=pathlib.Path(tmp_indexed_filename.name),
offline=False,
)

assert indexed_filename is not None
# Prepare the compressed index
with tempfile.NamedTemporaryFile() as tmp_indexed_filename:
CompressedIndexedText.IndexTextFile(
i_cached_content.path.as_posix(),
tmp_indexed_filename.name,
substart=remote_wordlist.substart,
subend=remote_wordlist.subend,
)
# And inject it in the cache
indexed_filename, _ = self.cacheHandler.inject(
wordlist_internal_uri,
destdir=self.cacheDir,
tempCachedFilename=pathlib.Path(
tmp_indexed_filename.name
),
)
except Exception as e:
self.logger.error(
f"Unable to index {word_set_uri} (exception {e.__class__.__name__}). It might impact passphrase generation. Skipping"
)

indexed_filenames.append(indexed_filename)
if indexed_filename is not None:
indexed_filenames.append(indexed_filename)

word_sets[wordlist_tag] = CompressedIndexedText(
cfiles=list(map(lambda infil: infil.as_posix(), indexed_filenames))
Expand Down

0 comments on commit 2fd054a

Please sign in to comment.