PoC for CVE-2022-0492# Shell Script Template
A modern Bash script template with colorized output formatting and utility functions for creating professional command-line tools.
## Features
- 🎨 **Colorized Output**: Pre-defined color schemes and formatting functions
- 📝 **Standardized Messages**: Consistent info, success, warning, and error message formats
- 🔧 **Utility Functions**: Ready-to-use functions for common shell script operations
- 📦 **Modular Design**: Separate library file for easy reuse across projects
- ⚡ **Easy Setup**: Simple sourcing mechanism for immediate use
## Quick Start
1. Clone or download this template
2. Make your script executable:
```bash
chmod +x script.sh
```
3. Run the example script:
```bash
./script.sh
```
## Usage
### Basic Template Structure
```bash
#!/bin/bash
LIB="lib"
source $LIB/format.sh
section "Your Script Section"
info "Information message"
ok "Success message"
warn "Warning message"
error "Error message"
```
### Available Functions
#### Message Types
- `info "message"` - Displays informational messages with cyan `[i]` prefix
- `ok "message"` - Displays success messages with green `[+]` prefix
- `warn "message"` - Displays warning messages with yellow `[!]` prefix
- `error "message"` - Displays error messages with red `[-]` prefix (sent to stderr)
#### Interactive Functions
- `prompt "question"` - Displays a prompt with magenta `[?]` prefix and waits for user input
- `section "title"` - Creates a formatted section header
#### Text Formatting
- `bold "text"` - Displays text in bold formatting
### Color Constants
The following color constants are available for custom formatting:
```bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'
WHITE='\033[1;37m'
BOLD='\033[1m'
UNDERLINE='\033[4m'
RESET='\033[0m'
```
## Example Output
When you run the example script, you'll see:
```
=== Start ===
[i] Running exploit setup...
[+] Everything is ready
[!] This might break your system
[-] Something failed
[?] Continue? [y/N]:
```
## File Structure
```
shell_template/
├── script.sh # Example script demonstrating usage
├── lib/
│ └── format.sh # Core formatting library
├── LICENSE # MIT License
└── README.md # This file
```
## Customization
### Adding New Message Types
You can extend the library by adding new message types in `lib/format.sh`:
```bash
DEBUG="${BLUE}[D]${RESET}"
debug() { echo -e "${DEBUG} $*"; }
```
### Custom Colors
Define your own color schemes by modifying the color constants or creating new ones:
```bash
PURPLE='\033[0;35m'
CUSTOM_PREFIX="${PURPLE}[*]${RESET}"
custom() { echo -e "${CUSTOM_PREFIX} $*"; }
```
## Best Practices
1. **Always source the library**: Include `source $LIB/format.sh` at the beginning of your scripts
2. **Use appropriate message types**: Choose the right function for the context (info, ok, warn, error)
3. **Structure with sections**: Use `section` to organize your script output
4. **Handle errors properly**: Use `error` for error messages and redirect to stderr
5. **Make scripts executable**: Don't forget `chmod +x` for your scripts
## Contributing
Feel free to submit issues, fork the repository, and create pull requests for any improvements.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Author
Created by Christoph Huy
[4.0K] /data/pocs/6c47826c4c25cd2e1993f00f30429d651075b08f
├── [4.0K] lib
│ └── [ 822] format.sh
├── [1.0K] LICENSE
├── [3.4K] README.md
└── [ 246] script.sh
1 directory, 4 files