diff --git a/src/hashcat-cli.c b/src/hashcat-cli.c index e0c2927..1d2f19b 100644 --- a/src/hashcat-cli.c +++ b/src/hashcat-cli.c @@ -22,15 +22,11 @@ #include "engine.h" // for interactive status prompt -#if defined OSX || defined FREEBSD +#if defined OSX || defined FREEBSD || defined LINUX #include #include #endif -#if defined LINUX -#include -#endif - #define USAGE_VIEW 0 #define VERSION_VIEW 0 #define QUIET 0 @@ -2888,7 +2884,7 @@ void save_hash () unlink (old_input_file); } -#if defined OSX || defined FREEBSD +#if defined OSX || defined FREEBSD || defined LINUX static struct termios savemodes; static int havemodes = 0; @@ -2897,56 +2893,7 @@ int tty_break () { struct termios modmodes; - if (ioctl (fileno (stdin), TIOCGETA, &savemodes) < 0) return -1; - - havemodes = 1; - - modmodes = savemodes; - modmodes.c_lflag &= ~ICANON; - modmodes.c_cc[VMIN] = 1; - modmodes.c_cc[VTIME] = 0; - - return ioctl (fileno (stdin), TIOCSETAW, &modmodes); -} - -int tty_getchar () -{ - fd_set rfds; - - FD_ZERO (&rfds); - - FD_SET (fileno (stdin), &rfds); - - struct timeval tv; - - tv.tv_sec = 1; - tv.tv_usec = 0; - - int retval = select (1, &rfds, NULL, NULL, &tv); - - if (retval == 0) return 0; - if (retval == -1) return -1; - - return getchar (); -} - -int tty_fix () -{ - if (!havemodes) return 0; - - return ioctl (fileno (stdin), TIOCSETAW, &savemodes); -} -#endif - -#if defined LINUX -static struct termio savemodes; -static int havemodes = 0; - -int tty_break () -{ - struct termio modmodes; - - if (ioctl (fileno (stdin), TCGETA, &savemodes) < 0) return -1; + if (tcgetattr (fileno (stdin), &savemodes) < 0) return -1; havemodes = 1; @@ -2955,7 +2902,7 @@ int tty_break () modmodes.c_cc[VMIN] = 1; modmodes.c_cc[VTIME] = 0; - return ioctl (fileno (stdin), TCSETAW, &modmodes); + return tcsetattr (fileno (stdin), TCSANOW, &modmodes); } int tty_getchar () @@ -2983,7 +2930,7 @@ int tty_fix () { if (!havemodes) return 0; - return ioctl (fileno (stdin), TCSETAW, &savemodes); + return tcsetattr (fileno (stdin), TCSANOW, &savemodes); } #endif