Exemplo n.º 1
0
    def encrypto(self, payload, key, iv):
		aesKey = SecretKeySpec(base64.b64decode(key), "AES")
		aesIV = IvParameterSpec(base64.b64decode(iv))
		cipher = Cipher.getInstance("AES/CBC/PKCS7Padding")
		cipher.init(Cipher.ENCRYPT_MODE, aesKey, aesIV)
		encrypted = cipher.doFinal(payload)
		return Base64.getEncoder().encode(encrypted)
Exemplo n.º 2
0
def showImgWithLegend(width=None,height=None):
    """ This function shows the image and legend from current IDV window while in GUI mode. Optional arguments are width and height in pixels, they currently default to 600 and 400"""
    from java.util import Base64 ##only in java8
    from javax.imageio import ImageIO
    from java.io import ByteArrayOutputStream
    from ucar.unidata.ui.ImageUtils import resize,toBufferedImage
    import java
    import java.awt.Robot as Robot
    import java.awt.Rectangle as Rectangle
    import java.awt.Toolkit as Toolkit
    from ucar.unidata.util import Misc
    VM=idv.getViewManager()
    VMC=VM.getContents()
    VMCC=VMC.getComponent(1) # the view and legend ; 0 is left most part of view window with controls for perspective views
    siz=VMCC.getSize()
    loc= VMCC.getLocationOnScreen()
    gc= VMCC.getGraphicsConfiguration()
    loc.x -= gc.getBounds().x
    loc.y -= gc.getBounds().y
    robotx=Robot(gc.getDevice())
    VM.toFront()
    Misc.sleep(250)
    img = robotx.createScreenCapture(Rectangle(loc.x, loc.y,siz.width, siz.height))
    if width != None and height != None:
        img=toBufferedImage(resize(img,width,height));
    bos=ByteArrayOutputStream();
    ImageIO.write(img, "png", Base64.getEncoder().wrap(bos));
    data = bos.toString("UTF-8");
    return {"display":"image","data":data}
Exemplo n.º 3
0
def showImgWithFullWindow(width=None,height=None):
    """ This function shows the image from current IDV window while in GUI mode. optional arguments are width and height in pixels, they
    currently default to 600 and 400"""
    from java.util import Base64 ##only in java8
    from javax.imageio import ImageIO
    from java.io import ByteArrayOutputStream
    from ucar.unidata.ui.ImageUtils import resize,toBufferedImage
    import java
    import java.awt.Robot as Robot
    import java.awt.Rectangle as Rectangle
    import java.awt.Toolkit as Toolkit
    from ucar.unidata.util import Misc
    VM=idv.getViewManager()
    myframe=VM.getDisplayWindow().getComponent()
    robotx = Robot(myframe.getGraphicsConfiguration().getDevice())
    VM.toFront();
    #robotx.delay(250)
    Misc.sleep(350)
    pause()
    img=robotx.createScreenCapture(Rectangle( myframe.getX(),myframe.getY(),myframe.getWidth(),myframe.getHeight()))
    if width != None and height != None:
        img=toBufferedImage(resize(img,width,height));
    bos=ByteArrayOutputStream();
    ImageIO.write(img, "png", Base64.getEncoder().wrap(bos));
    data = bos.toString("UTF-8");
    return {"display":"image","data":data}
Exemplo n.º 4
0
def decryptJython(payload, key, iv):
    decoded = Base64.getDecoder().decode(payload)
    aesKey = SecretKeySpec(key, "AES")
    aesIV = IvParameterSpec(iv)
    cipher = Cipher.getInstance("AES/CFB/NOPADDING")
    cipher.init(Cipher.DECRYPT_MODE, aesKey, aesIV)
    return cipher.doFinal(decoded)
Exemplo n.º 5
0
def showImgWithFullWindow(width=None, height=None):
    """ This function shows the image from current IDV window while in GUI mode. optional arguments are width and height in pixels, they
    currently default to 600 and 400"""
    from java.util import Base64  ##only in java8
    from javax.imageio import ImageIO
    from java.io import ByteArrayOutputStream
    from ucar.unidata.ui.ImageUtils import resize, toBufferedImage
    import java
    import java.awt.Robot as Robot
    import java.awt.Rectangle as Rectangle
    import java.awt.Toolkit as Toolkit
    from ucar.unidata.util import Misc
    VM = idv.getViewManager()
    myframe = VM.getDisplayWindow().getComponent()
    robotx = Robot(myframe.getGraphicsConfiguration().getDevice())
    VM.toFront()
    #robotx.delay(250)
    Misc.sleep(350)
    pause()
    img = robotx.createScreenCapture(
        Rectangle(myframe.getX(), myframe.getY(), myframe.getWidth(),
                  myframe.getHeight()))
    if width != None and height != None:
        img = toBufferedImage(resize(img, width, height))
    bos = ByteArrayOutputStream()
    ImageIO.write(img, "png",
                  Base64.getEncoder().wrap(bos))
    data = bos.toString("UTF-8")
    return {"display": "image", "data": data}
Exemplo n.º 6
0
def encryptJython(payload, key, iv):
    aesKey = SecretKeySpec(key, "AES")
    aesIV = IvParameterSpec(iv)
    cipher = Cipher.getInstance("AES/CFB/NOPADDING")
    cipher.init(Cipher.ENCRYPT_MODE, aesKey, aesIV)
    encrypted = cipher.doFinal(payload)
    return Base64.getEncoder().encode(encrypted)
Exemplo n.º 7
0
def showImgWithLegend(width=None, height=None):
    """ This function shows the image and legend from current IDV window while in GUI mode. Optional arguments are width and height in pixels, they currently default to 600 and 400"""
    from java.util import Base64  ##only in java8
    from javax.imageio import ImageIO
    from java.io import ByteArrayOutputStream
    from ucar.unidata.ui.ImageUtils import resize, toBufferedImage
    import java
    import java.awt.Robot as Robot
    import java.awt.Rectangle as Rectangle
    import java.awt.Toolkit as Toolkit
    from ucar.unidata.util import Misc
    VM = idv.getViewManager()
    VMC = VM.getContents()
    VMCC = VMC.getComponent(
        1
    )  # the view and legend ; 0 is left most part of view window with controls for perspective views
    siz = VMCC.getSize()
    loc = VMCC.getLocationOnScreen()
    gc = VMCC.getGraphicsConfiguration()
    loc.x -= gc.getBounds().x
    loc.y -= gc.getBounds().y
    robotx = Robot(gc.getDevice())
    VM.toFront()
    Misc.sleep(250)
    img = robotx.createScreenCapture(
        Rectangle(loc.x, loc.y, siz.width, siz.height))
    if width != None and height != None:
        img = toBufferedImage(resize(img, width, height))
    bos = ByteArrayOutputStream()
    ImageIO.write(img, "png",
                  Base64.getEncoder().wrap(bos))
    data = bos.toString("UTF-8")
    return {"display": "image", "data": data}
Exemplo n.º 8
0
def BufferedImgToNotebook(img):
    from java.io import ByteArrayOutputStream
    from java.util import Base64 ##only in java8
    from javax.imageio import ImageIO
    bos=ByteArrayOutputStream();
    ImageIO.write(img, "png", Base64.getEncoder().wrap(bos));
    data = bos.toString("UTF-8");
    return {"display":"image","data":data}
Exemplo n.º 9
0
def BufferedImgToNotebook(img):
    from java.io import ByteArrayOutputStream
    from java.util import Base64  ##only in java8
    from javax.imageio import ImageIO
    bos = ByteArrayOutputStream()
    ImageIO.write(img, "png",
                  Base64.getEncoder().wrap(bos))
    data = bos.toString("UTF-8")
    return {"display": "image", "data": data}
Exemplo n.º 10
0
def encrypt(payload, key):
    salt = bytearray([1,2,3,4,5,6,7,8])
    k2, iv2 = derive_key_and_iv(key, salt, 32, 16)
    aesKey = SecretKeySpec(k2, "AES")
    aesIV = IvParameterSpec(iv2)
    # print key, binascii.hexlify(salt), binascii.hexlify(k2), binascii.hexlify(iv2), payload, "TESTING - ENCRYPT"

    cipher = Cipher.getInstance("AES/CBC/PKCS7Padding")
    cipher.init(Cipher.ENCRYPT_MODE, aesKey, aesIV)
    encrypted = cipher.doFinal(payload)
    out = Base64.getEncoder().encode(b'Salted__' + salt + encrypted)
    # print("DEBUG enc:", out.tostring(), binascii.hexlify(salt), binascii.hexlify(k2), binascii.hexlify(iv2), key)
    return out
Exemplo n.º 11
0
def showImg(width=400,height=300):
    """ This function shows the image from current IDV frame, optional arguments are width and height in pixels, they
    currently default to 400 and 300"""
    from java.util import Base64 ##only in java8
    from javax.imageio import ImageIO
    from java.io import ByteArrayOutputStream
    from ucar.unidata.ui.ImageUtils import resize,toBufferedImage
    pause()
    img=getImage() 
    img=toBufferedImage(resize(img,width,height));
    bos=ByteArrayOutputStream();
    ImageIO.write(img, "png", Base64.getEncoder().wrap(bos));
    data = bos.toString("UTF-8");
    return {"display":"image","data":data}
def decode_archive():
    try:
        print 'decoding archive...'
        encoded_archive_bytes = FileUtils.readFileToByteArray(
            File(node_archive_path))
        decoded_archive_bytes = Base64.getMimeDecoder().decode(
            encoded_archive_bytes)
        FileUtils.writeByteArrayToFile(File(archive_name),
                                       decoded_archive_bytes)
        print 'successfully decoded archive'
    except:
        print 'Decoding application archive failed'
        print dumpStack()
        apply(traceback.print_exception, sys.exc_info())
        exit(exitcode=1)
Exemplo n.º 13
0
def showImg(width=None,height=None):
    """ This function shows the image from current IDV frame, optional arguments are width and height in pixels, they
    currently default to 400 and 300"""
    from java.util import Base64 ##only in java8
    from javax.imageio import ImageIO
    from java.io import ByteArrayOutputStream
    from ucar.unidata.ui.ImageUtils import resize,toBufferedImage
    pause()
    #imgx=getImage() currently not working with new changes to idv
    img=idv.getViewManager().getMaster().getImage(True)
    if width != None and height != None:
        img=toBufferedImage(resize(img,width,height));
    bos=ByteArrayOutputStream();
    ImageIO.write(img, "png", Base64.getEncoder().wrap(bos));
    data = bos.toString("UTF-8");
    return {"display":"image","data":data}
Exemplo n.º 14
0
def showImg(width=None, height=None):
    """ This function shows the image from current IDV frame, optional arguments are width and height in pixels, they
    currently default to 400 and 300"""
    from java.util import Base64  ##only in java8
    from javax.imageio import ImageIO
    from java.io import ByteArrayOutputStream
    from ucar.unidata.ui.ImageUtils import resize, toBufferedImage
    pause()
    #imgx=getImage() currently not working with new changes to idv
    img = idv.getViewManager().getMaster().getImage(True)
    if width != None and height != None:
        img = toBufferedImage(resize(img, width, height))
    bos = ByteArrayOutputStream()
    ImageIO.write(img, "png",
                  Base64.getEncoder().wrap(bos))
    data = bos.toString("UTF-8")
    return {"display": "image", "data": data}
Exemplo n.º 15
0
def decrypt(payload, key):
    decoded = Base64.getDecoder().decode(payload)
    # print("Lol - decoded: ", decoded)

    if decoded.tostring()[:8] != "Salted__":
        print decoded.tostring()[:8]
        return False
    decoded = decoded[8:]
    
    salt = decoded[:8]
    k2, iv2 = derive_key_and_iv(key, salt, 32, 16)
    # print key, binascii.hexlify(salt), binascii.hexlify(k2), binascii.hexlify(iv2), payload, "TESTING - DECRYPT"
    aesKey = SecretKeySpec(k2, "AES")
    aesIV = IvParameterSpec(iv2)

    cipher = Cipher.getInstance("AES/CBC/PKCS7Padding")
    cipher.init(Cipher.DECRYPT_MODE, aesKey, aesIV)
    return cipher.doFinal(decoded[8:])
Exemplo n.º 16
0
    def parseXML(self, file):

        # Initialize XML stuff
        dbFactory = DocumentBuilderFactory.newInstance()
        dBuilder = dbFactory.newDocumentBuilder()
        doc = dBuilder.parse(file)
        doc.getDocumentElement().normalize()

        # All entries in Burp's XML Export File have tag <item>...</item>
        nodeList = doc.getElementsByTagName("item")

        # for i in reversed(range(0, nodeList.getLength())):
        for i in range(0, nodeList.getLength()):
            node = nodeList.item(i)

            if node.getNodeType() == Node.ELEMENT_NODE:

                request = node.getElementsByTagName("request").item(
                    0).getTextContent()
                response = node.getElementsByTagName("response").item(
                    0).getTextContent()

                request_isBase64 = node.getElementsByTagName("request").item(
                    0).getAttribute("base64")
                response_isBase64 = node.getElementsByTagName("response").item(
                    0).getAttribute("base64")

                if request_isBase64 == "true":
                    request = Base64.getDecoder().decode(request)

                if response_isBase64 == "true":
                    response = Base64.getDecoder().decode(response)

                info = {
                    "time":
                    node.getElementsByTagName("time").item(0).getTextContent(),
                    "url":
                    node.getElementsByTagName("url").item(0).getTextContent(),
                    "host":
                    node.getElementsByTagName("host").item(0).getTextContent(),
                    "port":
                    node.getElementsByTagName("port").item(0).getTextContent(),
                    "protocol":
                    node.getElementsByTagName("protocol").item(
                        0).getTextContent(),
                    "method":
                    node.getElementsByTagName("method").item(
                        0).getTextContent(),
                    "path":
                    node.getElementsByTagName("path").item(0).getTextContent(),
                    "extension":
                    node.getElementsByTagName("extension").item(
                        0).getTextContent(),
                    "request":
                    request,
                    "status":
                    node.getElementsByTagName("status").item(
                        0).getTextContent(),
                    "responselength":
                    node.getElementsByTagName("responselength").item(
                        0).getTextContent(),
                    "mimetype":
                    node.getElementsByTagName("mimetype").item(
                        0).getTextContent(),
                    "response":
                    response,
                    "comment":
                    node.getElementsByTagName("comment").item(
                        0).getTextContent(),
                    "highlight":
                    ""
                }

                logEntry = LogEntry(info)

                # Remove GET parameters from path component
                # Path component usually looks like this: /some/path/index.html?q=foo&z=faa
                info["path"] = info["path"].split("?")[0]

                # Extract GET parameters
                params = []
                for param in self._helpers.analyzeRequest(
                        logEntry).getParameters():
                    if param.getType() == IParameter.PARAM_URL:
                        params.append("{}={}".format(param.getName(),
                                                     param.getValue()))
                info["params"] = "&".join(params)

                self.addLogEntryToList(logEntry)