How to switch to modal window in the background
You can focus SecurityAgent:

osascript -e 'do shell script "ls /var/root" with administrator privileges' &amp;
open -a SecurityAgent


Displaying dialogs:

tell application (path to frontmost application as text)
    --activate
    display dialog "" default answer ""
end tell


⌃F6 (Move focus to the floating window) doesn't work with the password dialogs, and Witch doesn't include them either. You might use a script like this though:

tell application "System Events"
    repeat with p in {"SecurityAgent", "CoreServicesUIAgent", "loginwindow"}
        if exists process p then
            tell process p
                if windows is not {} then
                    set frontmost to true
                    exit repeat
                end if
            end tell
        end if
    end repeat
end tell


CoreServicesUIAgent displays Gatekeeper and quarantine dialogs. loginwindow displays many of the dialogs shown when logging out.