Skip to content

Commit

Permalink
restructured mfs library, divided into api and impl packages
Browse files Browse the repository at this point in the history
  • Loading branch information
tux-mind committed Oct 16, 2015
1 parent c4a116c commit 3b75a00
Show file tree
Hide file tree
Showing 78 changed files with 449 additions and 162 deletions.
2 changes: 1 addition & 1 deletion msf/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'java'

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'junit:junit:4.12'
testCompile 'junit:junit:4.12'
compile 'commons-io:commons-io:2.4'
compile 'org.apache.commons:commons-lang3:3.4'
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.csploit.msf.arch;
package org.csploit.msf.api;

/**
* Machines architectures
Expand Down Expand Up @@ -28,5 +28,5 @@ public enum Arch {
DALVIK,
PYTHON,
NODEJS,
FIREFOX;
FIREFOX
}
9 changes: 9 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/Author.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.csploit.msf.api;

/**
* Represent an author
*/
public interface Author {
String getName();
String getEmail();
}
10 changes: 10 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/Auxiliary.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.csploit.msf.api;

/**
* 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 {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package org.csploit.msf;
package org.csploit.msf.api;

import org.csploit.msf.impl.Option;

import java.util.Collection;

Expand Down
11 changes: 11 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/Exploit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.csploit.msf.api;

import org.csploit.msf.api.module.Target;

/**
* Represent an exploit module
*/
public interface Exploit extends Module {
Target[] getTargets();
Target getTarget();
}
11 changes: 11 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/Framework.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.csploit.msf.api;

import java.util.List;

/**
* A Metasploit Framework interface
*/
public interface Framework {
List<? extends Session> getSessions();
List<? extends Job> getJobs();
}
13 changes: 13 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/Job.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.csploit.msf.api;

import java.util.Date;

/**
* This class is the representation of an abstract job.
*/
public interface Job {
int getId();
String getName();
Date getStartTime();
void stop();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.csploit.msf;
package org.csploit.msf.api;

/**
* A license
Expand Down
13 changes: 13 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/Module.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.csploit.msf.api;

/**
* Represent a module of the MSF
*/
public interface Module {

String getRefname();
void setRefname(String refname);

String getFullName();
String getShortName();
}
15 changes: 15 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/Option.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.csploit.msf.api;

/**
* An option
*/
public interface Option<T> {
boolean isAdvanced();
boolean haveDefaultValue();
boolean isEvasion();
boolean isRequired();
T getDefaultValue();
String getDescription();
String getName();
Module getOwner();
}
9 changes: 9 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/Payload.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.csploit.msf.api;

/**
* This class represents the base class for a logical payload. The framework
* automatically generates payload combinations at runtime which are all
* extended for this Payload as a base class.
*/
public interface Payload extends Module {
}
7 changes: 7 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/Post.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.csploit.msf.api;

/**
* A Post-exploitation module.
*/
public interface Post extends Module {
}
29 changes: 29 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/Session.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.csploit.msf.api;

/**
* The session class represents a post-exploitation, uh, session.
* Sessions can be written to, read from, and interacted with. The
* underlying medium on which they are backed is arbitrary. For
* instance, when an exploit is provided with a command shell,
* either through a network connection or locally, the session's
* read and write operations end up reading from and writing to
* the shell that was spawned. The session object can be seen
* as a general means of interacting with various post-exploitation
* payloads through a common interface that is not necessarily
* tied to a network connection.
*/
public interface Session {
int getId();
String getLocalTunnel();
String getPeerTunnel();
Exploit getExploit();
Payload getPayload();
String getDescription();
String getInfo();
String getWorkspace();
String getSessionHost();
int getSessionPort();
String getTargetHost();
String getUsername();
String getUuid();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.csploit.msf.module;
package org.csploit.msf.api.module;

/**
* A platform
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.csploit.msf.module;
package org.csploit.msf.api.module;

/**
* A module rank
Expand Down
9 changes: 9 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/module/Reference.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.csploit.msf.api.module;

/**
* A reference to some sort of information. This is typically a URL, but could
* be any type of referential value that people could use to research a topic.
*/
public interface Reference {
String toString();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.csploit.msf.api.module;

/**
* A reference to a website.
*/
public interface SiteReference extends Reference {
String getUrl();
}
14 changes: 14 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/module/Target.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.csploit.msf.api.module;

import org.csploit.msf.api.Arch;

import java.util.Set;

/**
* Represent a target
*/
public interface Target {
String getName();
Set<Platform> getPlatform();
Set<Arch> getArch();
}
11 changes: 11 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/options/AddressOption.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.csploit.msf.api.options;

import org.csploit.msf.api.Option;

import java.net.InetAddress;

/**
* Network address option.
*/
public interface AddressOption extends Option<InetAddress> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.csploit.msf.api.options;

import org.csploit.msf.api.Option;

import java.net.InetAddress;

/**
* Network address range option.
*/
public interface AddressRangeOption extends Option<InetAddress[]> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.csploit.msf.api.options;

import org.csploit.msf.api.Option;

/**
* Boolean option.
*/
public interface BooleanOption extends Option<Boolean> {
}
10 changes: 10 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/options/EnumOption.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.csploit.msf.api.options;

import org.csploit.msf.api.Option;

/**
* Enum option.
*/
public interface EnumOption extends Option<String> {
String[] getValues();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.csploit.msf.api.options;

import org.csploit.msf.api.Option;

/**
* Integer option.
*/
public interface IntegerOption extends Option<Integer> {
}
11 changes: 11 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/options/PathOption.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.csploit.msf.api.options;

import org.csploit.msf.api.Option;

import java.io.File;

/**
* File system path option.
*/
public interface PathOption extends Option<File> {
}
9 changes: 9 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/options/PortOption.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.csploit.msf.api.options;

import org.csploit.msf.api.Option;

/**
* Network port option.
*/
public interface PortOption extends Option<Integer> {
}
9 changes: 9 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/options/RawOption.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.csploit.msf.api.options;

import org.csploit.msf.api.Option;

/**
* Raw, arbitrary data option.
*/
public interface RawOption extends Option<byte[]> {
}
11 changes: 11 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/options/RegexpOption.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.csploit.msf.api.options;

import org.csploit.msf.api.Option;

import java.util.regex.Pattern;

/**
* A regex option
*/
public interface RegexpOption extends Option<Pattern> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.csploit.msf.api.options;

import org.csploit.msf.api.Option;

/**
* Option string
*/
public interface StringOption extends Option<String> {
}
10 changes: 10 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/sessions/CommandShell.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.csploit.msf.api.sessions;

/**
* This class provides basic interaction with a command shell on the remote
* endpoint. This session is initialized with a stream that will be used
* as the pipe for reading and writing the command shell.
*/
public interface CommandShell extends SingleCommandShell, Scriptable {
//TODO
}
10 changes: 10 additions & 0 deletions msf/src/main/java/org/csploit/msf/api/sessions/Meterpreter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.csploit.msf.api.sessions;

/**
* This class represents a session compatible interface to a meterpreter server
* instance running on a remote machine. It provides the means of interacting
* with the server instance both at an API level as well as at a console level.
*/
public interface Meterpreter extends SingleCommandShell, Scriptable {
//TODO
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.csploit.msf.session;
package org.csploit.msf.api.sessions;

/**
* Executes multiple commands and optionally allows for reading/writing I/O
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.csploit.msf.session;
package org.csploit.msf.api.sessions;

/**
* This interface is to be implemented by a session that is capable of
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.csploit.msf.session;
package org.csploit.msf.api.sessions;

import org.csploit.msf.api.Session;

/**
* Represent a session that can run scripts
*/
public interface Scriptable {
public interface Scriptable extends Session {
boolean executeFile(String path, String[] args);
int executeScript(String scriptName, String[] args);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.csploit.msf.session;
package org.csploit.msf.api.sessions;

import org.csploit.msf.api.Session;

/**
* Executes a single command and optionally allows for reading/writing I/O
* to the new process.
*
* footnote: I didn't found any implementors of this interface in the framework
*/
public interface SingleCommandExecution {
public interface SingleCommandExecution extends Session {
void init(String cmd, String[] args); // TODO: options ??
String read(int length);
int write(String data);
Expand Down
Loading

4 comments on commit 3b75a00

@evertking
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

App crashes for me after starting

@fat-tire
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yah. /data/data/org.csploit.android/files empty except for stacktrace. No tools directory. I haven't built for about 24 hours tho so maybe a lot has changed. Nightly failed too.

10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]: /data/data/org.csploit.android/files/tools/nmap/nmap-mac-prefixes: open failed: ENOENT (No such file or directory)
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]: java.io.FileNotFoundException: /data/data/org.csploit.android/files/tools/nmap/nmap-mac-prefixes: open failed: ENOENT (No such file or directory)
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at libcore.io.IoBridge.open(IoBridge.java:456)
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.io.FileInputStream.<init>(FileInputStream.java:76)
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.io.FileInputStream.<init>(FileInputStream.java:103)
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at org.csploit.android.core.System.preloadVendors(System.java:597)
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at org.csploit.android.core.System.access$000(System.java:95)
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at org.csploit.android.core.System$1.run(System.java:202)
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.lang.Thread.run(Thread.java:818)
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:  Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at libcore.io.Posix.open(Native Method)
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at libcore.io.IoBridge.open(IoBridge.java:442)
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.io.FileInputStream.<init>(FileInputStream.java:76) 
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.io.FileInputStream.<init>(FileInputStream.java:103) 
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at org.csploit.android.core.System.preloadVendors(System.java:597) 
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at org.csploit.android.core.System.access$000(System.java:95) 
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at org.csploit.android.core.System$1.run(System.java:202) 
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
10-16 01:55:54.946 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.lang.Thread.run(Thread.java:818) 
10-16 01:55:54.948 15068-15102/org.csploit.android E/CSPLOIT[core.System.errorLogging]: cannot start commands
10-16 01:55:54.948 15068-15102/org.csploit.android E/CSPLOIT[core.System.errorLogging]: org.csploit.android.core.ChildManager$ChildNotStartedException: cannot start commands
10-16 01:55:54.948 15068-15102/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at org.csploit.android.tools.Tool.async(Tool.java:48)
10-16 01:55:54.948 15068-15102/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at org.csploit.android.tools.NMap.synScan(NMap.java:142)
10-16 01:55:54.948 15068-15102/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at org.csploit.android.tools.NMap.synScan(NMap.java:146)
10-16 01:55:54.948 15068-15102/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at org.csploit.android.services.NetworkRadar$2.run(NetworkRadar.java:90)
10-16 01:55:54.948 15068-15102/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
10-16 01:55:54.948 15068-15102/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
10-16 01:55:54.948 15068-15102/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.lang.Thread.run(Thread.java:818)
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]: /data/data/org.csploit.android/files/tools/nmap/nmap-services: open failed: ENOENT (No such file or directory)
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]: java.io.FileNotFoundException: /data/data/org.csploit.android/files/tools/nmap/nmap-services: open failed: ENOENT (No such file or directory)
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at libcore.io.IoBridge.open(IoBridge.java:456)
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.io.FileInputStream.<init>(FileInputStream.java:76)
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.io.FileInputStream.<init>(FileInputStream.java:103)
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.io.FileReader.<init>(FileReader.java:66)
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at org.csploit.android.core.System.preloadServices(System.java:565)
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at org.csploit.android.core.System$1.run(System.java:203)
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.lang.Thread.run(Thread.java:818)
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:  Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at libcore.io.Posix.open(Native Method)
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at libcore.io.IoBridge.open(IoBridge.java:442)
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.io.FileInputStream.<init>(FileInputStream.java:76) 
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.io.FileInputStream.<init>(FileInputStream.java:103) 
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.io.FileReader.<init>(FileReader.java:66) 
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at org.csploit.android.core.System.preloadServices(System.java:565) 
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at org.csploit.android.core.System$1.run(System.java:203) 
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
10-16 01:55:54.949 15068-15104/org.csploit.android E/CSPLOIT[core.System.errorLogging]:     at java.lang.Thread.run(Thread.java:818) 

@fat-tire
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong branch?

@tux-mind
Copy link
Member Author

@tux-mind tux-mind commented on 3b75a00 Oct 16, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.