-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added tests for Hoppy #26
Open
DoomTaper
wants to merge
1
commit into
owtf:develop
Choose a base branch
from
DoomTaper:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ class HoppyParser(FileParser): | |
_re_request = re.compile(r"(\S+ /.*?)\n(?=Server)", re.S) | ||
_re_response = re.compile(r"(?<=Responded:\n\n)(.*)", re.S) | ||
_re_response_status_code = re.compile(r"(?<=HTTP/\w.\w )(.*)") | ||
_re_response_parse = re.compile(r"(?P<headers>HTTP.*?)\n(?=\r\n)(?P<body>.*)", re.S) | ||
_re_response_parse = re.compile(r"(?P<headers>HTTP.*?)(?=\n)(?P<body>.*)", re.S) | ||
|
||
def __init__(self, pathname, filename='*.spider', **kwargs): | ||
"""Initialize HoppyParser. | ||
|
@@ -93,15 +93,26 @@ def parse_report(self): | |
if not transactions: | ||
return None | ||
for count, transaction in enumerate(transactions): | ||
response = self._re_response.search(transaction).group().strip() + '\n\n' | ||
status_code = self._re_response_status_code.findall(response) | ||
parsed_response = self._re_response_parse.findall(response) | ||
try: | ||
response = self._re_response.search(transaction).group().strip() + '\n\n' | ||
except AttributeError: | ||
response = "NOT FOUND" | ||
if(response != "NOT FOUND"): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Superfluous parenthesis. |
||
try: | ||
status_code = self._re_response_status_code.findall(response) | ||
parsed_response = self._re_response_parse.findall(response) | ||
except Exception: | ||
status_code = ["NOT FOUND"] | ||
parsed_response = [["NOT FOUND", "NOT FOUND"]] | ||
else: | ||
status_code = ["NOT FOUND"] | ||
parsed_response = [["NOT FOUND", "NOT FOUND"]] | ||
# Somehow follow naming conventions from http://docs.python-requests.org/en/master/ | ||
data.append({ | ||
'request': self._re_request.findall(transaction)[0].strip() + '\n\n', | ||
'status_code': status_code[0].strip() + '\n', | ||
'headers': parsed_response[0][0].strip() + '\n\n', | ||
'body': parsed_response[0][1].strip() + '\n\n' | ||
}) | ||
self.data.append({'ranking': constants.UNKOWN, 'transactions': data}) | ||
self.data.append({'ranking': constants.UNKNOWN, 'transactions': data}) | ||
return self.data |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,320 @@ | ||
|
||
[+] Spider Beggining for example.com:443 with a Virtual Host of example.com | ||
|
||
[+] Start points are '/' and '/images/dummy.txt' | ||
|
||
|
||
We Sent: | ||
|
||
GET / HTTP/1.1 | ||
Host: example.com | ||
|
||
|
||
|
||
Server Responded: | ||
|
||
HTTP/1.1 200 OK | ||
Cache-Control: max-age=604800 | ||
Content-Type: text/html | ||
Date: Tue, 24 Jan 2017 09:57:22 GMT | ||
Etag: "359670651+gzip+ident" | ||
Expires: Tue, 31 Jan 2017 09:57:22 GMT | ||
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT | ||
Server: ECS (cpm/F845) | ||
Vary: Accept-Encoding | ||
X-Cache: HIT | ||
x-ec-custom-error: 1 | ||
Content-Length: 1270 | ||
|
||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Example Domain</title> | ||
|
||
<meta charset="utf-8" /> | ||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<style type="text/css"> | ||
body { | ||
background-color: #f0f0f2; | ||
margin: 0; | ||
padding: 0; | ||
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; | ||
|
||
} | ||
div { | ||
width: 600px; | ||
margin: 5em auto; | ||
padding: 50px; | ||
background-color: #fff; | ||
border-radius: 1em; | ||
} | ||
a:link, a:visited { | ||
color: #38488f; | ||
text-decoration: none; | ||
} | ||
@media (max-width: 700px) { | ||
body { | ||
background-color: #fff; | ||
} | ||
div { | ||
width: auto; | ||
margin: 0 auto; | ||
border-radius: 0; | ||
padding: 1em; | ||
} | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div> | ||
<h1>Example Domain</h1> | ||
<p>This domain is established to be used for illustrative examples in documents. You may use this | ||
domain in examples without prior coordination or asking for permission.</p> | ||
<p><a href="http://www.iana.org/domains/example">More information...</a></p> | ||
</div> | ||
</body> | ||
</html> | ||
|
||
|
||
[+] Parsed Response: | ||
|
||
/domains/example | ||
|
||
We Sent: | ||
|
||
GET /images/dummy.txt HTTP/1.1 | ||
Host: example.com | ||
|
||
|
||
|
||
Server Responded: | ||
|
||
HTTP/1.1 404 Not Found | ||
Accept-Ranges: bytes | ||
Cache-Control: max-age=604800 | ||
Content-Type: text/html | ||
Date: Tue, 24 Jan 2017 09:57:22 GMT | ||
Etag: "359670651" | ||
Expires: Tue, 31 Jan 2017 09:57:22 GMT | ||
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT | ||
Server: ECS (oxr/83CA) | ||
Vary: Accept-Encoding | ||
X-Cache: HIT | ||
x-ec-custom-error: 1 | ||
Content-Length: 1270 | ||
|
||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Example Domain</title> | ||
|
||
<meta charset="utf-8" /> | ||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<style type="text/css"> | ||
body { | ||
background-color: #f0f0f2; | ||
margin: 0; | ||
padding: 0; | ||
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; | ||
|
||
} | ||
div { | ||
width: 600px; | ||
margin: 5em auto; | ||
padding: 50px; | ||
background-color: #fff; | ||
border-radius: 1em; | ||
} | ||
a:link, a:visited { | ||
color: #38488f; | ||
text-decoration: none; | ||
} | ||
@media (max-width: 700px) { | ||
body { | ||
background-color: #fff; | ||
} | ||
div { | ||
width: auto; | ||
margin: 0 auto; | ||
border-radius: 0; | ||
padding: 1em; | ||
} | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div> | ||
<h1>Example Domain</h1> | ||
<p>This domain is established to be used for illustrative examples in documents. You may use this | ||
domain in examples without prior coordination or asking for permission.</p> | ||
<p><a href="http://www.iana.org/domains/example">More information...</a></p> | ||
</div> | ||
</body> | ||
</html> | ||
|
||
|
||
[+] Parsed Response: | ||
|
||
/domains/example | ||
|
||
We Sent: | ||
|
||
GET /domains/example HTTP/1.1 | ||
Host: example.com | ||
|
||
|
||
|
||
Server Responded: | ||
|
||
HTTP/1.1 404 Not Found | ||
Accept-Ranges: bytes | ||
Cache-Control: max-age=604800 | ||
Content-Type: text/html | ||
Date: Tue, 24 Jan 2017 09:57:23 GMT | ||
Etag: "359670651" | ||
Expires: Tue, 31 Jan 2017 09:57:23 GMT | ||
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT | ||
Server: ECS (oxr/83CA) | ||
Vary: Accept-Encoding | ||
X-Cache: HIT | ||
x-ec-custom-error: 1 | ||
Content-Length: 1270 | ||
|
||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Example Domain</title> | ||
|
||
<meta charset="utf-8" /> | ||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<style type="text/css"> | ||
body { | ||
background-color: #f0f0f2; | ||
margin: 0; | ||
padding: 0; | ||
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; | ||
|
||
} | ||
div { | ||
width: 600px; | ||
margin: 5em auto; | ||
padding: 50px; | ||
background-color: #fff; | ||
border-radius: 1em; | ||
} | ||
a:link, a:visited { | ||
color: #38488f; | ||
text-decoration: none; | ||
} | ||
@media (max-width: 700px) { | ||
body { | ||
background-color: #fff; | ||
} | ||
div { | ||
width: auto; | ||
margin: 0 auto; | ||
border-radius: 0; | ||
padding: 1em; | ||
} | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div> | ||
<h1>Example Domain</h1> | ||
<p>This domain is established to be used for illustrative examples in documents. You may use this | ||
domain in examples without prior coordination or asking for permission.</p> | ||
<p><a href="http://www.iana.org/domains/example">More information...</a></p> | ||
</div> | ||
</body> | ||
</html> | ||
|
||
|
||
[+] Parsed Response: | ||
|
||
/domains/example | ||
|
||
We Sent: | ||
|
||
GET /domains/ HTTP/1.1 | ||
Host: example.com | ||
|
||
|
||
|
||
Server Responded: | ||
|
||
HTTP/1.1 404 Not Found | ||
Accept-Ranges: bytes | ||
Cache-Control: max-age=604800 | ||
Content-Type: text/html | ||
Date: Tue, 24 Jan 2017 09:57:23 GMT | ||
Etag: "359670651" | ||
Expires: Tue, 31 Jan 2017 09:57:23 GMT | ||
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT | ||
Server: ECS (oxr/83CA) | ||
Vary: Accept-Encoding | ||
X-Cache: HIT | ||
x-ec-custom-error: 1 | ||
Content-Length: 1270 | ||
|
||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Example Domain</title> | ||
|
||
<meta charset="utf-8" /> | ||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<style type="text/css"> | ||
body { | ||
background-color: #f0f0f2; | ||
margin: 0; | ||
padding: 0; | ||
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; | ||
|
||
} | ||
div { | ||
width: 600px; | ||
margin: 5em auto; | ||
padding: 50px; | ||
background-color: #fff; | ||
border-radius: 1em; | ||
} | ||
a:link, a:visited { | ||
color: #38488f; | ||
text-decoration: none; | ||
} | ||
@media (max-width: 700px) { | ||
body { | ||
background-color: #fff; | ||
} | ||
div { | ||
width: auto; | ||
margin: 0 auto; | ||
border-radius: 0; | ||
padding: 1em; | ||
} | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div> | ||
<h1>Example Domain</h1> | ||
<p>This domain is established to be used for illustrative examples in documents. You may use this | ||
domain in examples without prior coordination or asking for permission.</p> | ||
<p><a href="http://www.iana.org/domains/example">More information...</a></p> | ||
</div> | ||
</body> | ||
</html> | ||
|
||
|
||
[+] Parsed Response: | ||
|
||
/domains/example |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it would be better to have a sentinel value like
None
or''
instead of a hardcoded arbitrary string.