AKUMA
  • README πŸ₯·πŸ½
  • Red Teaming πŸ‘Ή
    • Loading 50% πŸ˜’
  • πŸ‘ΏBLUE TEAM
    • YARA rules
  • πŸ“¦Containers
    • DOCKER
      • Docker Security & Pentesting
        • Commond Docker error
      • 8 Best Practices for Docker Host Security
  • Windows Hardening πŸ›‘οΈ
    • Windows Active Directory Pentesting
      • Dll Hijacking
      • MSDT - Microsoft Support Diagnostic Tool Vulnerability
      • AD Enumeration TOOL
      • AD Certificate Templates
      • Kerberos Delegation
    • Windows Security Controls
      • Applocker Basics
    • Powershell Cheat sheet
    • AMSI Bypass
  • Linux Hardening πŸ›‘οΈ
    • Page 1
  • Network Services Pentesting
    • Footprinting Cheat sheet
      • 21-FTP
      • 161-SNMP
      • 445-SMB-139
      • 2049-NFS
      • 53-DNS
      • 587-SMTP
      • 143-IMAP/POP3
    • Juicy Curl
  • Pentesting Web
    • 100 Web Vulnerabilities, categorized into various types
    • Deserialization
      • Node.js Deserialization
    • SHODAN DORK
    • Vulnerabilities PAYLOADS
      • Directory Traversal Payload
      • Html-Injection-Read-FIle
      • Html-Injection
      • OS-Command-Injection
      • SQL-Injection-Auth-Bypass
      • PHP-Code-Injection
      • SQL-Injection
      • SSRF Basic
      • SSRF
      • XML-External-Entity
      • XSLT (eXtensible Stylesheet Language Transformations)
      • XSS Cheat Sheet
        • XSS
        • XSS -
        • XSS-polyglots
        • Cloudflare's XSS protection
    • Base Information
      • File-Extension-Inclusion
        • File-Inclusion-Windows
        • File-Inclusion-Linux
        • File-Extension
      • Media-Type-(MIME)
      • Windows-Sensitive-Files
      • Linux-Sensitive-Files
      • Linux-Log-Files
  • Blogs
    • How I Passed HTB Certified Penetration Testing Specialist
    • A comparative analysis of Open Source Web Application vulnerability scanners (Rana Khalil)
    • Sean Metcalfe Path for AD
    • Secure Docker - HackerSploit
  • Projects
    • HOME LAB
      • HOME LAB Blogs | Active Directory
        • Active Directory Lab Setup - 101
        • Active Directory Lab Setup - 102
        • Active Directory Lab Setup [ AD Enumeration ] - 103
        • Active Directory Lab Setup [AD Attacks ] - 104
      • Home Lab | Splunk Setup & Configuration
    • HOSTING A WEBSITE AND HARDENING ITS SECURITY
  • CTF- Writeups/ Solutions
    • HTB - Advanced Labs
      • Fortress
        • Jet
        • Akerva
        • Context
        • Synacktv
        • Faraday
        • AWS
      • Endgames
        • Ascension
        • RPG
        • Hades
        • Xen
        • P.O.O.
    • idekCTF 2024 🚩
    • TFC CTF 2024 🏳
    • DeadSec CTF 2024 🏴
      • Bing2 (web)
      • Mic_check (misc)
      • Windows Server (OSINT)
    • ImaginaryCTF 2024 🚩
      • cartesian-1 [Forensics]
      • packed [FORENSICS]
      • bom [FORENSICS]
      • BANK [MISC]
    • NahamCon CTF 2024 🏳
      • all WARMUPs
      • Base3200
      • The Hacker Webstore
      • iDoor
      • All About Robots
      • Thomas DEVerson
      • Helpful Desk
      • Curly Fries
    • Cyber Apocalypse 2024: Hacker Royale 🏴
      • Unbreakable [MISC]
      • StopDropAndRoll [MISC]
      • Character [MISC]
      • Delulu [pwn]
      • Tutorial [pwn]
      • Maze [Hardware]
      • TimeKORP [web]
  • Tools
    • Content Discovery & Form Manipulation
      • ffuf
      • RustScan
      • Feroxbuster
      • Dirsearch
      • Gobuster
      • Wfuzz
      • Webshell
      • websocket
Powered by GitBook
On this page
  • Description:
  • File:
  • Solution:
  • Flag:
  1. CTF- Writeups/ Solutions
  2. ImaginaryCTF 2024 🚩

BANK [MISC]

Description:

Can you steal the bank’s money?

File:

pragma solidity ^0.7.0;

contract Bank {
    uint48 flag_cost = 50;
    uint48 amount_you_have = 0;
    uint48 loaned = 0;
    function deposit(uint48 amount) public payable {
        require(msg.sender==YOUR_WALLET_ADDRESS,"Please use the wallet provided to you"); // This is for security purposes
    require(amount==msg.value,"Please send exact amount");
        amount_you_have += amount;
    }
    function withdraw(uint48 amount) public payable {
        require(msg.sender==YOUR_WALLET_ADDRESS,"Please use the wallet provided to you"); // This is for security purposes
        require((amount) < amount_you_have, "You cannot withdraw what you do not have!");
        amount_you_have -= amount;
        msg.sender.call{value:amount}("");
    }

    function getMoney() public payable {
        // Used for deployment, can be safely ignored
    }
    function loan(uint48 amount) public payable {
        require(msg.sender==YOUR_WALLET_ADDRESS,"Please use the wallet provided to you"); // This is for security purposes
        loaned += amount;
        msg.sender.call{value:amount}("");
    }

    function isChallSolved() public view returns (bool solved) {
        if ((amount_you_have >= flag_cost) && (loaned == 0)) {
            return true;
        }
        else {
            return false;
        }
    }


}

Solution:

  • The goal of this challenge is to make the function isChallSolved() return true. Once achieved, the challenge will be completed. The function will check whether the balance of amount_you_have is greater than flag_cost and if the loan is zero.

    In this instance, they have provided the following details:

β”Œβ”€β”€ πŸ‘½AKUMA πŸ₯· ➀➀ 🌐10.10.0.12
β”œβ”€β”€[ο„•   ~/Desktop/CTF/imaginary2024]
└─ βš”  nc 34.30.117.150 40001
[1] Get an instance
[2] Get the flag
Choice: 1
contract address: 0x1969eF364FeFBeBa4E3509aF4D7B8b62E64fcEc4
rpc-url: http://34.30.117.150:49140
Wallet private-key: 0x1c8a5f5de62440776604396f557ebc76e3b23dfbe317b638a4b5b205eeb5c055
Wallet address: 0x6045a94A76888C0f6DC6Bc379FE8a41de4f44A64
Secret: a1fbb572080841e8b3f04d7a756b5c7727432c633094cd44f81bbb1ff283a997
Please save the provided secret, it will be needed to get the flag
  • First, I checked the balance of the provided wallet and contract. If the wallet has sufficient funds to deposit 50 wei into the contract, the challenge will be solved upon deposit. Here is the script to check the balance:

const { ethers } = require("ethers");

const provider = new ethers.providers.JsonRpcProvider(`http://34.30.117.150:41378`) 
const address1 = '0xB46fe37aE41576a6D7215cC9c0e7c78986fA8BBC'
const address2 = '0xD19d049033726BE400400CA8DbA401cC56f17472'

const main = async () => {
    const balance1 = await provider.getBalance(address1)
    console.log(`\nETH Balance of contract --> ${ethers.utils.formatEther(balance1)} ETH\n`)
    const balance2 = await provider.getBalance(address2)
    console.log(`\nETH Balance of wallet --> ${ethers.utils.formatEther(balance2)} ETH\n`)
}

main()
  • After running the above code, I obtained my balance as follows:

β”Œβ”€β”€ πŸ‘½AKUMA πŸ₯· ➀➀ 🌐10.10.0.12
β”œβ”€β”€[ο„•   ~/Desktop/CTF/imaginary2024]
└─ βš”  node 1_accounts.js

ETH Balance of contract --> 0.000117883415867467 ETH


ETH Balance of wallet --> 0.000244134809434108 ETH
  • We can see that the ETH balance of the wallet is much greater than 50 wei, which is also sufficient to cover the gas fee for calling the deposit() function. Once we call the deposit() function, the challenge will be solved.

  • Here is the script for calling the deposit() function:

const { ethers } = require("ethers");
const provider = new ethers.providers.JsonRpcProvider(`http://34.30.117.150:41378`) 
const privateKey="0xd6d9b94c56b738647ce6119556117f54510e2a46135fc19dfc60613fc16b8246"
const wallet = new ethers.Wallet(privateKey, provider)
const ABI = [
    "function loan(uint48 amount) public payable",
    "function deposit(uint48 amount) public payable",
    "function isChallSolved() public view returns (bool solved)",
];
const address = '0xB46fe37aE41576a6D7215cC9c0e7c78986fA8BBC';

const contract = new ethers.Contract(address, ABI, provider)
const contractWithWallet = contract.connect(wallet);

const deposit=async()=>{
    const tx=await contractWithWallet.deposit(50,{value: 50});
    await tx.wait()
    console.log(tx)
}

deposit()

Flag:

β”Œβ”€β”€ πŸ‘½AKUMA πŸ₯· ➀➀ 🌐10.10.0.12
β”œβ”€β”€[ο„•   ~/Desktop/CTF/imaginary2024]
└─ βš”  nc 34.30.117.150 40000
[1] Get an instance
[2] Get the flag
Choice: 2
Please enter the hash provided during deployment: 18e21d8ae3d0145a4f0cfdb824a408d15ee500198532d986f4593dc92f3f52f7
Flag: ictf{1_h4t3_uns1gn3d_1nt5_7f4d3a1b}
Previousbom [FORENSICS]NextNahamCon CTF 2024 🏳

Last updated 10 months ago