StringShark is a simple yet powerful command-line utility developed in Python, designed to offer seamless compatibility with Linux, macOS, and Windows. It enables efficient searches for keywords, secrets, or variables within files and directories, and offers flexible search parameters and the ability to replace identified matches with new values.
- Fast Keyword Search: Search for any string, keyword, or variable across multiple files and directories.
- Flexible Match Modes: Support for case-sensitive, case-insensitive, partial, and whole-word matching.
- Optional Replace Functionality: Easily replace any matched keywords with a new value in the files.
- Cross-Platform Compatibility: Works on Linux, macOS, and Windows, with OS-specific installation and functionality.
-
Download or clone the
stringshark
script. -
Run the following command to install the script:
./SETUP -i
This will:
- Make the script executable.
- Move it to
/usr/bin/
, making it accessible from anywhere in the terminal.
-
Download or clone the
stringshark
script. -
Open the command prompt or PowerShell as Administrator.
-
Run the following command:
./SETUP -i
This will:
- Make the script executable.
- Move it to
C:/Program Files/sshark
. - Add
C:/Program Files/sshark
to your systemPATH
, allowing you to run the script from any terminal window.
To uninstall stringshark
from your system, simply run the uninstall command:
./SETUP -u
This will remove the script from your system and revert any changes made during installation (such as removing it from /usr/bin/
or C:/Program Files/
).
After installing stringshark
, you can use it directly from the terminal. Here are some examples of how to use it:
sshark [-md|-mc|-mw|-me] "keyword" [-r "replace_value"] [-p "path"]
-md
(Default Match Mode): Case-insensitive partial match.-mc
: Case-sensitive match.-mw
: Case-insensitive whole-word match.-me
: Case-sensitive whole-word match. (exact match)-r "replace_value"
(Optional): Replace the matched keyword with a new value.-p "path"
(Optional): Specify the directory or file path to search. Defaults to the current directory if omitted.
-
Search for a keyword (case-insensitive, partial match) in the current directory:
sshark "password"
or
sshark -md "password"
-
Search for a case-sensitive keyword in all files:
sshark -mc "API_KEY"
-
Search and replace a keyword across a directory:
sshark -md "secret_key" -r "new_secret_key" -p /path/to/directory
-
Search for a whole-word keyword and replace it (case-insensitive):
sshark -mw "username" -r "new_username"
sshark -mw "variable" -r "new_variable"
-
Search Mode: StringShark walks through all directories and files, searching for the given keyword. The keyword can be matched using different modes:
- Default (case-insensitive and partial match).
- Case-sensitive match.
- Whole-word matching (case-insensitive or case-sensitive).
-
Replacement: If the
-r
argument is provided, StringShark will replace the matched keyword with the specified replacement string. It will print a summary of the changes made, including the filename and line number. -
Cross-Platform Functionality: The script handles file encodings and paths in a cross-platform way, so it works on Linux, macOS, and Windows. For Windows users, the script can be invoked from any terminal once installed.
- Linux/macOS: Python 3.x is required.
- Windows: Python 3.x must be installed and added to the system's PATH.
-
Optional: For colored terminal output on Windows, install
colorama
by running:pip install colorama
-
StringShark is released under the MIT License. See LICENSE for details.
We welcome contributions! If you find any issues or have suggestions for improvements, feel free to submit a pull request or open an issue.