diff --git a/msf/.gitignore b/msf/.gitignore new file mode 100644 index 0000000000..796b96d1c4 --- /dev/null +++ b/msf/.gitignore @@ -0,0 +1 @@ +/build diff --git a/msf/build.gradle b/msf/build.gradle new file mode 100644 index 0000000000..079b7cd5b2 --- /dev/null +++ b/msf/build.gradle @@ -0,0 +1,10 @@ +apply plugin: 'java' + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + testCompile 'junit:junit:4.12' + compile 'commons-io:commons-io:2.4' + compile 'org.apache.commons:commons-lang3:3.4' + compile 'commons-codec:commons-codec:1.10' + compile 'org.msgpack:msgpack:0.6.12' +} \ No newline at end of file diff --git a/msf/src/main/java/org/csploit/msf/api/Arch.java b/msf/src/main/java/org/csploit/msf/api/Arch.java new file mode 100644 index 0000000000..f59b479b40 --- /dev/null +++ b/msf/src/main/java/org/csploit/msf/api/Arch.java @@ -0,0 +1,32 @@ +package org.csploit.msf.api; + +/** + * Machines architectures + * + * source: lib/rex/constants.rb + */ +public enum Arch { + ANY, + X86, + X86_64, + X64, + MIPS, + MIPSLE, + MIPSBE, + PPC, + PPC64, + CBEA, + CBEA64, + SPARC, + CMD, + PHP, + TTY, + ARMLE, + ARMBE, + JAVA, + RUBY, + DALVIK, + PYTHON, + NODEJS, + FIREFOX +} \ No newline at end of file diff --git a/msf/src/main/java/org/csploit/msf/api/Author.java b/msf/src/main/java/org/csploit/msf/api/Author.java new file mode 100644 index 0000000000..19e97553ae --- /dev/null +++ b/msf/src/main/java/org/csploit/msf/api/Author.java @@ -0,0 +1,9 @@ +package org.csploit.msf.api; + +/** + * Represent an author + */ +public interface Author { + String getName(); + String getEmail(); +} diff --git a/msf/src/main/java/org/csploit/msf/api/Auxiliary.java b/msf/src/main/java/org/csploit/msf/api/Auxiliary.java new file mode 100644 index 0000000000..6b49227516 --- /dev/null +++ b/msf/src/main/java/org/csploit/msf/api/Auxiliary.java @@ -0,0 +1,14 @@ +package org.csploit.msf.api; + +import org.csploit.msf.api.module.AuxiliaryAction; + +/** + * The auxiliary class acts as a base class for all modules that perform + * reconnaissance, retrieve data, brute force logins, or any other action + * that doesn't fit our concept of an 'exploit' (involving payloads and + * targets and whatnot). + */ +public interface Auxiliary extends Module, Executable { + AuxiliaryAction[] getActions(); + AuxiliaryAction getDefaultAction(); +} diff --git a/msf/src/main/java/org/csploit/msf/api/Console.java b/msf/src/main/java/org/csploit/msf/api/Console.java new file mode 100644 index 0000000000..8145fe9e95 --- /dev/null +++ b/msf/src/main/java/org/csploit/msf/api/Console.java @@ -0,0 +1,56 @@ +package org.csploit.msf.api; + +import org.csploit.msf.api.sessions.Interactive; + +import java.io.IOException; + +/** + * A console interface to a Msf instance + */ +public interface Console extends Interactive { + /** + * get the ID of the console + * @return the console ID + */ + int getId(); + + /** + * get the prompt of the console + * @return a string that should be used as prompt for new commands + */ + String getPrompt(); + + /** + * get the console busy state + * @return {@code true} if the console is busy, {@code false} otherwise + */ + boolean isBusy(); + + /** + * close this console + */ + void close() throws IOException, MsfException; + + /** + * write to this console + * @param data the data to write + */ + void write(String data) throws IOException, MsfException; + + /** + * get tab completion for a command + * @param part partial command to complete + * @return an array of possibilities + */ + String[] tab(String part) throws IOException, MsfException; + + /** + * kill the session attached to this console, if any + */ + void killSession() throws IOException, MsfException; + + /** + * detach from an attached session, if any + */ + void detachSession() throws IOException, MsfException; +} diff --git a/msf/src/main/java/org/csploit/msf/api/ConsoleManager.java b/msf/src/main/java/org/csploit/msf/api/ConsoleManager.java new file mode 100644 index 0000000000..574fc6526b --- /dev/null +++ b/msf/src/main/java/org/csploit/msf/api/ConsoleManager.java @@ -0,0 +1,64 @@ +package org.csploit.msf.api; + +import org.csploit.msf.api.exceptions.ResourceNotFoundException; +import org.csploit.msf.api.listeners.ConsoleListener; + +import java.io.IOException; +import java.util.List; + +/** + * Manage consoles + */ +public interface ConsoleManager extends Publisher { + /** + * get a list of consoles managed by this {@link ConsoleManager} + * @return a list of consoles managed by this {@link ConsoleManager} + */ + List getConsoles() throws IOException, MsfException; + + /** + * get a console by it's id + * @param id of the console + * @return the console with the supplied id + * @throws ResourceNotFoundException when a console with + * the specified {@code id} cannot be found + */ + Console getConsole(int id) throws IOException, MsfException; + + /** + * Create a new console + * + * @param allowCommandPassthru Whether to allow + * unrecognized commands to be executed by the system shell + * @param realReadline Whether to use the system's + * readline library instead of RBReadline + * @param histFile Path to a file + * where we can store command history + * @param resources A list of resource files to load. + * If no resources are given, will load the default resource script, + * 'msfconsole.rc' in the user's config directory + * @param skipDatabaseInit Whether to skip connecting to the database + * and running migrations + * @return a new {@link Console} + */ + Console create(boolean allowCommandPassthru, boolean realReadline, + String histFile, String[] resources, boolean skipDatabaseInit) + throws IOException, MsfException; + + /** + * Create a new Console using framework defaults settings + * + * @return a new {@link Console} + */ + Console create() throws IOException, MsfException; + + /** + * start watching for consoles output + */ + void start(); + + /** + * stop watching for consoles output + */ + void stop(); +} diff --git a/msf/src/main/java/org/csploit/msf/api/Customizable.java b/msf/src/main/java/org/csploit/msf/api/Customizable.java new file mode 100644 index 0000000000..116c949605 --- /dev/null +++ b/msf/src/main/java/org/csploit/msf/api/Customizable.java @@ -0,0 +1,15 @@ +package org.csploit.msf.api; + +import java.io.IOException; +import java.util.Collection; + +/** + * An object that can be tuned up + * by editing it's options. + */ +public interface Customizable { + void setOption(String key, String value); + Collection