diff options
-rw-r--r-- | LICENSE | 21 | ||||
-rw-r--r-- | README.md | 64 | ||||
-rw-r--r-- | hosts.c | 113 |
3 files changed, 198 insertions, 0 deletions
@@ -0,0 +1,21 @@ +MIT/X Consortium License + +© 2024-2024 Marlon Ivo <email@marlonivo.xyz> + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..435057a --- /dev/null +++ b/README.md @@ -0,0 +1,64 @@ +```markdown +> [!CAUTION] +> This blocklist includes all Tor exit nodes +``` + +### 🟧 Description: + +This is an encompassing Blocklist, regarding my philosophical principles. + +### 🟧 Installation: + +```shell +git clone git.marlonivo.xyz/hosts +cd hosts +make +``` + +### 🟦 Lists: + +In your `/etc/hosts` are the following lists that you can individually search for: + +1. **Personal List**: Your stuff +2. **Luke Smith's List**: https://github.com/LukeSmithxyz/etc/blob/master/ips +3. **4skinskywalker's List:** https://github.com/4skinSkywalker/Anti-Porn-HOSTS-File +4. **columndeeply's List**: https://github.com/columndeeply/hosts +5. **dan.me.uk's List**: https://www.dan.me.uk/torlist/?full + +### 🟩 Functions: + +```shell +sulist merge list.com <-- merge another list at the end of the file +sulist remove list.com <-- remove a list from the file +``` + +### 🟩 Info: + +If you do not want the software and just want to use the blocklistgo ahead with: + +#### Linux: + +```bash +sudo cat hosts >> /etc/hosts +``` + +#### Windows: + +Place the domains in `C:\Windows\System32\drivers\etc\hosts`. + +#### Android: +1. Activate `USB debugging` and `Rooted debugging` on your phone +2. Install `adb` on your computer: + + ``` + sudo pacman -S adb + ``` +3. Plug phone into computer. +4. Run these commands: + ``` + adb root + adb remount + adb push /etc/hosts /system/etc + ``` + +### 🟦 License: MIT @@ -0,0 +1,113 @@ +#include <ncurses.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define MAX_LINES 1024 +#define MAX_LINE_LEN 512 + +char *lines[MAX_LINES]; +int total_lines = 0; +int current_line = 0; + +void load_hosts_file() { + FILE *fp = fopen("/etc/hosts", "r"); + if (!fp) exit(1); + + char buffer[MAX_LINE_LEN]; + while (fgets(buffer, sizeof(buffer), fp) && total_lines < MAX_LINES) { + lines[total_lines] = strdup(buffer); + total_lines++; + } + + fclose(fp); +} + +void cleanup() { + for (int i = 0; i < total_lines; i++) { + free(lines[i]); + } +} + +void draw_screen() { + clear(); + int max_y, max_x; + getmaxyx(stdscr, max_y, max_x); + + for (int i = 0; i < max_y && (i + current_line) < total_lines; i++) { + mvprintw(i, 0, "%s", lines[i + current_line]); + } + + refresh(); +} + +int main() { + load_hosts_file(); + + initscr(); + noecho(); + cbreak(); + keypad(stdscr, TRUE); + + int ch; + draw_screen(); + while ((ch = getch()) != 'q') { + switch (ch) { + case 'j': + if (current_line < total_lines - 1) current_line++; + break; + case 'k': + if (current_line > 0) current_line--; + break; + case 'c': { + for (int i = 0; i < total_lines; i++) { + if (lines[i][0] == '\n' || lines[i][0] == '#') { + free(lines[i]); + lines[i] = NULL; + } + } + int new_total_lines = 0; + for (int i = 0; i < total_lines; i++) { + if (lines[i] != NULL) { + lines[new_total_lines++] = lines[i]; + } + } + total_lines = new_total_lines; + draw_screen(); + break; + case 'a': { + echo(); + char url[256]; + mvprintw(LINES - 1, 0, "URL oder Pfad: "); + getnstr(url, 255); + noecho(); + + char tmpfile[] = "/tmp/hosts_tmp_XXXXXX"; + int fd = mkstemp(tmpfile); + close(fd); + + char cmd[512]; + snprintf(cmd, sizeof(cmd), "curl -fsSL '%s' -o %s", url, tmpfile); + if (system(cmd) == 0) { + FILE *fp = fopen(tmpfile, "r"); + if (fp) { + char buffer[MAX_LINE_LEN]; + while (fgets(buffer, sizeof(buffer), fp) && total_lines < MAX_LINES) { + lines[total_lines++] = strdup(buffer); + } + fclose(fp); + } + } + unlink(tmpfile); + draw_screen(); + break; + } + } + draw_screen(); + } + + endwin(); + cleanup(); + return 0; +} + |