All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.owasp.jbrofuzz.fuzz.SocketTimer Maven / Gradle / Ivy

Go to download

JBroFuzz is a stateless web application fuzzer for requests being made over HTTP and/or HTTPS. Its purpose is to provide a single, portable application that offers stable web protocol fuzzing capabilities. As a tool, it emerged from the needs of penetration testing.

There is a newer version: 2.5.1
Show newest version
/**
 * JbroFuzz 2.5
 *
 * JBroFuzz - A stateless network protocol fuzzer for web applications.
 * 
 * Copyright (C) 2007 - 2010 [email protected]
 *
 * This file is part of JBroFuzz.
 * 
 * JBroFuzz is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * JBroFuzz is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with JBroFuzz.  If not, see .
 * Alternatively, write to the Free Software Foundation, Inc., 51 
 * Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * 
 * Verbatim copying and distribution of this entire program file is 
 * permitted in any medium without royalty provided this notice 
 * is preserved. 
 * 
 */
package org.owasp.jbrofuzz.fuzz;


/**
 * 

Class inspired by the Timer.java class of David Reilly.

* *

Once a SocketTimer is started, it must be reset during * the course of a lengthy operation, otherwise the timer will * exit.

* *

This class varies from the original implementation in the * primitive data types used (shorts and bytes instead of ints). *

* *

Changed back to int due to memory allocations within * java.

* * @author [email protected] * @version 2.0 * @since 2.0 */ class SocketTimer extends Thread { // Rate at which timer is checked private static final int m_rate = Byte.MAX_VALUE; // Length of the Timer timeout in milliseconds private transient final int m_length; // The time that has elapsed on the counter thread private transient int tElapsed; // The Socket attached to this timer private transient final SocketConnection sConnection; /** *

Create a Timer of specified length, specified as a * short with a maximum value of +32767.

* * @param sConnection the socket connection * @param timeInMS Length of time (in ms) before timeout */ protected SocketTimer(final SocketConnection sConnection, final int timeInMS) { super(); this.sConnection = sConnection; this.m_length = timeInMS; this.tElapsed = 0; } /** *

Method for resetting the timer on the thread.

*

This method should be called in order for a * "timeout" not to be triggered.

* * @author [email protected] * @version 2.0 * @since 2.0 */ protected void reset() { synchronized(this) { tElapsed = 0; } } @Override public void run() { // Infinite loop... for (;;) { // Put the timer to sleep try { Thread.sleep(m_rate); } catch (final InterruptedException ioe) { continue; } // Use 'synchronized' to prevent conflicts synchronized(this) { // Increment time remaining tElapsed += m_rate; // Check to see if the time has been exceeded if (tElapsed > m_length) { // Close the connection, be rude... sConnection.close(); break; } } } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy