File handler.py
has 637 lines of code (exceeds 250 allowed). Consider refactoring.
"""Phpsploit HTTP request handler"""
__all__ = ["Request", "new_request", "get_raw_requests"]
import sys
import re
Function build_multipart_request
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
def build_multipart_request(self, method, php_payload):
"""build a multipart request for `php_payload` with HTTP `method`
For infos about return format, read build_request() docstring.
"""
Function Build
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
def Build(self, php_payload):
"""Main request Builder:
if takes the basic php payload as argument,
and returns the apropriate request object.
Cyclomatic complexity is too high in method Build. (19)
def Build(self, php_payload):
"""Main request Builder:
if takes the basic php payload as argument,
and returns the apropriate request object.
Function Send
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
def Send(self, request):
"""Main request Sender:
if takes the concerned request object as argument
and returns the unparsed and decapsulated phpsploit response
Cyclomatic complexity is too high in method build_multipart_request. (15)
def build_multipart_request(self, method, php_payload):
"""build a multipart request for `php_payload` with HTTP `method`
For infos about return format, read build_request() docstring.
"""
Cyclomatic complexity is too high in method Read. (12)
def Read(self, response):
"""Main request Reader
if takes the http response data as argument
and writes the __RESULT__'s php data into the self.response string,
Cyclomatic complexity is too high in method Send. (11)
def Send(self, request):
"""Main request Sender:
if takes the concerned request object as argument
and returns the unparsed and decapsulated phpsploit response
Request
has 22 functions (exceeds 20 allowed). Consider refactoring.
class Request:
"""Phpsploit HTTP Request Handler
"""
methods = ['GET', 'POST']
Cyclomatic complexity is too high in method send_single_request. (9)
def send_single_request(self, request):
"""send a single request object element (a request object's single
tuple, in the form mentionned in the build_request() docstring.
A response dict() will be returned, with 'error' and 'data' keys.
Cyclomatic complexity is too high in method build_forwarder. (9)
def build_forwarder(self, method, decoder):
"""build the effective payload forwarder, which is in fact
a header using the PASSKEY setting as name.
The payload forwarder is called by the remote backdoor, and then
formats the final payload if necessary before executing it.
Cyclomatic complexity is too high in method get_php_errors. (7)
@staticmethod
def get_php_errors(data):
"""function designed to parse php errors from phpsploit response
for better output and plugin debugging purposes.
Its is called by the Read() function and returns the $error string
Function open
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
def open(self, php_payload):
"""open a request to the server with the given php payload
It respectively calls the Build(), Send() and Read() methods.
if one of these methods returns a string, it will be considered as
an error, so execution will stop, and self.error will be filled.
Cyclomatic complexity is too high in method open. (6)
def open(self, php_payload):
"""open a request to the server with the given php payload
It respectively calls the Build(), Send() and Read() methods.
if one of these methods returns a string, it will be considered as
an error, so execution will stop, and self.error will be filled.
Cyclomatic complexity is too high in method load_multipart. (6)
def load_multipart(self):
"""enable the multi-request payload capability.
- ask user to determine a remote writeable directory if
tunnel opener couldn't file one automatically.
- choose appropriate multipart_file, which is a remote temporary file
Function Read
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
def Read(self, response):
"""Main request Reader
if takes the http response data as argument
and writes the __RESULT__'s php data into the self.response string,
Function send_single_request
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
def send_single_request(self, request):
"""send a single request object element (a request object's single
tuple, in the form mentionned in the build_request() docstring.
A response dict() will be returned, with 'error' and 'data' keys.
Function __init__
has 28 lines of code (exceeds 25 allowed). Consider refactoring.
def __init__(self):
self.target_obj = session.Conf.TARGET(call=False)
self.hostname = self.target_obj.host
self.port = self.target_obj.port
Function load_multipart
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def load_multipart(self):
"""enable the multi-request payload capability.
- ask user to determine a remote writeable directory if
tunnel opener couldn't file one automatically.
- choose appropriate multipart_file, which is a remote temporary file
Function get_php_errors
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def get_php_errors(data):
"""function designed to parse php errors from phpsploit response
for better output and plugin debugging purposes.
Its is called by the Read() function and returns the $error string
Function build_forwarder
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def build_forwarder(self, method, decoder):
"""build the effective payload forwarder, which is in fact
a header using the PASSKEY setting as name.
The payload forwarder is called by the remote backdoor, and then
formats the final payload if necessary before executing it.
Avoid too many return
statements within this function.
return response
Refactor this function to reduce its Cognitive Complexity from 34 to the 15 allowed.
def build_multipart_request(self, method, php_payload):
Refactor this function to reduce its Cognitive Complexity from 24 to the 15 allowed.
def Send(self, request):
Refactor this function to reduce its Cognitive Complexity from 29 to the 15 allowed.
def Build(self, php_payload):
Remove this commented out code.
Remove this commented out code.
Rename method "Read" to prevent any misunderstanding/clash with method "read" defined on line 582
def Read(self, response):
Remove the code after this "return".
return None
Either merge this branch with the identical one on line "40" or change one of the implementations.
_RAW_REQUESTS_LIST.append(data)
Similar blocks of code found in 2 locations. Consider refactoring.
elif "'%s'" not in hdr_payload and \
'"%s"' not in hdr_payload:
len_third = float(len(forwarder) / 3)
len_third = int(round(len_third + 0.5))
sample_sep = colorize("%Reset", "\n[*] ", "%Cyan")
Similar blocks of code found in 2 locations. Consider refactoring.
if "'%s'" not in hdr_payload and \
'"%s"' not in hdr_payload and \
not b64_forwarder.isalnum():
len_third = float(len(forwarder) / 3)
Expected 2 blank lines, found 1
class _CustomHTTPHandler(urllib.request.HTTPHandler):
Do not use bare 'except'
except:
Line too long (80 > 79 characters)
Expected 2 blank lines after class or function definition, found 0
http.client.__HTTPConnection__ = http.client.HTTPConnection
Line too long (80 > 79 characters)
line = re.sub(r' \[<a.*?a>\]', '', line)
Too many leading '#' for block comment
Do not use bare 'except'
except:
Expected 2 blank lines, found 1
class _CustomHTTPConnection(http.client.HTTPConnection):
Do not use bare 'except'
except:
Expected 2 blank lines after class or function definition, found 0
urllib.request.__HTTPHandler__ = urllib.request.HTTPHandler
Do not use bare 'except'
except:
Rename function "updateStatus" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
def updateStatus(curReqNum):
There are no issues that match your filters.