Skip to content

Commit

Permalink
v4.5 - See CHANGELOG.md
Browse files Browse the repository at this point in the history
  • Loading branch information
xnl-h4ck3r committed May 16, 2024
1 parent a67fc89 commit 6ed0cc1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

- v4.5

- New

- In the output `API calls made so far today`, also add the API limit reset time, if known.

- Changed

- Fix the bug that shows `:( There was a problem calling KNOXSS API: local variable 'resp' referenced before assignment` in certain situations where the KNOXSS API has initially timed out.
Expand Down
17 changes: 10 additions & 7 deletions knoxnl/knoxnl.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,18 +433,16 @@ def knoxssApi(targetUrl, headers, method, knoxssResponse):

# Try to get the JSON response
try:
try:
jsonResponse = json.loads(fullResponse)
except:
knoxssResponse.Error = 'No JSON response found'

# If the error has "expiration time reset", and we haven't already tried before, set to True to try one more time
if 'expiration time reset' in fullResponse.lower():
if tryAgain:
tryAgain = False
else:
tryAgain = True
else:
else:
jsonResponse = json.loads(fullResponse)

knoxssResponse.XSS = str(jsonResponse['XSS'])
knoxssResponse.PoC = str(jsonResponse['PoC'])
knoxssResponse.Calls = str(jsonResponse['API Call'])
Expand Down Expand Up @@ -472,7 +470,6 @@ def knoxssApi(targetUrl, headers, method, knoxssResponse):
knoxssResponse.Calls = 'Unknown'
if fullResponse is None:
fullResponse = ''
knoxssResponse.Error = 'Empty response from API'

# The response probably wasn't JSON, so check the response message
if fullResponse.lower() == 'incorrect apy key.' or fullResponse.lower() == 'invalid or expired api key.':
Expand All @@ -491,6 +488,9 @@ def knoxssApi(targetUrl, headers, method, knoxssResponse):
elif 'type of target page can\'t lead to xss' in fullResponse.lower():
knoxssResponse.Error = 'XSS is not possible with the requested URL'
inputValues.discard(targetUrl)

elif fullResponse == '':
knoxssResponse.Error = 'Empty response from API'

else:
print(colored('Something went wrong: '+str(e),'red'))
Expand Down Expand Up @@ -1095,7 +1095,10 @@ def main():
# Show the user the latest API quota
if latestApiCalls is None or latestApiCalls == '':
latestApiCalls = 'Unknown'
print(colored('\nAPI calls made so far today - ' + latestApiCalls + '\n', 'cyan'))
if timeAPIReset is not None:
print(colored('\nAPI calls made so far today - ' + latestApiCalls + ' (API Limit Reset Time: ' +str(timeAPIReset.strftime("%Y-%m-%d %H:%M")) + ')\n', 'cyan'))
else:
print(colored('\nAPI calls made so far today - ' + latestApiCalls + '\n', 'cyan'))

# If a file was passed, there is a reason to stop, write the .todo file and let the user know about it
if needToStop and not urlPassed and not args.burp_piper:
Expand Down

0 comments on commit 6ed0cc1

Please sign in to comment.