Skip to content

AdarshJha-1/Knight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Knight Knight

Knight is a small Linux CLI tool written in C that blocks domains and IP addresses by updating the system's /etc/hosts file.

The project was built to understand how hostname blocking works on Linux while getting hands-on with C, file handling, and hash tables.

Features

  • Block domains and IP addresses
  • Remove blocked entries
  • Save blocked entries to disk
  • Apply changes to /etc/hosts
  • Restore the original hosts file
  • Create backups
  • View all blocked entries

Commands

knight og
knight block google.com
knight unblock google.com
knight apply
knight reset
knight backup
knight show
Command Description
knight og Create a backup of the original /etc/hosts
`knight block <domain ip>`
`knight unblock <domain ip>`
knight apply Write all blocked entries to /etc/hosts
knight reset Restore the original hosts file
knight backup Backup the current hosts file
knight show List all blocked entries

How it works

Blocked domains and IPs are stored in memory using uthash. Every change is also written to blocked.txt, so the list is preserved between runs.

When you run knight apply, the tool updates /etc/hosts by mapping blocked domains to 0.0.0.0, preventing them from being resolved by the system.

Built With

  • C
  • uthash
  • Linux
  • /etc/hosts

Notes

  • Root privileges are required to modify /etc/hosts.
  • The block list is stored in blocked.txt.
  • This project is intended for learning and experimentation.

About

A lightweight Linux CLI tool written in C for blocking domains and IPs using /etc/hosts.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors