Skip to content

Commit

Permalink
Fix command line use, no-payload attacks, and status pane generation
Browse files Browse the repository at this point in the history
  • Loading branch information
albinowax committed Mar 6, 2019
1 parent a6053c7 commit 290fcef
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 11 deletions.
35 changes: 35 additions & 0 deletions resources/examples/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This is just for making sure the engine works during development
def queueRequests(target, wordlists):
engine = RequestEngine(endpoint='https://hackxor.net:443',
concurrentConnections=1,
requestsPerConnection=10,
pipeline=False
)
engine.start()

noPayload = '''GET /static/404 HTTP/1.1
Host: hackxor.net
Connection: close
'''
engine.queue(noPayload)

onePayload = '''GET /static/404?q=%s HTTP/1.1
Host: hackxor.net
Connection: close
'''
engine.queue(onePayload, 'one payload')

twoPayloads = '''GET /static/404?q=%s HTTP/1.1
Host: hackxor.net
Connection: close
'''

engine.queue(twoPayloads, ['first payload', 'second payload'])



def handleResponse(req, interesting):
table.add(req)
19 changes: 10 additions & 9 deletions src/RequestEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ abstract class RequestEngine {
queue(template, payloads, 0, null)
}

fun queue(template: String, payloads: List<String?>, learnBoring: Int?, callback: ((Request, Boolean) -> Boolean)?) {
fun queue(template: String, payloads: List<String?>, learnBoring: Int, callback: ((Request, Boolean) -> Boolean)?) {

if (!template.contains("%s")) {
Utils.out("Add %s to the request where you want the payload to go.")
throw Exception("Add %s to the request where you want the payload to go.")
}
val noPayload = payloads.isEmpty()
val noMarker = !template.contains("%s")

if ((payloads.isEmpty()) || (payloads.size == 1 && payloads[0] == null)) {
Utils.out("Add payloads to send requests")
throw Exception("Add payloads to send requests")
if (noMarker && !noPayload) {
throw Exception("The request has payloads specified, but no %s injection markers")
}
if (!noMarker && noPayload) {
throw Exception("The request has a %s injection point, but no payloads specified")
}

if (learnBoring != 0 && !Utils.gotBurp) {
Expand Down Expand Up @@ -138,7 +138,8 @@ abstract class RequestEngine {
fun statusString(): String {
val duration = Math.ceil(((System.nanoTime().toFloat() - start) / 1000000000).toDouble()).toInt()
val requests = successfulRequests.get().toFloat()
var statusString = String.format("Reqs: %d | Queued: %d | Duration: %d |RPS: %.0f | Connections: %d | Retries: %d | Fails: %d | Next: %s", requests.toInt(), requestQueue.count(), duration, requests / duration, connections.get(), retries.get(), permaFails.get(), requestQueue.peek().words.joinToString(separator="/"))
val nextWord = requestQueue?.peek()?.words?.joinToString(separator="/")
var statusString = String.format("Reqs: %d | Queued: %d | Duration: %d |RPS: %.0f | Connections: %d | Retries: %d | Fails: %d | Next: %s", requests.toInt(), requestQueue.count(), duration, requests / duration, connections.get(), retries.get(), permaFails.get(), nextWord)
val state = attackState.get()
if (state < 3) {
return statusString
Expand Down
6 changes: 4 additions & 2 deletions src/fast-http.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ class RequestEngine:
self.engine.setOutput(outputHandler)
def queue(self, template, payloads=None, learn=None, callback=None):
if(not isinstance(payloads, list)):
def queue(self, template, payloads=None, learn=0, callback=None):
if payloads == None:
payloads = []
elif(not isinstance(payloads, list)):
payloads = [payloads]
self.engine.queue(template, payloads, learn, callback)
Expand Down

0 comments on commit 290fcef

Please sign in to comment.