Skip to content
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

Add skip_wildcard flag to skip wild card origin test #43

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ Using Corsy is pretty simple
##### Skip printing tips
`-q` can be used to skip printing of `description`, `severity`, `exploitation` fields in the output.

##### Skip wildcard test
Since wild card origin can't be used to exploitation `--skip-wildcard` can be used to skip printing of wildcard origin output.

### Tests implemented
- Pre-domain bypass
- Post-domain bypass
Expand Down
8 changes: 4 additions & 4 deletions core/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

details = load_json(sys.path[0] + '/db/details.json')

def passive_tests(url, headers):
def passive_tests(url, headers, skip_wildcard = False):
root = host(url)
acao_header, acac_header = headers.get('access-control-allow-origin', None), headers.get('access-control-allow-credentials', None)
if acao_header == '*':
if acao_header == '*' and not skip_wildcard:
info = details['wildcard value']
info['acao header'] = acao_header
info['acac header'] = acac_header
Expand All @@ -22,7 +22,7 @@ def passive_tests(url, headers):
return {url : info}


def active_tests(url, root, scheme, header_dict, delay):
def active_tests(url, root, scheme, header_dict, delay, skip_wildcard = False):
origin = scheme + '://' + root
headers = requester(url, scheme, header_dict, origin)
acao_header, acac_header = headers.get('access-control-allow-origin', None), headers.get('access-control-allow-credentials', None)
Expand Down Expand Up @@ -108,4 +108,4 @@ def active_tests(url, root, scheme, header_dict, delay):
info['acac header'] = acac_header
return {url : info}
else:
return passive_tests(url, headers)
return passive_tests(url, headers, skip_wildcard)
8 changes: 5 additions & 3 deletions corsy.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
parser.add_argument('-d', help='request delay', dest='delay', type=float, default=0)
parser.add_argument('-q', help='don\'t print help tips', dest='quiet', action='store_true')
parser.add_argument('--headers', help='add headers', dest='header_dict', nargs='?', const=True)
parser.add_argument('--skip-wildcard', help='skip wildcard origin check', dest='skip_wildcard', action='store_true')
args = parser.parse_args()

delay = args.delay
Expand All @@ -40,6 +41,7 @@
inp_file = args.inp_file
json_file = args.json_file
header_dict = args.header_dict
skip_wildcard = args.skip_wildcard

if type(header_dict) == bool:
header_dict = extractHeaders(prompt())
Expand All @@ -63,15 +65,15 @@
urls = create_stdin_list(target, sys.stdin)


def cors(target, header_dict, delay):
def cors(target, header_dict, delay, skip_wildcard = False):
url = target
root = host(url)
parsed = urlparse(url)
netloc = parsed.netloc
scheme = parsed.scheme
url = scheme + '://' + netloc + parsed.path
try:
return active_tests(url, root, scheme, header_dict, delay)
return active_tests(url, root, scheme, header_dict, delay, skip_wildcard)
except ConnectionError as exc:
print('%s Unable to connect to %s' % (bad, root))

Expand All @@ -80,7 +82,7 @@ def cors(target, header_dict, delay):
print(' %s Estimated scan time: %i secs' % (run, round(len(urls) * 1.75)))
results = []
threadpool = concurrent.futures.ThreadPoolExecutor(max_workers=threads)
futures = (threadpool.submit(cors, url, header_dict, delay) for url in urls)
futures = (threadpool.submit(cors, url, header_dict, delay, skip_wildcard) for url in urls)
for each in concurrent.futures.as_completed(futures):
result = each.result()
results.append(result)
Expand Down