0xricksanchez / AFL_Runner

Scaling best-practice AFLPlusPlus fuzzing campaigns made easy
https://crates.io/crates/afl_runner
Apache License 2.0
51 stars 7 forks source link

tmux sends the keys to the window before the shell finishes loading #42

Open wizche opened 4 days ago

wizche commented 4 days ago

Resulting in the instance not starting properly. maybe should we add a sleep?

0xricksanchez commented 3 days ago

The TMUX/Screen interaction can indeed be a little finicky. It seemed to work fine on my end and I already experimented with some sleeps before but wasn’t quite satisfied with my approach. Happy to review a PR regarding that as well

wizche commented 1 day ago

What I do now is send a tmux send-keys -t $SESSION_NAME:$WINDOW_NAME "" C-m before the actual afl-fuzz command, that seems to fix the problem in my case. Here some ChatGPT suggestions:

Function to check if the target pane is ready

check_pane_ready() { tmux send-keys -t mysession "pwd" C-m # Run a harmless command sleep 0.1 # Small delay to give tmux time to process

Capture the last output from the pane

last_output=$(tmux capture-pane -t mysession -p -S -1)

# Check if the output of 'pwd' was captured (or other suitable prompt check)
[[ -n "$last_output" ]]

}

Loop until the shell prompt is ready

until check_pane_ready; do sleep 0.1 # Retry interval done



---
Not sure which want you wanna go, maybe keeping a sleep is enough? 
We don't actually care if the whole campaign start is delayed for a second.
0xricksanchez commented 1 day ago

We don't actually care if the whole campaign start is delayed for a second. That's what I'm thinking. If there's a significant delay upon startup, it should be communicated to the user so (like a visual indicator or whatever).

I think either solution could work. Something that checks for a sane state/output before continuing seems reasonable and good to debug if we need to make further adjustments eventually if this keeps being a problem.