FleexSecurity / fleex

Fleex makes it easy to create multiple VPS on cloud providers and use them to distribute workloads.
https://fleexsecurity.github.io/fleex-docs/
Apache License 2.0
250 stars 30 forks source link

"terminal make raw:inappropriate ioctl for device" #20

Closed michael1026 closed 2 years ago

michael1026 commented 3 years ago

Hello,

I noticed when running fleex scans from within a bash loop, it causes an issue with SSH. I have not been able to figure out the solution to this yet, but it should be easy to reproduce.

Error I get: FATA[0002] terminal make raw:inappropriate ioctl for device

Working bash script

#!/bin/bash
fleex scan -n pwn -i "/home/myInput.txt" -c "~/go/bin/httpx -l {{INPUT}} -o {{OUTPUT}}" -o "/home/myOutput.txt"

Erroring bash script

#!/bin/bash
while read f; do
  FILE="/home/$f.txt"
  fleex scan -n pwn -i "${f}" -c "~/go/bin/httpx -l {{INPUT}} -o {{OUTPUT}}" -o "/home/${f}-output.txt"
done </home/hosts.txt

You should even be able to reproduce with less code...

#!/bin/bash
while read f; do
  fleex scan -n pwn -i "/home/myInput.txt" -c "~/go/bin/httpx -l {{INPUT}} -o {{OUTPUT}}" -o "/home/myOutput.txt"
done </home/hosts.txt

Possible code in question: https://github.com/FleexSecurity/fleex/blob/f4a0d874ba5c933dec2602145abfca1fdb8ef980/pkg/sshutils/sshutils.go#L101

Possible solution 1: https://github.com/golang/go/issues/19909 Possible solution 2: https://github.com/c-bata/go-prompt/issues/88

Thanks!

michael1026 commented 3 years ago

I was able to get around this issue using for f in $(cat myfile.txt); do ... done instead. Not sure why the other loop wasn't working, so it actually might not be an issue with this project.

sw33tLie commented 2 years ago

Hi there, apologies for the late reply. I had the same issue a while ago and ended up fixing it in a similar way as well. It's also in the docs.

I think there's a way to change something in the code to avoid this entirely, but not really sure what to touch :smile:

michael1026 commented 2 years ago

Ah! How did I mange to miss that in the docs. Thanks for the reply.