Skip to content

Commit b39f55b

Browse files
authored
Add files via upload
1 parent 63a7ac1 commit b39f55b

File tree

5 files changed

+279
-2
lines changed

5 files changed

+279
-2
lines changed

LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2024 Carlos Henrique
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

README.md

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,68 @@
1-
# bashwords
2-
Bashwords is a simple password manager made in BASH.
1+
# Bashwords
2+
3+
This is a simple password manager script written in bash. It allows users to add, get, delete, and list passwords for different accounts or services. The passwords are encrypted using the AES-256 encryption algorithm and stored in separate files.
4+
5+
## Usage
6+
7+
To use the password manager script, you can run it with different command-line options.
8+
9+
```bash
10+
./main.sh [options]
11+
```
12+
13+
### Options
14+
15+
- **-a, --add**: Add a new password for an account/service.
16+
- **-g, --get**: Get the password for a specified account/service.
17+
- **-d, --delete**: Delete the password for a specified account/service.
18+
- **-l, --list**: List all the passwords for all accounts/services.
19+
- **-h, --help**: Show the help message with usage instructions.
20+
21+
## File Structure
22+
23+
The script uses the following files:
24+
25+
- **data/passwords/**: A directory that stores the encrypted password files for each account/service.
26+
- **data/key.passman**: A file that contains the encryption key used for encrypting and decrypting passwords.
27+
28+
## Functions
29+
30+
The script includes the following functions:
31+
32+
- **usage()**: Displays the usage instructions and options.
33+
- **encrypt()**: Encrypts a password using the AES-256 encryption algorithm.
34+
- **decrypt()**: Decrypts an encrypted password using the AES-256 encryption algorithm.
35+
- **add_password()**: Prompts the user to enter an account/service name and password, encrypts the password, and stores it in a password file.
36+
- **get_password()**: Prompts the user to enter an account/service name and retrieves the encrypted password from the corresponding password file, decrypts it, and displays it.
37+
- **delete_password()**: Prompts the user to enter an account/service name and deletes the corresponding password file if it exists.
38+
- **list_passwords()**: Lists all the account/service names for which passwords are stored.
39+
40+
## Implementation
41+
42+
The script uses a `while` loop to process the command-line options provided by the user. It checks the option and calls the corresponding function accordingly. If an invalid option is provided, it displays an error message and shows the usage instructions.
43+
44+
## Examples
45+
46+
Here are some examples of how to use the script:
47+
48+
- **Adding a Password**: `./main.sh --add`
49+
Prompts the user to enter an account/service name and password. Encrypts the password and stores it in a corresponding password file.
50+
51+
- **Getting a Password**: `./main.sh --get`
52+
Prompts the user to enter an account/service name and retrieves the encrypted password from the corresponding password file. Decrypts the password and displays it.
53+
54+
- **Deleting a Password**: `./main.sh --delete`
55+
Prompts the user to enter an account/service name and deletes the corresponding password file if it exists.
56+
57+
- **Listing Passwords**: `./main.sh --list`
58+
Lists all the account/service names for which passwords are stored.
59+
60+
## Security Considerations
61+
62+
- Make sure to keep the encryption key (`data/key.passman`) secure and confidential.
63+
- Store the password files (`data/passwords/*.passman`) in a secure location.
64+
- Regularly backup the password files and encryption key to prevent data loss.
65+
66+
Note: This is a simple password manager script and may not provide all the security features and considerations of a professional password manager. Use at your own risk.
67+
68+
For more information on password security, refer to industry best practices and guidelines.

REQUIREMENTS.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Bashwords Script - System Requirements
2+
3+
To run the password manager script successfully, there are a few requirements that need to be met. This document outlines the necessary software and configurations needed on your system.
4+
5+
## System Compatibility
6+
7+
The password manager script is developed primarily for Unix-like systems such as Linux and macOS. While it may work on other platforms, the following requirements are specifically tailored for Unix-like systems.
8+
9+
## Prerequisites
10+
11+
Ensure that the following software packages are installed on your system:
12+
13+
- **Bash**: The password manager script is written in Bash, so a compatible Bash shell is necessary. Most Unix-like systems come with Bash pre-installed. To check the installed version, open a terminal and run the command:
14+
```bash
15+
bash --version
16+
```
17+
18+
- **OpenSSL**: The script utilizes OpenSSL for AES-256 encryption. Make sure OpenSSL is installed on your system. To check the installed version, run the command:
19+
```bash
20+
openssl version
21+
```
22+
23+
If any of the required software is missing or outdated, please install or update them to meet the minimum version requirements.
24+
25+
## File Permissions
26+
27+
Ensure that you have read, write, and execute permissions in the directory where the password manager script is located. The script needs these permissions to create and modify the necessary files.
28+
29+
Additionally, if you plan to run the script using elevated privileges (e.g., as a system administrator), make sure you have the appropriate permissions to access and modify the system files and components the script interacts with.
30+
31+
## Configuration
32+
33+
The password manager script relies on the presence of specific directories and files. Please ensure the following configurations:
34+
35+
- **Data Directory**: The `data/` directory should be present in the same location as the password manager script. This directory stores encrypted password files, the encryption key, and other necessary data.
36+
37+
- **Passwords Directory**: Inside the `data/` directory, create a subdirectory named `passwords/`. This directory will hold the encrypted password files for each account or service.
38+
39+
- **Encryption Key**: Create a file named `key.passman` inside the `data/` directory. This file should contain the encryption key for the password files. Make sure to keep this key secure and confidential.
40+
41+
## Usage
42+
43+
For detailed instructions on how to use the password manager script and its available command-line options, please refer to the main README file.
44+
45+
By fulfilling these requirements and configurations, you should be able to run the password manager script smoothly and securely on your system.

SECURITY.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Bashwords - Security Considerations
2+
3+
The password manager script takes security seriously and encourages users to report any vulnerabilities or security concerns they may discover. This document outlines the process for reporting vulnerabilities and provides support contact information.
4+
5+
## Reporting Vulnerabilities
6+
7+
We greatly appreciate the efforts of security researchers and users in identifying potential vulnerabilities. If you believe you have discovered a security vulnerability in the password manager script, please follow these steps:
8+
9+
1. Report the vulnerability as soon as possible by sending an email to our dedicated security team at [carlos.henrique.de.paula.oliveira@hotmail.com](mailto:carlos.henrique.de.paula.oliveira@hotmail.com). Please avoid discussing or disclosing the vulnerability details publicly until we have addressed the issue.
10+
11+
2. Provide a detailed description of the vulnerability, including the steps to reproduce it. It will help us understand the potential impact and take necessary actions promptly.
12+
13+
3. If possible, include any supporting files, scripts, or screenshots that demonstrate the vulnerability. This information will assist in our investigation and allow us to validate the reported vulnerability effectively.
14+
15+
4. We will acknowledge receipt of your report within 48 hours and initiate our investigation promptly. We will keep you informed about the progress and any further actions taken.
16+
17+
5. Once the vulnerability is resolved, we will attribute the discovery appropriately if desired. However, please let us know if you wish to remain anonymous.
18+
19+
## Support Contact Information
20+
21+
For general inquiries, feedback, or support requests regarding the password manager script, you can reach out to our support team at the following email address:
22+
23+
- Email: [carlos.henrique.de.paula.oliveira@hotmail.com](carlos.henrique.de.paula.oliveira@hotmail.com)
24+
25+
Please allow up to 24-48 hours for a response from our support team. We strive to provide timely assistance and address your concerns or questions related to the script.
26+
27+
We value your input and appreciate your cooperation in helping us maintain the security and reliability of the password manager script.
28+
29+
**Important:** For security-related concerns, such as reporting vulnerabilities, please use the dedicated email address mentioned earlier ([carlos.henrique.de.paula.oliveira@hotmail.com](carlos.henrique.de.paula.oliveira@hotmail.com)) for quicker attention and confidentiality.
30+
31+
Thank you for your understanding and support in making the password manager script more secure.

main.sh

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/bin/bash
2+
3+
: <<LICENSE
4+
Copyright 2024 Carlos Henrique
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
LICENSE
18+
19+
PASSWORD_DIR="data/passwords/"
20+
KEY_FILE="data/key.passman"
21+
22+
usage() {
23+
echo "Usage: ./password_manager.sh [options]"
24+
echo "Options:"
25+
echo " -a, --add Add a new password"
26+
echo " -g, --get Get a password"
27+
echo " -d, --delete Delete a password"
28+
echo " -l, --list List all passwords"
29+
echo " -h, --help Show help"
30+
}
31+
32+
encrypt() {
33+
password="$1"
34+
key=$(cat "$KEY_FILE")
35+
echo "$password" | openssl enc -aes-256-cbc -a -salt -pass pass:"$key"
36+
}
37+
38+
decrypt() {
39+
encrypted_password="$1"
40+
key=$(cat "$KEY_FILE")
41+
echo "$encrypted_password" | openssl enc -d -aes-256-cbc -a -salt -pass pass:"$key"
42+
}
43+
44+
add_password() {
45+
echo -n "Enter the account/service name: "
46+
read -r account
47+
echo -n "Enter the password: "
48+
read -s password
49+
50+
encrypted_password=$(encrypt "$password")
51+
echo "$encrypted_password" > "$PASSWORD_DIR$account.passman"
52+
echo "Password added successfully."
53+
}
54+
55+
get_password() {
56+
echo -n "Enter the account/service name: "
57+
read -r account
58+
59+
if [[ -f "$PASSWORD_DIR$account.passman" ]]; then
60+
encrypted_password=$(cat "$PASSWORD_DIR$account.passman")
61+
password=$(decrypt "$encrypted_password")
62+
echo "Password for $account: $password"
63+
else
64+
echo "Password not found for $account."
65+
fi
66+
}
67+
68+
delete_password() {
69+
echo -n "Enter the account/service name: "
70+
read -r account
71+
72+
if [[ -f "$PASSWORD_DIR$account.passman" ]]; then
73+
rm "$PASSWORD_DIR$account.passman"
74+
echo "Password deleted successfully for $account."
75+
else
76+
echo "Password not found for $account."
77+
fi
78+
}
79+
80+
list_passwords() {
81+
if [[ -n "$(ls -A "$PASSWORD_DIR")" ]]; then
82+
echo "All passwords:"
83+
for file in "$PASSWORD_DIR"*.passman; do
84+
account=$(basename "$file" .passman)
85+
echo "$account"
86+
done
87+
else
88+
echo "No passwords found."
89+
fi
90+
}
91+
92+
while [[ $# -gt 0 ]]; do
93+
case "$1" in
94+
-a|--add)
95+
add_password
96+
exit
97+
;;
98+
-g|--get)
99+
get_password
100+
exit
101+
;;
102+
-d|--delete)
103+
delete_password
104+
exit
105+
;;
106+
-l|--list)
107+
list_passwords
108+
exit
109+
;;
110+
-h|--help)
111+
usage
112+
exit
113+
;;
114+
*)
115+
echo "Invalid option: $1"
116+
usage
117+
exit 1
118+
;;
119+
esac
120+
done
121+
122+
usage

0 commit comments

Comments
 (0)