diff --git a/README.md b/README.md
index 269074e..0935daf 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ Miscellaneous scripts for different purposes. Mostly unrelated to each other.
| Email | [`mail-prepender.sh`](bin/mail-prepender.sh)
Shell (bash) | Prepends (to stdin/stdout) email header strings given in as flags `i`, `I`, `a`, or `A`; after possible mbox `From` & `Return-Path` header lines. Intended as a limited `formail` replacement that ignores the nyanses of the flags and simply prepends the valid (RFC 5322, 2.2) non-empty headers keeping the other headers as is. Flags `x` & `X` are implemented. Any other flags are ignored. |
| Git | [`git-find-commits-by-file-hash.sh`](bin/git-find-commits-by-file-hash.sh)
Shell (bash) | Search Git repository history for commits with SHA-256 checksum of a file. Answers the question "Has this version of this file ever been committed as the file on this path of this Git repository?" and shows a summary (`git show --stat`) of the matching commit(s). The `path` should be relative to the repository root.
`git-find-commits-by-file-hash.sh sha256sum path`|
| Infosec | [`netcat-proxy.sh`](bin/netcat-proxy.sh)
Shell (sh) | Creates a simple persistent TCP proxy with netcat & named pipes.
`netcat-proxy.sh listenport targethost targetport` |
-| Infosec | [`follow-cvelist.py`](bin/follow-cvelist.py)
Python 3 | Follow changes (commits) in CVEProject / [cvelistV5](https://github.com/CVEProject/cvelistV5). Requires git. Working directory must be the root of the cvelistV5 repository.
`follow-cvelist.py [-haou4] [-vvvv] [-i s] [-c N]`|
+| Infosec | [`follow-cvelist.py`](bin/follow-cvelist.py)
Python 3 | Follow changes (commits) in CVEProject / [cvelistV5](https://github.com/CVEProject/cvelistV5). Requires git. Working directory must be the root of the cvelistV5 repository.
`follow-cvelist.py [-haou4] [-vvvv] [-i s] [-c N] [-w c]`|
| Infosec | [`partialpassword.sh`](bin/partialpassword.sh)
Shell (bash) | Creates a new wordlist from a wordlist by replacing all ambiguous characters with all their possible combinations.
`partialpassword.sh input.txt output.txt O0 [Il1 ...]` |
| Infosec | [`duplicate-ssh-hostkeys.sh`](bin/duplicate-ssh-hostkeys.sh)
Shell (bash) | Find duplicate SSH host keys in a CIDR range. Examine your network for shared host keys that could potentially be dangerous.
`duplicate-ssh-hostkeys.sh CIDR [HostKeyAlgorithm ...]` |
| Infosec
Automation | [`make-mac-prefixes.py`](bin/make-mac-prefixes.py)
Python 3 | Processes registered MAC address prefixes from [IEEE MA-L Assignments (CSV)](https://standards.ieee.org/products-programs/regauth/) (stdin) to Nmap's [`nmap-mac-prefixes`](https://github.com/nmap/nmap/blob/master/nmap-mac-prefixes) (stdout) with a few additional unregistered OUIs.
`curl https://standards-oui.ieee.org/oui/oui.csv \| make-mac-prefixes.py > nmap-mac-prefixes` |
diff --git a/bin/follow-cvelist.py b/bin/follow-cvelist.py
index 196177c..42c217b 100755
--- a/bin/follow-cvelist.py
+++ b/bin/follow-cvelist.py
@@ -3,7 +3,7 @@
# ------------------------------------------------------------------------------
# Follow changes (commits) in CVEProject / cvelistV5
#
-# Usage: follow-cvelist.py [-haou4] [-vvvv] [-i s] [-c N]
+# Usage: follow-cvelist.py [-haou4] [-vvvv] [-i s] [-c N] [-w c]
#
# -h, --help show this help message and exit
# -a, --ansi add ansi colors to the output (default: False)
@@ -13,6 +13,7 @@
# -v, --verbose each -v increases verbosity (commits, git pull, raw data)
# -i s, --interval s pull interval in seconds (default: 150)
# -c N, --commits N number of commits to print initially (default: 30)
+# -w c, --width c overwrite autodetected terminal width (<50 => multiline)
#
# Requires git. Working directory must be the root of the cvelistV5 repository.
#
@@ -89,6 +90,16 @@ def check_interrupt(self) -> None:
)
sys.exit(0)
+ def width(self) -> int:
+ """Configured or detected terminal width for line lenght limits"""
+ if args.width:
+ return int(args.width)
+ else:
+ try:
+ return os.get_terminal_size()[0]
+ except OSError:
+ return 1
+
def header(self) -> None:
"""Print header"""
if self.args.cvss4:
@@ -106,10 +117,7 @@ def header(self) -> None:
f"{cvss_title.ljust(10)} SUMMARY [vendor: product]",
file=sys.stderr,
)
- try:
- print(f"{''.ljust(os.get_terminal_size()[0], '-')}", file=sys.stderr)
- except OSError:
- print(f"{''.ljust(80, '-')}", file=sys.stderr)
+ print(f"{''.ljust(self.width(), '-')}", file=sys.stderr)
def history(self) -> None:
"""Prints CVE changes from the commit history, one commit at a time"""
@@ -174,14 +182,15 @@ def get_cursor(self, offset: int = 0) -> str:
def print_changes(self, current_commit: str, past_commit: str) -> None:
"""Print summary of changed CVE"""
lines = []
- try:
+ # multiline mode if terminal width is too small to fit summary on the same line
+ if self.width() >= 50:
if self.args.ansi:
# add extra width for invisible characters (ANSI codes)
- width = os.get_terminal_size()[0] + 21
+ width = self.width() + 21
else:
# substract one character to fit occasional wide characters like emojis
- width = os.get_terminal_size()[0] - 1
- except OSError:
+ width = self.width() - 1
+ else:
width = False
for change in self.get_changes(current_commit, past_commit):
@@ -584,6 +593,13 @@ def check_positive(value: str) -> int:
help="number of commits to print initially",
default=30,
)
+ argParser.add_argument(
+ "-w",
+ "--width",
+ type=check_positive,
+ metavar="c",
+ help="overwrite autodetected terminal width (<50 => multiline)",
+ )
args = argParser.parse_args()
if args.verbose > 4:
args.verbose = 4