Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch OSError on ioctl TIOCSTI Error #82

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions arsenal/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,18 @@ def prefil_shell_cmd(self, cmd):
# use the new attributes
termios.tcsetattr(stdin, termios.TCSANOW, newattr)
# write the selected command in stdin queue
for c in cmd.cmdline:
fcntl.ioctl(stdin, termios.TIOCSTI, c)
try:
for c in cmd.cmdline:
fcntl.ioctl(stdin, termios.TIOCSTI, c)
except OSError:
message = "========== OSError ============\n"
message += "Arsenal needs TIOCSTI enable for running\n"
message += "Please run the following commands as root to fix this issue on the current session :\n"
message += "sysctl -w dev.tty.legacy_tiocsti=1\n"
message += "If you want this workaround to survive a reboot, add the following configuration to sysctl.conf file and reboot :\n"
message += "echo \"dev.tty.legacy_tiocsti=1\" >> /etc/sysctl.conf\n"
message += "More details about this bug here: https://github.com/Orange-Cyberdefense/arsenal/issues/77"
print(message)
# restore TTY attribute for stdin
termios.tcsetattr(stdin, termios.TCSADRAIN, oldattr)

Expand Down
Loading