21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

compute the future time at which the next authentication attempt will be accepted,<br />

and ignore any input until that time arrives.<br />

When authenticating a user interactively on a terminal on Unix, the best solution is<br />

likely to be to use the sleep( ) function. On Windows, there is no strict equivalent.<br />

The Win32 API functions Sleep( ) and SleepEx( ) will both return immediately—<br />

regardless of the specified wait time—if there are no other threads of equal priority<br />

waiting to run.<br />

Some of these techniques can increase the risk of denial-of-service<br />

attacks.<br />

In a GUI environment, any authentication dialog presented to the user will have a<br />

button labeled “OK” or some equivalent. When a delay must be made, disable the<br />

button for the duration of the delay, then enable it. On Windows, this is easily<br />

accomplished using timers.<br />

The following function, spc_throttle( ), computes the number of seconds to delay<br />

based on the three variables we’ve described and the number of failed authentication<br />

attempts. It has four arguments:<br />

attempts<br />

Pointer to an integer used to count the number of failed attempts. Initially, the<br />

value of the integer to which it points should be zero, and each call to spc_<br />

throttle( ) will increment it by one.<br />

max_attempts<br />

Maximum number of attempts to allow. When this number of attempts has<br />

been made, the return from spc_throttle( ) will be –1 to indicate a complete<br />

failure to authenticate.<br />

allowed_fails<br />

Number of attempts allowed before enabling throttling.<br />

delay<br />

Base delay in seconds.<br />

If the maximum number of attempts has been reached, the return value from spc_<br />

throttle( ) will be –1. If there is to be no delay, the return value will be 0; otherwise,<br />

the return value will be the number of seconds to delay before allowing another<br />

authentication attempt.<br />

int spc_throttle(int *attempts, int max_attempts, int allowed_fails, int delay) {<br />

int exp;<br />

(*attempts)++;<br />

if (*attempts > max_attempts) return -1;<br />

if (*attempts

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!