Survival of the Fittest

My first Block Chain CTF

Host

159.65.24.125:30266

after we have downloaded the necessary files we can unzip them

unzip Survival\ of\ the\ Fittest.zip

we are presented with two files

  • Creature.sol

  • Setup.sol

What are these files?

  • .sol files are associated with Solidity. a programing language used for developing smart contracts on blockchain platforms, particularly Ethereum

  • Solidity is a high-level language that enables developers to write code for smart contracts, which are self-executing contracts with the terms of agreement directly written into the code

  • These .sol files contain logic and rules that govern the behavior of the smart contract when it is deployed on a blockchain

  • After writing solidity code, developers typically compile it into bytecode, which can be executed by the Ethereum Virtual Machine (EVM) or a compatible blockchains virtual machine

  • Once compiled, the bytecode is deployed as a smart contract on the blockchain

when we navigate to 159.65.20.166:30532

we can see the following

we can also view the docs

we also have within the connection tab

Lets set up

lets download foundry: a suite of tools that let you test and implement projects on the blockchain

To interact with the blockchain we need the following information

  • Private key: A cryptographic private key that is only known to the owner and is used to sign transactions, particularly for crypto's like bitcoin and ethereum, a private key is associated with a specific wallet address

  • The RPC URL :This is the endpoint or URL through which a user or application can make remote calls to interact with a blockchain node, it is often used to send requests to the blockchain network for tasks like querying information, sending transactions, or interacting with smart contracts

    • RPC call: in blockchain tech, a RPC allows a program to cause a procedure (subroutine) to execute on another address space, typically a remote server

  • The address of the target contract: In the context of smart contracts, the address refers to the unique identifier assigned to a deployed smart contract on the blockchain. Each smart contract has a distinct address

How do we interact with the RPC endpoint

  • when we had a look at the docs, we can see the rpc endpoint is located at /rpc

when we open these .sol files through vi we can see the following

Creatures.sol

we can see

  • a constructor

  • multiple functions that we can interact with using the cast tool

Setup.sol

we can see a few things

pragma solidity ^0.8.13: defines the version of the compiler and instructions on how to read the code

we can see we have functions specified with the function key word

  • we can see the function isSolved that t is declared as a public view, meaning it is only a view function, only to view data not modified it

our goal is to beat the creatures in the web application game

Modifying Data

  • within the Creatures.sol, we have the function strongAttack which deals deals a certain amount of damage to the creatures,

  • we can see the function takes an argument

  • we can see in the in the first box the argument type, then the value

Now we can use cast to modify the data

  • essentially this is a transaction in the blockchain

  • Once we have send this transaction if our specific value this should set us up to drain the lifePoints of the creatures

Now we can call the loot function

Last updated