from nessusapi.session import Session
from getpass import getpass

def authenticate():
    Session( prompt("Username"),
             prompt("Password", hidden=True),
             prompt("Host", "127.0.0.1"),
             prompt("Port", "8834") )

def prompt(text, default=None, hidden=False):
    choice = ""
    while choice == "":
        prompt = "{0}{1}: ".format(text, " (default: {0})".format(default) if default else "")
        if hidden:
            choice = getpass(prompt)
        else:
            choice = raw_input(prompt)

        if choice == "" and default is not None:
            return default
    return choice
            

@@ -88,33 +88,84 @@
     
-Session( prompt(%22Username
+print(%22Logging into Nessus instance%22)%0A    Session( prompt(%22Host%22, %22127.0.0.1
 %22),%0A
@@ -190,29 +190,20 @@
 t(%22P
-assw
 or
-d%22, hidden=True
+t%22, %228834%22
 ),%0A 
@@ -222,33 +222,24 @@
 prompt(%22
-Host%22, %22127.0.0.1
+Username
 %22),%0A    
@@ -256,28 +256,37 @@
 rompt(%22P
+assw
 or
-t%22, %228834%22
+d%22, hidden=True
 ) )%0A%0Adef

Improve authentication dialog