Exemplo n.º 1
0
 def getGrid2D(self, idx):
     """ generated source for method getGrid2D """
     if idx < 0 or idx >= shape[0]:
         raise IllegalArgumentException("index out of range")
     itemSize = shape[1] * shape[2] * dataType.getSize()
     pos = idx * itemSize
     newBuffer = buffer_.slice_()
     newBuffer.position(pos)
     newBuffer.limit(pos + itemSize)
     newBuffer = newBuffer.slice_()
     return Grid2D(newBuffer, dataType,
                   Arrays.copyOfRange(origin, 1, origin.length),
                   Arrays.copyOfRange(shape, 1, shape.length))
Exemplo n.º 2
0
def replace_header_name(callbacks, rule, request):
    """
    Finds header name and replaces it with a new value, provided by the user.

    Args:
        callbacks: the burp callbacks object.
        rule: the rule that we should apply.
        request: a byte[] object that should be modified.

    Returns:
        tuple: the first element is a boolean that indicates whether the request was modified and the second one is the modified request or None if we didn't modify the request.
    """
    helpers = callbacks.helpers
    analyzedRequest = helpers.analyzeRequest(request)
    headers = analyzedRequest.headers

    modified = False
    newHeaders = ArrayList()
    for header in headers:
        splat = header.split(":")
        if len(splat) >= 2:
            name, value = splat[0], splat[1]
        else:
            newHeaders.add(header)
            continue  # First line of header doesn't have ":"

        if name.lower().strip() == rule.search.lower().strip():
            newHeaders.add("%s: %s" % (name, rule.replacement))
            modified = True
        else:
            newHeaders.add(header)

    if modified:
        body = Arrays.copyOfRange(request, analyzedRequest.bodyOffset,
                                  len(request))
        return modified, helpers.buildHttpMessage(newHeaders, body)
    else:
        return modified, None