def registerExtenderCallbacks(self, callbacks):
        # for error handling
        sys.stdout = callbacks.getStdout()
        sys.stderr = callbacks.getStderr()

        self._callbacks = callbacks
        self._helpers = callbacks.getHelpers()

        callbacks.setExtensionName(NAME)

        for frame in Frame.getFrames():
            self._find_repeater(frame)
        if not self._repeater:
            print("ERROR: Unable to locate Repeater")
            return

        callbacks.registerExtensionStateListener(self)
        callbacks.registerContextMenuFactory(self)
        self._repeater.addChangeListener(self.tabChanged)
        # preload tab colours for an extension reload
        for idx in range(self._repeater.getTabCount() - 1):
            tab = self._repeater.getTabComponentAt(idx)
            tabLabel = tab.getComponent(0)
            self._tabs[tab] = [
                tabLabel.getForeground(),
                tabLabel.getFont().getStyle()
            ]
    def registerExtenderCallbacks(self, callbacks):
        # for error handling
        sys.stdout = callbacks.getStdout()
        sys.stderr = callbacks.getStderr()

        self._callbacks = callbacks
        self._helpers = callbacks.getHelpers()

        callbacks.setExtensionName(NAME)

        for frame in Frame.getFrames():
            self._find_repeater(frame)
        if not self._repeater:
            print("ERROR: Unable to locate Repeater")
            return

        callbacks.registerExtensionStateListener(self)
        callbacks.registerContextMenuFactory(self)
        self._repeater.addChangeListener(self.tabChanged)
        # load saved tab colours
        self._colours = self.loadSettings()
        if self._colours:
            for idx, col in enumerate(self._colours):
                if idx > self._repeater.getTabCount() - 2:
                    # some tabs must be missing
                    print("Too many entries!!!")
                    break
                if col:  # un-highlighted tabs are empty arrays
                    self._highlight_tab(None,
                                        Color(col[0], col[1], col[2]),
                                        col[3],
                                        idx=idx)

        self._tabCount = self._repeater.getTabCount()
        self._thread = threading.Thread(target=self.scheduledSave)
        self._thread.daemon = True
        self._thread.start()
Exemplo n.º 3
0
    def __init__(self, burp_callbacks, typedef, callback):
        burp_window = None
        for frame in Frame.getFrames():
            if "Burp Suite" in frame.getName():
                burp_window = frame
                break
        JDialog.__init__(self, burp_window)
        self._burp_callbacks = burp_callbacks
        self._type_callback = callback
        self.setSize(1000, 700)

        self._original_typedef = typedef
        self._type_editor = burp_callbacks.createTextEditor()
        self._type_editor.setEditable(True)
        self._type_editor.setText(json.dumps(self._original_typedef, indent=4))

        splitPane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT)
        splitPane.setLeftComponent(self._type_editor.getComponent())
        splitPane.setRightComponent(self.createButtonPane())
        splitPane.setResizeWeight(0.8)

        self.add(splitPane)

        self.is_open = True
Exemplo n.º 4
0
 def __init__(self, title):
         Frame.__init__(self, title)
Exemplo n.º 5
0
def run(title):
    gd = GenericDialog("Record Window")
    gd.addMessage("Maximum number of frames to record.\nZero means infinite, interrupt with ESC key.")
    gd.addNumericField("Max. frames:", 50, 0)
    gd.addNumericField("Milisecond interval:", 300, 0)
    gd.addSlider("Start in (seconds):", 0, 20, 5)
    frames = []
    titles = []
    for f in Frame.getFrames():
        if f.isEnabled() and f.isVisible():
            frames.append(f)
            titles.append(f.getTitle())
    gd.addChoice("Window:", titles, titles[0])
    gd.addCheckbox("To file", False)
    gd.showDialog()
    if gd.wasCanceled():
        return
    n_frames = int(gd.getNextNumber())
    interval = gd.getNextNumber() / 1000.0  # in seconds
    frame = frames[gd.getNextChoiceIndex()]
    delay = int(gd.getNextNumber())
    tofile = gd.getNextBoolean()

    dir = None
    if tofile:
        dc = DirectoryChooser("Directory to store image frames")
        dir = dc.getDirectory()
        if dir is None:
            return  # dialog canceled

    snaps = []
    borders = None
    executors = Executors.newFixedThreadPool(1)
    try:
        while delay > 0:
            IJ.showStatus("Starting in " + str(delay) + "s.")
            time.sleep(1)  # one second
            delay -= 1

        IJ.showStatus("Capturing frame borders...")
        bounds = frame.getBounds()
        robot = Robot()
        frame.toFront()
        time.sleep(0.5)  # half a second
        borders = robot.createScreenCapture(bounds)

        IJ.showStatus("Recording " + frame.getTitle())

        # Set box to the inside borders of the frame
        insets = frame.getInsets()
        box = bounds.clone()
        box.x = insets.left
        box.y = insets.top
        box.width -= insets.left + insets.right
        box.height -= insets.top + insets.bottom

        start = System.currentTimeMillis() / 1000.0  # in seconds
        last = start
        intervals = []
        real_interval = 0
        i = 1
        fus = None
        if tofile:
            fus = []

            # 0 n_frames means continuous acquisition
        while 0 == n_frames or (len(snaps) < n_frames and last - start < n_frames * interval):
            now = System.currentTimeMillis() / 1000.0  # in seconds
            real_interval = now - last
            if real_interval >= interval:
                last = now
                img = snapshot(frame, box)
                if tofile:
                    fus.append(executors.submit(Saver(i, dir, bounds, borders, img, insets)))  # will flush img
                    i += 1
                else:
                    snaps.append(img)
                intervals.append(real_interval)
            else:
                time.sleep(interval / 5)
                # interrupt capturing:
            if IJ.escapePressed():
                IJ.showStatus("Recording user-interrupted")
                break

                # debug:
                # print "insets:", insets
                # print "bounds:", bounds
                # print "box:", box
                # print "snap dimensions:", snaps[0].getWidth(), snaps[0].getHeight()

                # Create stack
        stack = None
        if tofile:
            for fu in snaps:
                fu.get()  # wait on all
            stack = VirtualStack(bounds.width, bounds.height, None, dir)
            files = File(dir).list(TifFilter())
            Arrays.sort(files)
            for f in files:
                stack.addSlice(f)
        else:
            stack = ImageStack(bounds.width, bounds.height, None)
            t = 0
            for snap, real_interval in zip(snaps, intervals):
                bi = BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_RGB)
                g = bi.createGraphics()
                g.drawImage(borders, 0, 0, None)
                g.drawImage(snap, insets.left, insets.top, None)
                stack.addSlice(str(IJ.d2s(t, 3)), ImagePlus("", bi).getProcessor())
                t += real_interval
                snap.flush()
                bi.flush()

        borders.flush()

        ImagePlus(frame.getTitle() + " recording", stack).show()
        IJ.showStatus("Done recording " + frame.getTitle())
    except Exception, e:
        print "Some error ocurred:"
        print e.printStackTrace()
        IJ.showStatus("")
        if borders is not None:
            borders.flush()
        for snap in snaps:
            snap.flush()
Exemplo n.º 6
0
from java.awt import Panel, Dimension, Frame, Color
class a(Panel):
        pass

class b(a):
        def paint(self, g):
                w = self.getSize().width
                h = self.getSize().height
                g.setColor(Color.black)
                g.fillRect(0, 0, w, h)

test = b()

f = Frame()
f.add(test)
f.setSize(400,400)
f.setVisible(1)
 def shouldWait(self): # pragma: no cover - replayer disabled, cannot create automated tests
     return any((frame.isShowing() for frame in Frame.getFrames()))
Exemplo n.º 8
0
 def cleanup(self, interface):
     for frame in Frame.getFrames():
         if frame.isValid() and frame.isDisplayable():
             frame.setVisible(False) # don't leave the window up, looks weird
     self.replaceAutoRecordingForUsecase(interface, exitHook=True)
Exemplo n.º 9
0
from java.awt import Panel, Dimension, Frame, Color


class a(Panel):
    pass


class b(a):
    def paint(self, g):
        w = self.getSize().width
        h = self.getSize().height
        g.setColor(Color.black)
        g.fillRect(0, 0, w, h)


test = b()

f = Frame()
f.add(test)
f.setSize(400, 400)
f.setVisible(1)
Exemplo n.º 10
0
from java.awt import Frame
from net.imglib2.realtransform import AffineTransform3D

for frame in Frame.getFrames():
    if frame.getTitle() == "BigDataViewer":
        root = frame.getComponent(0)
        jlayeredpane = root.getComponents()[1]
        jpanel = jlayeredpane.getComponent(0)
        bdv_viewerpanel = jpanel.getComponent(0)
        #print bdv_viewerpanel
        # see: https://github.com/bigdataviewer/bigdataviewer-core/blob/master/src/main/java/bdv/viewer/ViewerPanel.java
        viewerstate = bdv_viewerpanel.getState(
        )  # a copy of the ViewerState instance that wraps the sources
        sources_and_converters = viewerstate.getSources(
        )  # a list of SourceState instances wrapping the sources
        for sc in sources_and_converters:
            source = sc.getSpimSource()
            print source  # bdv.tools.transformation.TransformedSource
            # Print the transform
            transform = AffineTransform3D()
            timepoint = 0
            mipmap_level = 0
            source.getSourceTransform(timepoint, mipmap_level, transform)
            print transform
            # Grab the RandomAccessible
            print source.getType().getClass()
            rai = source.getSource(timepoint, mipmap_level)
            print rai  # an imglib2 PlanarImg that wraps an ij.ImagePlus

# TODO:
# * demonstrate adding another source
Exemplo n.º 11
0
def run(title):
    gd = GenericDialog('Record Window')
    gd.addMessage(
        "Maximum number of frames to record.\nZero means infinite, interrupt with ESC key."
    )
    gd.addNumericField('Max. frames:', 50, 0)
    gd.addNumericField('Milisecond interval:', 300, 0)
    gd.addSlider('Start in (seconds):', 0, 20, 5)
    frames = []
    titles = []
    for f in Frame.getFrames():
        if f.isEnabled() and f.isVisible():
            frames.append(f)
            titles.append(f.getTitle())
    gd.addChoice('Window:', titles, titles[0])
    gd.addCheckbox("To file", False)
    gd.showDialog()
    if gd.wasCanceled():
        return
    n_frames = int(gd.getNextNumber())
    interval = gd.getNextNumber() / 1000.0  # in seconds
    frame = frames[gd.getNextChoiceIndex()]
    delay = int(gd.getNextNumber())
    tofile = gd.getNextBoolean()

    dir = None
    if tofile:
        dc = DirectoryChooser("Directory to store image frames")
        dir = dc.getDirectory()
        if dir is None:
            return  # dialog canceled

    snaps = []
    borders = None
    executors = Executors.newFixedThreadPool(1)
    try:
        while delay > 0:
            IJ.showStatus('Starting in ' + str(delay) + 's.')
            time.sleep(1)  # one second
            delay -= 1

        IJ.showStatus('Capturing frame borders...')
        bounds = frame.getBounds()
        robot = Robot()
        frame.toFront()
        time.sleep(0.5)  # half a second
        borders = robot.createScreenCapture(bounds)

        IJ.showStatus("Recording " + frame.getTitle())

        # Set box to the inside borders of the frame
        insets = frame.getInsets()
        box = bounds.clone()
        box.x = insets.left
        box.y = insets.top
        box.width -= insets.left + insets.right
        box.height -= insets.top + insets.bottom

        start = System.currentTimeMillis() / 1000.0  # in seconds
        last = start
        intervals = []
        real_interval = 0
        i = 1
        fus = None
        if tofile:
            fus = []

        # 0 n_frames means continuous acquisition
        while 0 == n_frames or (len(snaps) < n_frames
                                and last - start < n_frames * interval):
            now = System.currentTimeMillis() / 1000.0  # in seconds
            real_interval = now - last
            if real_interval >= interval:
                last = now
                img = snapshot(frame, box)
                if tofile:
                    fus.append(
                        executors.submit(
                            Saver(i, dir, bounds, borders, img,
                                  insets)))  # will flush img
                    i += 1
                else:
                    snaps.append(img)
                intervals.append(real_interval)
            else:
                time.sleep(interval / 5)
            # interrupt capturing:
            if IJ.escapePressed():
                IJ.showStatus("Recording user-interrupted")
                break

        # debug:
        #print "insets:", insets
        #print "bounds:", bounds
        #print "box:", box
        #print "snap dimensions:", snaps[0].getWidth(), snaps[0].getHeight()

        # Create stack
        stack = None
        if tofile:
            for fu in snaps:
                fu.get()  # wait on all
            stack = VirtualStack(bounds.width, bounds.height, None, dir)
            files = File(dir).list(TifFilter())
            Arrays.sort(files)
            for f in files:
                stack.addSlice(f)
        else:
            stack = ImageStack(bounds.width, bounds.height, None)
            t = 0
            for snap, real_interval in zip(snaps, intervals):
                bi = BufferedImage(bounds.width, bounds.height,
                                   BufferedImage.TYPE_INT_RGB)
                g = bi.createGraphics()
                g.drawImage(borders, 0, 0, None)
                g.drawImage(snap, insets.left, insets.top, None)
                stack.addSlice(str(IJ.d2s(t, 3)),
                               ImagePlus('', bi).getProcessor())
                t += real_interval
                snap.flush()
                bi.flush()

        borders.flush()

        ImagePlus(frame.getTitle() + " recording", stack).show()
        IJ.showStatus('Done recording ' + frame.getTitle())
    except Exception, e:
        print "Some error ocurred:"
        print e.printStackTrace()
        IJ.showStatus('')
        if borders is not None: borders.flush()
        for snap in snaps:
            snap.flush()
Exemplo n.º 12
0
from java.awt import Frame
from java.applet import Applet
from test185m import *


class test185a(Applet):
    def __init__(self):
        self.mydd = dd()
        self.add(self.mydd)


class foo:
    pass


class bar(foo):
    pass


if __name__ == "__main__":
    f = Frame()
    c = c()
    f.add(c)
    f.pack()
    f.show()
Exemplo n.º 13
0
    def run(self):
        if len(sys.argv) > 1:
            map_file = open(sys.argv[1], 'r')
        else:
            map_file = None
        frame = Frame()
        frame.setTitle('Babal')
        canvas = JGLBabalCanvas(320, 240, map_file)
        frame.add(canvas)
	frame.addWindowListener(CloseListener())
        frame.pack()
        frame.setVisible(1)
        canvas.start()
Exemplo n.º 14
0
# Define the TestButtonAction class. TestButtonAction
# inherits from the Java ActionListener interface.
#


class TestButtonAction(ActionListener):
    def actionPerformed(self, e):
        textArea.append("Test Button Clicked!\n")


#
# Create the Frame, Panel, Button,
# TextArea, and TestButtonAction objects.
#

frame = Frame("Hello World")
panel = Panel()
button = Button("Test Button")
buttonAction = TestButtonAction()
textArea = TextArea()


#
# Put everything together and show
# the window.
#

button.addActionListener(buttonAction)
panel.add(button)
panel.add(textArea)
frame.add(panel)
Exemplo n.º 15
0
 def _get_parent_frame():
     for frame in Frame.getFrames():
         if 'burp suite' in frame.getTitle().lower():
             return frame
Exemplo n.º 16
0
# Define the TestButtonAction class. TestButtonAction
# inherits from the Java ActionListener interface.
#


class TestButtonAction(ActionListener):
    def actionPerformed(self, e):
        textArea.append("Test Button Clicked!\n")


#
# Create the Frame, Panel, Button,
# TextArea, and TestButtonAction objects.
#

frame = Frame("Hello World")
panel = Panel()
button = Button("Test Button")
buttonAction = TestButtonAction()
textArea = TextArea()

#
# Put everything together and show
# the window.
#

button.addActionListener(buttonAction)
panel.add(button)
panel.add(textArea)
frame.add(panel)
frame.pack()
Exemplo n.º 17
0
 def __init__(self, title):
     Frame.__init__(self, title)
Exemplo n.º 18
0
    def registerExtenderCallbacks(self, callbacks):
        # for error handling
        sys.stdout = callbacks.getStdout()
        sys.stderr = callbacks.getStderr()

        self._callbacks = callbacks
        self._helpers = callbacks.getHelpers()

        callbacks.setExtensionName(NAME)
        callbacks.registerExtensionStateListener(self)
        callbacks.registerHttpListener(self)

        self._field
        self._parameter = self._field + ''.join(
            random.choice(string.ascii_lowercase) for c in range(8))
        print("Using random querystring parameter {}".format(self._parameter))

        burp_frame = None
        for frame in Frame.getFrames():
            if frame.isVisible() and frame.getTitle().startswith("Burp Suite"):
                burp_frame = frame

        self._menu = swing.JMenu("Reflect/Detect")
        self._enabled_menu = swing.JCheckBoxMenuItem("Enabled", False)
        self._menu.add(self._enabled_menu)

        s_iso = self._callbacks.loadExtensionSetting(SETTING_IN_SCOPE_ONLY)
        iso = True if s_iso is None else s_iso.lower(
        ) == 'true'  # why doesn't bool() work?

        s_tools = self._callbacks.loadExtensionSetting(SETTING_TOOLS)
        self._tools = {}
        if s_tools:
            self._tools = json.loads(s_tools.decode())

        self._scope_menu = swing.JCheckBoxMenuItem("In scope only", iso)
        self._menu.add(self._scope_menu)
        self._tool_menu = swing.JMenu("Apply to ...")

        self._proxy_menu = swing.JCheckBoxMenuItem(
            "Proxy", self._tools.get("PROXY", True))
        self._tool_menu.add(self._proxy_menu)

        self._repeater_menu = swing.JCheckBoxMenuItem(
            "Repeater", self._tools.get("REPEATER", False))
        self._tool_menu.add(self._repeater_menu)

        self._scanner_menu = swing.JCheckBoxMenuItem(
            "Scanner", self._tools.get("SCANNER", False))
        self._tool_menu.add(self._scanner_menu)

        self._spider_menu = swing.JCheckBoxMenuItem(
            "Spider", self._tools.get("SPIDER", False))
        self._tool_menu.add(self._spider_menu)

        self._intruder_menu = swing.JCheckBoxMenuItem(
            "Intruder", self._tools.get("INTRUDER", False))
        self._tool_menu.add(self._intruder_menu)

        self._sequencer_menu = swing.JCheckBoxMenuItem(
            "Sequencer", self._tools.get("SEQUENCER", False))
        self._tool_menu.add(self._sequencer_menu)

        self._menu.add(self._tool_menu)
        bar = burp_frame.getJMenuBar()
        bar.add(self._menu, bar.getMenuCount())
        bar.repaint()
Exemplo n.º 19
0
from java.awt import Frame
from java.applet import Applet
from test185m import *

class test185a(Applet):
        def __init__(self):
                self.mydd = dd()
                self.add(self.mydd)


class foo:
	pass

class bar(foo):
	pass

if __name__ == "__main__":
        f = Frame(); c = c()
        f.add(c); f.pack(); f.show()

Exemplo n.º 20
0
 def cleanup(self, interface):
     for frame in Frame.getFrames():
         frame.setVisible(False) # don't leave the window up, looks weird
     self.replaceAutoRecordingForUsecase(interface)