-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add wpscan recommendations * add wpscan facts --------- Signed-off-by: Patrick Double <pat@patdouble.com>
- Loading branch information
Showing
35 changed files
with
1,215 additions
and
78 deletions.
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
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
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
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
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
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
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
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,81 @@ | ||
import json | ||
import urllib.parse | ||
|
||
from experta import Fact | ||
|
||
from shadycompass.config import ToolCategory | ||
from shadycompass.facts import FactReader, check_file_signature, fact_reader_registry, ScanPresent, Product, \ | ||
guess_target, HttpService, \ | ||
Username | ||
|
||
|
||
class WpscanReader(FactReader): | ||
def read_facts(self, file_path: str) -> list[Fact]: | ||
if not check_file_signature(file_path, '"description": "WordPress Security Scanner'): | ||
return [] | ||
result = [] | ||
try: | ||
with open(file_path, 'rt') as f: | ||
data = json.load(f) | ||
except ValueError: | ||
return result | ||
if not isinstance(data, dict): | ||
return result | ||
print(f"[*] Reading wpscan findings from {file_path}") | ||
|
||
scan_present_kwargs = {} | ||
|
||
target_url = data.get('target_url') | ||
if not target_url: | ||
return result | ||
target_parsed = urllib.parse.urlparse(target_url) | ||
target_fact = guess_target(target_parsed.hostname) | ||
scan_present_kwargs['url'] = target_url | ||
if 'hostname' in target_fact: | ||
scan_present_kwargs['hostname'] = target_fact.get('hostname') | ||
if 'addr' in target_fact: | ||
scan_present_kwargs['addr'] = target_fact.get('addr') | ||
if target_parsed.port: | ||
scan_present_kwargs['port'] = target_parsed.port | ||
else: | ||
scan_present_kwargs['port'] = 80 | ||
if target_parsed.scheme.endswith('s'): | ||
secure = True | ||
else: | ||
secure = False | ||
|
||
target_ip = data.get('target_ip') | ||
if target_ip: | ||
scan_present_kwargs['addr'] = target_ip | ||
result.append(guess_target(target_ip)) | ||
|
||
result.append(ScanPresent(category=ToolCategory.wordpress_scanner, name='wpscan', **scan_present_kwargs)) | ||
|
||
if 'addr' in scan_present_kwargs and 'port' in scan_present_kwargs: | ||
result.append( | ||
HttpService(addr=scan_present_kwargs['addr'], port=scan_present_kwargs['port'], secure=secure)) | ||
|
||
product_kwargs = { | ||
'product': 'wordpress', | ||
'addr': scan_present_kwargs['addr'], | ||
'port': scan_present_kwargs['port'], | ||
'secure': secure, | ||
} | ||
if data.get('version', {}).get('number', ''): | ||
product_kwargs['version'] = data.get('version', {}).get('number', '') | ||
if 'hostname' in scan_present_kwargs: | ||
product_kwargs['hostname'] = scan_present_kwargs['hostname'] | ||
result.append(Product(**product_kwargs)) | ||
|
||
user_kwargs = { | ||
'addr': scan_present_kwargs['addr'], | ||
} | ||
if 'hostname' in scan_present_kwargs: | ||
user_kwargs['hostname'] = scan_present_kwargs['hostname'] | ||
for user in data.get('users', {}).keys(): | ||
result.append(Username(username=user, **user_kwargs)) | ||
|
||
return result | ||
|
||
|
||
fact_reader_registry.append(WpscanReader()) |
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
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,43 @@ | ||
from abc import ABC | ||
|
||
from experta import Rule, OR, AS, MATCH, NOT | ||
|
||
from shadycompass.facts import HttpService, HttpUrl, HttpBustingNeeded, TargetIPv4Address, TargetIPv6Address, \ | ||
HostnameIPv4Resolution, HostnameIPv6Resolution, VirtualHostname | ||
from shadycompass.rules.irules import IRules | ||
|
||
""" | ||
Rules to decide if we need to bust HTTP servers. | ||
""" | ||
|
||
|
||
class HttpBusting(IRules, ABC): | ||
@Rule( | ||
HttpService(addr=MATCH.addr, port=MATCH.port, secure=MATCH.secure), | ||
OR(TargetIPv4Address(addr=MATCH.addr), TargetIPv6Address(addr=MATCH.addr)), | ||
OR(HostnameIPv4Resolution(hostname=MATCH.hostname, addr=MATCH.addr), | ||
HostnameIPv6Resolution(hostname=MATCH.hostname, addr=MATCH.addr)), | ||
NOT(VirtualHostname(hostname=MATCH.hostname, port=MATCH.port)), | ||
) | ||
def virtualhostname_from_httpservice(self, port, hostname, secure): | ||
self.declare(VirtualHostname(hostname=hostname, port=port, secure=secure)) | ||
|
||
@Rule( | ||
AS.f1 << HttpService(addr=MATCH.addr, port=MATCH.port), | ||
VirtualHostname(hostname=MATCH.hostname, domain=MATCH.domain, port=MATCH.port), | ||
OR(TargetIPv4Address(addr=MATCH.addr), TargetIPv6Address(addr=MATCH.addr)), | ||
OR( | ||
HostnameIPv4Resolution(addr=MATCH.addr, hostname=MATCH.hostname | MATCH.domain), | ||
HostnameIPv6Resolution(addr=MATCH.addr, hostname=MATCH.hostname | MATCH.domain), | ||
), | ||
NOT(HttpUrl(port=MATCH.port, vhost=MATCH.hostname)), | ||
) | ||
def need_http_busting(self, f1: HttpService, addr, port, hostname): | ||
self.declare(HttpBustingNeeded(secure=f1.is_secure(), addr=addr, port=port, vhost=hostname)) | ||
|
||
@Rule( | ||
AS.f1 << HttpBustingNeeded(secure=MATCH.secure, addr=MATCH.addr, port=MATCH.port, vhost=MATCH.hostname), | ||
HttpUrl(secure=MATCH.secure, port=MATCH.port, vhost=MATCH.hostname), | ||
) | ||
def do_not_need_http_busting(self, f1: HttpBustingNeeded): | ||
self.retract(f1) |
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.