New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Carlos Sanchez I Beginners Track Capture the Flag CTF Intro I ETHGlobal Prague 2025

ETHGlobalThu, Oct 9, 2025, 12:00 AM

Carlos Sanchez introduces the Capture the Flag (CTF) challenge at ETHGlobal Prague 2025, designed to help developers deepen their Solidity and security skills. Learn how to solve 12 progressively difficult challenges deployed on Optimism, earning SVG NFTs as flags. The workshop covers using Scaffold-Ethereum tools, interacting with contracts through multiple methods (UI, scripts, Etherscan), and demonstrates solving the first two challenges. Perfect for developers looking to practice smart contract security in a gamified environment. 00:00 Introduction to CTF concept and history 00:48 How CTF games work in blockchain context 01:19 Why breaking things leads to deeper understanding 01:49 Popular Ethereum CTF examples 02:30 Defcon CTF experience and results 02:59 Introducing ctfbillgill.com challenge platform 03:35 How flag NFTs work with SVG images 04:15 Scaffold-Ethereum extension setup 04:47 Website walkthrough and first challenge 05:21 Connecting wallet and checking flags 05:53 Installing scaffold-eth CTF extension 06:36 Running local blockchain instance 07:17 Deploying challenge contracts locally 07:52 Examining challenge 1 contract code 08:29 Understanding the flag minting mechanism 09:07 Debug contract UI demonstration 09:39 Solving challenge 1 through UI 10:17 Funding account and completing challenge 10:52 Alternative methods to interact with contracts 11:28 Using AI Ninja contract interface 12:07 Solving via script with private key 13:11 Testing solution on local network 13:57 Running script on Optimism mainnet 14:46 Capturing first flag on live network 15:43 Introducing challenge 2 requirements 16:18 Understanding msg.sender vs tx.origin 16:54 Solution approach using intermediate contract 17:50 Writing solution contract code 18:42 Deploying solution contract locally 19:38 Testing solution contract interaction 20:24 Deploying solution to Optimism 21:23 Switching frontend to Optimism network 22:08 Capturing second flag on mainnet 22:58 Recommended next steps for learners 23:33 Importance of hands-on practice 24:23 Estimated completion times for challenges 25:35 Demo of AI Ninja contract interface tool _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 🇨🇿 *ETHGlobal Prague* This workshop is specifically for ETHGlobal Prague, a 3-day hackathon held May 30 - June 1 2025, bringing together the most skilled web3 developers, designers and product builders from all around the globe for a weekend-long adventure to advance the Ethereum ecosystem! Watch the full ETHGlobal Prague 2025 playlist here: https://youtube.com/playlist?list=PLXzKMXK2aHh5Vv-ZobDU2YMWekDFYvOqd&si=SoQ5O2TOAK8RkYf- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ✅ Follow Buidl Guidl Website: https://buidlguidl.com ✅ *Follow ETHGlobal* X: https://x.com/ETHGlobal​ Warpcast: https://warpcast.com/ethglobal Website: https://ethglobal.com YouTube: https://www.youtube.com/c/ETHGlobal _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _Are you interested in Ethereum development and entrepreneurship?_ 👉 Sign up for the next ETHGlobal event: https://ethglobal.com/events 🎁 Get exclusive access and perks with ETHGlobal Plus! https://ethglobal.com/plus 📣 Want us to throw an event in your city? Tell us where! https://ethglobal.com/city _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Transcript

[Music] If you have been here for the last um couple of hours, this is the perfect next step uh to do after because we went through all the speed theum challenges scaffold and this is going to be at least an introduction to go deeper into solidity and security and more advanced concepts. So um just to give a little bit of context um capture the flag games I think the first time that um someone played was 30 years ago in the DevCon cyber security conference. Basically it's like a challenge game with with different levels uh where you have to capture this uh flag. This flag used to be like a password or like a text string and it could be anything. It could be like a file into a server that you're not supposed to have access so you have to hack it and go inside and get the password or it could be like a database uh row and you maybe do like a little bit of like SQL injection to get that flag and it got really popular and I think it was because um I don't know there's something on our brains that when you know that there's like a challenge there's like a door that you are not supposed to cross um and then you know your brain just like try to do it and it's like a gamifying finding experience and I personally love it and I think when you learn to break things um you get like a deep knowledge of the thing right imagine that you have like a physical device if you know how to disassemble it put the pieces out put the pieces in again maybe tweak a little a little piece if you know how to do that you probably have like a deep understanding of the of the thing right so I put some examples here some of them are super like classic like over the wire or the boogie web application and also we have some good ones on Ethereum like Ethernet is a classic then vulnerable defi capture the ether and of course um Belgill's CTF um this is something that we created for last year Defcon in Thailand so we have like a bunch of people playing in teams and we have like a big leaderboard in the screen um it was great um the thing is that funny story we planned for three hours Um I think the first two teams they did it in 30 minutes which was a bit scary you know we were like oh these people I might be cheating but no like the reality was like they were doing that for a living.

Uh and it was uh interesting but I think only how many I think probably five or six teams finished. Um but you know now the thing that we did is after Defcon we put this on a website uh so anyone can play at home you at your own pace. I will show it in a moment, but this ctfbellgill.com. Yeah.

Um, so a little bit on on the on the game dynamic. There are basically 12 challenges uh increasing in complexity. At the be the first few are like super easy, but then it gets complicated, you know, and you're going to learn a bunch of these concepts like brute forcing um decompiling bite code, learning about delegate calls, which are super scary. Um and all of these contracts are deployed on optimism but you can also play locally if you want as as we will see now. Um so in this case uh one flag equals to one um NFT in this case is like a SVG NFT which are my favorite kind of NFTs is like you the contract return the SVG code.

So if you take a look at the image on the on the left you will see how how it works. So we have like a central um NFT contract and the only allowed mters are each of the challenges, right? So challenge number one can mean like the NFT or the flag look like that number one. So basically you have to the premise is you have to get your way around the contract to uh make them mean you an NFT. Um and yeah, we'll see that in a moment.

If you are already an experienced developer, you can just go to the website and play. But if you don't have like a stack, h we are we created like a scaffold e extension which has a lot of like interesting tools that you can use to to play everything you need to play the game. Um and yeah, let's let's go to the website and let's start coding a little bit. My hands are start to get like, you know, I want to code right now. Stop talking.

Um so yeah, let's see. Go to the Yeah. So this is the website ctfbillgill.com. You don't need to do anything.

Uh you don't need to register. You can just go start and you will be seeing the first the first challenge. So a challenge is basically like a description. In this case is like a lot of like um text in here and some hints. And in this hint you will see like the scaffold extension that I was talking about that this is what we are going to be using today.

Um so for example I can connect my wallet here. Um I created like a fresh account just for this. Um so I haven't I don't have any as you can see here I don't have any flags yet. Um so yeah let's start with setting because you could just like I said if you have your own stack already working you can just go here to the contract address go to optimist optimistic ether scan and check the contract out here and you know and do whatever you need to do to to beat that challenge but we are going to take a step back and use our extension. So you can click here.

It's basically like a GitHub repo with some nice instruction like everything you need is here like how to install it, how to run it and you know like how to deploy a contract, how to um run a script, all of that stuff is is here. So you just need to take this command, go to the console and let's see this paste it and and yeah, this will um install the scaffold with the yeah with the CTF extension. And I'm not going to do this. I did this before just to save some some minutes. I choose hard hat by the way just to you know feed the haters a little bit.

Um, okay. So, let's go to Prague, TTF, Prague, and then let's run the three magic commands. So, yarn chain is going to spin like a local blockchain. If you are with hard hat, it will be like a hardhead, you know, um, node. If you are using foundry, it will be anvil.

Um, okay. Then you're going to deploy all the contracts. And these contracts um when you you do yarn deploy on a scaffold it's going to deploy all the contract that you have on your scaffold instance. And in this case those contracts are all the challenge contract like the one to 12 contracts are going to be deployed locally. Oh my computer is slow today Linux probably.

Uh hello. Okay, you see so all the contacts are being deployed and the next thing you have to do just yarn start which is going to give you like a nice uh UI and yeah well let's I mean let's this is going to take a while let's loading let's take a look at the code so if you open that folder this is the instance of escapolith um you will have three packages here hard hat or foundry nex and a script folder so let's go directly to the contract right so if you go to the contract cont folder you will see all the contracts here. Um so challenge one um and here we will see like the pattern I was talking about before. So okay take a look. Um this is the first challenge should be easy.

Uh so this contract only have one function called register me take some arguments a name. The name needs to be you know not not empty. And then here we just like um saving some data and emitting an event. And this is what I was talking about before, right? So each contract is talking with a central NFT contract and it's minting in this case, you know, this is like basically the flag is two, three, four.

So in this case is one and these are the only ones uh allowed to to mint an NFT. So I mean it's obvious anyone knows the how to beat this challenge. What do you have to do here? It's just to call that function, right? You just have to if you call that function register, that will already give you the NFT.

And and there so so many ways that you can let me disconnect this to get the boner wallet maybe like this. Yeah. Okay. So this is the the UI that you that you get with extension. Some explanation, some links and this is the the flag tracker.

So you will see here all the flags that you are capturing and again this is locally right like we are playing on hard hatut but anytime we can like switch to optimism and just like play here you know or playing against the contract that are deployed on optimism. So okay let's just start the one of the good things about scaffold is like this um component like the debug contract component which gives you um a nice UI for every contract that you have deployed. So it automatically reads the AI and the addresses. So you see this is getting all the challenges from hard and you get like challenge one and you get all the you know like AI functions here in this case race me super easy. If I do like Carlos from UI I will send it.

Okay, I don't have any funds. Get it from the faucet. And I don't know if you know already, but this is like a ber wallet. This is something that um the pre private key is stored in local storage. Not not very safe, but this is just for development, but you can also connect your metamas as we will do or your wallet as we will do right now.

So, okay, we got the funds already. We are going to send the transaction and that's it. Boom. Challenge one completed. But again this is local host.

Um this is free fake money. But what if we want to have it here right? Um so again multiple ways of interacting with a contract. Um also take you know uh when you are doing this I think take take your time right even if you are already solve this challenge because it's really easy like think about other ways that you can solve it. So you will learn a lot of things.

For example, here if we go to the challenge one and we will just like one option will be click it go to the verified contract in optimistic ether scan and then going to write contract and it will have like a a bit of a not the best UI but you could connect your wallet and call it the function here. If you want like a better UI you can use AI ninja which is really cool something that we built at buildgill. So for example, you can choose optimistic optimism um paste the contract address and then load the contract and you get all the contract here. So I can connect my wallet here and just call it from from here. So what else?

So we could also do cast you know if you have foundry uh I think there's something like cast sent and then probably like the contract address then the RPC something then the function signature then the arguments so you can basically call um the function contract from the CLI but what we are going to do uh we are going to do a script and that's where we have some per example here so I think we are going to use that. So if you go to the scripts folder, there's like a example here. Um what it's doing is um basically creating a you know getting like this like some logic to get your encrypted private key. Um I already imported mine um and here is basically getting the contract right so we have all the contract data already set up on the instance. So you can do challenge one address or challenge one.

abi AI and once you have that you just have to we are using VM for the scripting so you see we are calling the the function here so we are saying okay challenge one contract right register me I'm passing like a bob and I'm going to say here like uh Carlos from a script and then yeah I want to change that too yeah thank you um okay so um what I did before the talk I just imported my private key here my dev account so you and do yarn account. So, let's see. Um, it's going to ask for my password, I think. Okay. One, two, three, four.

Don't steal me. Um, okay. So, you can see I have like some optimism uh balance and it's like 19F. So, let's see if I if I have the same wallet connected here. Uh, yes, 19F.

Right. So, I'm on my local machine creating a script. Um, and I'm going to I'm going to test first, I guess, on on hard hat, you know, just to test if if that works. So, I'm going to go to my UI here. I'm going to connect my wallet.

Uh, let's see. Yes, that is the one. 19F, right? Yes. I'm going to get some funds.

And you can see I don't have any flags right now. So, I'm just going to um to CD into the script folder and I'm going to do t um yarn tsx with pk. All of this is on the documentation too. And then I'm going to run example ts. So, let's see what happens.

I it will prompt for my password and then then seems working. Let's see. Boom. Yeah, I go back here. I capture the flag, right?

Um but like from from a script which is really nice on hard hatut. So now I just want to play like the real game, right? On optimism. So look at this. I just have to change the target chain to optimism.

You have to have some some gas that I already have. So if I do this, it should do exactly the same but on a live network. So let's see. Let's see if that works. Is that the last block number?

I think it works. My flags. Boom. I have it. So, as you can see, like the first challenge, super easy, but there like so many ways to to interact with a contract.

Um, so yeah, now let's let's move to the to the next one. Um, let's check it on here or challenge two. Okay, I'll let you guys take a a look at the the contract and see if anyone has an idea on how to So, what's happening here? Like what what's like the required any any thoughts? So there is like this message sender and TX origin.

They're like globals from solidity and usually um the message sender I guess is like the last entity that talks with the contract and TX origin is the one that originated the transaction like EOA, right? So for example, if I try to call this directly from my UI, from my metamas, it's not going to allow me because message sender is going to be equal to tx origin. Um, and we are requiring here to be different. So yeah, let's try that. Uh, if I go here, go to the back contracts challenge to if I okay again, just call me.

I'm going to click it. Boom. Not allowed. Yes. Why?

Because the the, you know, message sender and txin are the same. and we need to them to be different. So the way to go about it is you will need to deploy a contract and then that contract will call this contract right. So then from your EOA you will call a function in your contract that will talk to another contract and then you say okay the message sender is like this contract but the TX origin is my EOA there are different addresses right so then it will it will pass the the check. So let's do that.

Let's let's of course try locally first. Um I'm going to create a new contract here. I'm going to call it solution two. Um yeah. Oh, let's see.

Yeah, this is this is the thing right with AI now. Uh things get a little bit tricky. Um but I'm going to do it in a different way. I'm going to I'm going to do like a the old like interface interface um challenge to and then that function and then my contract is going to be contract solution oh solution two and then yeah we are hard coding the address here I don't like this I'm going to do like a argument so Yeah, challenge two. That's good.

That's good. So, yeah. So, if we deploy this contract, then I can call this um function pass in the challenge to address and then this will be calling the challenge to contract, right? So then that will hopefully bypass this check. So to deploy that we have deploy scripts here.

Um we have an example here. Um let's unc comment this and yeah okay so I call it solution two doesn't get like any arguments right it's like that okay so in order to run it you can you can do this uh so you don't redeploy all the solutions so let's do like yarn uh deploy I think I have it tag solution two. So, this should deploy my solution to uh Okay, I'm on the wrong folder. This should deploy my solution to contract. And this will appear on the debug contract page.

Let's see. Boom, boom, boom, boom. It's deployed. Let's see if it's here. It's reloading.

Here is it. Like uh solution two. And then it just take the address, right? So we are going to go to challenge number two. Copy the address.

Go to the solution two uh contract. And again this is going to call the solution two contract with the challenge two address. And that's going to call this uh challenge two contract. And then that hopefully will bypass that check and mint the NFT for me. So let's see.

Send the transaction. Um this is local. Let's see. Boom. Flag does flag flex two is uh is there.

Um and again this is um hard hat right. So this is um this is not aware of that. Um and in order to do that it's like again super easy just have to do the same but as a does network optimism and this will do exactly the same like deploy the contract but now not to a local chain but to optimism. So let's see if that works. It's deploying.

Boom, boom, boom. Worked. So now I think um okay, the thing is that our front end is still pointing to hard hat, right? Uh but that's like super easy. You can just go to scaffold config and say, okay, I want my front end to point to optimism, right?

So now if I go here and refresh instead of saying hard hat it should be optimism and if I go to the debug contract page it should have all the live optimism contracts. Let's see this is something that we need to fix. Okay. Um OP we are there 19F going to the back contracts. As you can see all of these are on OP mainet.

So, same thing. We go to challenge two, grab the address, go to solution two, paste it here. Same process, but now in a live network. And if I do this, uh, this should get me flag number two. Let's wait.

Oh, boom. Already there. So, yeah, as you can see, this is like a nice workflow. you are testing on local host with fake money uh with your dev or banner wallet and then once that is tested you can just like point to optimism and and do it the same um I think we don't have much more time but uh yeah like I think you know um this gets more complicated you know as you see like this award like really easy but you know I think the moment that you go after yeah probably after six that gets really tricky and if you beat all of them I assure that you are going to have like a deep knowledge of uh solidity. Um so let's see if I have something else here.

Uh okay maybe let me open this. So yes. So next steps would be if this still sounds a bit um scary to you uh you're a bit lost I recommend you go to back to speed ethereum and revisit some fundamentals and also get familiar with scaffoldith and then you know just go and try to complete the 12 challenges on your own and after that yeah there are a lot of options like I said before like like if not a lot of good content out there security related and just like keep building and testing stuff right I that um a lot of us has been into this tutorial hell about just like reading or watching like um you know happy path videos. So the best way to learn is just like getting your hands dirty and build things and I think I don't have anything else. Yeah.

So thank you. And if you have like any questions u um we'll be here for a while too, right? I mean we have another thing with Austin now. But yeah, thank you very much to everyone. Any questions?

No. Andrea, you know where to go? Yes. So like in the Oh yeah, that's that's true. So the the average time of of finishing the the challenges I mean I think we when we were in Thailand I think only six teams finished and you know the most developers finishing it was like a team two of like of four playing and it was like 30 minutes which is crazy.

I mean like the day before we were like testing in our hotel just like you know testing if everything worked and it it took us like one hour to test everything with the solutions you know and these people do it in 30 minutes. But I don't know if you are doing that on your own at home depending on your level. I think you can just like probably the first few challenges you can do them in a in a few hours but then maybe a few weeks if you just dedicate a bit of time every every day. I think a few weeks you can like tackle all of them. the ABI Ninja.

Yeah. So, you want to learn more about the AI Ninja. So, the thing is that um imagine that you have a contract and but you don't have a UI for it. You just have the you know that a contract lives on etherscan but you you don't know where like the UI to interact with that contract because for example you are on uniop right so you have all the unisop contracts and you want an UI and you go to unisop and you use it right but imagine that you don't have a UI for it you only have the contract so what AI ninja does is getting all the like the like the information the AI from the contract and it's create like a you know like a nice nice UI for you so you have all the function you see this for example So it's like the die stable coin and you get all the read and write functions here and you can basically connect your wallet and and send transaction to it. So it's like a you know like a UI for any contraon on any EVM compatible chain.

Thank you [Music]

Automatic transcript — names and jargon may be misspelled.