Commit Graph

16 Commits

Author SHA1 Message Date
cschantz f7d1a47f7e Simplify trace eraser - unset HISTFILE to prevent re-adding
Changes:
- Remove complex history -d loop (unreliable)
- Clean file directly with grep -Ev only
- Clear current session with history -c
- Unset HISTFILE to prevent session from writing on exit
- Disable histappend for current session

Issue:
- Complex history manipulation was unreliable
- Current session kept re-adding commands on exit
- history -w then grep -Ev was conflicting

Solution:
- Just clean the file, period
- Unset HISTFILE so current session won't write anything
- Tell user to exit immediately and start fresh shell

Tested:
✓ File cleaned with grep -Ev
✓ HISTFILE unset prevents writing on exit
2025-11-11 17:32:43 -05:00
cschantz 87840a9d20 Add history reload after file cleaning to prevent re-adding
Changes:
- Add history -c && history -r after cleaning file
- Reloads cleaned history into current session
- Prevents bash from appending dirty history on shell exit

Issue:
- Trace eraser cleaned file but current session kept dirty history
- On shell exit, bash appended current session to file
- All curl commands were re-added to ~/.bash_history

Solution:
- After cleaning file, clear and reload current session history
- Current session now has only cleaned history
- On exit, only clean commands are appended

Tested:
✓ File cleaned with grep -Ev
✓ Current session reloaded from cleaned file
2025-11-11 17:28:58 -05:00
cschantz f9ca08fc3f Fix trace eraser execution order - clean history before directory removal
Changes:
- Move bash history cleaning BEFORE directory removal prompt
- Ensures history is always cleaned regardless of directory choice
- Remove exit 0 that was skipping history cleaning

Issue:
- When user answered "yes" to remove directory, script exited immediately
- History cleaning code never executed (was after exit 0)
- User's curl commands remained in ~/.bash_history

Solution:
- Restructure: clean history first, then ask about directory
- History cleaning always runs now

Tested:
✓ History cleaning happens before directory prompt
✓ Works whether user keeps or removes directory
2025-11-11 17:26:41 -05:00
cschantz 1645c165c3 Add file-based history cleaning to trace eraser
Changes:
- Clean ~/.bash_history file directly after in-memory cleaning
- Handles commands from other terminal sessions
- Ensures complete cleanup even if history not yet written

Issue:
- history -d only cleans current session's in-memory history
- Commands from other sessions remain in ~/.bash_history file
- User's curl command persisted because it was from different session

Solution:
- After history -w, also grep -Ev on the history file
- Removes toolkit commands regardless of which session added them

Tested:
✓ Pattern matches user's curl command format
✓ Extracts correct entry numbers
2025-11-11 17:15:54 -05:00
cschantz 612fd84d3e Add history command removal to trace eraser
Changes:
- Remove all 'history' command entries after toolkit cleanup
- Prevents showing investigation/debugging commands
- Uses same history -d approach for consistency

Removes:
- history
- history | grep curl
- cat .bash_history
- Any other history command variants

Tested:
✓ Removed 3 history command entries from test
✓ Only clean commands remain in history
2025-11-10 23:18:16 -05:00
cschantz 65b4a5e78b Simplify trace eraser with history -d approach
Changes:
- Replace complex awk/grep file manipulation with history -d
- Use in-memory history deletion instead of file parsing
- Delete entries in reverse order to maintain numbering
- Write cleaned history back to file with history -w

Benefits:
- Much simpler and more reliable
- Works with any HISTTIMEFORMAT configuration
- Native bash command handling (no awk complexity)
- Automatically handles timestamps correctly
- User-suggested improvement

Tested:
✓ Deletes 3 toolkit entries from 7-line test history
✓ Preserves normal commands
✓ Timestamps handled automatically by history -d
2025-11-10 23:16:37 -05:00
cschantz 74587a9ba5 Fix trace eraser for HISTTIMEFORMAT-enabled systems
Changes:
- Replace grep with awk to handle timestamp lines
- Remove matching commands AND their preceding timestamp lines
- Properly handle history format: #timestamp followed by command

Issue:
- Systems with HISTTIMEFORMAT set store timestamps as #<unix_time>
- Simple grep only removed command lines, left orphaned timestamps
- User's history showed toolkit commands still present (lines 990-1030)

Solution:
- awk script that tracks timestamp lines
- Only prints timestamp if following command is kept
- Removes both timestamp and command together atomically

Tested:
✓ Removes 16 lines (8 commands + 8 timestamps) from 32-line test
✓ Preserves normal commands with their timestamps
✓ No toolkit patterns found after cleaning
2025-11-10 23:12:13 -05:00
cschantz 4d99e59383 Improve trace eraser history cleaning efficiency and reliability
Changes:
- Replace chained grep -v with single grep -Ev for efficiency
- Fix critical bug: history -w was overwriting cleaned file
- Use history -r instead of history -w to reload cleaned history
- Single-pass filtering instead of 5 separate grep processes
- Better user messaging about other terminal sessions

Technical improvements:
- Escaped regex metacharacters in pattern (git\.mull\.lol)
- Use 3988207 for unique temp file names
- More efficient: 1 process vs 5 processes

Tested:
✓ Removes all toolkit commands regardless of position
✓ Preserves normal commands
✓ No temp file errors
✓ History properly reloaded into memory
✓ 7 toolkit entries removed from 20-line test history
2025-11-10 23:05:48 -05:00
cschantz 957489457e Fix trace eraser temp file bug
Changes:
- Calculate lines removed before deleting temp files
- Add error handling to line count calculations
- Prevent 'No such file or directory' error on line 163

Tested:
✓ Pattern-based removal works correctly
✓ Removes toolkit entries regardless of position
✓ No temp file access errors
2025-11-10 23:01:13 -05:00
cschantz 71fd27148a Fix history cleaning - disable history recording
Added 'set +o history' to prevent the trace eraser commands from being re-added to history.

Changes:
• Disable history recording before cleaning (set +o history)
• Clear in-memory history with history -c
• Write empty history with history -w
• Added note to run 'exec bash' for clean shell
• Prevents script commands from being saved

This ensures the last 10 entries are properly removed and the cleanup commands themselves don't get recorded.
2025-11-10 22:50:17 -05:00
cschantz 0dc684f839 Change bash history cleanup to only remove last 10 entries
Reduced from 50 to 10 entries for more targeted cleanup.

Changes:
• Only removes last 10 bash history entries
• More conservative approach
• Still covers toolkit download and usage
• Less impact on normal command history

Tested and confirmed working.
2025-11-10 22:47:22 -05:00
cschantz 53d5b84ea0 Fix bash history cleaning - move to end of script
Bash history cleaning was happening too early, causing script commands to be re-added to history.

Changes:
• Moved history cleaning to the very end of the script
• History is now cleaned after all other operations complete
• Prevents script commands from being re-added to history
• Clear in-memory history as final action

Now properly removes the last 50 bash history entries including all toolkit-related commands.
2025-11-10 22:46:00 -05:00
cschantz fa71bef8ef Remove user history cleaning - only clean root
User bash histories are now completely skipped. The script only cleans root's bash history.

Changes:
• Removed user history detection and cleaning
• Removed prompt for user history cleaning
• Only root bash history is cleaned (last 50 entries)
• Faster execution, no prompts for user accounts
2025-11-10 22:39:20 -05:00
cschantz e441649846 Make user history cleaning optional in trace eraser
User bash history cleaning is now optional with a prompt, since most users only work as root.

Changes:
• Added user count detection
• Prompts: "Clean user bash histories too? (y/n) [n]"
• Default is "no" (skip user histories)
• If no users exist, automatically skips
• Only cleans root history by default (faster, covers 99% of use cases)

This makes the script faster and more sensible for typical usage where only root is used to run the toolkit.
2025-11-10 22:20:11 -05:00
cschantz 40bbe30f5c Fix bash history cleaning in trace eraser script
The trace eraser was failing with "no previous regular expression" sed errors and wasn't effectively cleaning bash history.

Problems fixed:
• Broken sed pattern matching (caused errors, unreliable)
• Pattern-based deletion doesn't catch all toolkit usage
• In-memory history wasn't being cleared

New approach:
• Simply removes last 50 entries from bash history files
• More reliable than pattern matching (catches downloads, usage, everything)
• Clears in-memory history with history -c && history -w
• Creates .bak backup before cleaning
• Handles both root and user histories
• Changed system log cleaning from sed to grep -v (more reliable)
• Added symlink check for log files

This ensures the last 50 commands (covering toolkit download, installation, and usage) are completely removed from bash history.
2025-11-10 22:08:52 -05:00
cschantz 2ee6d7d698 Add trace eraser tool for privacy
- New tool: erase-toolkit-traces.sh removes all toolkit traces
- Cleans bash history for all users
- Removes toolkit mentions from system logs
- Deletes download artifacts and temp files
- Optional: complete toolkit directory removal
- Added to main menu as option 10
2025-11-03 18:41:30 -05:00