From 8cd97c41034fa717c7fe6803664253d7f71dda18 Mon Sep 17 00:00:00 2001 From: patrik Date: Fri, 20 Aug 2010 17:58:13 +0000 Subject: [PATCH] added additional documentation regarding the Error object --- nselib/brute.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/nselib/brute.lua b/nselib/brute.lua index b72aa29d0..7bfa69214 100644 --- a/nselib/brute.lua +++ b/nselib/brute.lua @@ -37,6 +37,28 @@ -- setRetry method. It may also signal the Engine to abort all -- password guessing by calling the Error objects setAbort method. -- +-- The following example code demonstrates how the Error object can be used. +-- +-- +-- -- After a number of incorrect attempts VNC blocks us, so we abort +-- if ( not(status) and x:match("Too many authentication failures") ) then +-- local err = brute.Error:new( data ) +-- -- signal the engine to abort +-- err:setAbort( true ) +-- return false, err +-- elseif ( not(status) ) then +-- local err = brute.Error:new( "VNC handshake failed" ) +-- -- This might be temporary, signal the engine to retry +-- err:setRetry( true ) +-- return false, err +-- end +-- . +-- . +-- . +-- -- Return a simple error, no retry needed +-- return false, brute.Error:new( "Incorrect password" ) +-- +-- -- The purpose of the check method is to be able to determine -- whether the script has all the information it needs, before starting the -- brute force. It's the method where you should check, e.g., if the correct