# Phrack-Reader
This is nothing special, like most of the code you will find here.
Just a little personal project to occupy my time.
Phrack-Reader is a bash script for reading a nostalgic e-zine. Today it is delivered in a compressed archive of text files. There may be better, more efficient ways of doing things like this, but I learn by doing. So things here may change as my ideas evolve. This is designed to match my current system theme.
### Phrack-Reader Bash Script
```bash
#!/usr/bin/env bash
# =====================================================================
# MODERNISED PHRACK DIRECTORY READER ENGINE (FOR SPLIT .TXT MODULES)
# =====================================================================
# Color Matrix Definitions
BG_BLACK="\033[0;30m"
NEON_CYAN="\033[1;36m"
CYBER_PINK="\033[1;35m"
TERM_GREEN="\033[1;32m"
WARN_YELLOW="\033[1;33m"
TEXT_DIM="\033[0;90m"
RESET_COLOR="\033[0m"
# Pager Configuration
PAGER_ENGINE=$(command -v less || command -v more)
if [ "$(basename "$PAGER_ENGINE")" = "less" ]; then
export LESS="-R -e -F -X"
fi
# Detect Current Target Directory (Where the user is standing)
TARGET_DIR=$(pwd)
ISSUE_NAME=$(basename "$TARGET_DIR")
# Verify this directory actually contains Phrack files (e.g., 1.txt, 2.txt)
if [ ! -f "1.txt" ] && [ ! -f "2.txt" ]; then
echo -e "${WARN_YELLOW}[!] ERROR: No Phrack file sequence (1.txt, 2.txt) detected in this folder.${RESET_COLOR}"
echo -e "Navigate inside the extracted issue directory (e.g., ~/Downloads/Books/phrack72) and run: ${NEON_CYAN}phrack-read${RESET_COLOR}"
exit 1
fi
display_article() {
local art_num="$1"
local file_target="${art_num}.txt"
if [ -f "$file_target" ]; then
clear
echo -e "${NEON_CYAN}[ SYSTEM: READING $ISSUE_NAME // FILE: $file_target ]${RESET_COLOR}"
echo -e "${TEXT_DIM}-----------------------------------------------------------------------${RESET_COLOR}"
$PAGER_ENGINE "$file_target"
else
echo -e "\n${WARN_YELLOW}[!] Target File Error: $file_target does not exist in this matrix.${RESET_COLOR}"
sleep 2
fi
}
display_interactive_menu() {
while true; do
clear
echo -e "${CYBER_PINK}[ PHRACK EXPANDED DIRECTORY INTERFACE ]${RESET_COLOR}"
echo -e "${TEXT_DIM}Active Node: $TARGET_DIR${RESET_COLOR}"
echo -e "${TEXT_DIM}=======================================================================${RESET_COLOR}"
# Pull the introduction or title lines from 1.txt if available to show a sneak peek
if [ -f "1.txt" ]; then
echo -e "${NEON_CYAN}---[ Issue Index Summary (File 1.txt) ]---${RESET_COLOR}"
grep -E "^[^[:space:]]" 1.txt | head -n 8 | while read -r line; do
echo -e " ${TEXT_DIM}${line}${RESET_COLOR}"
done
echo -e "${TEXT_DIM}=======================================================================${RESET_COLOR}"
fi
# Display available text files sorted numerically
echo -e "${TERM_GREEN}Detected Article Files Available In This Node:${RESET_COLOR}"
ls -v *.txt | sed 's/\.txt//g' | xargs | fmt -w 65 | while read -r line; do
echo -e " Files: $line"
done
echo -e "${TEXT_DIM}=======================================================================${RESET_COLOR}"
echo -en "${NEON_CYAN}Enter File Number to load (${WARN_YELLOW}q${NEON_CYAN} to exit): ${RESET_COLOR}"
read -r USER_INPUT
if [[ "$USER_INPUT" =~ ^[qQ]$ ]]; then
echo -e "\n${TEXT_DIM}Terminal session detached.${RESET_COLOR}"
break
elif [[ "$USER_INPUT" =~ ^[0-9]+$ ]]; then
display_article "$USER_INPUT"
else
echo -e "\n${WARN_YELLOW}[!] Invalid Sequence String.${RESET_COLOR}"
sleep 1
fi
done
}
# Entry Pointer: If user passed an argument (e.g., phrack-read 12), open it immediately
if [ -n "$1" ]; then
display_article "$1"
else
display_interactive_menu
fi
```