| .github/workflows | ||
| images | ||
| samples | ||
| src | ||
| .envrc | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| ChangeLog | ||
| flake.lock | ||
| flake.nix | ||
| hed.1.gz | ||
| LICENSE | ||
| README.md | ||
| rust-toolchain | ||
Host EDitor
A command-line tool to easily manage you hosts file.
View Demo
·
Report Bug
·
Request Feature
Table of Contents
About The Project
hed allows you to manipulate your hosts file from the command-line. By providing safe and easy commands you can add new hosts and aliases to your environment.
This tool was inspired by my students to whom I teach a Basic Cyber Security class. In this class we utilize Hack The Box as a learning platform and most students struggle with editing the hosts file when they get started. To make this easier for them I wrote a tool that gives them a safe means of adding and removing hosts in this file.
The tool is to be used as a regular user, it will elevate privileges when it requires it by calling sudo and respawning the process.
Built With
Getting Started
Installation
Using cargo
If you have the rust package manager cargo installed you can simply install hed by running
cargo install hed
It will pull in the latest version.
Manual installation
- Create your local
bindirectorymkdir ~/.local/bin - Download the latest binary release
wget https://github.com/credmp/hed/releases/latest/download/hed -O ~/.local/bin/hed - Make it executable
chmod +x ~/.local/bin/hed - Ensure the
bindirectory is in your pathecho export PATH=\$PATH:~/.local/bin >> ~/.zshrc # if you use zsh echo export PATH=\$PATH:~/.local/bin >> ~/.bashrc # if you use bash
Usage
View the current hostsfile
hed show will color print the current hosts file.
hed show
Output:
# This is a comment
127.0.0.1 localhost
::1 localhost
127.0.1.1 pop-os.localdomain pop-os
Add a new entry
hed add example.com 127.1.1.1
Will add the following line to the hosts file.
127.1.1.1 example.com
Add a subdomain
hed add demo.example.com
Will update the hosts file to add the subdomain to the parent domain as an alias
127.1.1.1 example.com demo.example.com
Remove a hostname
hed delete demo.example.com
If it is the primary name , the shortest alias will be chosen as new name for the host entry. If there are no aliases, the entire record is deleted.
hed delete 127.1.1.1
Will remove the entire record even if there are many aliases defined.
Add an alias
hed alias demo.example.com arjenwiersma.nl
Add a non-subdomain alias to a hostname. This is useful when a host (ip) has many different hostnames. Instead of adding an entry for every unique top level domain they can be added as aliasses.
Testing
Use the --file parameter to test the features of hed on a file that is not your hosts file.
hed --file test.txt add example.com 127.0.0.1
Roadmap
See the open issues for a full list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Write your beautiful code
- Ensure test coverage did not decrease (
cargo tarpaulin --verbose --all-features --workspace --timeout 120 --out Lcov) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
Distributed under the GPLv3 License. See LICENSE.txt for more information.
Contact
Arjen Wiersma - @credmp - My website
Project Link: https://github.com/credmp/hed
Acknowledgments
- My students for showing me that editing a
hostsfile is not that easy.
