├── dist
├── mac
│ ├── Armitage.app
│ │ └── Contents
│ │ │ ├── Java
│ │ │ └── index.txt
│ │ │ ├── PkgInfo
│ │ │ ├── Resources
│ │ │ ├── Java
│ │ │ │ └── index.txt
│ │ │ └── aquaicon2.icns
│ │ │ ├── MacOS
│ │ │ └── JavaAppLauncher
│ │ │ └── Info.plist
│ ├── build.sh
│ └── readme-osx.rtf
├── unix
│ ├── armitage
│ ├── armitage-logo.png
│ └── teamserver
└── windows
│ └── armitage.exe
├── run.sh
├── lib
├── sleep.jar
├── jgraphx.jar
├── javassist-3.15.0-GA.jar
├── msgpack-0.6.12-devel.jar
└── postgresql-9.1-901.jdbc4.jar
├── resources
├── bsd.png
├── ios.png
├── cisco.png
├── linux.png
├── android.png
├── computer.png
├── firewall.png
├── hacked.png
├── macosx.png
├── printer.png
├── solaris.png
├── unknown.png
├── vmware.png
├── windows7.png
├── windows8.png
├── windowsxp.png
├── armitage-icon.gif
├── armitage-logo.gif
├── windows2000.png
├── eventlog.style
├── about.html
├── msfconsole.style
├── msfrpcd.bat
├── error.txt
├── msfrpcd_new.bat
└── armitage.prop
├── release
├── armitage-unix
│ ├── armitage
│ ├── armitage.jar
│ ├── cortana.jar
│ ├── armitage-logo.png
│ ├── teamserver
│ └── readme.txt
└── armitage-windows
│ ├── armitage.exe
│ ├── armitage.jar
│ ├── cortana.jar
│ └── readme.txt
├── src
├── msf
│ ├── RpcCallback.java
│ ├── Async.java
│ ├── RpcConnection.java
│ ├── RpcQueue.java
│ ├── RpcAsync.java
│ ├── ConsolePool.java
│ └── Base64.java
├── ui
│ ├── KeyHandler.java
│ ├── ScreenshotManager.java
│ ├── ATree.java
│ ├── SafeMouseListener.java
│ ├── DynamicMenu.java
│ ├── CopyPopup.java
│ ├── ModuleTransferHandler.java
│ ├── CutCopyPastePopup.java
│ ├── ATextField.java
│ ├── ZoomableImage.java
│ ├── APasswordField.java
│ ├── SafeDialogs.java
│ ├── DraggableTabbedPane.java
│ └── UploadFile.java
├── ssl
│ ├── ArmitageTrustListener.java
│ ├── ArmitageTrustManager.java
│ └── SecureSocket.java
├── armitage
│ ├── Activity.java
│ ├── ConsoleCallback.java
│ ├── ArmitageThreadClient.java
│ ├── QueueTabCompletion.java
│ ├── ArmitageTimerClient.java
│ ├── ArmitageThread.java
│ ├── DisconnectNotifier.java
│ ├── SimpleTimer.java
│ ├── ActivityConsole.java
│ ├── TabCompletion.java
│ ├── EventLogTabCompletion.java
│ ├── GenericTabCompletion.java
│ ├── MeterpreterClient.java
│ ├── ArmitageBuffer.java
│ └── ArmitageTimer.java
├── console
│ ├── ConsolePopup.java
│ └── SearchPanel.java
├── graph
│ ├── GraphPopup.java
│ ├── Refreshable.java
│ ├── TouchList.java
│ ├── TouchMap.java
│ ├── CircleLayout.java
│ ├── RefreshGraph.java
│ └── Route.java
├── cortana
│ ├── data
│ │ ├── CortanaTimer.java
│ │ ├── DataUtils.java
│ │ ├── ManagedData.java
│ │ ├── Service.java
│ │ ├── Host.java
│ │ ├── Credential.java
│ │ ├── Loots.java
│ │ ├── Credentials.java
│ │ ├── Routes.java
│ │ ├── Hosts.java
│ │ └── Services.java
│ ├── gui
│ │ ├── CortanaTabCompletion.java
│ │ ├── ScriptedMenuItem.java
│ │ ├── ScriptedMenu.java
│ │ ├── UIBridge.java
│ │ ├── MenuBuilder.java
│ │ └── KeyBridge.java
│ ├── CortanaTabCompletion.java
│ ├── core
│ │ ├── EventQueue.java
│ │ ├── Commands.java
│ │ ├── Events.java
│ │ ├── Filters.java
│ │ ├── CommandManager.java
│ │ ├── EventManager.java
│ │ └── FilterManager.java
│ ├── CortanaPipe.java
│ ├── Safety.java
│ ├── support
│ │ ├── Heartbeat.java
│ │ ├── Shared.java
│ │ └── LockBridge.java
│ ├── metasploit
│ │ └── EventLogBridge.java
│ └── Loader.java
└── tree
│ └── SimpleTreeNode.java
├── fixfiles.sh
├── package.sh
├── license.txt
├── scripts
├── log.sl
├── downloads.sl
├── tokens.sl
├── hosts.sl
├── process.sl
├── screenshot.sl
└── services.sl
├── readme.txt
└── scripts-cortana
└── cortanadb.sl
/dist/mac/Armitage.app/Contents/Java/index.txt:
--------------------------------------------------------------------------------
1 | .
2 |
--------------------------------------------------------------------------------
/dist/mac/Armitage.app/Contents/PkgInfo:
--------------------------------------------------------------------------------
1 | APPLarmi
2 |
--------------------------------------------------------------------------------
/run.sh:
--------------------------------------------------------------------------------
1 | java -classpath bin:lib/\*:. armitage.ArmitageMain $*
2 |
--------------------------------------------------------------------------------
/lib/sleep.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/lib/sleep.jar
--------------------------------------------------------------------------------
/lib/jgraphx.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/lib/jgraphx.jar
--------------------------------------------------------------------------------
/resources/bsd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/bsd.png
--------------------------------------------------------------------------------
/resources/ios.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/ios.png
--------------------------------------------------------------------------------
/resources/cisco.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/cisco.png
--------------------------------------------------------------------------------
/resources/linux.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/linux.png
--------------------------------------------------------------------------------
/dist/mac/Armitage.app/Contents/Resources/Java/index.txt:
--------------------------------------------------------------------------------
1 | armitage.jar goes in this directory.
2 |
--------------------------------------------------------------------------------
/resources/android.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/android.png
--------------------------------------------------------------------------------
/resources/computer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/computer.png
--------------------------------------------------------------------------------
/resources/firewall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/firewall.png
--------------------------------------------------------------------------------
/resources/hacked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/hacked.png
--------------------------------------------------------------------------------
/resources/macosx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/macosx.png
--------------------------------------------------------------------------------
/resources/printer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/printer.png
--------------------------------------------------------------------------------
/resources/solaris.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/solaris.png
--------------------------------------------------------------------------------
/resources/unknown.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/unknown.png
--------------------------------------------------------------------------------
/resources/vmware.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/vmware.png
--------------------------------------------------------------------------------
/resources/windows7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/windows7.png
--------------------------------------------------------------------------------
/resources/windows8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/windows8.png
--------------------------------------------------------------------------------
/dist/unix/armitage:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | java -XX:+AggressiveHeap -XX:+UseParallelGC -jar armitage.jar $@
3 |
--------------------------------------------------------------------------------
/resources/windowsxp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/windowsxp.png
--------------------------------------------------------------------------------
/dist/unix/armitage-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/dist/unix/armitage-logo.png
--------------------------------------------------------------------------------
/dist/windows/armitage.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/dist/windows/armitage.exe
--------------------------------------------------------------------------------
/lib/javassist-3.15.0-GA.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/lib/javassist-3.15.0-GA.jar
--------------------------------------------------------------------------------
/resources/armitage-icon.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/armitage-icon.gif
--------------------------------------------------------------------------------
/resources/armitage-logo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/armitage-logo.gif
--------------------------------------------------------------------------------
/resources/windows2000.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/resources/windows2000.png
--------------------------------------------------------------------------------
/lib/msgpack-0.6.12-devel.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/lib/msgpack-0.6.12-devel.jar
--------------------------------------------------------------------------------
/release/armitage-unix/armitage:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | java -XX:+AggressiveHeap -XX:+UseParallelGC -jar armitage.jar $@
3 |
--------------------------------------------------------------------------------
/lib/postgresql-9.1-901.jdbc4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/lib/postgresql-9.1-901.jdbc4.jar
--------------------------------------------------------------------------------
/release/armitage-unix/armitage.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/release/armitage-unix/armitage.jar
--------------------------------------------------------------------------------
/release/armitage-unix/cortana.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/release/armitage-unix/cortana.jar
--------------------------------------------------------------------------------
/release/armitage-windows/armitage.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/release/armitage-windows/armitage.exe
--------------------------------------------------------------------------------
/release/armitage-windows/armitage.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/release/armitage-windows/armitage.jar
--------------------------------------------------------------------------------
/release/armitage-windows/cortana.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/release/armitage-windows/cortana.jar
--------------------------------------------------------------------------------
/src/msf/RpcCallback.java:
--------------------------------------------------------------------------------
1 | package msf;
2 |
3 | public interface RpcCallback {
4 | public void result(Object result);
5 | }
6 |
--------------------------------------------------------------------------------
/release/armitage-unix/armitage-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/release/armitage-unix/armitage-logo.png
--------------------------------------------------------------------------------
/src/ui/KeyHandler.java:
--------------------------------------------------------------------------------
1 | package ui;
2 |
3 | public interface KeyHandler {
4 | public void key_pressed(String description);
5 | }
6 |
--------------------------------------------------------------------------------
/dist/mac/Armitage.app/Contents/MacOS/JavaAppLauncher:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/dist/mac/Armitage.app/Contents/MacOS/JavaAppLauncher
--------------------------------------------------------------------------------
/src/ssl/ArmitageTrustListener.java:
--------------------------------------------------------------------------------
1 | package ssl;
2 |
3 | public interface ArmitageTrustListener {
4 | public boolean trust(String fingerprint);
5 | }
6 |
--------------------------------------------------------------------------------
/dist/mac/Armitage.app/Contents/Resources/aquaicon2.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rsmudge/armitage/master/dist/mac/Armitage.app/Contents/Resources/aquaicon2.icns
--------------------------------------------------------------------------------
/fixfiles.sh:
--------------------------------------------------------------------------------
1 | #
2 | # fix the line formats so windows users can read the files too
3 | #
4 | perl -pi -e 's/\n/\r\n/g' readme.txt
5 | perl -pi -e 's/\n/\r\n/g' whatsnew.txt
6 |
7 |
--------------------------------------------------------------------------------
/src/ui/ScreenshotManager.java:
--------------------------------------------------------------------------------
1 | package ui;
2 |
3 | import java.awt.Image;
4 |
5 | public interface ScreenshotManager {
6 | public void saveScreenshot(Image screenshot, String title);
7 | }
8 |
--------------------------------------------------------------------------------
/src/armitage/Activity.java:
--------------------------------------------------------------------------------
1 | package armitage;
2 |
3 | import javax.swing.JLabel;
4 |
5 | public interface Activity {
6 | public void registerLabel(JLabel label);
7 | public void resetNotification();
8 | }
9 |
--------------------------------------------------------------------------------
/src/armitage/ConsoleCallback.java:
--------------------------------------------------------------------------------
1 | package armitage;
2 |
3 | public interface ConsoleCallback {
4 | public void sessionRead(String sessionid, String text);
5 | public void sessionWrote(String sessionid, String text);
6 | }
7 |
--------------------------------------------------------------------------------
/resources/eventlog.style:
--------------------------------------------------------------------------------
1 | ^(../.. ..:..:..) \[\*\] (.*) $1 \cC[*]\o $2
2 | ^\[\*\] (.*) \cC[*]\o $1
3 | ^(../.. ..:..:..) \* (.*) $1 \cD*\o $2
4 | ^(../.. ..:..:..) <(.*?)> (.*?$ME$.*) $1 <\c7$2\o> $3
5 | ^(\w+)> \u$1\o>
6 |
--------------------------------------------------------------------------------
/src/armitage/ArmitageThreadClient.java:
--------------------------------------------------------------------------------
1 | package armitage;
2 |
3 | import java.util.*;
4 |
5 | public interface ArmitageThreadClient {
6 | /** return -1 to stop the thread, return >=0 value to have the thread call this client again */
7 | public long execute();
8 | }
9 |
--------------------------------------------------------------------------------
/src/ui/ATree.java:
--------------------------------------------------------------------------------
1 | package ui;
2 |
3 | import java.awt.*;
4 | import javax.swing.*;
5 | import javax.swing.tree.*;
6 | import java.util.*;
7 |
8 | public class ATree extends JTree {
9 | public ATree(TreeNode root) {
10 | super(root);
11 | }
12 |
13 | public boolean getScrollableTracksViewportWidth() {
14 | return true;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/console/ConsolePopup.java:
--------------------------------------------------------------------------------
1 | package console;
2 |
3 | import java.awt.event.MouseEvent;
4 |
5 | /** an interface to accept a clicked on word and a mouse event... it's up to the implementor to decide
6 | what should happen with this magical information */
7 | public interface ConsolePopup {
8 | public void showPopup(String word, MouseEvent ev);
9 | }
10 |
--------------------------------------------------------------------------------
/src/graph/GraphPopup.java:
--------------------------------------------------------------------------------
1 | package graph;
2 |
3 | import java.awt.event.MouseEvent;
4 |
5 | /** an interface to accept a clicked on word and a mouse event... it's up to the implementor to decide
6 | what should happen with this magical information */
7 | public interface GraphPopup {
8 | public void showGraphPopup(String[] nodes, MouseEvent ev);
9 | }
10 |
--------------------------------------------------------------------------------
/dist/mac/build.sh:
--------------------------------------------------------------------------------
1 | #
2 | # unzip armitage.tgz in this directory first.
3 | #
4 |
5 | rm -rf dist
6 | mkdir dist
7 | cp -r Armitage.app dist
8 | cp armitage/armitage.jar dist/Armitage.app/Contents/Java
9 | cp armitage/*.txt dist/
10 | cp *.rtf dist/
11 | rm -rf armitage
12 | mv dist Armitage
13 | hdiutil create -ov -volname Armitage -srcfolder ./Armitage armitage.dmg
14 | rm -rf armitage
15 |
--------------------------------------------------------------------------------
/resources/about.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Armitage 1.4.11
4 |
5 | An attack management tool for Metasploit®
6 |
Release: 13 August 2015
7 |
8 | Developed by:
9 |
12 |
13 | Metasploit® is a registered trademark of Rapid7
14 |
15 |
16 |
--------------------------------------------------------------------------------
/resources/msfconsole.style:
--------------------------------------------------------------------------------
1 | ^msf> \umsf\u>
2 | ^meterpreter > \umeterpreter\u >
3 | ^msf > \umsf\u >
4 | ^msf (.*?)\((.*?)\) > \umsf\u $1(\c4$2\o) >
5 | ^\[\*\] (.*) \cC[*]\o $1
6 | ^\[\+\] (.*) \c9[+]\o $1
7 | ^\[\!\] (.*) \c8[!]\o $1
8 | ^\[\-\] (.*) \c4[-]\o $1
9 | ^ =\[ (.*) =[\c7 $1
10 | ^(=[=\s]+) \cE$1
11 | ^(\s*-[-\s]+) \cE$1
12 | ^(.*?): (.*) $1\cE:\o $2
13 |
--------------------------------------------------------------------------------
/src/msf/Async.java:
--------------------------------------------------------------------------------
1 | package msf;
2 |
3 | import java.io.*;
4 |
5 | public interface Async {
6 | public void execute_async(String methodName);
7 | public void execute_async(String methodName, Object[] args);
8 | public void execute_async(String methodName, Object[] args, RpcCallback callback);
9 | public boolean isConnected();
10 | public void disconnect();
11 | public boolean isResponsive();
12 | }
13 |
--------------------------------------------------------------------------------
/resources/msfrpcd.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | set BASE=$$BASE$$
3 | cd "%BASE%"
4 | set PATH=%BASE%ruby\bin;%BASE%java\bin;%BASE%tools;%BASE%svn\bin;%BASE%nmap;%BASE%postgresql\bin;%PATH%
5 | IF NOT EXIST "%BASE%java" GOTO NO_JAVA
6 | set JAVA_HOME="%BASE%java"
7 | :NO_JAVA
8 | set MSF_DATABASE_CONFIG="%BASE%\config\database.yml"
9 | cd "%BASE%msf3"
10 | rubyw msfrpcd -a 127.0.0.1 -U $$USER$$ -P $$PASS$$ -S -f -p $$PORT$$
11 |
--------------------------------------------------------------------------------
/resources/error.txt:
--------------------------------------------------------------------------------
1 | Metasploit's RPC daemon shut down. This is the
2 | service Armitage uses to talk to Metasploit.
3 |
4 | When this happens, it means something is wrong.
5 | The developer of Armitage feels your pain from
6 | afar. Would you like help troubleshooting this?
7 |
8 | P.S. yes you would--the answer is known and it's
9 | easy to deal with. Click Yes to visit the
10 | troubleshooting guide at:
11 |
12 | http://www.fastandeasyhacking.com/nomsfrpcd
13 |
--------------------------------------------------------------------------------
/resources/msfrpcd_new.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | set BASE=$$BASE$$..\..\
3 | cd "%BASE%"
4 | set PATH=%BASE%ruby\bin;%BASE%java\bin;%BASE%tools;%BASE%nmap;%BASE%postgresql\bin;%PATH%
5 | IF NOT EXIST "%BASE%java" GOTO NO_JAVA
6 | set JAVA_HOME="%BASE%java"
7 | :NO_JAVA
8 | set MSF_DATABASE_CONFIG="%BASE%apps\pro\ui\config\database.yml"
9 | set MSF_BUNDLE_GEMS=0
10 | set BUNDLE_GEMFILE=%BASE%apps\pro\ui\Gemfile
11 | cd "%BASE%apps\pro\msf3"
12 | rubyw msfrpcd -a 127.0.0.1 -U $$USER$$ -P $$PASS$$ -S -f -p $$PORT$$
13 |
--------------------------------------------------------------------------------
/src/armitage/QueueTabCompletion.java:
--------------------------------------------------------------------------------
1 | package armitage;
2 |
3 | import console.Console;
4 | import java.util.*;
5 |
6 | /* uses a console queue as a tab completion source */
7 | public class QueueTabCompletion extends GenericTabCompletion {
8 | protected ConsoleQueue queue;
9 |
10 | public QueueTabCompletion(Console window, ConsoleQueue queue) {
11 | super(window);
12 | this.queue = queue;
13 | }
14 |
15 | public Collection getOptions(String text) {
16 | return queue.tabComplete(text);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/cortana/data/CortanaTimer.java:
--------------------------------------------------------------------------------
1 | package cortana.data;
2 |
3 | import armitage.*;
4 | import msf.*;
5 |
6 | public class CortanaTimer extends ArmitageTimer {
7 | protected DataManager clientz;
8 |
9 | protected boolean alwaysFire() {
10 | return !clientz.isReady();
11 | }
12 |
13 | public CortanaTimer(RpcConnection connection, String command, long sleepPeriod, DataManager client, boolean doCache) {
14 | super(connection, command, sleepPeriod, client, doCache);
15 | this.clientz = client;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/armitage/ArmitageTimerClient.java:
--------------------------------------------------------------------------------
1 | package armitage;
2 |
3 | import java.util.*;
4 |
5 | /** A client for the ArmitageTimer class. It's easier to have a Java class handle all this vs. using Sleep's fork mechanism. This way we get thread safety
6 | for any Sleep data structures by default. */
7 | public interface ArmitageTimerClient {
8 | /** return true if you want the timer to continue running. The arguments are the command, arguments, and the result of them. */
9 | public boolean result(String command, Object[] arguments, Map result);
10 | }
11 |
--------------------------------------------------------------------------------
/src/cortana/data/DataUtils.java:
--------------------------------------------------------------------------------
1 | package cortana.data;
2 |
3 | import sleep.runtime.*;
4 | import java.util.*;
5 |
6 | public class DataUtils {
7 | /* calculate the difference between two sets */
8 | public static Set difference(Set a, Set b) {
9 | Set temp = new HashSet();
10 | temp.addAll(a);
11 | temp.removeAll(b);
12 | return temp;
13 | }
14 |
15 | /* calculate the intersection of two sets */
16 | public static Set intersection(Set a, Set b) {
17 | Set temp = new HashSet();
18 | temp.addAll(a);
19 | temp.retainAll(b);
20 | return temp;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/ui/SafeMouseListener.java:
--------------------------------------------------------------------------------
1 | package ui;
2 |
3 | import java.awt.*;
4 | import java.awt.event.*;
5 |
6 | public class SafeMouseListener extends MouseAdapter {
7 | protected MouseListener listener;
8 |
9 | public SafeMouseListener(MouseListener listener) {
10 | this.listener = listener;
11 | }
12 |
13 | public void mouseClicked(MouseEvent ev) {
14 | listener.mouseClicked(ev);
15 | }
16 |
17 | public void mousePressed(MouseEvent ev) {
18 | listener.mousePressed(ev);
19 | }
20 |
21 | public void mouseReleased(MouseEvent ev) {
22 | listener.mouseReleased(ev);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/msf/RpcConnection.java:
--------------------------------------------------------------------------------
1 | package msf;
2 |
3 | import java.io.*;
4 | import java.net.*;
5 | import java.text.*;
6 | import java.util.*;
7 | import javax.xml.*;
8 | import javax.xml.parsers.*;
9 | import javax.xml.transform.*;
10 | import javax.xml.transform.dom.*;
11 | import javax.xml.transform.stream.*;
12 | import org.w3c.dom.*;
13 |
14 | /**
15 | * This is a modification of msfgui/RpcConnection.java by scriptjunkie. Taken from
16 | * the Metasploit Framework Java GUI.
17 | */
18 | public interface RpcConnection {
19 | public Object execute(String methodName) throws IOException;
20 | public Object execute(String methodName, Object[] params) throws IOException;
21 | }
22 |
--------------------------------------------------------------------------------
/src/graph/Refreshable.java:
--------------------------------------------------------------------------------
1 | package graph;
2 |
3 | import java.awt.Image;
4 |
5 | public interface Refreshable {
6 | /* called to indicate that we're starting an update */
7 | public void start();
8 |
9 | /* add a node */
10 | public Object addNode(String id, String label, String description, Image image, String tooltip);
11 |
12 | /* setup all of our routes in one fell swoop */
13 | public void setRoutes(Route[] routes);
14 |
15 | /* highlight a pivot line please */
16 | public void highlightRoute(String src, String dst);
17 |
18 | /* clear any untouched nodes */
19 | public void deleteNodes();
20 |
21 | /* called to indicate that we're ending an update */
22 | public void end();
23 | }
24 |
--------------------------------------------------------------------------------
/src/cortana/data/ManagedData.java:
--------------------------------------------------------------------------------
1 | package cortana.data;
2 |
3 | import cortana.core.*;
4 |
5 | import armitage.ArmitageTimerClient;
6 | import armitage.ArmitageTimer;
7 |
8 | import graph.Route;
9 |
10 | import sleep.bridges.*;
11 | import sleep.interfaces.*;
12 | import sleep.runtime.*;
13 | import sleep.engine.*;
14 |
15 | import java.util.*;
16 |
17 | import java.io.IOException;
18 |
19 | import msf.*;
20 |
21 | public abstract class ManagedData {
22 | protected boolean initial = true;
23 | protected Scalar cache = null;
24 |
25 | public boolean isInitial() {
26 | return initial;
27 | }
28 |
29 | public abstract Scalar getScalar();
30 |
31 | public void reset() {
32 | initial = true;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/graph/TouchList.java:
--------------------------------------------------------------------------------
1 | package graph;
2 |
3 | import java.util.*;
4 |
5 | /** A touch map lets me start an operation, "touch" each updated node, and then delete any untouched node */
6 | public class TouchList extends LinkedList {
7 | protected Set touched = new HashSet();
8 |
9 | public void startUpdates() {
10 | touched.clear();
11 | }
12 |
13 | public void touch(Object key) {
14 | touched.add(key);
15 | }
16 |
17 | public List clearUntouched() {
18 | List results = new LinkedList();
19 |
20 | Iterator i = this.iterator();
21 | while (i.hasNext()) {
22 | Object j = i.next();
23 | if (!touched.contains(j)) {
24 | results.add(j);
25 | i.remove();
26 | }
27 | }
28 |
29 | return results;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/cortana/gui/CortanaTabCompletion.java:
--------------------------------------------------------------------------------
1 | package cortana.gui;
2 |
3 | import console.Console;
4 | import msf.*;
5 | import armitage.*;
6 | import java.util.*;
7 | import java.awt.*;
8 | import java.awt.event.*;
9 | import javax.swing.*;
10 |
11 | import java.io.IOException;
12 |
13 | /* scriptable tab completion... */
14 | public class CortanaTabCompletion extends GenericTabCompletion {
15 | public static interface Completer {
16 | public Collection getOptions(String text);
17 | }
18 |
19 | protected Completer completer;
20 |
21 | public CortanaTabCompletion(Console window, Completer c) {
22 | super(window);
23 | this.completer = c;
24 | }
25 |
26 | public Collection getOptions(String text) {
27 | return completer.getOptions(text);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/graph/TouchMap.java:
--------------------------------------------------------------------------------
1 | package graph;
2 |
3 | import java.util.*;
4 |
5 | /** A touch map lets me start an operation, "touch" each updated node, and then delete any untouched node */
6 | public class TouchMap extends HashMap {
7 | protected Set touched = new HashSet();
8 |
9 | public void startUpdates() {
10 | touched.clear();
11 | }
12 |
13 | public void touch(Object key) {
14 | touched.add(key);
15 | }
16 |
17 | public List clearUntouched() {
18 | List results = new LinkedList();
19 |
20 | Iterator i = this.entrySet().iterator();
21 | while (i.hasNext()) {
22 | Map.Entry j = (Map.Entry)i.next();
23 | if (!touched.contains(j.getKey())) {
24 | results.add(j);
25 | i.remove();
26 | }
27 | }
28 |
29 | return results;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/armitage/ArmitageThread.java:
--------------------------------------------------------------------------------
1 | package armitage;
2 |
3 | import console.Console;
4 | import msf.*;
5 | import java.util.*;
6 |
7 | /** A generic class to execute several queries and return their results */
8 | public class ArmitageThread implements Runnable {
9 | protected ArmitageThreadClient client;
10 |
11 | public ArmitageThread(ArmitageThreadClient c) {
12 | this.client = c;
13 | }
14 |
15 | public void start() {
16 | new Thread(this).start();
17 | }
18 |
19 | public void run() {
20 | while (true) {
21 | long sleepFor = client.execute();
22 |
23 | if (sleepFor <= 0) {
24 | return;
25 | }
26 | else {
27 | try {
28 | Thread.sleep(sleepFor);
29 | }
30 | catch (Exception ex) {
31 |
32 | }
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/ui/DynamicMenu.java:
--------------------------------------------------------------------------------
1 | package ui;
2 |
3 | import java.awt.*;
4 | import java.awt.event.*;
5 |
6 | import javax.swing.*;
7 | import javax.swing.event.*;
8 |
9 | public class DynamicMenu extends JMenu implements MenuListener {
10 | public DynamicMenu(String s) {
11 | super(s);
12 | addMenuListener(this);
13 | }
14 |
15 | public void setHandler(DynamicMenuHandler h) {
16 | handler = h;
17 | }
18 |
19 | protected DynamicMenuHandler handler = null;
20 |
21 | public interface DynamicMenuHandler {
22 | public void setupMenu(JMenu parent);
23 | }
24 |
25 | public void menuSelected(MenuEvent ev) {
26 | if (handler != null) {
27 | handler.setupMenu(this);
28 | }
29 | }
30 |
31 | public void menuCanceled(MenuEvent ev) {
32 | removeAll();
33 | }
34 |
35 | public void menuDeselected(MenuEvent ev) {
36 | removeAll();
37 | }
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/src/cortana/CortanaTabCompletion.java:
--------------------------------------------------------------------------------
1 | package cortana;
2 |
3 | import armitage.GenericTabCompletion;
4 | import console.Console;
5 | import msf.*;
6 | import java.util.*;
7 | import java.awt.*;
8 | import java.awt.event.*;
9 | import javax.swing.*;
10 |
11 | /* A generic class to manage reading/writing to a console. Keeps the code simpler (although the Sleep code to do this is
12 | simpler than this Java code. *sigh* */
13 | public class CortanaTabCompletion extends GenericTabCompletion {
14 | protected Cortana engine;
15 |
16 | public String transformText(String text) {
17 | return text.replace(" ~", " " + System.getProperty("user.home"));
18 | }
19 |
20 | public CortanaTabCompletion(Console window, Cortana engine) {
21 | super(window);
22 | this.engine = engine;
23 | }
24 |
25 | public Collection getOptions(String text) {
26 | return engine.commandList(text);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/armitage/DisconnectNotifier.java:
--------------------------------------------------------------------------------
1 | package armitage;
2 |
3 | import java.util.*;
4 |
5 | /* an object to track listeners for disconnects... */
6 | public class DisconnectNotifier {
7 | public interface DisconnectListener {
8 | public void disconnected(String reason);
9 | }
10 |
11 | protected List listeners = new LinkedList();
12 | protected boolean connected = true;
13 |
14 | public void addDisconnectListener(DisconnectListener l) {
15 | synchronized (listeners) {
16 | listeners.add(l);
17 | }
18 | }
19 |
20 | public void fireDisconnectEvent(final String reason) {
21 | new Thread(new Runnable() {
22 | public void run() {
23 | synchronized (listeners) {
24 | if (!connected)
25 | return;
26 |
27 | Iterator i = listeners.iterator();
28 | while (i.hasNext()) {
29 | DisconnectListener l = (DisconnectListener)i.next();
30 | l.disconnected(reason);
31 | }
32 |
33 | connected = false;
34 | }
35 | }
36 | }).start();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/armitage/SimpleTimer.java:
--------------------------------------------------------------------------------
1 | package armitage;
2 |
3 | import console.Console;
4 | import msf.*;
5 | import java.util.*;
6 |
7 | /** A generic class to execute several queries and return their results */
8 | public class SimpleTimer implements Runnable {
9 | protected long sleepPeriod;
10 | protected Runnable doit;
11 | protected boolean flag;
12 |
13 | public SimpleTimer(long period) {
14 | sleepPeriod = period;
15 | flag = true;
16 | }
17 |
18 | public void setRunnable(Runnable r) {
19 | doit = r;
20 | new Thread(this).start();
21 | }
22 |
23 | /* this should only be called within the thread executing the runnable */
24 | public void stop() {
25 | flag = false;
26 | }
27 |
28 | public void run() {
29 | try {
30 | while (flag) {
31 | doit.run();
32 | Thread.sleep(sleepPeriod);
33 | }
34 | }
35 | catch (Exception ex) {
36 | System.err.println("TIMER DIED | continue: " + flag + ", " + sleepPeriod + "ms, " + doit);
37 | ex.printStackTrace();
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/cortana/data/Service.java:
--------------------------------------------------------------------------------
1 | package cortana.data;
2 |
3 | import java.util.*;
4 | import sleep.runtime.*;
5 |
6 | /* represent a host/port pair in a Set */
7 | public class Service {
8 | protected String host;
9 | protected String port;
10 |
11 | public String getHost() {
12 | return host;
13 | }
14 |
15 | public String getPort() {
16 | return port;
17 | }
18 |
19 | public Service(String host, String port) {
20 | this.host = host;
21 | this.port = port;
22 | }
23 |
24 | public Stack arguments() {
25 | Stack arguments = new Stack();
26 | arguments.push(SleepUtils.getScalar(port));
27 | arguments.push(SleepUtils.getScalar(host));
28 | return arguments;
29 | }
30 |
31 | public boolean equals(Object o) {
32 | if (o instanceof Service) {
33 | Service t = (Service)o;
34 | return (t.host.equals(host) && t.port.equals(port));
35 | }
36 | return false;
37 | }
38 |
39 | public int hashCode() {
40 | return host.hashCode() + port.hashCode();
41 | }
42 |
43 | public String toString() {
44 | return host + ":" + port;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/armitage/ActivityConsole.java:
--------------------------------------------------------------------------------
1 | package armitage;
2 |
3 | import javax.swing.*;
4 | import javax.swing.event.*;
5 | import javax.swing.border.*;
6 | import javax.swing.text.*;
7 |
8 | import java.awt.*;
9 | import java.awt.event.*;
10 |
11 | import java.io.PrintStream;
12 |
13 | import java.util.*;
14 |
15 | import console.*;
16 |
17 | /** A generic multi-feature console for use in the Armitage network attack tool */
18 | public class ActivityConsole extends Console implements Activity {
19 | protected JLabel label;
20 | protected Color original;
21 | public void registerLabel(JLabel l) {
22 | label = l;
23 | original = l.getForeground();
24 | }
25 |
26 | public void resetNotification() {
27 | label.setForeground(original);
28 | }
29 |
30 | protected void appendToConsole(String _text) {
31 | super.appendToConsole(_text);
32 |
33 | if (_text.length() > 0 && label != null && !isShowing()) {
34 | label.setForeground(Color.decode(display.getProperty("tab.highlight.color", "#0000ff")));
35 | }
36 | }
37 |
38 | public ActivityConsole(Properties preferences) {
39 | super(preferences);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/cortana/gui/ScriptedMenuItem.java:
--------------------------------------------------------------------------------
1 | package cortana.gui;
2 |
3 | import sleep.runtime.*;
4 | import sleep.bridges.*;
5 |
6 | import java.awt.*;
7 | import java.awt.event.*;
8 |
9 | import javax.swing.*;
10 |
11 | import java.util.*;
12 |
13 | public class ScriptedMenuItem extends JMenuItem implements ActionListener {
14 | protected String label;
15 | protected SleepClosure code;
16 | protected MenuBridge bridge;
17 | protected Stack args;
18 |
19 | public ScriptedMenuItem(String label, SleepClosure code, MenuBridge bridge) {
20 | if (label.indexOf('&') > -1) {
21 | setText( label.substring(0, label.indexOf('&')) +
22 | label.substring(label.indexOf('&') + 1, label.length())
23 | );
24 | setMnemonic(label.charAt(label.indexOf('&') + 1));
25 | }
26 | else {
27 | setText(label);
28 | }
29 |
30 | this.code = code;
31 | this.bridge = bridge;
32 | this.label = label;
33 | args = bridge.getArguments();
34 | addActionListener(this);
35 | }
36 |
37 | public void actionPerformed(ActionEvent ev) {
38 | SleepUtils.runCode(code, label, null, cortana.core.EventManager.shallowCopy(args));
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/armitage/TabCompletion.java:
--------------------------------------------------------------------------------
1 | package armitage;
2 |
3 | import console.Console;
4 | import msf.*;
5 | import java.util.*;
6 | import java.awt.*;
7 | import java.awt.event.*;
8 | import javax.swing.*;
9 |
10 | import java.io.IOException;
11 |
12 | /* A generic class to manage reading/writing to a console. Keeps the code simpler (although the Sleep code to do this is
13 | simpler than this Java code. *sigh* */
14 | public class TabCompletion extends GenericTabCompletion {
15 | protected RpcConnection connection;
16 | protected String session;
17 | protected String tabsCommand;
18 |
19 | public TabCompletion(Console window, RpcConnection connection, String session, String tabsCommand) {
20 | super(window);
21 | this.connection = connection;
22 | this.session = session;
23 | this.tabsCommand = tabsCommand;
24 | }
25 |
26 | public Collection getOptions(String text) {
27 | try {
28 | Map response = (Map)connection.execute(tabsCommand, new Object[] { session, text });
29 |
30 | if (response.get("tabs") == null)
31 | return null;
32 |
33 | Collection options = (Collection)response.get("tabs");
34 | return options;
35 | }
36 | catch (IOException ioex) {
37 | ioex.printStackTrace();
38 | }
39 | return null;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/package.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # I know Apache Ant does all of this stuff... I hate working with XML though
4 | #
5 |
6 | rm -f armitage.zip
7 | rm -f armitage.tgz
8 |
9 | ant clean
10 | ant compile
11 | cp -r resources/ bin/
12 | cp -r scripts/ bin/
13 | rm -rf bin/*/*/.svn
14 | rm -rf bin/*/.svn
15 | ant jar
16 |
17 | #
18 | # build *NIX package
19 | #
20 | mkdir armitage
21 | cp armitage.jar armitage
22 | cp cortana.jar armitage
23 | cp readme.txt armitage
24 | cp whatsnew.txt armitage
25 | cp -r dist/unix/* armitage
26 |
27 | # kill the silly .svn file
28 | rm -rf armitage/.svn
29 | tar zcvf armitage.tgz armitage
30 |
31 | rm -rf armitage
32 |
33 | #
34 | # build Windows package
35 | #
36 | mkdir armitage
37 | cp -r dist/windows/* armitage
38 | cp armitage.jar armitage/
39 | cp cortana.jar armitage/
40 | cp readme.txt armitage/readme.txt
41 | cp whatsnew.txt armitage/whatsnew.txt
42 |
43 | # kill that silly .svn file
44 | rm -rf armitage/.svn
45 | rm -rf armitage/*/*/.svn
46 | rm -rf armitage/*/.svn
47 | cd armitage
48 | zip -r ../armitage.zip .
49 | cd ..
50 |
51 | rm -rf armitage
52 |
53 | #
54 | # update the release directory
55 | #
56 | cd release/
57 | tar zxvf ../armitage.tgz
58 | mv armitage/* armitage-unix
59 | rm -rf armitage
60 |
61 | cd ../release/
62 | cd armitage-windows
63 | unzip -o ../../armitage.zip
64 |
--------------------------------------------------------------------------------
/src/cortana/core/EventQueue.java:
--------------------------------------------------------------------------------
1 | package cortana.core;
2 |
3 | import java.util.*;
4 | import sleep.runtime.*;
5 |
6 | /* an event for firing events outside of the data management threads */
7 | public class EventQueue implements Runnable {
8 | protected EventManager manager;
9 | protected LinkedList queue = new LinkedList();
10 |
11 | private static class Event {
12 | public String name;
13 | public Stack args;
14 | }
15 |
16 | public EventQueue(EventManager manager) {
17 | this.manager = manager;
18 | new Thread(this).start();
19 | }
20 |
21 | public void add(String name, Stack args) {
22 | Event e = new Event();
23 | e.name = name;
24 | e.args = args;
25 |
26 | synchronized (this) {
27 | queue.add(e);
28 | }
29 | }
30 |
31 | protected Event grabEvent() {
32 | synchronized (this) {
33 | return (Event)queue.pollFirst();
34 | }
35 | }
36 |
37 | public void run() {
38 | while (true) {
39 | Event ev = grabEvent();
40 |
41 | try {
42 | if (ev != null) {
43 | manager.fireEvent(ev.name, ev.args, null);
44 | }
45 | else {
46 | Thread.sleep(25);
47 | }
48 | }
49 | catch (Exception ex) {
50 | if (ev != null)
51 | System.err.println(ev.name + " => " + SleepUtils.describe(ev.args));
52 | ex.printStackTrace();
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/ui/CopyPopup.java:
--------------------------------------------------------------------------------
1 | package ui;
2 |
3 | import javax.swing.*;
4 | import javax.swing.event.*;
5 | import javax.swing.text.*;
6 |
7 | import java.awt.*;
8 | import java.awt.event.*;
9 |
10 |
11 | /* A textfield with a popup menu to cut, copy, paste, and clear the textfield */
12 | public class CopyPopup {
13 | protected JPopupMenu menu = null;
14 | protected JTextComponent component = null;
15 |
16 | public CopyPopup(JTextComponent component) {
17 | this.component = component;
18 | createMenu();
19 | }
20 |
21 | public void createMenu() {
22 | if (menu != null)
23 | return;
24 |
25 | menu = new JPopupMenu();
26 | JMenuItem copy = new JMenuItem("Copy", 'o');
27 |
28 | copy.addActionListener(new ActionListener() {
29 | public void actionPerformed(ActionEvent ev) {
30 | component.copy();
31 | }
32 | });
33 |
34 | menu.add(copy);
35 |
36 | component.addMouseListener(new MouseAdapter() {
37 | public void handle(MouseEvent ev) {
38 | if (ev.isPopupTrigger()) {
39 | menu.show((JComponent)ev.getSource(), ev.getX(), ev.getY());
40 | }
41 | }
42 |
43 | public void mousePressed(MouseEvent ev) {
44 | handle(ev);
45 | }
46 |
47 | public void mouseClicked(MouseEvent ev) {
48 | handle(ev);
49 | }
50 |
51 | public void mouseReleased(MouseEvent ev) {
52 | handle(ev);
53 | }
54 | });
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/cortana/gui/ScriptedMenu.java:
--------------------------------------------------------------------------------
1 | package cortana.gui;
2 |
3 | import java.awt.*;
4 | import java.awt.event.*;
5 |
6 | import javax.swing.*;
7 | import javax.swing.event.*;
8 |
9 | import sleep.runtime.*;
10 | import sleep.engine.*;
11 | import sleep.bridges.*;
12 |
13 | import java.util.*;
14 |
15 | /* implements a scripted menu */
16 | public class ScriptedMenu extends JMenu implements MenuListener {
17 | protected MenuBridge bridge;
18 | protected SleepClosure f;
19 | protected String label;
20 | protected Stack args;
21 |
22 | public ScriptedMenu(String _label, SleepClosure f, MenuBridge bridge) {
23 | if (_label.indexOf('&') > -1) {
24 | setText( _label.substring(0, _label.indexOf('&')) + _label.substring(_label.indexOf('&') + 1, _label.length()) );
25 | setMnemonic(_label.charAt(_label.indexOf('&') + 1));
26 | }
27 | else {
28 | setText(_label);
29 | }
30 |
31 | this.label = _label;
32 | this.bridge = bridge;
33 | this.f = f;
34 | this.args = bridge.getArguments();
35 | addMenuListener(this);
36 | }
37 |
38 | public void menuSelected(MenuEvent e) {
39 | bridge.push(this, args);
40 | SleepUtils.runCode(f, label, null, cortana.core.EventManager.shallowCopy(args));
41 | bridge.pop();
42 | }
43 |
44 | public void menuDeselected(MenuEvent e) {
45 | removeAll();
46 | }
47 |
48 | public void menuCanceled(MenuEvent e) {
49 | removeAll();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/cortana/gui/UIBridge.java:
--------------------------------------------------------------------------------
1 | package cortana.gui;
2 |
3 | import cortana.core.*;
4 | import msf.*;
5 | import armitage.*;
6 | import ui.*;
7 |
8 | import sleep.bridges.*;
9 | import sleep.interfaces.*;
10 | import sleep.runtime.*;
11 | import sleep.engine.*;
12 |
13 | import java.awt.*;
14 | import java.awt.event.*;
15 | import javax.swing.*;
16 |
17 | import java.util.*;
18 |
19 | import java.io.IOException;
20 |
21 | /* some methods to help out with user interface stuff */
22 | public class UIBridge implements Loadable, Function {
23 | protected ArmitageApplication armitage;
24 |
25 | public UIBridge(ArmitageApplication a) {
26 | armitage = a;
27 | }
28 |
29 | public Scalar evaluate(String name, ScriptInstance script, Stack args) {
30 | if (name.equals("&later")) {
31 | final SleepClosure f = BridgeUtilities.getFunction(args, script);
32 | final Stack argz = EventManager.shallowCopy(args);
33 | if (SwingUtilities.isEventDispatchThread()) {
34 | SleepUtils.runCode(f, "laterz", null, argz);
35 | }
36 | else {
37 | SwingUtilities.invokeLater(new Runnable() {
38 | public void run() {
39 | SleepUtils.runCode(f, "laterz", null, argz);
40 | }
41 | });
42 | }
43 | }
44 |
45 | return SleepUtils.getEmptyScalar();
46 | }
47 |
48 | public void scriptLoaded(ScriptInstance si) {
49 | si.getScriptEnvironment().getEnvironment().put("&later", this);
50 | }
51 |
52 | public void scriptUnloaded(ScriptInstance si) {
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/dist/mac/Armitage.app/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleName
6 | Armitage
7 | CFBundleVersion
8 | 03.03.11
9 | CFBundleAllowMixedLocalizations
10 | true
11 | CFBundleExecutable
12 | JavaAppLauncher
13 | CFBundleDevelopmentRegion
14 | English
15 | CFBundlePackageType
16 | APPL
17 | CFBundleSignature
18 | faha
19 | CFBundleInfoDictionaryVersion
20 | 6.0
21 | CFBundleIdentifier
22 | Armitage
23 | CFBundleDisplayName
24 | Armitage
25 | CFBundlePackageType
26 | APPL
27 | CFBundleShortVersionString
28 | MacOS X Client
29 | CFBundleSignature
30 | cblt
31 | CFBundleVersion
32 | 1
33 | NSHumanReadableCopyright
34 |
35 | JVMMainClassName
36 | armitage.ArmitageMain
37 | CFBundleIconFile
38 | aquaicon2
39 | JVMOptions
40 |
41 | -XX:+AggressiveHeap
42 | -XX:+UseParallelGC
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/src/armitage/EventLogTabCompletion.java:
--------------------------------------------------------------------------------
1 | package armitage;
2 |
3 | import console.Console;
4 | import msf.*;
5 | import java.util.*;
6 | import java.awt.*;
7 | import java.awt.event.*;
8 | import javax.swing.*;
9 |
10 | import java.io.IOException;
11 |
12 | public class EventLogTabCompletion extends GenericTabCompletion {
13 | protected RpcConnection connection;
14 |
15 | public EventLogTabCompletion(Console window, RpcConnection connection) {
16 | super(window);
17 | this.connection = connection;
18 | }
19 |
20 | public Collection getOptions(String text) {
21 | try {
22 | Map response = (Map)connection.execute("armitage.lusers", new Object[] {});
23 |
24 | if (response.get("lusers") == null)
25 | return null;
26 |
27 | Iterator users = ((Collection)response.get("lusers")).iterator();
28 |
29 | LinkedList options = new LinkedList();
30 | String word;
31 | String pre;
32 |
33 | if (text.endsWith(" ")) {
34 | word = "";
35 | pre = text;
36 | }
37 | if (text.lastIndexOf(" ") != -1) {
38 | word = text.substring(text.lastIndexOf(" ") + 1);
39 | pre = text.substring(0, text.lastIndexOf(" ") + 1);
40 | }
41 | else {
42 | word = text;
43 | pre = "";
44 | }
45 |
46 | while (users.hasNext()) {
47 | String user = users.next() + "";
48 | if (user.startsWith(word)) {
49 | options.add(pre + user);
50 | }
51 | }
52 |
53 | return options;
54 | }
55 | catch (IOException ioex) {
56 | ioex.printStackTrace();
57 | }
58 | return null;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/cortana/data/Host.java:
--------------------------------------------------------------------------------
1 | package cortana.data;
2 |
3 | import java.util.*;
4 |
5 | /* A container for a host. */
6 | public class Host {
7 | protected Map sessions;
8 | protected Map services;
9 | protected String address;
10 | protected Map data;
11 |
12 | public Host(String address, Map data) {
13 | this.address = address;
14 | this.data = data;
15 | sessions = new HashMap();
16 | services = new HashMap();
17 |
18 | fixOSValues();
19 |
20 | data.put("sessions", sessions);
21 | data.put("services", services);
22 | }
23 |
24 | public Map getData() {
25 | return data;
26 | }
27 |
28 | public Map getSessions() {
29 | return sessions;
30 | }
31 |
32 | public Map getServices() {
33 | return services;
34 | }
35 |
36 | public boolean hasService(String port) {
37 | return services.containsKey(port);
38 | }
39 |
40 | public Set serviceSet() {
41 | Set rv = new HashSet();
42 | Iterator i = services.keySet().iterator();
43 | while (i.hasNext()) {
44 | rv.add(new Service(address, i.next() + ""));
45 | }
46 | return rv;
47 | }
48 |
49 | /* fix up some operating system identifying information */
50 | protected void fixOSValues() {
51 | if ("".equals(data.get("os_name"))) {
52 | data.put("os_name", "Unknown");
53 | }
54 | else {
55 | data.put("os_match", data.get("os_name") + " " + data.get("os_flavor") + " " + data.get("os_sp"));
56 | }
57 | data.put("show", Boolean.TRUE);
58 | }
59 |
60 | public void update(Map data) {
61 | this.data.putAll(data);
62 | fixOSValues();
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015, Raphael Mudge
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification,
5 | are permitted provided that the following conditions are met:
6 |
7 | 1. Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 |
10 | 2. Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation and/or
12 | other materials provided with the distribution.
13 |
14 | 3. Neither the name of the copyright holder nor the names of its contributors
15 | may be used to endorse or promote products derived from this software without
16 | specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/src/cortana/data/Credential.java:
--------------------------------------------------------------------------------
1 | package cortana.data;
2 |
3 | import java.util.*;
4 | import sleep.runtime.*;
5 |
6 | /* represent a credential in a Set */
7 | public class Credential {
8 | protected String host;
9 | protected String port;
10 | protected String user;
11 | protected String pass;
12 | protected String type;
13 |
14 | public String getHost() {
15 | return host;
16 | }
17 |
18 | public String getPort() {
19 | return port;
20 | }
21 |
22 | public Credential(String host, String port, String user, String pass, String type) {
23 | this.host = host;
24 | this.port = port;
25 | this.user = user;
26 | this.pass = pass;
27 | this.type = type;
28 | }
29 |
30 | public Stack arguments() {
31 | Stack arguments = new Stack();
32 | arguments.push(SleepUtils.getScalar(type));
33 | arguments.push(SleepUtils.getScalar(pass));
34 | arguments.push(SleepUtils.getScalar(user));
35 | arguments.push(SleepUtils.getScalar(port));
36 | arguments.push(SleepUtils.getScalar(host));
37 | return arguments;
38 | }
39 |
40 | public boolean equals(Object o) {
41 | if (o instanceof Credential) {
42 | Credential t = (Credential)o;
43 | return (t.host.equals(host) && t.port.equals(port) && t.user.equals(user) && t.pass.equals(pass) && t.type.equals(type));
44 | }
45 | return false;
46 | }
47 |
48 | public int hashCode() {
49 | return host.hashCode() + port.hashCode() + user.hashCode() + pass.hashCode() + type.hashCode();
50 | }
51 |
52 | public String toString() {
53 | return user + ":" + pass + "@" + host + ":" + port + "/" + type;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/ssl/ArmitageTrustManager.java:
--------------------------------------------------------------------------------
1 | package ssl;
2 |
3 | import java.net.*;
4 | import java.io.*;
5 | import javax.net.ssl.*;
6 | import javax.net.*;
7 | import java.util.*;
8 |
9 | import java.security.*;
10 | import java.security.cert.*;
11 |
12 | import java.math.*;
13 |
14 | import javax.swing.*;
15 |
16 | public class ArmitageTrustManager implements X509TrustManager {
17 | protected ArmitageTrustListener checker;
18 |
19 | public ArmitageTrustManager(ArmitageTrustListener checker) {
20 | this.checker = checker;
21 | }
22 |
23 | public void checkClientTrusted(X509Certificate ax509certificate[], String authType) {
24 | return;
25 | }
26 |
27 | public void checkServerTrusted(X509Certificate ax509certificate[], String authType) throws CertificateException {
28 | try {
29 | for (int x = 0; x < ax509certificate.length; x++) {
30 | byte[] bytesOfMessage = ax509certificate[x].getEncoded();
31 | MessageDigest md = MessageDigest.getInstance("SHA1");
32 | byte[] thedigest = md.digest(bytesOfMessage);
33 |
34 | BigInteger bi = new BigInteger(1, thedigest);
35 | String fingerprint = bi.toString(16);
36 |
37 | if (checker != null && !checker.trust(fingerprint))
38 | throw new CertificateException("Certificate Rejected. Press Cancel.");
39 | }
40 |
41 | return;
42 | }
43 | catch (CertificateException cex) {
44 | throw cex;
45 | }
46 | catch (Exception ex) {
47 | throw new CertificateException(ex.getMessage());
48 | }
49 | }
50 |
51 | public X509Certificate[] getAcceptedIssuers() {
52 | return new X509Certificate[0];
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/dist/mac/readme-osx.rtf:
--------------------------------------------------------------------------------
1 | {\rtf1\ansi\ansicpg1252\cocoartf1265
2 | \cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
3 | {\colortbl;\red255\green255\blue255;}
4 | {\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid1}}
5 | {\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}}
6 | \margl1440\margr1440\vieww10980\viewh8600\viewkind0
7 | \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
8 |
9 | \f0\fs24 \cf0 Welcome to
10 | \b Armitage for Mac OS X
11 | \b0 .\
12 | \
13 | A few things to note:\
14 | \
15 | \pard\tx220\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\fi-720\pardirnatural
16 | \ls1\ilvl0\cf0 {\listtext \'95 }Armitage requires Oracle\'92s Java 1.7. \
17 | {\listtext \'95 }I do not provide help installing Metasploit on MacOS X. You're on your own.\
18 | \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
19 | \cf0 \
20 | \pard\tx560\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
21 | \cf0 That said, you may use Armitage to connect to a remote Metasploit instance and collaborate with your team. It's for this use case I have created this package.\
22 | \
23 | If you opt to install Metasploit on MacOS X, make sure msfrpcd is in your $PATH. Consider using sudo -E to start armitage (to inherit the necessary environment info to start MSF).\
24 | }
--------------------------------------------------------------------------------
/src/cortana/CortanaPipe.java:
--------------------------------------------------------------------------------
1 | package cortana;
2 |
3 | import java.io.*;
4 | import java.util.*;
5 |
6 | /* a pipe to receive output from Cortana and make it available in an event driven way to the user */
7 | public class CortanaPipe implements Runnable {
8 | protected PipedInputStream readme;
9 | protected PipedOutputStream writeme;
10 |
11 | public OutputStream getOutput() {
12 | return writeme;
13 | }
14 |
15 | public CortanaPipe() {
16 | try {
17 | readme = new PipedInputStream(1024 * 1024 * 1);
18 | writeme = new PipedOutputStream(readme);
19 | }
20 | catch (IOException ioex) {
21 | ioex.printStackTrace();
22 | }
23 | }
24 |
25 | public interface CortanaPipeListener {
26 | public void read(String text);
27 | }
28 |
29 | protected List listeners = new LinkedList();
30 |
31 | public void addCortanaPipeListener(CortanaPipeListener l) {
32 | synchronized (this) {
33 | listeners.add(l);
34 | }
35 |
36 | if (listeners.size() == 1) {
37 | new Thread(this).start();
38 | }
39 | }
40 |
41 | public void run() {
42 | BufferedReader in = new BufferedReader(new InputStreamReader(readme));
43 | while (true) {
44 | try {
45 | String entry = in.readLine();
46 | if (entry != null) {
47 | synchronized (this) {
48 | Iterator i = listeners.iterator();
49 | while (i.hasNext()) {
50 | CortanaPipeListener l = (CortanaPipeListener)i.next();
51 | l.read(entry);
52 | }
53 | }
54 | }
55 | }
56 | catch (IOException ioex) {
57 | try {
58 | Thread.sleep(500);
59 | }
60 | catch (Exception ex) { }
61 | //ioex.printStackTrace();
62 | }
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/cortana/Safety.java:
--------------------------------------------------------------------------------
1 | package cortana;
2 |
3 | import javax.swing.*;
4 | import sleep.runtime.*;
5 |
6 | /** Safety utilities */
7 | public class Safety {
8 | /* should we ask the user what they want in life? */
9 | public static boolean shouldAsk(ScriptInstance script) {
10 | return (script.getDebugFlags() & Cortana.DEBUG_INTERACT_ASK) == Cortana.DEBUG_INTERACT_ASK;
11 | }
12 |
13 | /* should we log what the script is d oing? */
14 | public static boolean shouldLog(ScriptInstance script) {
15 | return (script.getDebugFlags() & Cortana.DEBUG_INTERACT_LOG) == Cortana.DEBUG_INTERACT_LOG;
16 | }
17 |
18 | /* let's log what the script is doing... for giggles */
19 | public static void log(ScriptInstance script, String text) {
20 | script.getScriptEnvironment().showDebugMessage(text);
21 | }
22 |
23 | /* let's prompt the user and act accordingly */
24 | public static boolean ask(ScriptInstance script, String description, String shortd) {
25 | int result = JOptionPane.showConfirmDialog(null, description, "Approve Script Action?", JOptionPane.YES_NO_CANCEL_OPTION);
26 | if (result == JOptionPane.YES_OPTION) {
27 | return true;
28 | }
29 | else if (result == JOptionPane.NO_OPTION) {
30 | Safety.log(script, "blocked " + shortd);
31 | return false;
32 | }
33 | else if (result == JOptionPane.CANCEL_OPTION) {
34 | //int flags = script.getDebugFlags() & ~Cortana.DEBUG_INTERACT_ASK;
35 | //script.setDebugFlags(flags);
36 | Safety.log(script, "user canceled script");
37 | script.getScriptEnvironment().flagReturn(SleepUtils.getScalar("user canceled script"), ScriptEnvironment.FLOW_CONTROL_THROW);
38 | return true;
39 | }
40 |
41 | return false;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/cortana/core/Commands.java:
--------------------------------------------------------------------------------
1 | package cortana.core;
2 |
3 | import java.util.*;
4 |
5 | import sleep.runtime.*;
6 | import sleep.interfaces.*;
7 | import sleep.engine.*;
8 | import sleep.bridges.*;
9 |
10 | public class Commands implements Function, Environment, Loadable {
11 | protected CommandManager manager;
12 |
13 | public void scriptLoaded(ScriptInstance si) {
14 | Hashtable environment = si.getScriptEnvironment().getEnvironment();
15 |
16 | environment.put("&command", this);
17 | environment.put("command", this);
18 |
19 | environment.put("&fire_command", this);
20 | }
21 |
22 | public void scriptUnloaded(ScriptInstance si) {
23 | }
24 |
25 | public void bindFunction(ScriptInstance si, String type, String command, Block body) {
26 | SleepClosure f = new SleepClosure(si, body);
27 | manager.registerCommand(command, f);
28 | }
29 |
30 | public Scalar evaluate(String name, ScriptInstance script, Stack args) {
31 | String command = BridgeUtilities.getString(args, "");
32 | if (name.equals("&fire_command")) {
33 | StringBuffer arstring = new StringBuffer();
34 | LinkedList l = new LinkedList(args);
35 | l.add(command);
36 | Collections.reverse(l);
37 | Iterator i = l.iterator();
38 | while (i.hasNext()) {
39 | arstring.append(i.next() + "");
40 | if (i.hasNext())
41 | arstring.append(" ");
42 | }
43 |
44 | manager.fireCommand(command, arstring + "", args);
45 | return SleepUtils.getEmptyScalar();
46 | }
47 | else {
48 | SleepClosure f = BridgeUtilities.getFunction(args, script);
49 | manager.registerCommand(command, f);
50 | return SleepUtils.getEmptyScalar();
51 | }
52 | }
53 |
54 | public Commands(CommandManager m) {
55 | this.manager = m;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/cortana/gui/MenuBuilder.java:
--------------------------------------------------------------------------------
1 | package cortana.gui;
2 |
3 | import cortana.core.*;
4 | import msf.*;
5 | import armitage.*;
6 | import ui.*;
7 |
8 | import sleep.bridges.*;
9 | import sleep.interfaces.*;
10 | import sleep.runtime.*;
11 | import sleep.engine.*;
12 |
13 | import java.util.*;
14 |
15 | import java.awt.*;
16 | import java.awt.event.*;
17 | import javax.swing.*;
18 | import javax.swing.event.*;
19 |
20 | import java.io.IOException;
21 |
22 | /* an API to bind new menus in Armitage */
23 | public class MenuBuilder {
24 | protected ArmitageApplication armitage;
25 | protected MenuBridge bridge;
26 |
27 | public MenuBuilder(ArmitageApplication a) {
28 | armitage = a;
29 | bridge = new MenuBridge(a);
30 | }
31 |
32 | public Loadable getBridge() {
33 | return bridge;
34 | }
35 |
36 | public void installMenu(MouseEvent ev, String key, Stack argz) {
37 | if (ev.isPopupTrigger() && bridge.isPopulated(key)) {
38 | JPopupMenu menu = new JPopupMenu();
39 | setupMenu(menu, key, argz);
40 |
41 | /* we check, because it may have changed its mind after setupMenu failed */
42 | if (bridge.isPopulated(key)) {
43 | menu.show((JComponent)ev.getSource(), ev.getX(), ev.getY());
44 | ev.consume();
45 | }
46 | }
47 | }
48 |
49 | public void setupMenu(JComponent parent, String key, Stack argz) {
50 | if (!bridge.isPopulated(key))
51 | return;
52 |
53 | /* setup the menu */
54 | bridge.push(parent, argz);
55 |
56 | Iterator i = bridge.getMenus(key).iterator();
57 | while (i.hasNext()) {
58 | SleepClosure f = (SleepClosure)i.next();
59 | if (f.getOwner().isLoaded()) {
60 | SleepUtils.runCode(f, key, null, cortana.core.EventManager.shallowCopy(argz));
61 | }
62 | else {
63 | i.remove();
64 | }
65 | }
66 |
67 | bridge.pop();
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/ui/ModuleTransferHandler.java:
--------------------------------------------------------------------------------
1 | package ui;
2 |
3 | import java.awt.*;
4 | import java.awt.event.*;
5 | import javax.swing.*;
6 |
7 | import java.awt.datatransfer.*;
8 | import java.awt.dnd.*;
9 | import javax.swing.tree.*;
10 |
11 | public class ModuleTransferHandler extends TransferHandler {
12 | public int getSourceActions(JComponent c) {
13 | return COPY_OR_MOVE;
14 | }
15 |
16 | public Transferable createTransferable(JComponent c) {
17 | if (c instanceof JTree) {
18 | JTree temp = (JTree)c;
19 | TreePath path = temp.getSelectionPath();
20 |
21 | if (path != null) {
22 | StringBuffer pathz = new StringBuffer();
23 | Object o[] = path.getPath();
24 | for (int x = 1; x < o.length; x++) {
25 | pathz.append(o[x] + "");
26 |
27 | if ((x + 1) < o.length)
28 | pathz.append("/");
29 | }
30 |
31 | return new StringSelection(pathz + "");
32 | }
33 | }
34 | return null;
35 | }
36 |
37 | public void exportDone(JComponent c, Transferable t, int action) {
38 | }
39 |
40 | public boolean canImport(TransferHandler.TransferSupport blah) {
41 | if (blah.getComponent() instanceof JTree) {
42 | return false;
43 | }
44 | return true;
45 | }
46 |
47 | public interface ModuleTransferListener {
48 | public void completeTransfer(String text, Point location);
49 | }
50 |
51 | protected ModuleTransferListener completeJob = null;
52 | public void setHandler(ModuleTransferListener l) {
53 | completeJob = l;
54 | }
55 |
56 | public boolean importData(TransferHandler.TransferSupport blah) {
57 | try {
58 | Point coords = blah.getDropLocation().getDropPoint();
59 | String text = blah.getTransferable().getTransferData(DataFlavor.stringFlavor) + "";
60 | if (completeJob != null)
61 | completeJob.completeTransfer(text, coords);
62 | }
63 | catch (Exception ex) {
64 |
65 | }
66 | return true;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/cortana/gui/KeyBridge.java:
--------------------------------------------------------------------------------
1 | package cortana.gui;
2 |
3 | import cortana.core.*;
4 | import msf.*;
5 | import armitage.*;
6 | import ui.*;
7 |
8 | import sleep.bridges.*;
9 | import sleep.interfaces.*;
10 | import sleep.runtime.*;
11 | import sleep.engine.*;
12 |
13 | import java.util.*;
14 |
15 | import java.io.IOException;
16 |
17 | /* an API to bind new keys in Armitage */
18 | public class KeyBridge implements Loadable, Function, Environment {
19 | protected ArmitageApplication armitage;
20 |
21 | public KeyBridge(ArmitageApplication a) {
22 | armitage = a;
23 | }
24 |
25 | private static class Binding implements KeyHandler {
26 | protected SleepClosure code;
27 |
28 | public Binding(SleepClosure c) {
29 | code = c;
30 | }
31 |
32 | public void key_pressed(String description) {
33 | if (code != null && code.getOwner().isLoaded()) {
34 | SleepUtils.runCode(code, description, null, new Stack());
35 | }
36 | else {
37 | code = null;
38 | }
39 | }
40 | }
41 |
42 | protected void registerKey(String combination, SleepClosure closure) {
43 | Binding b = new Binding(closure);
44 | armitage.bindKey(combination, b);
45 | }
46 |
47 | public void bindFunction(ScriptInstance si, String type, String event, Block body) {
48 | SleepClosure f = new SleepClosure(si, body);
49 | registerKey(event, f);
50 | }
51 |
52 | public Scalar evaluate(String name, ScriptInstance script, Stack args) {
53 | String desc = BridgeUtilities.getString(args, "");
54 | SleepClosure f = BridgeUtilities.getFunction(args, script);
55 | registerKey(desc, f);
56 | return SleepUtils.getEmptyScalar();
57 | }
58 |
59 | public void scriptLoaded(ScriptInstance si) {
60 | si.getScriptEnvironment().getEnvironment().put("bind", this);
61 | si.getScriptEnvironment().getEnvironment().put("&bind", this);
62 | }
63 |
64 | public void scriptUnloaded(ScriptInstance si) {
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/cortana/support/Heartbeat.java:
--------------------------------------------------------------------------------
1 | package cortana.support;
2 |
3 | import cortana.core.*;
4 | import cortana.*;
5 |
6 | import java.util.*;
7 |
8 | /* a thread to keep track of different timer events and fire them off when it's appropriate */
9 | public class Heartbeat implements Runnable {
10 | protected EventManager events;
11 | protected List beats;
12 |
13 | private class Beat {
14 | protected long next = 0L;
15 | protected long mark;
16 | protected String event;
17 |
18 | public Beat(String event, long mark) {
19 | this.mark = mark;
20 | this.event = event;
21 | next = System.currentTimeMillis() + mark;
22 | }
23 |
24 | public void check(long now) {
25 | if (next <= now) {
26 | next = System.currentTimeMillis() + mark;
27 | events.fireEvent(event, new Stack());
28 | }
29 | }
30 | }
31 |
32 | public Heartbeat(EventManager e) {
33 | events = e;
34 | beats = new LinkedList();
35 | beats.add(new Beat("heartbeat_1s", 1 * 1000));
36 | beats.add(new Beat("heartbeat_5s", 5 * 1000));
37 | beats.add(new Beat("heartbeat_10s", 10 * 1000));
38 | beats.add(new Beat("heartbeat_15s", 15 * 1000));
39 | beats.add(new Beat("heartbeat_30s", 30 * 1000));
40 | beats.add(new Beat("heartbeat_1m", 60 * 1000));
41 | beats.add(new Beat("heartbeat_5m", 5 * 60 * 1000));
42 | beats.add(new Beat("heartbeat_10m", 10 * 60 * 1000));
43 | beats.add(new Beat("heartbeat_15m", 15 * 60 * 1000));
44 | beats.add(new Beat("heartbeat_20m", 20 * 60 * 1000));
45 | beats.add(new Beat("heartbeat_30m", 30 * 60 * 1000));
46 | beats.add(new Beat("heartbeat_60m", 60 * 60 * 1000));
47 | }
48 |
49 | public void start() {
50 | new Thread(this).start();
51 | }
52 |
53 | public void run() {
54 | while (true) {
55 | try {
56 | long now = System.currentTimeMillis();
57 | Iterator i = beats.iterator();
58 | while (i.hasNext()) {
59 | Beat temp = (Beat)i.next();
60 | temp.check(now);
61 | }
62 | Thread.sleep(1000);
63 | }
64 | catch (Exception ex) {
65 | ex.printStackTrace();
66 | }
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/ui/CutCopyPastePopup.java:
--------------------------------------------------------------------------------
1 | package ui;
2 |
3 | import javax.swing.*;
4 | import javax.swing.event.*;
5 | import javax.swing.text.*;
6 |
7 | import java.awt.*;
8 | import java.awt.event.*;
9 |
10 |
11 | /* A textfield with a popup menu to cut, copy, paste, and clear the textfield */
12 | public class CutCopyPastePopup {
13 | protected JPopupMenu menu = null;
14 | protected JTextComponent component = null;
15 |
16 | public CutCopyPastePopup(JTextComponent component) {
17 | this.component = component;
18 | createMenu();
19 | }
20 |
21 | public void createMenu() {
22 | if (menu != null)
23 | return;
24 |
25 | menu = new JPopupMenu();
26 | JMenuItem cut = new JMenuItem("Cut", 'C');
27 |
28 | cut.addActionListener(new ActionListener() {
29 | public void actionPerformed(ActionEvent ev) {
30 | component.cut();
31 | }
32 | });
33 |
34 | JMenuItem copy = new JMenuItem("Copy", 'o');
35 |
36 | copy.addActionListener(new ActionListener() {
37 | public void actionPerformed(ActionEvent ev) {
38 | component.copy();
39 | }
40 | });
41 |
42 | JMenuItem paste = new JMenuItem("Paste", 'p');
43 |
44 | paste.addActionListener(new ActionListener() {
45 | public void actionPerformed(ActionEvent ev) {
46 | component.paste();
47 | }
48 | });
49 |
50 | JMenuItem clear = new JMenuItem("Clear", 'l');
51 |
52 | clear.addActionListener(new ActionListener() {
53 | public void actionPerformed(ActionEvent ev) {
54 | component.setText("");
55 | }
56 | });
57 |
58 | menu.add(cut);
59 | menu.add(copy);
60 | menu.add(paste);
61 | menu.add(clear);
62 |
63 | component.addMouseListener(new MouseAdapter() {
64 | public void handle(MouseEvent ev) {
65 | if (ev.isPopupTrigger()) {
66 | menu.show((JComponent)ev.getSource(), ev.getX(), ev.getY());
67 | }
68 | }
69 |
70 | public void mousePressed(MouseEvent ev) {
71 | handle(ev);
72 | }
73 |
74 | public void mouseClicked(MouseEvent ev) {
75 | handle(ev);
76 | }
77 |
78 | public void mouseReleased(MouseEvent ev) {
79 | handle(ev);
80 | }
81 | });
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/cortana/core/Events.java:
--------------------------------------------------------------------------------
1 | package cortana.core;
2 |
3 | import java.util.*;
4 |
5 | import sleep.runtime.*;
6 | import sleep.interfaces.*;
7 | import sleep.engine.*;
8 | import sleep.bridges.*;
9 |
10 | public class Events implements Function, Environment, Loadable {
11 | protected EventManager manager;
12 |
13 | public void scriptLoaded(ScriptInstance si) {
14 | Hashtable environment = si.getScriptEnvironment().getEnvironment();
15 |
16 | environment.put("&on", this);
17 | environment.put("on", this);
18 |
19 | environment.put("&when", this);
20 | environment.put("when", this);
21 |
22 | environment.put("&fire_event", this);
23 | environment.put("&fire_event_async", this);
24 | environment.put("&fire_event_local", this);
25 | }
26 |
27 | public void scriptUnloaded(ScriptInstance si) {
28 | }
29 |
30 | protected void addListener(String name, SleepClosure c, boolean temp) {
31 | manager.addListener(name, c, temp);
32 | }
33 |
34 | public void bindFunction(ScriptInstance si, String type, String event, Block body) {
35 | boolean temporary = type.equals("when") ? true : false;
36 | SleepClosure f = new SleepClosure(si, body);
37 | addListener(event, f, temporary);
38 | }
39 |
40 | public Scalar evaluate(String name, ScriptInstance script, Stack args) {
41 | if (name.equals("&fire_event_async") || name.equals("&fire_event")) {
42 | String event = BridgeUtilities.getString(args, "");
43 | manager.fireEventAsync(event, EventManager.shallowCopy(args));
44 | return SleepUtils.getEmptyScalar();
45 | }
46 | else if (name.equals("&fire_event_local")) {
47 | String event = BridgeUtilities.getString(args, "");
48 | manager.fireEvent(event, args, script);
49 | return SleepUtils.getEmptyScalar();
50 | }
51 | else {
52 | boolean temporary = name.equals("&when") ? true : false;
53 | String event = BridgeUtilities.getString(args, "");
54 | SleepClosure f = BridgeUtilities.getFunction(args, script);
55 | addListener(event, f, temporary);
56 | return SleepUtils.getEmptyScalar();
57 | }
58 | }
59 |
60 | public Events(EventManager m) {
61 | this.manager = m;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/cortana/core/Filters.java:
--------------------------------------------------------------------------------
1 | package cortana.core;
2 |
3 | import java.util.*;
4 |
5 | import sleep.runtime.*;
6 | import sleep.interfaces.*;
7 | import sleep.engine.*;
8 | import sleep.bridges.*;
9 |
10 | public class Filters implements Function, Environment, Loadable {
11 | protected FilterManager manager;
12 |
13 | public void scriptLoaded(ScriptInstance si) {
14 | Hashtable environment = si.getScriptEnvironment().getEnvironment();
15 |
16 | environment.put("filter", this);
17 | environment.put("&filter_data", this);
18 | environment.put("&filter_data_array", this);
19 | environment.put("&filterd", this);
20 | }
21 |
22 | public void scriptUnloaded(ScriptInstance si) {
23 | }
24 |
25 | protected void addFilter(String name, SleepClosure c) {
26 | manager.addFilter(name, c);
27 | }
28 |
29 | public void bindFunction(ScriptInstance si, String type, String event, Block body) {
30 | SleepClosure f = new SleepClosure(si, body);
31 | addFilter(event, f);
32 | }
33 |
34 | public Scalar evaluate(String name, ScriptInstance script, Stack args) {
35 | args = (Stack)args.clone();
36 |
37 | if (name.equals("&filter_data")) {
38 | String event = BridgeUtilities.getString(args, "");
39 | Stack results = manager.filterScalarData(event, args);
40 | Scalar r = SleepUtils.getArrayScalar();
41 |
42 | while (!results.isEmpty()) {
43 | r.getArray().push((Scalar)results.pop());
44 | }
45 |
46 | return r;
47 | }
48 | else if (name.equals("&filter_data_array")) {
49 | Stack argz = new Stack();
50 | Scalar event = BridgeUtilities.getScalar(args);
51 |
52 | ScalarArray temp = BridgeUtilities.getArray(args);
53 | while (temp.size() > 0) {
54 | argz.push(temp.pop());
55 | }
56 |
57 | argz.push(event);
58 | return evaluate("&filter_data", script, argz);
59 | }
60 | else {
61 | String event = BridgeUtilities.getString(args, "");
62 | SleepClosure f = BridgeUtilities.getFunction(args, script);
63 | addFilter(event, f);
64 | return SleepUtils.getEmptyScalar();
65 | }
66 | }
67 |
68 | public Filters(FilterManager m) {
69 | this.manager = m;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/graph/CircleLayout.java:
--------------------------------------------------------------------------------
1 | package graph;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import com.mxgraph.model.mxIGraphModel;
7 | import com.mxgraph.util.mxRectangle;
8 | import com.mxgraph.view.mxGraph;
9 | import com.mxgraph.layout.*;
10 |
11 | public class CircleLayout extends mxCircleLayout
12 | {
13 | public CircleLayout(mxGraph graph, double r) {
14 | super(graph, r);
15 | }
16 |
17 | /* override this so it doesn't make the circle so damned big :P */
18 | public void execute(Object parent, int width, int height, double zoom)
19 | {
20 | mxIGraphModel model = graph.getModel();
21 | model.beginUpdate();
22 | try
23 | {
24 | double max = 0;
25 | Double top = null;
26 | Double left = null;
27 | List