How would one write a loop to reach the limit on $HISTFILESIZE in bash?
Something like this that would actually print the commands?
for i in $(seq 1 $HISTFILESIZE); do echo test-$i;done
The goal is to see if logs can be overwritten with a simple loop that a malicious user might use to hide his shell history. I have .bash_history append only with: chattr +a
I know that relying on .bash_history is probably not the best way to keep track, this is more of a “I’m curious” question.
Thanks
Jon
You don’t need
seq, Bash has two ways of providing numbers to iterate over with aforloop.which won’t take variables as arguments (unless you use
eval).And
which obviously can use variables.
You can do:
With this technique a user can obliterate the in-memory history list of the current session. When the user exits, that list is written to the history file.
You can truncate the history file:
Assuming it’s not append-only.