Try   HackMD

Hack The Box - Reversing (Easy Part 1)

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Ghi chú:

Difficulty: Easy

Challenge 1: The Art of Reversing

This is a program that generates Product Keys for a specific Software Brand. The input is the client UserName and the Number of Days that the sofware will remain active on the client.
The output is the product key that client will use to activate the software package. We just have the following product key 'cathhtkeepaln-wymddd'
Could you find the corresponding Username say A and the number of activation days say B given as input? The flag you need to enter must follow this format: HTB{AB}

Download Challenge Here

Solution

Chúng ta có thể sử dụng lệnh 'file' để cung cấp cái nhìn tổng quan về loại tệp.

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Mở chương trình trong dnSpy

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Phần này chứa hàm main(), thiết lập các ứng dụng mà chúng ta quan tâm. Trong đó, ta chú ý Run(Form1) - InitializeComponent().

Chương trình sẽ cho ta nhập vào UsernameActivate Day. Thực hiện mã hóa để tạo ra Key.

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Ta quan sát hàm buttonCreateProductKey_Click() để biết nội dung mã hóa.

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Đầu tiên chúng ta thấy hàm này kiểm tra xem hộp văn bản Tên người dùng hoặc Số ngày có trống hay không. Nếu một trong hai trống, nó sẽ ném, báo lỗi và trả về.

  • nPr(): tạo key bằng username. Tên người dùng đã bị đảo thứ tự, không phải bị mã hóa.
  • ToR() là thuật toán đệ quy chuyển đổi số đầu vào thành chữ số La Mã..
  • DoR() thực hiện đảo ngược mảng, đẩy tất cả các ký tự sang bên phải một lần. Điều này có nghĩa là C biến thành D, V thành W, v.v.
givenUser = "cathhtkeepaln"
Input = "0123456789abc"
Output = "21450c3b6798a"

dictionary = {}

for i in range(13):
    dictionary[Output[i]] = givenUser[i]
    
print("".join(dictionary[key] for key in sorted(dictionary.keys())))    #hacktheplanet
givenDay = "dddmyw"
originalGivenDay = "".join([chr(ord(givenDay[i])-1) for i in range(len(givenDay))]) #ccclxv

C = 100, L = 50, X = 10, V = 5. So we have 100 + 100 + 100 + 50 + 10 + 5 = 365
Flag: HTB{hacktheplanet365}

Challenge 2: Tear Or Dear

Find the username and password and put them in the flag in the format: HTB{username:password}. Warning: It can produce false positives.

Download Challenge Here

Solution

Mở chương trình trong dnSpy

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Phần này chứa hàm chính và hàm thích hợp khác mà chúng ta quan tâm. Nếu mở rộng nó, chúng ta sẽ thấy hai thành phần: LogonForm. Hàm này chỉ gọi hàm, chỉ gọi hàm InitializeComponent().

Chương trình tìm kiếm thông tin về Tên người dùng và Mật khẩu. Nếu chúng ta nhấp vào nút Đăng nhập, nó sẽ kiểm tra thông tin đầu vào của chúng ta.

Nó hiển thị cho chúng ta 2 điều kiện để nhận được thông báo “Chính xác”.

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Nó hiển thị cho chúng ta 2 điều kiện để nhận được thông báo “Chính xác”.

  • this.username == this.o
  • this.check1(s) == True

Nếu đi sâu xuống, chúng ta có thể nhận ra điều gì đó:

  • this.o = encrypted10("1hpip"+ 9 times password) nhưng bất kể mật khẩu là gì, 100% nó sẽ trả về "roiw!@#". Vậy this.o = "roiw!@#"
  • UserName = this.aa in order to check1(string s) = True
  • Chương trình tạo ra các chuỗi như: "1hpip"+ 9 lần mật khẩu. Sau đó lấy 5 ký tự đầu tiên của chuỗi. Đảo ngược và xóa ký tự cuối cùng. Vậy this.aa = "piph"
Flag: HTB{piph:roiw!@#}

Challenge 3: Find The Easy Pass

Find the password (say PASS) and enter the flag in the form HTB{PASS}

Download Challenge Here

Solution

Chúng ta có thể sử dụng lệnh 'file' để cung cấp cái nhìn tổng quan về loại tệp.

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Chương trình này được biên dịch với Borland Delphi. Mở chương trình trong IDA.

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Hàm LStrLAsg trong Delphi được sử dụng trong lập trình Delphi để gán các giá trị chuỗi. Nó là viết tắt của "Long String Assign" (Chỉ định Chuỗi Dài). Thủ tục này thường liên quan đến việc xử lý các hoạt động gán chuỗi, bao gồm cả việc quản lý bộ nhớ.

Hàm LStrCatN trong Delphi được sử dụng để nối một số ký tự được chỉ định từ chuỗi này sang chuỗi khác. Nó là viết tắt của "Long String Concatenate N" (Nối Chuỗi Dài N). Hàm này thường được sử dụng khi bạn muốn nối một số ký tự cụ thể từ chuỗi này đến cuối chuỗi khác.

Chương trình thực hiện kiểm tra dữ liệu ta nhập vào và chuỗi đã được nối bởi hàm LStrCatN - chuỗi đó là fortran!.

Flag: HTB{fortran!}

Challenge 4: Eat the Cake!

Find the Password and enter it in the form HTB{password}

Download Challenge Here

Solution

Chúng ta có thể sử dụng lệnh 'file' để cung cấp cái nhìn tổng quan về loại tệp.

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Chúng tôi có trình đóng gói/giải nén UPX.

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Mở chương trình trong IDA

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Thật dễ dàng để nhận ra chương trình này kiểm tra từng kí tự của input với từng ký tự của Destination. Chúng ta có thể nhận được input = “h@ckth3parad1$E” .

Flag: HTB{h@ckth3parad1$E}

Challenge 5: Impossible Password

Are you able to cheat me and get the flag?

Download Challenge Here

Solution

Chúng ta có thể sử dụng lệnh 'file' để cung cấp cái nhìn tổng quan về loại tệp.

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Mở chương trình trong IDA.

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Thử thách này có 2 giai đoạn. Nếu chúng ta vượt qua cả hai giai đoạn, nó sẽ in cờ.

  • Stage 1: input = SuperSeKretKey
  • Stage 2: strcmp(input_value,random_value).

Tôi đã vá bằng một đoạn code IDApython để sửa lệnh nhảy

import ida_bytes
ida_bytes.patch_byte(0x400968,0x74)

Nếu bạn không muốn làm như trên, bạn có thể sử dụng SuperSeKretKey ^ 0x09

upload_2b595f23af5397d1bd974672b03eac69

Flag: HTB{40b949f92b86b18}

Challenge 6: Baby RE

Chúng ta có thể sử dụng lệnh 'file' để cung cấp cái nhìn tổng quan về loại tệp.

Download Challenge Here

Solution

Chúng ta có thể sử dụng lệnh 'file' để cung cấp cái nhìn tổng quan về loại tệp.

upload_612453a0ac1e70ec9e521452c5f8a6b9

Mở chương trình trong IDA.

upload_118f4513a6c14737550a7ac5725e68a6

Flag: HTB{B4BY_R3V_TH4TS_EZ}

Challenge 7: Ransom

We received an email from Microsoft Support recommending that we apply a critical patch to our Windows servers. A system administrator downloaded the attachment from the email and ran it, and now all our company data is encrypted. Can you help us decrypt our files?

Download Challenge Here

Solution

Chúng ta có thể sử dụng lệnh 'file' để cung cấp cái nhìn tổng quan về loại tệp.

upload_f2d36ea595a89312678dc505b3d3fb0f

Mở chương trình trong IDA.

upload_2386d61898b53aa644b4e905f3c45835

Hàm này thực hiện mã hóa tệp được đưa làm tham sốghi tệp đã được mã hóa

upload_c0b9bd0dbd39718a4e78edc640514e61

Bây giờ là lúc để khai thác nó.

from Crypto.Util.number import long_to_bytes

key = list(b"SUPERSECURE")
encrypted_bytes = open("login.xlsx.enc", "rb").read()
count = 0
decrypted_bytes = b""

for byte in encrypted_bytes:
    decrypted_bytes += long_to_bytes(((byte - key[count % len(key)]) % 256))
    count += 1

with open('login.xlsx', 'wb') as file:
    file.write(decrypted_bytes)

upload_9efdef7d743db0ef4bc61068ace21b08

Flag: HTB{M4lW4R3_4n4LY5I5_IN73r357iN9_57uFF}