List of usage examples for org.eclipse.jface.viewers TreeViewer TreeViewer
public TreeViewer(Composite parent, int style)
From source file:com.ebmwebsourcing.petals.common.internal.wizards.JbiXmlNewWizardPage.java
License:Open Source License
@Override public void createControl(Composite parent) { // Create the composite container and define its layout final Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginLeft = layout.marginRight = 15; layout.marginTop = 15;/*from www .j a v a2 s . c o m*/ container.setLayout(layout); container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Container viewer new Label(container, SWT.NONE).setText(Messages.NewJbiXmlWizardPage_2); final Text folderPathText = new Text(container, SWT.SINGLE | SWT.BORDER); folderPathText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); TreeViewer viewer = new TreeViewer(container, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.HIDE_SELECTION); GridData layoutData = new GridData(GridData.FILL_BOTH); layoutData.heightHint = 100; viewer.getTree().setLayoutData(layoutData); viewer.setLabelProvider(new WorkbenchLabelProvider()); viewer.setContentProvider(new WorkbenchContentProvider() { /* * (non-Javadoc) * @see org.eclipse.ui.model.BaseWorkbenchContentProvider * #getChildren(java.lang.Object) */ @Override public Object[] getChildren(Object o) { if (o instanceof IProject && !((IProject) o).isOpen()) return new Object[0]; List<IResource> children = new ArrayList<IResource>(); if (o instanceof IContainer) { try { IResource[] members = ((IContainer) o).members(); for (IResource member : members) { if (member instanceof IContainer || (member instanceof IFile && member.getName().equals("jbi.xml"))) //$NON-NLS-1$ children.add(member); } } catch (CoreException e) { PetalsCommonPlugin.log(e, IStatus.ERROR); } } return children.toArray(new IResource[0]); } /* * (non-Javadoc) * @see org.eclipse.ui.model.BaseWorkbenchContentProvider * #hasChildren(java.lang.Object) */ @Override public boolean hasChildren(Object element) { return getChildren(element).length > 0; } }); // Set page input IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); viewer.setInput(root); if (this.selectedContainer != null) { viewer.setSelection(new StructuredSelection(this.selectedContainer), true); viewer.expandToLevel(this.selectedContainer, 1); } viewer.addPostSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { Object o = ((IStructuredSelection) event.getSelection()).getFirstElement(); if (o instanceof IContainer) JbiXmlNewWizardPage.this.selectedContainer = (IContainer) o; else JbiXmlNewWizardPage.this.selectedContainer = ((IFile) o).getParent(); String path = JbiXmlNewWizardPage.this.selectedContainer.getFullPath().toOSString(); String fileSeparator = System.getProperty("file.separator"); //$NON-NLS-1$ if (path.startsWith(fileSeparator)) path = path.substring(fileSeparator.length()); folderPathText.setText(path); validate(); } }); // Overwrite existing file ? final Button overwriteButton = new Button(container, SWT.CHECK); overwriteButton.setText(Messages.NewJbiXmlWizardPage_5); overwriteButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { JbiXmlNewWizardPage.this.overwriteExistingFile = overwriteButton.getSelection(); validate(); } }); // Set control setControl(container); }
From source file:com.ebmwebsourcing.petals.services.su.wizards.pages.ChoicePage.java
License:Open Source License
@Override public void createControl(Composite parent) { // Create the composite container and define its layout final Composite container = SwtFactory.createComposite(parent); setControl(container);//from www. j a v a 2s.c om SwtFactory.applyNewGridLayout(container, 2, false, 15, 0, 0, 15); SwtFactory.applyHorizontalGridData(container); // Add a tool tip to display in case of problem this.helpTooltip = new FixedShellTooltip(getShell(), true, 90) { @Override public void populateTooltip(Composite parent) { GridLayout layout = new GridLayout(); layout.verticalSpacing = 2; parent.setLayout(layout); parent.setLayoutData(new GridData(GridData.FILL_BOTH)); parent.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); try { ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin( PetalsConstants.PETALS_COMMON_PLUGIN_ID, "icons/petals/thinking_hard.png"); if (desc != null) ChoicePage.this.helpImg = desc.createImage(); parent.setBackgroundMode(SWT.INHERIT_DEFAULT); Label imgLabel = new Label(parent, SWT.NONE); imgLabel.setImage(ChoicePage.this.helpImg); imgLabel.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true, true)); } catch (Exception e) { PetalsServicesPlugin.log(e, IStatus.WARNING); } FontData[] fd = PlatformUtils.getModifiedFontData(getFont().getFontData(), SWT.BOLD); ChoicePage.this.boldFont = new Font(getShell().getDisplay(), fd); Label titleLabel = new Label(parent, SWT.NONE); titleLabel.setFont(ChoicePage.this.boldFont); GridData layoutData = new GridData(SWT.CENTER, SWT.DEFAULT, true, true); layoutData.verticalIndent = 5; titleLabel.setLayoutData(layoutData); titleLabel.setText("What does this error mean?"); Label l = new Label(parent, SWT.WRAP); l.setText("This wizard will generate, among other things, Maven artifacts."); layoutData = new GridData(); layoutData.verticalIndent = 8; l.setLayoutData(layoutData); RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL); rowLayout.marginLeft = 0; rowLayout.marginTop = 0; rowLayout.marginRight = 0; rowLayout.marginBottom = 0; rowLayout.spacing = 0; Composite rowComposite = new Composite(parent, SWT.NONE); rowComposite.setLayout(rowLayout); rowComposite.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true, true)); new Label(rowComposite, SWT.WRAP).setText("Unfortunately, there is a problem with the "); Link link = new Link(rowComposite, SWT.WRAP | SWT.NO_FOCUS); link.setText("<A>the Petals Maven preferences</A>"); new Label(rowComposite, SWT.WRAP).setText("."); new Label(parent, SWT.WRAP).setText("Please, make them correct."); link.addSelectionListener(new DefaultSelectionListener() { @Override public void widgetSelected(SelectionEvent e) { try { PreferencesUtil.createPreferenceDialogOn(new Shell(), "com.ebmwebsourcing.petals.services.prefs.maven", null, null).open(); } catch (Exception e1) { PetalsServicesPlugin.log(e1, IStatus.ERROR); } } }); } }; // Prepare the input Comparator<AbstractServiceUnitWizard> comparator = new Comparator<AbstractServiceUnitWizard>() { @Override public int compare(AbstractServiceUnitWizard o1, AbstractServiceUnitWizard o2) { String v1 = o1.getComponentVersionDescription().getComponentVersion(); String v2 = o2.getComponentVersionDescription().getComponentVersion(); return -v1.compareTo(v2); // negative so that the most recent is first } }; final Map<String, Collection<AbstractServiceUnitWizard>> componentNameToHandler = new TreeMap<String, Collection<AbstractServiceUnitWizard>>(); final Map<PetalsKeyWords, Set<String>> keywordToComponentName = new TreeMap<PetalsKeyWords, Set<String>>(); for (AbstractServiceUnitWizard handler : ExtensionManager.INSTANCE.findComponentWizards(this.petalsMode)) { for (PetalsKeyWords keyword : handler.getComponentVersionDescription().getKeyWords()) { Set<String> list = keywordToComponentName.get(keyword); if (list == null) list = new TreeSet<String>(); String componentName = handler.getComponentVersionDescription().getComponentName(); list.add(componentName); keywordToComponentName.put(keyword, list); Collection<AbstractServiceUnitWizard> handlers = componentNameToHandler.get(componentName); if (handlers == null) handlers = new TreeSet<AbstractServiceUnitWizard>(comparator); handlers.add(handler); componentNameToHandler.put(componentName, handlers); } } // Add the selection area final PhantomText searchText = new PhantomText(container, SWT.SINGLE | SWT.BORDER); searchText.setDefaultValue("Search..."); GridDataFactory.swtDefaults().grab(true, false).align(SWT.FILL, SWT.TOP).span(2, 1).applyTo(searchText); final TreeViewer componentsViewer = new TreeViewer(container, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); GridDataFactory.fillDefaults().span(2, 1).hint(380, 300).applyTo(componentsViewer.getTree()); componentsViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { String result; if (element instanceof String) { IComponentDescription desc = componentNameToHandler.get(element).iterator().next() .getComponentVersionDescription(); String componentName = desc.getComponentName(); String componentAlias = desc.getComponentAlias(); String annotation = desc.getComponentAnnotation(); StringBuilder sb = new StringBuilder(); if (StringUtils.isEmpty(componentName)) sb.append(componentAlias); // Generic component else sb.append(componentAlias + " - " + componentName); if (!StringUtils.isEmpty(annotation)) sb.append(" ( " + annotation + " )"); result = sb.toString(); } else { result = super.getText(element); } return result; } @Override public Image getImage(Object element) { Image result = null; if (element instanceof PetalsKeyWords) { result = ChoicePage.this.keywordToImage.get(element); } else { IComponentDescription desc = componentNameToHandler.get(element).iterator().next() .getComponentVersionDescription(); result = desc.isBc() ? ChoicePage.this.bcImg : ChoicePage.this.seImg; } return result; } }); componentsViewer.setContentProvider(new DefaultTreeContentProvider() { @Override public Object[] getElements(Object inputElement) { return keywordToComponentName.keySet().toArray(); } @Override public Object[] getChildren(Object parentElement) { Object[] result; if (parentElement instanceof PetalsKeyWords) { Collection<String> componentNames = keywordToComponentName.get(parentElement); result = componentNames == null ? new Object[0] : componentNames.toArray(); } else { result = new Object[0]; } return result; } @Override public boolean hasChildren(Object element) { return element instanceof PetalsKeyWords; } }); componentsViewer.addFilter(new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { boolean result = false; String filter = searchText.getTextValue().trim().toLowerCase(); if (filter.length() == 0) result = true; else if (element instanceof PetalsKeyWords) { Set<String> names = keywordToComponentName.get(element); if (names != null) { for (String s : names) { if (select(viewer, null, s)) { result = true; break; } } } } else if (element instanceof String) result = ((String) element).toLowerCase().contains(filter); return result; } }); componentsViewer.setInput(new Object()); if (keywordToComponentName.size() > 0) componentsViewer.expandToLevel(keywordToComponentName.keySet().iterator().next(), 1); // Display the available versions new Label(container, SWT.NONE).setText("Component Version:"); final ComboViewer versionCombo = new ComboViewer(container, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY); GridData layoutData = new GridData(); layoutData.widthHint = 130; versionCombo.getCombo().setLayoutData(layoutData); versionCombo.setContentProvider(new ArrayContentProvider()); versionCombo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((AbstractServiceUnitWizard) element).getComponentVersionDescription().getComponentVersion(); } }); final Label descriptionLabel = new Label(container, SWT.NONE); GridDataFactory.swtDefaults().span(2, 1).indent(0, 10).applyTo(descriptionLabel); // Selection listeners searchText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { componentsViewer.refresh(); if (searchText.getTextValue().trim().length() == 0) componentsViewer.collapseAll(); else componentsViewer.expandAll(); } }); componentsViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { // Get the selection Object o = ((IStructuredSelection) event.getSelection()).getFirstElement(); Collection<?> input; if (o == null || o instanceof PetalsKeyWords) input = Collections.emptyList(); else input = componentNameToHandler.get(o); // Default selection - there is always one versionCombo.setInput(input); versionCombo.getCombo().setVisibleItemCount(input.size() > 0 ? input.size() : 1); if (!input.isEmpty()) { versionCombo.setSelection(new StructuredSelection(input.iterator().next())); versionCombo.getCombo().notifyListeners(SWT.Selection, new Event()); } else { setPageComplete(false); setSelectedNode(null); descriptionLabel.setText(""); descriptionLabel.getParent().layout(); } } }); versionCombo.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { AbstractServiceUnitWizard suWizard = (AbstractServiceUnitWizard) ((IStructuredSelection) event .getSelection()).getFirstElement(); if (suWizard == null) return; setPageComplete(true); setSelectedNode(getWizardNode(suWizard)); String desc = ChoicePage.this.petalsMode == PetalsMode.provides ? suWizard.getComponentVersionDescription().getProvideDescription() : suWizard.getComponentVersionDescription().getConsumeDescription(); descriptionLabel.setText(desc); descriptionLabel.getParent().layout(); } }); // Initialize if (PreferencesManager.isMavenTemplateConfigurationValid()) this.helpTooltip.hide(); componentsViewer.getTree().setFocus(); }
From source file:com.ebmwebsourcing.petals.studio.dev.properties.internal.wizards.GenerateConstantsWizardPage.java
License:Open Source License
@Override public void createControl(Composite parent) { // Create the composite container and define its layout final Composite container = new Composite(parent, SWT.NONE); GridLayoutFactory.swtDefaults().extendedMargins(15, 15, 15, 10).numColumns(2).applyTo(container); container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Container viewer Label l = new Label(container, SWT.NONE); l.setText("Select the output directory to generate the Java constants."); GridDataFactory.swtDefaults().span(2, 1).applyTo(l); TreeViewer viewer = new TreeViewer(container, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.HIDE_SELECTION); GridData layoutData = new GridData(GridData.FILL_BOTH); layoutData.heightHint = 100;//from w ww.j av a 2s . c o m layoutData.horizontalSpan = 2; viewer.getTree().setLayoutData(layoutData); viewer.setLabelProvider(new WorkbenchLabelProvider()); viewer.setContentProvider(new WorkbenchContentProvider() { /* * (non-Javadoc) * @see org.eclipse.ui.model.BaseWorkbenchContentProvider * #getChildren(java.lang.Object) */ @Override public Object[] getChildren(Object o) { List<Object> children = new ArrayList<Object>(); try { if (o instanceof IJavaProject) { for (IPackageFragmentRoot root : ((IJavaProject) o).getPackageFragmentRoots()) { if (root.getResource() instanceof IContainer) children.add(root); } } else if (o instanceof IWorkspaceRoot) { for (IProject p : ((IWorkspaceRoot) o).getProjects()) { if (!p.isAccessible() || !p.hasNature(JavaCore.NATURE_ID)) continue; IJavaProject jp = JavaCore.create(p); if (jp != null) children.add(jp); } } } catch (CoreException e) { PetalsStudioDevPlugin.log(e, IStatus.ERROR); } return children.toArray(new Object[0]); } /* * (non-Javadoc) * @see org.eclipse.ui.model.BaseWorkbenchContentProvider * #hasChildren(java.lang.Object) */ @Override public boolean hasChildren(Object element) { return getChildren(element).length > 0; } }); // Set page input viewer.setInput(ResourcesPlugin.getWorkspace().getRoot()); if (this.originalSelection != null) { try { IJavaProject jp = JavaCore.create(this.originalSelection); for (IPackageFragmentRoot root : jp.getPackageFragmentRoots()) { if (root.getResource() instanceof IContainer) { GenerateConstantsWizardPage.this.target = root; break; } } } catch (JavaModelException e) { PetalsStudioDevPlugin.log(e, IStatus.ERROR, "This should not happen (check in the handler)."); } } if (this.target != null) { viewer.setSelection(new StructuredSelection(this.target), true); viewer.expandToLevel(this.target, 1); viewer.getTree().notifyListeners(SWT.Selection, new Event()); } // Java meta new Label(container, SWT.NONE).setText("Java Package:"); final Text packageText = new Text(container, SWT.SINGLE | SWT.BORDER); packageText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); packageText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { GenerateConstantsWizardPage.this.javaPackage = ((Text) e.widget).getText().trim(); validate(); } }); new Label(container, SWT.NONE).setText("Java Class Name:"); final Text classText = new Text(container, SWT.SINGLE | SWT.BORDER); classText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); classText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { GenerateConstantsWizardPage.this.className = ((Text) e.widget).getText().trim(); validate(); } }); // Add the missing listeners viewer.addPostSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { Object o = ((IStructuredSelection) event.getSelection()).getFirstElement(); if (o instanceof IPackageFragmentRoot) { GenerateConstantsWizardPage.this.target = (IPackageFragmentRoot) o; String pName = GenerateConstantsWizardPage.this.target.getJavaProject().getProject().getName(); packageText.setText(pName.replaceAll("-", ".") + ".generated"); int index = pName.lastIndexOf('.') + 1; if (index <= 0 || index > pName.length()) pName = "Default"; else pName = pName.substring(index); classText.setText(pName); } else { GenerateConstantsWizardPage.this.target = null; } } }); // Set control setControl(container); }
From source file:com.eclipsesource.rowtemplate.demo.RowTemplateDemo.java
License:Open Source License
private void createTree(Composite parent) { TreeViewer treeViewer = new TreeViewer(parent, getStyle()); exampleControl = treeViewer.getTree(); treeViewer.setContentProvider(new ITreeContentProvider() { @Override//from w w w . j a va2 s . c o m public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } @Override public void dispose() { } @Override public boolean hasChildren(Object element) { return ((Person) element).getChildren() != null; } @Override public Object getParent(Object element) { return null; } @Override public Object[] getElements(Object inputElement) { return (Person[]) inputElement; } @Override public Object[] getChildren(Object parentElement) { return ((Person) parentElement).getChildren(); } }); configColumnViewer(treeViewer); treeViewer.getTree().addSelectionListener(new SelectionListener(parent)); treeViewer.getTree().setHeaderVisible(headerVisible.getSelection()); treeViewer.getTree().setLinesVisible(headerVisible.getSelection()); }
From source file:com.eclipsesource.tabris.demos.enron.EnronExample.java
License:Open Source License
private void createTreeArea(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = ExampleUtil.createGridLayout(); composite.setLayout(layout);//from w w w.j ava2 s . c o m viewer = new TreeViewer(composite, SWT.SINGLE | SWT.VIRTUAL); viewer.setUseHashlookup(true); onTree(viewer.getTree()).setBackButtonNavigationEnabled(true); TreeColumn treeColumn = new TreeColumn(viewer.getTree(), SWT.NONE); treeColumn.setWidth(200); TreeColumn treeColumn2 = new TreeColumn(viewer.getTree(), SWT.NONE); treeColumn2.setWidth(200); Tree tree = viewer.getTree(); tree.setLinesVisible(true); tree.setToolTipText("Enron Mailbox"); viewer.getControl().setLayoutData(ExampleUtil.createFillData()); viewer.setLabelProvider(new EnronLabelProvider(parent.getDisplay())); viewer.setContentProvider(new EnronLazyContentProvider(viewer)); viewer.setInput(getDataSet()); viewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); Object firstElement = selection.getFirstElement(); if (firstElement instanceof Node) { nodeSelected((Node) firstElement); } } }); }
From source file:com.eclipsesource.tabris.demos.ui.BooksListPage.java
License:Open Source License
public static TreeViewer createTreeViewer(AbstractPage page, Composite container) { TreeViewer viewer = new TreeViewer(container, SWT.V_SCROLL); viewer.setContentProvider(new BooksContentProvider()); addBookSelectionListener(page, viewer); Tree tree = viewer.getTree();//from w ww . j a v a 2 s . c o m tree.setLinesVisible(true); tree.setData(RWT.MARKUP_ENABLED, Boolean.TRUE); onTree(tree).setTemplate(createRowTemplate()); onTree(tree).setItemHeight(68); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tree); viewer.setLabelProvider(new BooksLabelProvider()); new TreeColumn(tree, SWT.LEFT); new TreeColumn(tree, SWT.LEFT); new TreeColumn(tree, SWT.LEFT); return viewer; }
From source file:com.elphel.vdt.ui.views.DesignFlowView.java
License:Open Source License
/** * This is a callback that will allow us * to create the viewer and initialize it. *///from w w w.j a v a 2 s . c o m public void createPartControl(Composite parent) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) System.out.println("+++++ createPartControl()"); // compositeParent=parent; // will it help to re-draw viewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); // drillDownAdapter = new DrillDownAdapter(viewer); viewer.setContentProvider(new ViewContentProvider()); viewer.setLabelProvider(new ViewLabelProvider()); // more complex sorter is needed // viewer.setSorter(new NameSorter()); // viewer.setInput(getViewSite()); // viewer.setInput(ToolsCore.getDesignMenu()); viewer.addSelectionChangedListener(new ToolSelectionChangedListener()); // Draw tool state (running, success, failure, ...) icon after the label in the tree final Tree tree = viewer.getTree(); tree.addListener(SWT.MeasureItem, new Listener() { public void handleEvent(Event event) { ((DesignMenuModel.Item) ((TreeItem) event.item).getData()).measureItem(event); } }); tree.addListener(SWT.PaintItem, new Listener() { public void handleEvent(Event event) { TreeItem item = (TreeItem) event.item; ((DesignMenuModel.Item) item.getData()).showStateIcon(event, tree, item); } }); makeActions(); hookContextMenu(); /**+ hookDoubleClickAction(); */ contributeToActionBars(); if (memento != null) restoreState(memento); memento = null; tree.addListener(SWT.KeyUp, new Listener() { @Override public void handleEvent(Event event) { if (event.keyCode == SWT.SHIFT) { toolSequence.setShiftPressed(false); } } }); tree.addListener(SWT.KeyDown, new Listener() { @Override public void handleEvent(Event event) { if (event.keyCode == SWT.SHIFT) { toolSequence.setShiftPressed(true); } } }); }
From source file:com.essiembre.eclipse.rbe.ui.editor.i18n.tree.KeyTreeComposite.java
License:Apache License
/** * Creates the middle (tree) section of this composite. *//*from w w w .j a va2 s . com*/ private void createMiddleSection() { GridData gridData = new GridData(); gridData.verticalAlignment = GridData.FILL; gridData.grabExcessVerticalSpace = true; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; treeViewer = new TreeViewer(this, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); treeViewer.setContentProvider(new KeyTreeContentProvider()); labelProvider = new KeyTreeLabelProvider(); treeViewer.setLabelProvider(labelProvider); treeViewer.setUseHashlookup(true); treeViewer.setInput(keyTree); if (RBEPreferences.getKeyTreeExpanded()) { treeViewer.expandAll(); } treeViewer.getTree().setLayoutData(gridData); treeViewer.getTree().addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent event) { if (event.character == SWT.DEL) { deleteKeyOrGroup(); } } }); treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (syncAddTextBox && getSelectedKey() != null) { addTextBox.setText(getSelectedKey()); keyTree.selectKey(getSelectedKey()); } syncAddTextBox = true; } }); treeViewer.getTree().addMouseListener(new MouseAdapter() { public void mouseDoubleClick(MouseEvent event) { Object element = getSelection(); if (treeViewer.isExpandable(element)) { if (treeViewer.getExpandedState(element)) { treeViewer.collapseToLevel(element, 1); } else { treeViewer.expandToLevel(element, 1); } } } }); ViewerFilter filter = new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { // if (parentElement instanceof KeyTreeItem) { // KeyTreeItem parent = (KeyTreeItem) parentElement; // if (parent.isSelected()) // return true; // } if (element instanceof KeyTreeItem) { KeyTreeItem item = (KeyTreeItem) element; return item.isVisible(); } return true; // String text = filterTextBox.getText(); // if (element instanceof KeyTreeItem) { // KeyTreeItem item = (KeyTreeItem) element; // if (item.getId().indexOf(text) != -1) // return true; // } // return true; } }; treeViewer.addFilter(filter); treeviewerContributor = new TreeViewerContributor(keyTree, treeViewer); treeviewerContributor.createControl(this); }
From source file:com.exploitpack.main.MainWindow.java
License:Open Source License
@SuppressWarnings("unused") public void createContents() { // Set App Version CurrentAppVersion = "2.1"; // Obtain local time Format formatter;/*ww w . j a va 2 s .c o m*/ Date date = new Date(); formatter = new SimpleDateFormat("hh:mm:ss"); LogTime = formatter.format(date); // Try to install python // Obtain Python Path try { // Read file FileReader fstream = new FileReader("data/config/exploitpack.config"); BufferedReader in = new BufferedReader(fstream); pythonFullPath = in.readLine() + "\n"; System.out.print(pythonFullPath); // Close the output stream in.close(); } catch (Exception e1) { // Catch exception if any RequirementInstaller.main(null); System.err.println("Error: " + e1.getMessage()); } // Try to obtain local IP and Hostname try { InetAddress addr = InetAddress.getLocalHost(); // Get IP Address byte[] ipAddr = addr.getAddress(); // Convert to dot representation ipAddrStr = ""; for (int i = 0; i < ipAddr.length; i++) { if (i > 0) { ipAddrStr += "."; } ipAddrStr += ipAddr[i] & 0xFF; // Get hostname HostName = addr.getHostName(); } } catch (UnknownHostException e) { } // Start to load the Window shlExploitPack = new Shell(); // Start Systray SysTray.main(null); Composite composite = new Composite(shlExploitPack, SWT.NONE); FormData fd_composite = new FormData(); fd_composite.left = new FormAttachment(0); fd_composite.top = new FormAttachment(0, 666); fd_composite.bottom = new FormAttachment(0, 689); fd_composite.right = new FormAttachment(0, 1370); composite.setLayoutData(fd_composite); composite.setLayout(new FormLayout()); formToolkit.adapt(composite); formToolkit.paintBordersFor(composite); Label lblNewLabel_3 = new Label(composite, SWT.NONE); FormData fd_lblNewLabel_3 = new FormData(); fd_lblNewLabel_3.top = new FormAttachment(0, 5); fd_lblNewLabel_3.left = new FormAttachment(0, 10); lblNewLabel_3.setLayoutData(fd_lblNewLabel_3); formToolkit.adapt(lblNewLabel_3, true, true); lblNewLabel_3.setText("Welcome to Exploit Pack - Security Framework"); final ProgressBar moduleProgressBar = new ProgressBar(composite, SWT.NONE); FormData fd_moduleProgressBar = new FormData(); fd_moduleProgressBar.left = new FormAttachment(100, -180); fd_moduleProgressBar.right = new FormAttachment(100, -10); fd_moduleProgressBar.bottom = new FormAttachment(0, 18); fd_moduleProgressBar.top = new FormAttachment(0, 5); moduleProgressBar.setLayoutData(fd_moduleProgressBar); formToolkit.adapt(moduleProgressBar, true, true); Label lblNewLabel_4 = new Label(composite, SWT.NONE); FormData fd_lblNewLabel_4 = new FormData(); fd_lblNewLabel_4.top = new FormAttachment(0, 5); fd_lblNewLabel_4.right = new FormAttachment(moduleProgressBar, -6); fd_lblNewLabel_4.left = new FormAttachment(moduleProgressBar, -101, SWT.LEFT); lblNewLabel_4.setLayoutData(fd_lblNewLabel_4); formToolkit.adapt(lblNewLabel_4, true, true); lblNewLabel_4.setText("Module Progress"); final ToolBar toolBar_1 = new ToolBar(shlExploitPack, SWT.FLAT | SWT.RIGHT); ToolItem tltmVisitWebsiteJs = new ToolItem(toolBar_1, SWT.DROP_DOWN); FormData fd_toolBar_1 = new FormData(); fd_toolBar_1.bottom = new FormAttachment(0, 33); fd_toolBar_1.left = new FormAttachment(100, -120); fd_toolBar_1.right = new FormAttachment(100); fd_toolBar_1.top = new FormAttachment(0, 3); toolBar_1.setLayoutData(fd_toolBar_1); formToolkit.adapt(toolBar_1); formToolkit.paintBordersFor(toolBar_1); tltmVisitWebsiteJs.setText("Visit Website"); tltmVisitWebsiteJs.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/www.png")); ToolItem toolItem_8 = new ToolItem(toolBar_1, SWT.SEPARATOR); toolBar = new ToolBar(shlExploitPack, SWT.FLAT | SWT.WRAP | SWT.RIGHT); FormData fd_toolBar = new FormData(); fd_toolBar.left = new FormAttachment(toolBar_1, -1250, SWT.LEFT); fd_toolBar.right = new FormAttachment(toolBar_1, 1); fd_toolBar.top = new FormAttachment(0, 3); toolBar.setLayoutData(fd_toolBar); toolBar.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY)); formToolkit.adapt(toolBar); formToolkit.paintBordersFor(toolBar); ToolItem toolItem_5 = new ToolItem(toolBar, SWT.SEPARATOR); ToolItem tltmNewProject = new ToolItem(toolBar, SWT.NONE); tltmNewProject.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ProjectWindow.main(null); } }); tltmNewProject.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/1316133906_package.png")); tltmNewProject.setText("New Project"); ToolItem tltmOpenProject = new ToolItem(toolBar, SWT.NONE); tltmOpenProject.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { OpenFile(); } }); tltmOpenProject .setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/1316133571_package_go.png")); tltmOpenProject.setText("Open Project"); ToolItem toolItem_6 = new ToolItem(toolBar, SWT.SEPARATOR); ToolItem tltmNewItem = new ToolItem(toolBar, SWT.NONE); tltmNewItem.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/1316134049_table_save.png")); tltmNewItem.setText("Save Project"); ToolItem toolItem = new ToolItem(toolBar, SWT.SEPARATOR); ToolItem tltmNewItem_1 = new ToolItem(toolBar, SWT.NONE); tltmNewItem_1.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/1316134425_cut_red.png")); tltmNewItem_1.setText("Cut"); ToolItem tltmNewItem_2 = new ToolItem(toolBar, SWT.NONE); tltmNewItem_2 .setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/1316134439_page_copy.png")); tltmNewItem_2.setText("Copy"); ToolItem tltmNewItem_3 = new ToolItem(toolBar, SWT.NONE); tltmNewItem_3.setImage( SWTResourceManager.getImage(MainWindow.class, "/resources/1316134460_page_white_paste.png")); tltmNewItem_3.setText("Paste"); ToolItem toolItem_1 = new ToolItem(toolBar, SWT.SEPARATOR); ToolItem LocalInterface = new ToolItem(toolBar, SWT.DROP_DOWN); LocalInterface.setImage( SWTResourceManager.getImage(MainWindow.class, "/resources/1316134303_application_form_delete.png")); LocalInterface.setText("Interface: " + HostName); ToolItem toolItem_2 = new ToolItem(toolBar, SWT.SEPARATOR); ToolItem tltmNewItem_4 = new ToolItem(toolBar, SWT.NONE); tltmNewItem_4.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { } }); tltmNewItem_4 .setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/1316134599_chart_bar.png")); tltmNewItem_4.setText("View Report"); ToolItem toolItem_3 = new ToolItem(toolBar, SWT.SEPARATOR); ToolItem tltmModuleEditor = new ToolItem(toolBar, SWT.NONE); tltmModuleEditor.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { com.exploitpack.editor.MainEditor.main(null); } }); tltmModuleEditor.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/editor.png")); tltmModuleEditor.setText("Module Editor"); ToolItem toolItem_4 = new ToolItem(toolBar, SWT.SEPARATOR); ToolItem tltmNewItem_5 = new ToolItem(toolBar, SWT.NONE); tltmNewItem_5.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Updater.main(null); } }); tltmNewItem_5.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/checkupdate.png")); tltmNewItem_5.setText("Update Manager"); formToolkit.adapt(toolBar); formToolkit.paintBordersFor(toolBar); ToolItem toolItem_9 = new ToolItem(toolBar, SWT.SEPARATOR); ToolItem tltmRun = new ToolItem(toolBar, SWT.NONE); tltmRun.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { btnLaunch.setSelection(true); //btnLaunch. } }); tltmRun.setText("Run"); tltmRun.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/run.png")); ToolItem toolItem_7 = new ToolItem(toolBar, SWT.SEPARATOR); ToolItem tltmStop = new ToolItem(toolBar, SWT.NONE); tltmStop.setText("Stop"); tltmStop.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/stop.png")); ToolItem toolItem_10 = new ToolItem(toolBar, SWT.SEPARATOR); ToolItem tltmDebug = new ToolItem(toolBar, SWT.NONE); tltmDebug.setText("Debug"); tltmDebug.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/bug.png")); shlExploitPack.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/1316133906_package.png")); shlExploitPack.setSize(1397, 747); shlExploitPack.setText("Exploit Pack - Security Framework"); shlExploitPack.setLayout(new FormLayout()); Menu menu = new Menu(shlExploitPack, SWT.BAR); shlExploitPack.setMenuBar(menu); MenuItem mntmFile = new MenuItem(menu, SWT.CASCADE); mntmFile.setText("File"); Menu menu_1 = new Menu(mntmFile); mntmFile.setMenu(menu_1); MenuItem mntmNewProject = new MenuItem(menu_1, SWT.NONE); mntmNewProject.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/1316133906_package.png")); mntmNewProject.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ProjectWindow.main(null); } }); mntmNewProject.setAccelerator(SWT.MOD1 + 'N'); mntmNewProject.setText("New Project \tCtrl+N"); MenuItem mntmLoadProject = new MenuItem(menu_1, SWT.NONE); mntmLoadProject.setText("Open Project.. \tCtrl+O"); new MenuItem(menu_1, SWT.SEPARATOR); MenuItem mntmSaveProject = new MenuItem(menu_1, SWT.NONE); mntmSaveProject .setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/1316134049_table_save.png")); mntmSaveProject.setText("Save Project \tCtrl+S"); MenuItem mntmCloseProject = new MenuItem(menu_1, SWT.NONE); mntmCloseProject.setText("Close Project \tCtrl+W"); new MenuItem(menu_1, SWT.SEPARATOR); MenuItem mntmExit = new MenuItem(menu_1, SWT.NONE); mntmExit.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { shlExploitPack.dispose(); } }); mntmExit.setText("Exit"); mntmExit.setAccelerator(SWT.MOD1 + 'Q'); MenuItem mntmEdit = new MenuItem(menu, SWT.CASCADE); mntmEdit.setText("Edit"); Menu menu_2 = new Menu(mntmEdit); mntmEdit.setMenu(menu_2); MenuItem mntmNewItem = new MenuItem(menu_2, SWT.NONE); mntmNewItem.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/arrow_undo.png")); mntmNewItem.setText("Undo"); MenuItem mntmNewItem_1 = new MenuItem(menu_2, SWT.NONE); mntmNewItem_1.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/arrow_redo.png")); mntmNewItem_1.setText("Redo"); new MenuItem(menu_2, SWT.SEPARATOR); MenuItem mntmCut = new MenuItem(menu_2, SWT.NONE); mntmCut.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/1316134425_cut_red.png")); mntmCut.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ShellcodeConsole.cut(); } }); mntmCut.setText("Cut \tCtrl+X"); mntmCut.setAccelerator(SWT.MOD1 + 'X'); MenuItem mntmCopy = new MenuItem(menu_2, SWT.NONE); mntmCopy.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/1316134439_page_copy.png")); mntmCopy.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ShellcodeConsole.copy(); } }); mntmCopy.setText("Copy \tCtrl+C"); mntmCopy.setAccelerator(SWT.MOD1 + 'C'); MenuItem mntmPaste = new MenuItem(menu_2, SWT.NONE); mntmPaste.setImage( SWTResourceManager.getImage(MainWindow.class, "/resources/1316134460_page_white_paste.png")); mntmPaste.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ShellcodeConsole.paste(); } }); mntmPaste.setText("Paste \tCtrl+P"); mntmPaste.setAccelerator(SWT.MOD1 + 'P'); MenuItem mntmModules = new MenuItem(menu, SWT.CASCADE); mntmModules.setText("Modules"); Menu menu_3 = new Menu(mntmModules); mntmModules.setMenu(menu_3); MenuItem mntmShowModules = new MenuItem(menu_3, SWT.NONE); mntmShowModules.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/cog.png")); mntmShowModules.setText("Show Modules"); MenuItem mntmTools = new MenuItem(menu, SWT.CASCADE); mntmTools.setText("Tools"); Menu menu_4 = new Menu(mntmTools); mntmTools.setMenu(menu_4); MenuItem mntmConsole = new MenuItem(menu_4, SWT.NONE); mntmConsole.setText("Console \tCtrl+C"); MenuItem mntmRefreshModules = new MenuItem(menu_4, SWT.NONE); mntmRefreshModules.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/refresh.png")); mntmRefreshModules.setText("Refresh Modules \tF5"); new MenuItem(menu_4, SWT.SEPARATOR); MenuItem mntmModuleEditor = new MenuItem(menu_4, SWT.NONE); mntmModuleEditor.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/editor.png")); mntmModuleEditor.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { com.exploitpack.editor.MainEditor.main(null); } }); mntmModuleEditor.setText("Module Editor \tCtrl+M"); new MenuItem(menu_4, SWT.SEPARATOR); MenuItem mntmEditPreferences = new MenuItem(menu_4, SWT.NONE); mntmEditPreferences.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Preferences.main(null); } }); mntmEditPreferences.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/preferences.png")); mntmEditPreferences.setText("Edit Preferences"); mntmPaste.setAccelerator(SWT.MOD1 + 'C'); MenuItem mntmRun = new MenuItem(menu, SWT.CASCADE); mntmRun.setText("Run"); Menu menu_7 = new Menu(mntmRun); mntmRun.setMenu(menu_7); MenuItem mntmRun_1 = new MenuItem(menu_7, SWT.NONE); mntmRun_1.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { } }); mntmRun_1.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/run.png")); mntmRun_1.setText("Run \tCtrl+F11"); MenuItem mntmStop = new MenuItem(menu_7, SWT.NONE); mntmStop.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/stop.png")); mntmStop.setText("Stop"); new MenuItem(menu_7, SWT.SEPARATOR); MenuItem mntmDebug = new MenuItem(menu_7, SWT.NONE); mntmDebug.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/bug.png")); mntmDebug.setText("Debug \tF11"); MenuItem mntmUpdate = new MenuItem(menu, SWT.CASCADE); mntmUpdate.setText("Update"); Menu menu_5 = new Menu(mntmUpdate); mntmUpdate.setMenu(menu_5); MenuItem mntmCheckUpdates = new MenuItem(menu_5, SWT.NONE); mntmCheckUpdates.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/checkupdate.png")); mntmCheckUpdates.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { CheckUpdate.main(null); } }); mntmCheckUpdates.setText("Check Updates \tCtrl+U"); mntmPaste.setAccelerator(SWT.MOD1 + 'U'); MenuItem mntmHelp = new MenuItem(menu, SWT.CASCADE); mntmHelp.setText("Help"); Menu menu_6 = new Menu(mntmHelp); mntmHelp.setMenu(menu_6); MenuItem mntmViewHelp = new MenuItem(menu_6, SWT.NONE); mntmViewHelp.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/help.png")); mntmViewHelp.setText("View Help \tCtrl+H"); mntmPaste.setAccelerator(SWT.MOD1 + 'H'); MenuItem mntmReportABug = new MenuItem(menu_6, SWT.NONE); mntmReportABug.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/reportbug.png")); mntmReportABug.setText("Report a Bug"); new MenuItem(menu_6, SWT.SEPARATOR); MenuItem mntmCheckForUpdates = new MenuItem(menu_6, SWT.NONE); mntmCheckForUpdates.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/updatemanager.png")); mntmCheckForUpdates.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { com.exploitpack.main.Updater.main(null); } }); mntmCheckForUpdates.setText("Update Manager"); MenuItem mntmLicense = new MenuItem(menu_6, SWT.NONE); mntmLicense.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { License.main(null); } }); mntmLicense.setText("License"); MenuItem menuItem = new MenuItem(menu_6, SWT.SEPARATOR); MenuItem mntmAbout = new MenuItem(menu_6, SWT.NONE); mntmAbout.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/about.png")); mntmAbout.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { About OpenForm = new About(); OpenForm.open(); } }); mntmAbout.setText("About - Exploit Pack"); tabFolder = new TabFolder(shlExploitPack, SWT.NONE); FormData fd_tabFolder = new FormData(); fd_tabFolder.right = new FormAttachment(toolBar_1, 0, SWT.RIGHT); fd_tabFolder.left = new FormAttachment(0, 283); fd_tabFolder.bottom = new FormAttachment(0, 502); fd_tabFolder.top = new FormAttachment(0, 39); tabFolder.setLayoutData(fd_tabFolder); TabItem tbtmModules = new TabItem(tabFolder, SWT.NONE); tbtmModules.setText("Modules"); Composite composite1 = new Composite(tabFolder, SWT.NONE); tbtmModules.setControl(composite1); composite1.setLayout(new FormLayout()); Group grpTargetInformation = new Group(composite1, SWT.NONE); FormData fd_grpTargetInformation = new FormData(); fd_grpTargetInformation.right = new FormAttachment(0, 387); fd_grpTargetInformation.bottom = new FormAttachment(0, 140); fd_grpTargetInformation.left = new FormAttachment(0, 10); fd_grpTargetInformation.top = new FormAttachment(0, 10); grpTargetInformation.setLayoutData(fd_grpTargetInformation); grpTargetInformation.setText("Target Properties"); Group grpShellcodeConsole = new Group(composite1, SWT.NONE); grpShellcodeConsole.setLayout(new FormLayout()); FormData fd_grpShellcodeConsole = new FormData(); fd_grpShellcodeConsole.left = new FormAttachment(0, 10); fd_grpShellcodeConsole.top = new FormAttachment(0, 145); fd_grpShellcodeConsole.bottom = new FormAttachment(100, -10); grpShellcodeConsole.setLayoutData(fd_grpShellcodeConsole); grpShellcodeConsole.setText("Shellcode Console"); Group grpExecutedModules = new Group(composite1, SWT.NONE); grpExecutedModules.setLayout(new FormLayout()); FormData fd_grpExecutedModules = new FormData(); fd_grpExecutedModules.left = new FormAttachment(grpTargetInformation, 6); fd_grpExecutedModules.bottom = new FormAttachment(0, 140); final Text TargetHost = new Text(grpTargetInformation, SWT.BORDER); TargetHost.setBounds(58, 46, 134, 19); formToolkit.adapt(TargetHost, true, true); final Text TargetPort = new Text(grpTargetInformation, SWT.BORDER); TargetPort.setBounds(58, 71, 134, 19); formToolkit.adapt(TargetPort, true, true); Label lblTarget = new Label(grpTargetInformation, SWT.NONE); lblTarget.setBounds(10, 46, 36, 16); formToolkit.adapt(lblTarget, true, true); lblTarget.setText("Target:"); Label lblPort = new Label(grpTargetInformation, SWT.NONE); lblPort.setBounds(10, 71, 32, 13); formToolkit.adapt(lblPort, true, true); lblPort.setText("Port:"); Label lblProject = formToolkit.createLabel(grpTargetInformation, "Project:", SWT.NONE); lblProject.setBounds(10, 21, 42, 19); Label lblArgs = formToolkit.createLabel(grpTargetInformation, "Special:", SWT.NONE); lblArgs.setBounds(198, 74, 55, 16); TargetName = new Text(grpTargetInformation, SWT.BORDER); TargetName.setText("Exploit Pack"); TargetName.setBounds(58, 21, 134, 19); formToolkit.adapt(TargetName, true, true); TargetArgs = new Text(grpTargetInformation, SWT.BORDER); TargetArgs.setBounds(266, 71, 101, 19); formToolkit.adapt(TargetArgs, true, true); TargetLhost = new Text(grpTargetInformation, SWT.BORDER); TargetLhost.setBounds(266, 21, 101, 19); TargetLhost.setText(ipAddrStr); formToolkit.adapt(TargetLhost, true, true); TargetLPort = new Text(grpTargetInformation, SWT.BORDER); TargetLPort.setBounds(266, 46, 101, 19); formToolkit.adapt(TargetLPort, true, true); Label lblNewLabel_2 = formToolkit.createLabel(grpTargetInformation, "Shellcode:", SWT.NONE); lblNewLabel_2.setBounds(198, 101, 55, 13); Label lblLocalHost = formToolkit.createLabel(grpTargetInformation, "Local Host:", SWT.NONE); lblLocalHost.setBounds(198, 21, 62, 15); Label lblLocalPort = formToolkit.createLabel(grpTargetInformation, "Local Port:", SWT.NONE); lblLocalPort.setBounds(200, 46, 55, 15); final Combo ShellcodeCombo = new Combo(grpTargetInformation, SWT.NONE); ShellcodeCombo.setItems(new String[] { "Remote Shell", "Execute Code", "Command", "Local Shell" }); ShellcodeCombo.setBounds(266, 96, 101, 19); formToolkit.adapt(ShellcodeCombo); formToolkit.paintBordersFor(ShellcodeCombo); ShellcodeCombo.setText("Select"); Label lblNewLabel_6 = new Label(grpTargetInformation, SWT.NONE); lblNewLabel_6.setBounds(10, 101, 36, 15); formToolkit.adapt(lblNewLabel_6, true, true); lblNewLabel_6.setText("Path:"); TargetPath = new Text(grpTargetInformation, SWT.BORDER); TargetPath.setBounds(58, 96, 134, 19); formToolkit.adapt(TargetPath, true, true); fd_grpExecutedModules.top = new FormAttachment(0, 10); grpExecutedModules.setLayoutData(fd_grpExecutedModules); grpExecutedModules.setText("Executed Modules"); Group grpModulesLog = new Group(composite1, SWT.NONE); fd_grpExecutedModules.right = new FormAttachment(100, -249); grpModulesLog.setLayout(new FormLayout()); FormData fd_grpModulesLog = new FormData(); fd_grpModulesLog.left = new FormAttachment(100, -243); fd_grpModulesLog.bottom = new FormAttachment(2, 130); fd_grpModulesLog.right = new FormAttachment(100, -10); fd_grpModulesLog.top = new FormAttachment(2); grpModulesLog.setLayoutData(fd_grpModulesLog); grpModulesLog.setText("Modules Log"); Group grpAvailableTargets = new Group(composite1, SWT.NONE); fd_grpShellcodeConsole.right = new FormAttachment(grpAvailableTargets, -6); ShellcodeConsole = new Text(grpShellcodeConsole, SWT.BORDER | SWT.MULTI); ShellcodeConsole.setToolTipText("Shellcode Console - Built in"); FormData fd_ShellcodeConsole = new FormData(); fd_ShellcodeConsole.top = new FormAttachment(0, 11); fd_ShellcodeConsole.right = new FormAttachment(100, -7); fd_ShellcodeConsole.left = new FormAttachment(0, 7); ShellcodeConsole.setLayoutData(fd_ShellcodeConsole); ShellcodeConsole.setForeground(SWTResourceManager.getColor(SWT.COLOR_GREEN)); ShellcodeConsole.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK)); ShellcodeConsole.setEditable(false); ShellcodeConsole.setText("=> Welcome to the Shellcode console Built-In Exploit Pack " + CurrentAppVersion + "\r\n=> The programs or scripts included with Exploit Pack are free software;\r\n=> the exact distribution terms for each one are described in the individual files\r\n=> \r\n=> Exploit Pack comes with ABSOLUTELY NO WARRANTY, for this free software\r\n=> to the extend permitted by applicable law\r\n=> Type ? for help\n"); ShellcodeConsole.append("=> \n"); ShellcodeInput = new Text(grpShellcodeConsole, SWT.BORDER); FormData fd_ShellcodeInput = new FormData(); fd_ShellcodeInput.left = new FormAttachment(ShellcodeConsole, 0, SWT.LEFT); fd_ShellcodeInput.top = new FormAttachment(100, -30); fd_ShellcodeInput.bottom = new FormAttachment(100, -12); ShellcodeInput.setLayoutData(fd_ShellcodeInput); // Handle the Shell code console input ShellcodeInput.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { int code = e.keyCode; String Switch = ShellcodeInput.getText(); if (code == 13) { // Connect if ((Switch.equals("connect") || (Switch.equals("c")) || (Switch.equals("y")))) { ShellcodeConsole.setText("=> Connecting to the target: " + TargetHost.getText() + "\n"); ShellcodeConsole.append(" Please wait while I open a console for you\n"); Connect.main(null, TargetHost.getText(), AgentPort); // Clean input ShellcodeInput.setText(""); } // Help if ((Switch.equals("help") || (Switch.equals("h") || (Switch.equals("?"))))) { ShellcodeConsole.setText("=> Base commands :\n"); ShellcodeConsole.append("=> Help menu: ? or help\n"); ShellcodeConsole.append("=> List sessions: ls or sessions\n"); ShellcodeConsole.append("=> Connect to: c or connect\n"); ShellcodeConsole.append("=> Disconnect from: d or disconnect\n"); ShellcodeConsole.append("=> Version: v or version\n"); // Clean input ShellcodeInput.setText(""); } // Session list if ((Switch.equals("session") || (Switch.equals("s") || (Switch.equals("ls"))))) { ShellcodeConsole.setText("=> Active sessions: \n"); // Clean input ShellcodeInput.setText(""); } // Version if ((Switch.equals("version") || (Switch.equals("v")))) { ShellcodeConsole.setText("=> Exploit Pack - Security Framework\n"); ShellcodeConsole.append("=> Author: Juan Sacco\n"); ShellcodeConsole.append("=> Version " + CurrentAppVersion + "\n"); // Clean input ShellcodeInput.setText(""); } // Disconnect if ((Switch.equals("disconnect") || (Switch.equals("d")) || (Switch.equals("n")))) { ShellcodeConsole.setText("=> Closing connection from " + TargetHost.getText() + "\n"); ShellcodeConsole.append("=> Done.\n"); // Clean input ShellcodeInput.setText(""); } // Clean input ShellcodeInput.setText(""); } } }); ShellcodeInput.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { String CheckInput = ShellcodeInput.getText(); System.out.print(CheckInput); ShellcodeInput.setText(""); } }); ShellcodeInput.setText("Type your command here.."); ShellcodeInput.setForeground(SWTResourceManager.getColor(255, 0, 255)); formToolkit.adapt(ShellcodeInput, true, true); Button btnNewButton = new Button(grpShellcodeConsole, SWT.NONE); fd_ShellcodeConsole.bottom = new FormAttachment(btnNewButton, -6); fd_ShellcodeInput.right = new FormAttachment(btnNewButton, -6); FormData fd_btnNewButton = new FormData(); fd_btnNewButton.bottom = new FormAttachment(100, -10); fd_btnNewButton.right = new FormAttachment(100, -10); btnNewButton.setLayoutData(fd_btnNewButton); formToolkit.adapt(btnNewButton, true, true); btnNewButton.setText("Send"); FormData fd_grpAvailableTargets = new FormData(); fd_grpAvailableTargets.top = new FormAttachment(100, -290); fd_grpAvailableTargets.bottom = new FormAttachment(100, -10); fd_grpAvailableTargets.right = new FormAttachment(100, -249); final Tree ExecutedModules = new Tree(grpExecutedModules, SWT.SINGLE | SWT.BORDER); ExecutedModules.setLinesVisible(true); ExecutedModules.setToolTipText("Executed Modules - Time and state"); FormData fd_tree111 = new FormData(); fd_tree111.top = new FormAttachment(0, 5); fd_tree111.left = new FormAttachment(0, 7); fd_tree111.bottom = new FormAttachment(100, -5); fd_tree111.right = new FormAttachment(100, -7); ExecutedModules.setLayoutData(fd_tree111); final TreeItem ExecuteModulesNode = new TreeItem(ExecutedModules, SWT.NONE, 0); ExecuteModulesNode.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/application.png")); ExecuteModulesNode.setText("Modules State View"); final Tree ModulesLog = new Tree(grpModulesLog, SWT.SINGLE | SWT.BORDER); ModulesLog.setLinesVisible(true); ModulesLog.setToolTipText("Log activities"); FormData fd_ModulesLog = new FormData(); fd_ModulesLog.bottom = new FormAttachment(100, -7); fd_ModulesLog.right = new FormAttachment(100, -10); fd_ModulesLog.top = new FormAttachment(0, 5); fd_ModulesLog.left = new FormAttachment(0, 10); ModulesLog.setLayoutData(fd_ModulesLog); final TreeItem ModulesLogNode = new TreeItem(ModulesLog, SWT.NONE, 0); ModulesLogNode.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/binary.png")); ModulesLogNode.setText("Modules Load Status: Ok"); grpAvailableTargets.setLayout(new FormLayout()); grpAvailableTargets.setLayoutData(fd_grpAvailableTargets); grpAvailableTargets.setText("Available Targets"); Group grpNetworkScanner = new Group(composite1, SWT.NONE); grpNetworkScanner.setText("Network Scanner"); FormData fd_grpNetworkScanner = new FormData(); fd_grpNetworkScanner.top = new FormAttachment(100, -290); fd_grpNetworkScanner.left = new FormAttachment(100, -243); fd_grpNetworkScanner.bottom = new FormAttachment(100, -10); Composite composite_61 = new Composite(grpAvailableTargets, SWT.NONE); FormData fd_composite_6 = new FormData(); fd_composite_6.right = new FormAttachment(100, -7); fd_composite_6.left = new FormAttachment(0, 8); fd_composite_6.bottom = new FormAttachment(100, -7); fd_composite_6.top = new FormAttachment(0, 11); composite_61.setLayoutData(fd_composite_6); formToolkit.adapt(composite_61); formToolkit.paintBordersFor(composite_61); Label lblRightClick = new Label(composite_61, SWT.NONE); lblRightClick.setText("Right click for menu"); lblRightClick.setBounds(62, 219, 107, 15); formToolkit.adapt(lblRightClick, true, true); final Tree TreeAvailableTargets = new Tree(composite_61, SWT.SINGLE | SWT.BORDER); TreeAvailableTargets.setSortDirection(SWT.UP); TreeAvailableTargets.setBounds(0, 0, 179, 244); TreeAvailableTargets.setToolTipText("Right Click for Menu"); TreeAvailableTargets.addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { } @Override public void mouseDown(MouseEvent e) { TreeAvailableTargets.addListener(SWT.MenuDetect, new Listener() { @Override public void handleEvent(org.eclipse.swt.widgets.Event event) { // We need a Shell as the parent of our menu final Shell shlSysTray = new Shell(event.display); // Style must be pop up Menu m = new Menu(shlSysTray, SWT.POP_UP); // Creates a new menu item that terminates the // program // when selected MenuItem restore = new MenuItem(m, SWT.NONE); restore.setText("Check connection"); restore.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { } }); MenuItem help = new MenuItem(m, SWT.NONE); help.setText("Connect"); help.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { Connect.main(null, TargetHost.getText(), AgentPort); } }); MenuItem about = new MenuItem(m, SWT.NONE); about.setText("Disconnect"); about.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { About.main(null); } }); // We need to make the menu visible m.setVisible(true); }; }); } }); final TreeItem AvailableTargets = new TreeItem(TreeAvailableTargets, SWT.NONE, 0); AvailableTargets.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/computer.png")); AvailableTargets.setText("Localhost ( 127.0.0.1 )"); fd_grpNetworkScanner.right = new FormAttachment(100, -10); grpNetworkScanner.setLayoutData(fd_grpNetworkScanner); formToolkit.adapt(grpNetworkScanner); formToolkit.paintBordersFor(grpNetworkScanner); TreeViewer treeViewer = new TreeViewer(grpNetworkScanner, SWT.BORDER); Tree TreePortScanner = treeViewer.getTree(); TreePortScanner.setToolTipText("Network mapper"); TreePortScanner.setBounds(10, 25, 213, 245); formToolkit.paintBordersFor(TreePortScanner); final TreeItem OpenPorts = new TreeItem(TreePortScanner, SWT.NONE); OpenPorts.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/port.png")); OpenPorts.setText("Open Ports ( 127.0.0.1 )"); TabItem tbtmHttpFuzzer = new TabItem(tabFolder, SWT.NONE); tbtmHttpFuzzer.setText("HTTP Fuzzer"); Composite composite_1 = new Composite(tabFolder, SWT.NONE); tbtmHttpFuzzer.setControl(composite_1); composite_1.setLayout(new FormLayout()); Label lblMethod = formToolkit.createLabel(composite_1, "Method:", SWT.NONE); FormData fd_lblMethod = new FormData(); fd_lblMethod.bottom = new FormAttachment(0, 25); fd_lblMethod.right = new FormAttachment(0, 65); fd_lblMethod.top = new FormAttachment(0, 10); fd_lblMethod.left = new FormAttachment(0, 10); lblMethod.setLayoutData(fd_lblMethod); Label lblProtocol = formToolkit.createLabel(composite_1, "Protocol:", SWT.NONE); FormData fd_lblProtocol = new FormData(); fd_lblProtocol.top = new FormAttachment(lblMethod, 0, SWT.TOP); fd_lblProtocol.right = new FormAttachment(0, 189); lblProtocol.setLayoutData(fd_lblProtocol); Combo combo_1 = new Combo(composite_1, SWT.NONE); combo_1.setItems(new String[] { "HTTP/1.1", "HTTP/1.0" }); FormData fd_combo_1 = new FormData(); fd_combo_1.left = new FormAttachment(lblProtocol, 6); fd_combo_1.top = new FormAttachment(0, 10); combo_1.setLayoutData(fd_combo_1); formToolkit.adapt(combo_1); formToolkit.paintBordersFor(combo_1); Label lblNewLabel = formToolkit.createLabel(composite_1, "Web URL:", SWT.NONE); fd_combo_1.right = new FormAttachment(lblNewLabel, -6); combo_1.setText("HTTP/1.1"); FormData fd_lblNewLabel = new FormData(); fd_lblNewLabel.bottom = new FormAttachment(0, 31); fd_lblNewLabel.right = new FormAttachment(0, 337); fd_lblNewLabel.top = new FormAttachment(0, 16); fd_lblNewLabel.left = new FormAttachment(0, 282); lblNewLabel.setLayoutData(fd_lblNewLabel); Label lblPostData = formToolkit.createLabel(composite_1, "Post Data:", SWT.NONE); FormData fd_lblPostData = new FormData(); fd_lblPostData.bottom = new FormAttachment(0, 63); fd_lblPostData.right = new FormAttachment(0, 337); fd_lblPostData.top = new FormAttachment(0, 48); fd_lblPostData.left = new FormAttachment(0, 282); lblPostData.setLayoutData(fd_lblPostData); Button btnCheckButton = new Button(composite_1, SWT.CHECK); FormData fd_btnCheckButton = new FormData(); fd_btnCheckButton.right = new FormAttachment(lblPostData, -27); fd_btnCheckButton.bottom = new FormAttachment(lblPostData, 0, SWT.BOTTOM); btnCheckButton.setLayoutData(fd_btnCheckButton); formToolkit.adapt(btnCheckButton, true, true); btnCheckButton.setText("Enable Post Data"); ResponseData = new Text(composite_1, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI); FormData fd_ResponseData = new FormData(); fd_ResponseData.top = new FormAttachment(lblPostData, 6); fd_ResponseData.left = new FormAttachment(0, 10); fd_ResponseData.bottom = new FormAttachment(100, -10); fd_ResponseData.right = new FormAttachment(100, -10); ResponseData.setLayoutData(fd_ResponseData); formToolkit.adapt(ResponseData, true, true); Label lblNewLabel_1 = formToolkit.createLabel(composite_1, "Response Data:", SWT.NONE); fd_btnCheckButton.left = new FormAttachment(0, 117); FormData fd_lblNewLabel_1 = new FormData(); fd_lblNewLabel_1.left = new FormAttachment(0, 10); fd_lblNewLabel_1.right = new FormAttachment(lblPostData, -171); fd_lblNewLabel_1.bottom = new FormAttachment(0, 63); fd_lblNewLabel_1.top = new FormAttachment(0, 48); lblNewLabel_1.setLayoutData(fd_lblNewLabel_1); Combo ComboMethod = new Combo(composite_1, SWT.NONE); ComboMethod.setItems(new String[] { "GET", "POST" }); fd_lblProtocol.left = new FormAttachment(ComboMethod, 6); FormData fd_ComboMethod = new FormData(); fd_ComboMethod.right = new FormAttachment(0, 128); fd_ComboMethod.top = new FormAttachment(0, 10); fd_ComboMethod.left = new FormAttachment(0, 66); ComboMethod.setLayoutData(fd_ComboMethod); formToolkit.adapt(ComboMethod); formToolkit.paintBordersFor(ComboMethod); ComboMethod.setText("GET"); WebURL = new Text(composite_1, SWT.BORDER); WebURL.setText("http://www.exploitpack.com/"); FormData fd_WebURL = new FormData(); fd_WebURL.top = new FormAttachment(0, 12); fd_WebURL.left = new FormAttachment(lblNewLabel, 6); WebURL.setLayoutData(fd_WebURL); formToolkit.adapt(WebURL, true, true); Button GoWebFuzz = new Button(composite_1, SWT.NONE); GoWebFuzz.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { // Create a URL to check app version URL url = new URL(WebURL.getText()); // Read all the text returned by the server BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); ResponseData.setText(""); while ((in.readLine() != null)) { if (in.readLine() != null) { ResponseData.append(in.readLine() + "\n"); } if (in.readLine() == "null") { return; } } } catch (Exception e2) { System.out.println(e2); } } }); fd_WebURL.right = new FormAttachment(GoWebFuzz, -6); FormData fd_GoWebFuzz = new FormData(); fd_GoWebFuzz.left = new FormAttachment(ResponseData, -79); fd_GoWebFuzz.right = new FormAttachment(ResponseData, 0, SWT.RIGHT); fd_GoWebFuzz.top = new FormAttachment(0, 10); GoWebFuzz.setLayoutData(fd_GoWebFuzz); formToolkit.adapt(GoWebFuzz, true, true); GoWebFuzz.setText("Go"); PostData = new Text(composite_1, SWT.BORDER); FormData fd_PostData = new FormData(); fd_PostData.right = new FormAttachment(ResponseData, 0, SWT.RIGHT); fd_PostData.bottom = new FormAttachment(ResponseData, -6); fd_PostData.left = new FormAttachment(lblPostData, 6); PostData.setLayoutData(fd_PostData); formToolkit.adapt(PostData, true, true); TabItem tbtmBrowser = new TabItem(tabFolder, SWT.NONE); tbtmBrowser.setText("Web Browser"); Composite composite_6 = new Composite(tabFolder, SWT.NONE); tbtmBrowser.setControl(composite_6); formToolkit.paintBordersFor(composite_6); Label lblNewLabel_5 = new Label(composite_6, SWT.NONE); lblNewLabel_5.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/updatebrowser.png")); lblNewLabel_5.setBounds(954, 15, 16, 15); formToolkit.adapt(lblNewLabel_5, true, true); final Browser EBrowser = new Browser(composite_6, SWT.BORDER); EBrowser.setUrl("http://exploitpack.com"); EBrowser.setBounds(0, 37, 1069, 398); formToolkit.adapt(EBrowser); formToolkit.paintBordersFor(EBrowser); Button btnBrowser = new Button(composite_6, SWT.NONE); btnBrowser.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { EBrowser.setUrl(URLBrowser.getText()); } }); btnBrowser.setBounds(981, 10, 78, 25); formToolkit.adapt(btnBrowser, true, true); btnBrowser.setText("Go"); URLBrowser = new Text(composite_6, SWT.BORDER); URLBrowser.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { int code = e.keyCode; if (code == 13) { EBrowser.setUrl(URLBrowser.getText()); } } }); tltmVisitWebsiteJs.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { EBrowser.setUrl("http://exploitpack.com"); } }); URLBrowser.setText("http://www.exploitpack.com"); URLBrowser.setBounds(10, 12, 965, 21); formToolkit.adapt(URLBrowser, true, true); TabItem tbtmCheckWebsite = new TabItem(tabFolder, SWT.NONE); tbtmCheckWebsite.setText("Check Website"); Composite composite_7 = new Composite(tabFolder, SWT.NONE); tbtmCheckWebsite.setControl(composite_7); formToolkit.paintBordersFor(composite_7); Label label = new Label(composite_7, SWT.NONE); label.setText("Check this website for me:"); label.setBounds(10, 15, 139, 15); formToolkit.adapt(label, true, true); Label label_1 = new Label(composite_7, SWT.NONE); label_1.setText("Website status:"); label_1.setBounds(10, 44, 79, 15); formToolkit.adapt(label_1, true, true); final Browser checksiteBrowser = new Browser(composite_7, SWT.NONE); checksiteBrowser.setBounds(10, 65, 1049, 360); checksiteBrowser.setUrl("http://exploitpack.com"); formToolkit.adapt(checksiteBrowser); formToolkit.paintBordersFor(checksiteBrowser); urlToCheck = new Text(composite_7, SWT.BORDER); urlToCheck.setBounds(155, 12, 823, 21); urlToCheck.setText("http://exploitpack.com"); formToolkit.adapt(urlToCheck, true, true); final Label imgUP = new Label(composite_7, SWT.NONE); imgUP.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/webup.gif")); imgUP.setBounds(95, 36, 24, 23); formToolkit.adapt(imgUP, true, true); final Label siteStatusText = new Label(composite_7, SWT.NONE); siteStatusText.setText("It's just you"); siteStatusText.setBounds(125, 44, 409, 15); siteStatusText.setText("It's just you " + urlToCheck.getText() + " looks up from here"); formToolkit.adapt(siteStatusText, true, true); Label imgDOWN = new Label(composite_7, SWT.NONE); imgDOWN.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/webdown.gif")); imgDOWN.setBounds(95, 36, 24, 23); formToolkit.adapt(imgDOWN, true, true); Button button = new Button(composite_7, SWT.NONE); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // Show website checksiteBrowser.setUrl(urlToCheck.getText()); try { // Create a URL to check availability URL url = new URL("http://www.isup.me/" + urlToCheck.getText()); // Read all the text returned by the server BufferedReader in = new BufferedReader( new InputStreamReader(url.openStream())); String upornot; while ((upornot = in.readLine()) != null) { if (upornot.contains("It's not just you! ")) { imgUP.setVisible(false); siteStatusText .setText("It's not just you " + urlToCheck.getText() + " looks down from here"); checksiteBrowser.setUrl("http://www.exploitpack.com/dostest.html"); System.out.println("DOWN"); break; } else { imgUP.setVisible(true); siteStatusText.setText("It's just you " + urlToCheck.getText() + " looks up from here"); System.out.println("UP"); } System.out.println(upornot); } in.close(); } catch (MalformedURLException e1) { } catch (IOException e1) { } } }); button.setText("Check"); button.setBounds(984, 10, 75, 25); formToolkit.adapt(button, true, true); Label lblUsingIsupmeAs = new Label(composite_7, SWT.NONE); lblUsingIsupmeAs.setBounds(902, 44, 157, 15); formToolkit.adapt(lblUsingIsupmeAs, true, true); lblUsingIsupmeAs.setText("as engine to check availability"); Label lblUsing = new Label(composite_7, SWT.NONE); lblUsing.setBounds(817, 44, 30, 15); formToolkit.adapt(lblUsing, true, true); lblUsing.setText("Using"); Label lblIsupme = new Label(composite_7, SWT.NONE); lblIsupme.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD)); lblIsupme.setBounds(853, 44, 43, 15); formToolkit.adapt(lblIsupme, true, true); lblIsupme.setText("isup.me"); TabItem tbtmNewItem_1 = new TabItem(tabFolder, SWT.NONE); tbtmNewItem_1.setText("Changelog"); Composite composite_2 = new Composite(tabFolder, SWT.NONE); tbtmNewItem_1.setControl(composite_2); composite_2.setLayout(new FormLayout()); Browser News = new Browser(composite_2, SWT.NONE); FormData fd_News = new FormData(); fd_News.bottom = new FormAttachment(100); fd_News.right = new FormAttachment(100); fd_News.top = new FormAttachment(0); fd_News.left = new FormAttachment(0); News.setLayoutData(fd_News); News.setUrl("http://exploitpack.com/changelog/"); banner = new CBanner(shlExploitPack, SWT.NONE); FormData fd_banner = new FormData(); fd_banner.top = new FormAttachment(0, 3); fd_banner.left = new FormAttachment(0, 662); banner.setLayoutData(fd_banner); TabFolder InfoLogFolder = new TabFolder(shlExploitPack, SWT.NONE); FormData fd_InfoLogFolder = new FormData(); fd_InfoLogFolder.bottom = new FormAttachment(0, 662); fd_InfoLogFolder.right = new FormAttachment(0, 1360); fd_InfoLogFolder.top = new FormAttachment(0, 508); fd_InfoLogFolder.left = new FormAttachment(0, 283); InfoLogFolder.setLayoutData(fd_InfoLogFolder); TabItem tbtmNewItem_2 = new TabItem(InfoLogFolder, SWT.NONE); tbtmNewItem_2.setText("Quick Information"); Composite composite_3 = new Composite(InfoLogFolder, SWT.NONE); tbtmNewItem_2.setControl(composite_3); formToolkit.paintBordersFor(composite_3); composite_3.setLayout(new FormLayout()); // Load of Quick Information QuickInformation = new Text(composite_3, SWT.BORDER | SWT.MULTI); QuickInformation.setLayoutData(new FormData()); QuickInformation.setText("[" + LogTime + "]" + " Application started\n"); QuickInformation.append("[" + LogTime + "]" + " Internals check: Ok\n"); QuickInformation.append("[" + LogTime + "]" + " Running...\n"); FormData fd_QuickInformation = new FormData(); fd_QuickInformation.left = new FormAttachment(0); fd_QuickInformation.right = new FormAttachment(100); fd_QuickInformation.bottom = new FormAttachment(100); fd_QuickInformation.top = new FormAttachment(0); QuickInformation.setLayoutData(fd_QuickInformation); formToolkit.adapt(QuickInformation, true, true); TabItem tbtmNewItem_3 = new TabItem(InfoLogFolder, SWT.NONE); tbtmNewItem_3.setText("Application Log"); Composite composite_4 = new Composite(InfoLogFolder, SWT.NONE); tbtmNewItem_3.setControl(composite_4); formToolkit.paintBordersFor(composite_4); composite_4.setLayout(new FormLayout()); ApplicationLog = new Text(composite_4, SWT.BORDER | SWT.MULTI); FormData fd_ApplicationLog = new FormData(); fd_ApplicationLog.top = new FormAttachment(0); fd_ApplicationLog.bottom = new FormAttachment(100); fd_ApplicationLog.right = new FormAttachment(100); fd_ApplicationLog.left = new FormAttachment(0); ApplicationLog.setLayoutData(fd_ApplicationLog); formToolkit.adapt(ApplicationLog, true, true); TabItem tbtmNewItem_4 = new TabItem(InfoLogFolder, SWT.NONE); tbtmNewItem_4.setText("Debug Log"); Composite composite_5 = new Composite(InfoLogFolder, SWT.NONE); tbtmNewItem_4.setControl(composite_5); formToolkit.paintBordersFor(composite_5); composite_5.setLayout(new FormLayout()); DebugLog = new Text(composite_5, SWT.BORDER | SWT.MULTI); FormData fd_DebugLog = new FormData(); fd_DebugLog.bottom = new FormAttachment(100); fd_DebugLog.right = new FormAttachment(100); fd_DebugLog.top = new FormAttachment(0); fd_DebugLog.left = new FormAttachment(0); DebugLog.setLayoutData(fd_DebugLog); // Load of Application Log ApplicationLog.setText("[" + LogTime + "]" + " Log started\n"); ApplicationLog.append("[" + LogTime + "]" + " Internals check: OK\n"); ApplicationLog.append("[" + LogTime + "]" + " Running...\n"); // Load of Debug Log DebugLog.setText("[" + LogTime + "]" + " Debug Log started\n"); DebugLog.append("[" + LogTime + "]" + " Internals check: OK\n"); DebugLog.append("[" + LogTime + "]" + " Running...\n"); formToolkit.adapt(DebugLog, true, true); btnLaunch = new Button(shlExploitPack, SWT.NONE); FormData fd_btnLaunch = new FormData(); fd_btnLaunch.right = new FormAttachment(0, 277); fd_btnLaunch.left = new FormAttachment(0, 10); btnLaunch.setLayoutData(fd_btnLaunch); TreeExploits = new Tree(shlExploitPack, SWT.SINGLE | SWT.BORDER); fd_btnLaunch.bottom = new FormAttachment(TreeExploits, 31, SWT.BOTTOM); fd_btnLaunch.top = new FormAttachment(TreeExploits, 6); FormData fd_TreeExploits = new FormData(); fd_TreeExploits.bottom = new FormAttachment(0, 631); fd_TreeExploits.top = new FormAttachment(0, 95); fd_TreeExploits.right = new FormAttachment(0, 277); fd_TreeExploits.left = new FormAttachment(0, 10); TreeExploits.setLayoutData(fd_TreeExploits); TreeExploits.setToolTipText("Modules Explorer - Exploits and Tools"); // SELECCION DEL ARBOL TreeExploits.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event e) { try { ExploitSelection = ""; TreeItem[] selection = TreeExploits.getSelection(); for (int i = 0; i < selection.length; i++) ExploitSelection += selection[i]; ExploitSelection = ExploitSelection.replaceAll("TreeItem", ""); ExploitSelection = ExploitSelection.toString().replaceAll("\\{", ""); ExploitSelection = ExploitSelection.toString().replaceAll("\\}", ""); ExploitSelection = ExploitSelection.toString().substring(1, ExploitSelection.length()); // Check if the selected item is part of these categories if (ExploitSelection.equals("Exploits") || ExploitSelection.equals("Windows") || ExploitSelection.equals("BSD") || ExploitSelection.equals("Unix") || ExploitSelection.equals("Linux") || ExploitSelection.equals("Tools") || ExploitSelection.equals("Search") || ExploitSelection.equals("History")) { return; } else { if (LastTreeItemSelected != null) { LastTreeItemSelected.setImage( SWTResourceManager.getImage(MainWindow.class, "/resources/square_redS.gif")); } TreeItem ItemSelected = TreeExploits.getSelection()[0]; ItemSelected.setImage( SWTResourceManager.getImage(MainWindow.class, "/resources/square_yellowS.gif")); LastTreeItemSelected = ItemSelected; // QuickInformation ExploitSelection = ExploitSelection.concat(".xml"); try { // Clean QuickInformation QuickInformation.setText(""); // Start de la clase main de XMLTreenode NewXMLNode.main(null, ExploitSelection); QuickInformation.append("Exploit Name: " + NewXMLNode.ExploitName + " "); QuickInformation.append("Author: " + NewXMLNode.Author + "\n"); QuickInformation.append("Type: " + NewXMLNode.ExploitType + "\n"); QuickInformation.append("CVE: " + NewXMLNode.Vulnerability + "\n"); QuickInformation.append("Disclosure Date: " + NewXMLNode.Date); QuickInformation.append(NewXMLNode.Information); // Set variables from XML ExploitModule = NewXMLNode.ExploitName; ExploitCodeName = NewXMLNode.CodeName; ExploitType = NewXMLNode.ExploitType; ExploitPlatform = NewXMLNode.Platform; Service = NewXMLNode.Service; AgentPort = NewXMLNode.ShellPort; TargetPort.setText(NewXMLNode.RemotePort); TargetLPort.setText(NewXMLNode.LocalPort); // Set shellcodes for comboshell // but first initialize combo :D ShellcodeCombo.removeAll(); ShellcodeCombo.setText("Select"); // Load available shellcodes if (NewXMLNode.ShellcodeAvailable.contains("R")) { ShellcodeCombo.add("Remote Shell"); } if (NewXMLNode.ShellcodeAvailable.contains("E")) { ShellcodeCombo.add("Execute Code"); } if (NewXMLNode.ShellcodeAvailable.contains("C")) { ShellcodeCombo.add("Command"); } if (NewXMLNode.ShellcodeAvailable.contains("L")) { ShellcodeCombo.add("Local Shell"); } } catch (Exception e2) { System.out.print("Sorry error parsing XML" + e2); } } } catch (Exception e2) { System.out.println(e2); } } }); btnLaunch.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // Reproduce the wav file when the module is launched try { // Instance a new sound clip Clip sound = AudioSystem.getClip(); // Open Wav file sound.open(AudioSystem.getAudioInputStream(new File("data/newagent.wav"))); // Start reproduction sound.start(); // Wait until it finished while (sound.isRunning()) Thread.sleep(2000); // Close stream sound.close(); } catch (Exception e2) { System.out.println(e); } if (ExploitSelection.equals("Exploits") || ExploitSelection.equals("Windows") || ExploitSelection.equals("BSD") || ExploitSelection.equals("Unix") || ExploitSelection.equals("Linux") || ExploitSelection.equals("Tools") || ExploitSelection.equals("Search") || ExploitSelection.equals("History")) { MessageBox messageBox = new MessageBox(shlExploitPack, SWT.ICON_ERROR | SWT.OK); messageBox.setMessage("Sorry, you have to choose a module to launch"); messageBox.setText("No Module Selected"); messageBox.open(); return; } // Check if shellcodecombobox has a shellcode selected if (!ExploitType.toString().equals("tool")) { if (ShellcodeCombo.getText().equals("Select")) { MessageBox messageBox = new MessageBox(shlExploitPack, SWT.ICON_ERROR | SWT.OK); messageBox.setMessage("Sorry, you have to choose a shellcode from available list"); messageBox.setText("No shellcode Selected"); messageBox.open(); return; } } // Obtain Python Path try { // Read file FileReader fstream = new FileReader("data/config/exploitpack.config"); BufferedReader in = new BufferedReader(fstream); pythonFullPath = in.readLine() + "\n"; System.out.print(pythonFullPath); // Close the output stream in.close(); } catch (Exception e1) { // Catch exception if any Preferences.main(null); System.err.println("Error: " + e1.getMessage()); } // Port Scanner ToDo: Add threads and signature detection // Try to make nmap work here, ensure Nmap license is compatible // with GPL v3 if (ExploitCodeName.equals("Remote-Scanner")) { // PortScanner junk code // TODO Make the scanner, this is just a test for (port = 1023; port <= 65000; port++) try { Socket socket = new Socket(); socket.bind(null); socket.connect(new InetSocketAddress(TargetHost.getText(), port), 140); socket.close(); System.out.println("PortAAA: " + port); // // Add Available Targets TreeItem NewTarget = new TreeItem(OpenPorts, SWT.NONE, 0); NewTarget.setText("Port: " + port); NewTarget .setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/port.png")); OpenPorts.setExpanded(true); ports.add(port); } catch (IOException ex) { System.out.println(ex); } int portList = ports.size(); System.out.println("Total Ports: " + portList); // End PortScanner junk code return; } // Lauch the desire exploit Runtime RunModule = Runtime.getRuntime(); // Instance OSValidator OSValidator CheckOS = new OSValidator(); CheckOS.main(null); OSType = OSValidator.OSType; // Local VAR for ModuleType String RunModuleByType = null; // Local VAR Shellcode selected String ShellcodeSelected = null; // Shellcode remote shell if (ShellcodeCombo.getText().equals("Remote Shell")) { ShellcodeSelected = "R"; DebugLog.append("Shellcode selected" + ShellcodeCombo.getText()); } // Shellcode execute code if (ShellcodeCombo.getText().equals("Execute Code")) { ShellcodeSelected = "E"; DebugLog.append("Shellcode selected" + ShellcodeCombo.getText()); } // Shellcode command if (ShellcodeCombo.getText().equals("Command")) { ShellcodeSelected = "C"; DebugLog.append("Shellcode selected" + ShellcodeCombo.getText()); } // Shellcode local if (ShellcodeCombo.getText().equals("Local Shell")) { ShellcodeSelected = "L"; DebugLog.append("Shellcode selected" + ShellcodeCombo.getText()); } // Shellcode local if (ShellcodeCombo.getText().equals("Select") || ShellcodeCombo.getText().equals("")) { ShellcodeSelected = "N"; DebugLog.append("Shellcode selected" + ShellcodeCombo.getText()); } if (OSType.equals("Win")) { // Execute exploit WINDOWS DebugLog.append("I'm running in a windows system"); try { // Set exec options for remote if (ExploitType.equals("remote")) { RunModuleByType = "cmd.exe /T:0A /K start " + pythonFullPath + " \"exploits/code/" + ExploitCodeName + "\"" + " " + TargetHost.getText() + " " + TargetPort.getText() + " " + ShellcodeSelected; } // Set exec options for clientside if (ExploitType.equals("clientside")) { RunModuleByType = "cmd.exe /T:0A /K start python " + pythonFullPath + " \"exploits/code/" + ExploitCodeName + "\"" + " " + TargetLhost.getText() + " " + TargetLPort.getText() + " " + ShellcodeSelected; // Add location information to ShellcodeConsole ShellcodeConsole.append("=> New client-side exploit file created\n"); ShellcodeConsole.append("=> File located at: code/output/\n"); } // Set exec options for local if (ExploitType.equals("local")) { RunModuleByType = "cmd.exe /T:0A /K start " + pythonFullPath + " \"exploits/code/" + ExploitCodeName + "\"" + " " + TargetHost.getText() + " " + TargetPort.getText() + " " + ShellcodeSelected; } // Set exec options for remote if (ExploitType.equals("tool")) { RunModuleByType = "cmd.exe /T:0A /K start " + pythonFullPath + " \"exploits/code/" + ExploitCodeName + "\"" + " " + TargetHost.getText() + " " + TargetPort.getText(); } // Print output for exec string value DebugLog.append(RunModuleByType); // Finally exec module RunModule.exec(RunModuleByType); } catch (IOException e1) { System.out.println(e1); } } else if (OSType.equals("Unix")) { // Execute exploit LINUX try { // Set exec options for remote if (ExploitType.equals("remote")) { RunModuleByType = "python " + "\"exploits/code/" + ExploitCodeName + "\"" + " " + TargetHost.getText() + " " + TargetPort.getText() + " " + ShellcodeSelected; } // Set exec options for clientside if (ExploitType.equals("clientside")) { RunModuleByType = "python " + "\"exploits/code/" + ExploitCodeName + "\"" + " " + TargetLhost.getText() + " " + TargetLPort.getText() + " " + ShellcodeSelected; // Add location information to ShellcodeConsole ShellcodeConsole.append("=> New client-side exploit file created\n"); ShellcodeConsole.append("=> File located at: code/output/\n"); } // Set exec options for local if (ExploitType.equals("local")) { RunModuleByType = "python " + "\"exploits/code/" + ExploitCodeName + "\"" + " " + TargetHost.getText() + " " + TargetPort.getText() + " " + ShellcodeSelected; } // Print output for exec string value DebugLog.append(RunModuleByType); // Finally exec module RunModule.exec(RunModuleByType); System.out.println(RunModuleByType); } catch (IOException e1) { e1.printStackTrace(); } } else { DebugLog.append("This OS is not supported"); return; } // Add to shellcodeconsole if (!TargetHost.getText().equals("")) { if (ShellcodeCombo.getText().equals("Remote Shell")) { ShellcodeConsole.append("=> Connect to? " + "[" + TargetHost.getText() + "]\n"); ShellcodeConsole.append("=> [y/n]\n"); // Add Available Targets TreeItem NewTarget = new TreeItem(AvailableTargets, SWT.NONE, 0); NewTarget.setText(TargetHost.getText()); NewTarget.setImage(SWTResourceManager.getImage( MainWindow.class, "/resources/terminal.png")); AvailableTargets.setExpanded(true); } } // Add Log to modules log TreeItem ModulesModLog0 = new TreeItem(ModulesLog, SWT.NONE, 1); ModulesModLog0.setText(ExploitModule.toString()); ModulesModLog0.setImage(SWTResourceManager.getImage( MainWindow.class, "/resources/binary.png")); // Expand modules log ModulesLogNode.setExpanded(true); // Add Log to executed modules TreeItem ExecuteModLog0 = new TreeItem(ExecuteModulesNode, SWT.NONE, 0); ExecuteModLog0.setText("[" + LogTime + "]" + " " + "Beggining execution of: " + ExploitModule); ExecuteModLog0 .setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/application.png")); TreeItem ExecuteModLog1 = new TreeItem(ExecuteModulesNode, SWT.NONE, 1); ExecuteModLog1.setText("[" + LogTime + "]" + " " + "Exploiting trough host: " + ipAddrStr); ExecuteModLog1.setImage(SWTResourceManager.getImage( MainWindow.class, "/resources/application.png")); TreeItem ExecuteModLog2 = new TreeItem(ExecuteModulesNode, SWT.NONE, 2); ExecuteModLog2.setText("[" + LogTime + "]" + " " + "Module launched: " + ExploitModule); ExecuteModLog2 .setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/application.png")); // Expand executed modules ExecuteModulesNode.setExpanded(true); } }); btnLaunch.setText("Launch"); TreeItem NodeExploits = new TreeItem(TreeExploits, SWT.NONE, 0); NodeExploits.setText("Exploits"); NodeExploits.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/folder.png")); final TreeItem WindowsExploits = new TreeItem(NodeExploits, SWT.NONE, 0); WindowsExploits.setText("Windows"); WindowsExploits.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/folder.png")); final TreeItem LinuxExploits = new TreeItem(NodeExploits, SWT.NONE, 1); LinuxExploits.setText("Linux"); LinuxExploits.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/folder.png")); final TreeItem UnixExploits = new TreeItem(NodeExploits, 0, 2); UnixExploits.setText("Unix"); UnixExploits.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/folder.png")); final TreeItem BSDExploits = new TreeItem(NodeExploits, 0, 3); BSDExploits.setText("BSD"); BSDExploits.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/folder.png")); NodeExploits.setExpanded(true); TreeItem ToolList = new TreeItem(TreeExploits, SWT.NONE, 1); ToolList.setText("Tools"); ToolList.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/folder.png")); // TODO un-fix this values TreeItem PortScanner = new TreeItem(ToolList, SWT.NONE, 0); PortScanner.setText("Remote-Scanner"); PortScanner.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/square_redS.gif")); TreeItem DenialOfService = new TreeItem(ToolList, SWT.NONE, 1); DenialOfService.setText("Denial-Of-Service"); DenialOfService.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/square_redS.gif")); final TreeItem SearchExploits = new TreeItem(TreeExploits, SWT.NONE, 2); SearchExploits.setText("Search"); SearchExploits.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/modulesearch.png")); SearchExploits.setExpanded(true); final TreeItem SearchHistory = new TreeItem(TreeExploits, SWT.NONE, 3); SearchHistory.setText("History"); SearchHistory.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/history.png")); SearchHistory.setExpanded(true); // GENERO EL ARBOL String path = "exploits/"; String files; File folder = new File(path); File[] listOfFiles = folder.listFiles(); QuickInformation.append("[" + LogTime + "] " + "Modules Successfully Loaded: Ok" + "\n"); for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].isFile()) { files = listOfFiles[i].getName(); if (files.endsWith(".xml") || files.endsWith(".XML")) { // Instancio XMLTreenode XMLTreenode NewXMLNode = new XMLTreenode(); // Start de la clase main de XMLTreenode NewXMLNode.main(null, files); // Create tree item // Create Windows Exploits if (NewXMLNode.Platform.equals("windows")) { TreeItem ItemName = new TreeItem(WindowsExploits, SWT.NONE); ItemName.setText(NewXMLNode.ExploitName); ItemName.setImage( SWTResourceManager.getImage(MainWindow.class, "/resources/square_redS.gif")); } if (NewXMLNode.Platform.equals("linux")) { // Create Linux Exploits TreeItem ItemName = new TreeItem(LinuxExploits, SWT.NONE); ItemName.setText(NewXMLNode.ExploitName); ItemName.setImage( SWTResourceManager.getImage(MainWindow.class, "/resources/square_redS.gif")); } // Create Unix Exploits if (NewXMLNode.Platform.equals("unix")) { // Create Linux Exploits TreeItem ItemName = new TreeItem(UnixExploits, SWT.NONE); ItemName.setText(NewXMLNode.ExploitName); ItemName.setImage( SWTResourceManager.getImage(MainWindow.class, "/resources/square_redS.gif")); } // Create BSD Exploits if (NewXMLNode.Platform.equals("bsd")) { // Create Linux Exploits TreeItem ItemName = new TreeItem(UnixExploits, SWT.NONE); ItemName.setText(NewXMLNode.ExploitName); ItemName.setImage( SWTResourceManager.getImage(MainWindow.class, "/resources/square_redS.gif")); } // Obtain total modules TotalModulesLength = i; // QuickInformation.append("[" + LogTime + "] "+ // NewXMLNode.ExploitName + " "); } } } QuickInformation.append("[" + LogTime + "] " + "Total Modules: " + TotalModulesLength); // REFRESH MODULES TREE mntmRefreshModules.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // GENERO EL ARBOL String path = "exploits/"; String files; File folder = new File(path); File[] listOfFiles = folder.listFiles(); for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].isFile()) { files = listOfFiles[i].getName(); if (files.endsWith(".xml") || files.endsWith(".XML")) { // Instancio XMLTreenode XMLTreenode NewXMLNode = new XMLTreenode(); // Start de la clase main de XMLTreenode NewXMLNode.main(null, files); // Create tree item // Create Windows Exploits if (NewXMLNode.Platform.equals("windows")) { TreeItem ItemName = new TreeItem(WindowsExploits, SWT.NONE); ItemName.setText(NewXMLNode.ExploitName); ItemName.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/square_redS.gif")); } if (NewXMLNode.Platform.equals("linux")) { // Create Linux Exploits TreeItem ItemName = new TreeItem(LinuxExploits, SWT.NONE); ItemName.setText(NewXMLNode.ExploitName); ItemName.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/square_redS.gif")); } // Create Unix Exploits if (NewXMLNode.Platform.equals("unix")) { // Create Linux Exploits TreeItem ItemName = new TreeItem(UnixExploits, SWT.NONE); ItemName.setText(NewXMLNode.ExploitName); ItemName.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/square_redS.gif")); } // Create BSD Exploits if (NewXMLNode.Platform.equals("bsd")) { // Create Linux Exploits TreeItem ItemName = new TreeItem(BSDExploits, SWT.NONE); ItemName.setText(NewXMLNode.ExploitName); ItemName.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/square_redS.gif")); } } } } for (int PortNumber : OpenPortsList) { // Add Available Targets TreeItem NewTarget = new TreeItem(OpenPorts, SWT.NONE, 0); NewTarget.setText("Port: " + PortNumber); NewTarget.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/port.png")); OpenPorts.setExpanded(true); } } }); Composite SearchComposite = new Composite(shlExploitPack, SWT.NONE); FormData fd_SearchComposite = new FormData(); fd_SearchComposite.bottom = new FormAttachment(0, 89); fd_SearchComposite.top = new FormAttachment(0, 66); fd_SearchComposite.left = new FormAttachment(0, 10); SearchComposite.setLayoutData(fd_SearchComposite); formToolkit.adapt(SearchComposite); formToolkit.paintBordersFor(SearchComposite); final Label SearchImage = new Label(SearchComposite, SWT.NONE); SearchImage.setBounds(10, 6, 13, 13); SearchImage.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/search.gif")); formToolkit.adapt(SearchImage, true, true); // MODULE SEARCH SearchCombo = new Combo(SearchComposite, SWT.NONE); SearchCombo.setBounds(0, 1, 267, 21); SearchCombo.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { String SearchInput = SearchCombo.getText().toLowerCase(); // GENERO EL ARBOL String path = "exploits/"; String files; File folder = new File(path); File[] listOfFiles = folder.listFiles(); // Remove ALL SearchExploits.removeAll(); for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].isFile()) { files = listOfFiles[i].getName(); if (files.endsWith(".xml") || files.endsWith(".XML")) { // Instancio XMLTreenode XMLTreenode NewXMLNode = new XMLTreenode(); // Start de la clase main de XMLTreenode NewXMLNode.main(null, files); // Do nothing if search input contains word null if (SearchInput.toString().contains("null")) { SearchCombo.setText(" Sorry, try again"); SearchImage.setVisible(true); return; } // Condition for search if (NewXMLNode.ExploitName.equals(SearchInput) || NewXMLNode.Service.equals(SearchInput) || NewXMLNode.ExploitType.equals(SearchInput)) { // Create tree item TreeItem ItemName = new TreeItem(SearchExploits, SWT.NONE); ItemName.setText(NewXMLNode.ExploitName); ItemName.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/square_redS.gif")); SearchExploits.setExpanded(true); // Create tree item TreeItem ItemName1 = new TreeItem(SearchHistory, SWT.NONE); ItemName1.setText(NewXMLNode.ExploitName); ItemName1.setImage(SWTResourceManager.getImage(MainWindow.class, "/resources/square_redS.gif")); SearchHistory.setExpanded(true); SearchCombo.setText(" Search Modules"); SearchImage.setVisible(true); } } } } } }); SearchCombo.setItems(new String[] { "Show All Services: Type", "Show by Port Number: 123 ", "Show by Type: Remote", "Show by Type: Local", "Show by Type: Client-Side" }); formToolkit.adapt(SearchCombo); formToolkit.paintBordersFor(SearchCombo); SearchCombo.setText(" Search Modules"); SearchCombo.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { SearchCombo.setText(""); SearchImage.setVisible(false); } }); txtModulesExplorer = new Text(shlExploitPack, SWT.BORDER); FormData fd_txtModulesExplorer = new FormData(); fd_txtModulesExplorer.right = new FormAttachment(0, 277); fd_txtModulesExplorer.top = new FormAttachment(0, 39); fd_txtModulesExplorer.left = new FormAttachment(0, 10); txtModulesExplorer.setLayoutData(fd_txtModulesExplorer); txtModulesExplorer.setBackground(SWTResourceManager.getColor(245, 245, 245)); txtModulesExplorer.setText("Modules Explorer"); }
From source file:com.freescale.deadlockpreventer.agent.LauncherView.java
License:Open Source License
private void createConflictsPart(Composite conflicts) { viewer = new TreeViewer(conflicts, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); layoutData.horizontalSpan = 3;//from w w w .j a v a 2s . co m viewer.getControl().setLayoutData(layoutData); viewer.setContentProvider(new ViewContentProvider()); viewer.setLabelProvider(new ViewLabelProvider()); viewer.getControl().setLayoutData(layoutData); viewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { Object element = getSelection().getFirstElement(); if (element != null) { if (element instanceof Conflict) showInEditor((Conflict) element); if (element instanceof InstrumentedProcess) ((InstrumentedProcess) element).displayStatistics(); } } }); viewer.getControl().addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.keyCode == SWT.DEL) { Iterator<?> it = getSelection().iterator(); while (it.hasNext()) { Object obj = it.next(); if (obj instanceof Conflict) ((Conflict) obj).remove(); if (obj instanceof InstrumentedProcess) processes.remove(obj); } viewer.refresh(); } } }); final Menu menu = new Menu(conflicts.getShell(), SWT.POP_UP); viewer.getControl().setMenu(menu); MenuItem menuItem = new MenuItem(menu, SWT.PUSH); menuItem.setText("Statistics..."); menu.addListener(SWT.Show, new Listener() { public void handleEvent(Event event) { boolean isAProcess = selectionIsAProcess(); for (MenuItem item : menu.getItems()) item.setEnabled(isAProcess); } private boolean selectionIsAProcess() { Iterator<?> it = getSelection().iterator(); while (it.hasNext()) { Object obj = it.next(); if (!(obj instanceof InstrumentedProcess)) return false; } return true; } }); menuItem.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { displayStatistics(); } }); menuItem = new MenuItem(menu, SWT.PUSH); menuItem.setText("Download Global Lock State..."); menuItem.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { downloadGlobalLockState(); } }); displayWarning = new Button(conflicts, SWT.CHECK); displayWarning.setText("Display warnings"); displayWarning.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); displayWarning.setSelection(Boolean.parseBoolean(InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID) .get(PREF_DISPLAY_WARNINGS, Boolean.toString(false)))); displayWarning.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID).put(PREF_DISPLAY_WARNINGS, Boolean.toString(displayWarning.getSelection())); viewer.refresh(); } }); Button editFilters = new Button(conflicts, SWT.PUSH); editFilters.setText("Filters..."); editFilters.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); editFilters.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { String filtersString = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID).get(PREF_DISPLAY_FILTERS, defaultFilters); InputDialog dlg = new InputDialog(getSite().getShell(), "Conflict filters", "Conflicts matching the following list of regular expressions separated by semi-colons (;) will not be displayed:", filtersString, new FilterValidator()); if (dlg.open() == Window.OK) InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID).put(PREF_DISPLAY_FILTERS, dlg.getValue()); viewer.refresh(); } }); Button copyToClipBoard = new Button(conflicts, SWT.PUSH); copyToClipBoard.setText("Copy to clipboard"); copyToClipBoard.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); copyToClipBoard.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { StringBuffer buffer = new StringBuffer(); for (InstrumentedProcess process : processes) { Conflict[] conflicts = process.getDisplayedConflicts(); if (conflicts.length > 0) { for (Conflict conflict : conflicts) { buffer.append(conflict.message + "\n"); } } } Clipboard cb = new Clipboard(Display.getDefault()); TextTransfer textTransfer = TextTransfer.getInstance(); cb.setContents(new Object[] { buffer.toString() }, new Transfer[] { textTransfer }); } }); viewer.setInput(processes); }