Hosts EDitor, it will add/update/delete host entries for you

Overview

Contributors Forks Stargazers Issues GPLv3 License LinkedIn codecov_shield


Logo

Host EDitor

A command-line tool to easily manage you hosts file.

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

hed screencast

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.

(back to top)

Built With

(back to top)

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

  1. Create your local bin directory
    mkdir ~/.local/bin
  2. Download the latest binary release
    wget https://github.com/credmp/hed/releases/latest/download/hed -O ~/.local/bin/hed
  3. Make it executable
    chmod +x ~/.local/bin/hed
  4. Ensure the bin directory is in your path
    echo export PATH=\$PATH:~/.local/bin >> ~/.zshrc # if you use zsh
    echo export PATH=\$PATH:~/.local/bin >> ~/.bashrc # if you use bash

(back to top)

Usage

hed screencast

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.

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

(back to top)

Roadmap

See the open issues for a full list of proposed features (and known issues).

(back to top)

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Write your beautiful code
  4. Ensure test coverage did not decrease (cargo tarpaulin --verbose --all-features --workspace --timeout 120 --out Lcov)
  5. Commit your Changes (git commit -m 'Add some AmazingFeature')
  6. Push to the Branch (git push origin feature/AmazingFeature)
  7. Open a Pull Request

(back to top)

License

Distributed under the GPLv3 License. See LICENSE.txt for more information.

(back to top)

Contact

Arjen Wiersma - @credmp - My website

Project Link: https://github.com/credmp/hed

(back to top)

Acknowledgments

  • My students for showing me that editing a hosts file is not that easy.

(back to top)

Comments
  • :gear: Remove debian control files

    :gear: Remove debian control files

    I tried to include the tool into Debian. The process is horribly archaic and not very friendly to first time users. The approach I took based on the documentation turned out to be wrong for rust based applications. Will try again later.

    opened by credmp 1
  • :bookmark: Release hed on crates.io

    :bookmark: Release hed on crates.io

    • :books: Add cli as a keyword for crates.io
    • :arrow_up: Upgrade dependencies
    • :bug: Fix license identifier in toml
    • :books: Add instructions to install using cargo
    opened by credmp 1
  • Entries are double added if they already exist

    Entries are double added if they already exist

    Reproduce:

    hed  --file ../samples/kali-default.txt add example.com 127.0.1.1
    hed  --file ../samples/kali-default.txt add example.com 127.0.2.1
    

    output is:

    127.0.1.1	example.com	
    127.0.2.1	example.com
    

    while it should signal that example.com is already in the hosts file

    bug good first issue 
    opened by credmp 1
  • When adding a host domain, optimize the hostentry

    When adding a host domain, optimize the hostentry

    When adding example.com when a subdomain demo.example.com already exists, make the top level entry the name and move the subdomain to aliasses.

    ./hed --file test.txt show
    Reading file test.txt
    10.10.10.10	demo.example.com	
     ~/Downloads $ ./hed --file test.txt add example.com 
    Reading file test.txt
    Error: 
       0: Could not add host, no parent domain to resolve it.
    
    Location:
       src/main.rs:177
    
    Backtrace omitted.
    Run with RUST_BACKTRACE=1 environment variable to display it.
    Run with RUST_BACKTRACE=full to include source snippets.
    
    bug good first issue 
    opened by credmp 0
  • Include in Debian

    Include in Debian

    This package should be part of the debian repositories.

    Follow this guide for the required steps:

    • https://blog.hackeriet.no/packaging-a-rust-project-for-debian/
    opened by credmp 0
  • feature request: backup/restore

    feature request: backup/restore

    Request to add a feature to be able to backup and restore the hosts file using hed.

    Examples:

    $ hed backup
    backup /etc/hosts made to ~/hosts.bak
    $ hed restore
    restored /etc/hosts from ~/hosts.bak
    
    $ hed backup /tmp/x
    backup /etc/hosts made to /tmp/x
    $ hed restore /tmp/x
    restored /etc/hosts from /tmp/x
    
    enhancement 
    opened by amkuipers 1
  • feature request: ad blocker

    feature request: ad blocker

    Enable feature that hed can download an add-blocker list (like pi hole) and appends it to the hosts file.

    hed adblock https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts

    Advanced: mark beginning/end of the list with a magic comment so that the hed tool can also remove this list easy.

    Advanced: have some preconfigured url's for blocker lists

    enhancement 
    opened by amkuipers 3
  • images logo is missing

    images logo is missing

    The README.md refers the logo file at the top and that image is missing from the images folder.

    In case there is no logo. I propose the following; image search for "route sign icon" and use a route-66 icon and instead of the number use hed.

    good first issue 
    opened by amkuipers 1
Releases(0.1.8)
Code for connecting an RP2040 to a Bosch BNO055 IMU and having the realtime orientation data be sent to the host machine via serial USB

Code for connecting an RP2040 (via Raspberry Pi Pico) to a Bosch BNO055 IMU (via an Adafruit breakout board) and having the realtime orientation data be sent to the host machine via serial USB.

Gerald Nash 3 Nov 4, 2022
A stupidly simple and easy to self-host, personal server for file hosting on the web

Grasswave CDN A stupidly simple and easy to self-host, personal server for file hosting on the web. Written in Rust. Thanks, @Maciejowski, for the sty

Rafał Baran 3 Jan 3, 2023
Add nice user-facing diagnostics to your errors without being weird about it.

thisdiagnostic is a Rust library for adding rich diagnostic metadata to errors, for some really fancy and customizable error reporting!

Kat Marchán 14 Feb 2, 2022
Easily add emojis to your git commit messages 😎

gimoji A CLI tool that makes it easy to add emojis to your git commit messages. It's very similar to (and is based on) gitmoji-cli but written in Rust

Zeeshan Ali Khan 12 May 29, 2023
Searchbuddy is a browser extension that lets you chat with people that are searching for what you're searching for.

searchbuddy Make friends while searching! Searchbuddy is a browser extension that lets you chat with people that are searching for what you're searchi

Joseph Gerber 14 May 23, 2022
Flexcord! A custom Discord client to allow you to do what you want!

Disclaimer Flexcord is NO WHERE near done. Flexcord What is it? Flexcord is a Discord client that flexes for your needs, it allows you to do exactly w

null 2 Dec 5, 2022
Bongo Copy Cat wants to be involved in everything you do but instead just imitates you hitting your keyboard all day. After all it's just a cat.

Bongo Copy Cat Introduction Bongo Copy Cat wants to be involved in everything you do but instead just imitates you hitting your keyboard all day. Afte

Abhijeet Singh 4 Jan 23, 2023
Remote Secret Editor for AWS Secret Manager

Barberousse - Remote Secrets Editor About Usage Options Printing Editing Copying RoadMap 1.0 1.1 Future About A project aimed to avoid downloading sec

Mohamed Zenadi 18 Sep 28, 2021
Simple Spreadsheet editor written in Rust

Rexcel Simple Spreadsheet editor written in Rust Keyboard Shortcuts: CTRL + S => Save CTRL + Q => Quit CTRL + W +> Save And Quit CTRL + ALT + S => Sav

Saulane 16 Dec 1, 2022
Check Have I Been Pwned and see if it's time for you to change passwords.

checkpwn Check Have I Been Pwned and see if it's time for you to change passwords. Getting started Install: cargo install checkpwn Update: cargo inst

Johannes 93 Dec 13, 2022
bevy_blender is a Bevy library that allows you to use assets created in Blender directly from the .blend file

bevy_blender bevy_blender is a Bevy library that allows you to use assets created in Blender directly from the .blend file.

Jerald Thomas 45 Jan 4, 2023
miette is a diagnostic library for Rust. It includes a series of traits/protocols that allow you to hook into its error reporting facilities, and even write your own error reports!

miette is a diagnostic library for Rust. It includes a series of traits/protocols that allow you to hook into its error reporting facilities, and even write your own error reports!

Kat Marchán 1.2k Jan 1, 2023
This crate allows you to safely initialize Dynamically Sized Types (DST) using only safe Rust.

This crate allows you to safely initialize Dynamically Sized Types (DST) using only safe Rust.

Christofer Nolander 11 Dec 22, 2022
Fusion is a cross-platform App Dev ToolKit build on Rust . Fusion lets you create Beautiful and Fast apps for mobile and desktop platform.

Fusion is a cross-platform App Dev ToolKit build on Rust . Fusion lets you create Beautiful and Fast apps for mobile and desktop platform.

Fusion 1 Oct 19, 2021
File Tree Fuzzer allows you to create a pseudo-random directory hierarchy filled with some number of files.

FTZZ File Tree Fuzzer allows you to create a pseudo-random directory hierarchy filled with some number of files. Installation $ cargo +nightly install

Alex Saveau 22 Dec 28, 2022
A tool that generates a Sublime Text project file that helps you get started using Scoggle.

README A tool that generates a Sublime Text project file that helps you get started using Scoggle. While Scoggle-Gen may not find every single source

Sanjiv Sahayam 0 Jan 10, 2022
Tagref helps you maintain cross-references in your code.

Tagref helps you maintain cross-references in your code. You can use it to help keep things in sync, document assumptions, manage invariants, etc. Airbnb uses it for their front-end monorepo. You should use it too!

Stephan Boyer 119 Dec 28, 2022
cargo-lambda a Cargo subcommand to help you work with AWS Lambda

cargo-lambda cargo-lambda is a Cargo subcommand to help you work with AWS Lambda. This subcommand compiles AWS Lambda functions natively and produces

David Calavera 184 Jan 5, 2023
You can name anonymous Future from async fn without dyn or Box!

rename-future You can name anonymous Future from async fn without dyn or Box! PLEASE READ THIS THIS PROJECT NOT YET WELL TESTED! DON'T USE THIS IN PRO

Jun Ryung Ju 54 Sep 17, 2022