← All talks

Bodger And Badger - Paul Williams

BSides Newcastle24:3059 viewsPublished 2025-02Watch on YouTube ↗
Show transcript [en]

I'll try to be fairly quick because I know this is the last Talk of the day and everybody probably wants to go to pop right um more sorry there's one more in that last talk in here oh true uh right um so it's 20 minutes walk to the pub sorry it's 20 minutes it's a 20- minute walk to the pub right so I'm on the timer cool cool all right okay so I'm Paul um Paul hi uh my talk is called bodger and Badger uh not these chaps though some of you might remember them from the early 90s know um so oblig obligatory who am I uh I'm a pen member at cor swarm uh I am

a ha director uh I do CTS and I uh crew musle conferences you probably see me if You' done a few times Sor all right go back now bye yeah here we go I start again uh I'm a ha best director and I also volunteer for quite a few of the conferences if you've been anywhere northish you probably met me before cre maybe Steel Con besides whatever besides London besides leads yeah all those ones and uh I've done a few talks too I did the talk your SL just running forward I yeah right well I'm on a time he keeps doing that of course anyway you have time anyway anyway so uhit a like said who's clippering

it put it down head up what we doing do anything that was a black that a b key there go right anyway it wouldn't be a slide for me if i t for me if it wasn't breaking constantly so anyway these might zip forwards just ignore it I'll talk um so I made a badge with a few of my my colleagues from work and uh we did it for for Defcon uh I don't know if you're any familiar with the badge life sort of movement uh we wanted to make a badge that was cool and um this year defcom was all Under One Roof so the idea was that a lot of people would be coming

from different hotels and things like that and then they would all walk everywhere or move everywhere cuz obviously not everybody can walk so what we did was we made a badge that was fun um we're in one right here but I've taken the battery out um and it's the basically it's about this badge here we're going to talk about some of the TR tribulations of making a badge and you know what happens when things don't go quite the way you expect them to initially and that's what the bdge part of this uh talk is because bdge wires are basically as it says there you know wires when you make on the Fly improvements to Hardware you know when

you miss a trace or something like that which is you know what what we did how you fix it uh so that's the badge team uh me uh my brother and a couple of uh my colleagues at work we we made this badge the firmware designed it all and got it Fab from I think it was jlt PCB uh the badge itself um I'll not go too much into detail about because that's not what this talks about uh but it's basically it's a Raspberry Pi Pico microcontroller on the back there uh I don't if you can all see that yet and then it's connected to the screen and a couple other bits and pieces to do the

uh the screen of the buttons and uh trade and things like that which is quite interesting you've probably seen some badges before is doing it again isn't it so sorry a timer yeah it looks like it but I didn't set a timer so whenever you move your hand oh is it oh so I have to stand like this then okay put the controller on the table no it's not any so anyway so you've probably seen some electronic badges before I'll put it down case um some of the most interesting ones I've seen EMF 2024 don't know if any of you went to EMF Camp yeah uh the VES are super cool super modular you can has all sorts of

bits of pieces where you can add stuff in and uh customize it however you want you can even program it I believe there was some people that wrote new firmwares and if you were at EMF Camp you will know that on day one the badges were super boogy crashed a lot and which you know this what happens right you know nothing when you deploy looks first time unless you're very good um but you know most of us aren't so that's what happens um so then we've got obviously you've all got uh bid's Newcastle badge I can see quite a few of them wearing them yeah um Defcon obviously Defcon they great badges most years some years not so much I think

last year was just let a piece of plastic put a shard in and like it wasn't it didn't do anything it was just uh just a piece of plastic but like most of these it'll probably end up in a draw you know collecting dust with your Rasberry Pi Falls and whatever else you've got in there and then steelon was my favorite cuz it was the first conference I went to and uh they were handcuffs just engraved with steelon on them like legit handcuffs it was few people got handcuffed to polls and things like that throughout Sheffield that weekend it was it was very fun so saying for this is the ti gon badge it was uh quite cool um I think

they uh I think they are on about changing this for the next one because uh EMF only happens every two years but as you can see here it's uh bits and Bs here this is the main brain thingy of the chip but again that's not what this talked about um yeah very cool right you on voice is gun um and some of the different some of the different add-ons were they used were you could you could make different things one of the things that they made was a uh a CTF so there was all these little plugins all throughout the camp where you could go up to different things and plug them in and it would it was part of like an

interactive CTF that was one of the games that people would program for it I like the idea of doing sort of uh extensible Hardware because then it's not something that just sits in the badge after the one Ed because then you can you can basically use it again and again with tweaks which is you know like the simple add-on stuff I'm assuming you saw seen the badge life things uh like the defcom one oh so this one here is the you all got on that one not this one this one the fancy Punk one then the defcom one this year I don't know if any of you went to deathcon it was very cool wasn't it really cool

again there was some issues with it on day one uh they got fixed later on um but if you look down here this is the add the simple add-on Port I was talking about so that allowed people to make their own things that attach to it and that's kind of where the bad life stuff comes in because everybody can make something that interacts with with that Port because it's a standard it's a very sort of loose standard but it's a standard n again lots and lots and lots of badges all sorts of different things again so this is one of the Defcon badges with an add-on on it these are all different badges that people made same over there

those on are actually EMF ones from previous EMF years um but again with them being electronic they probably use once and they end up in a draw right so Earth Badge we made last year and it was designed to be uh like a hardware CTF uh lot of the sort of things that went into it I don't feel were um used very well because not a lot of people did the badge I don't think we had any solves of all of the challenges a few people have solved some challenges but I haven't seen anybody solve them all so this year what we wanted to do was make it a bit more of a bit more

accessible enter the moving Adventures so like I said it's off now but like the idea of this badge is it's like an RPG that uses a step counter to um to advance your experience point I don't I don't know if you all played RPGs before you familiar with RPG games yet so the idea is obviously the more experienc you get the higher the level that you you can lock new things and that's kind of the way we went with it so with ours we basically had you walked when you got a level you got experience sorry when you got experience you got a level and then when you leveled up you got items now some of the things we added to the badge

were like things like you could trade items with other people with the badge you can't really see it too well here I should have put a big thing on but it skipped anyway so don't um we Ed the TRS cable uh you know the the headphone jack effectively uh so that we could plug one into another and then we could trade between people so that if you had an item somebody else could use more because they were example a magic class you just plug that in and it trade there were a few issues with that things like depending on the length of the cable because the signal uh to travel further it would time out so we

ended up with like cables like a this long and then people stood really close to each other and just trading in Vegas so when we didn't stage we were like again we want to make it a bit more accessible than last year what can it do what should it do how can we make it fun for people and then like like I said we settled on the idea of a like an RPG so that's why it looks like a a little bit like a Game Boy not too much cuz you know Nintendo don't like when you copy them very much um and the idea was it look you know it's accessible because a lot of

people know uh d-pad buttons you know and you can navigate the badge through that there are various menus and stuff like that in it and then that allows you to do the the trading the the uh picking character adding the name all that kind of stuff and eventually this this project will be open sourced so people can make their own not there yet though because we made it for work so we need to get their permission for you know to release the files effectively you know it's how it goes there are Easter egg too uh by by the way these slides aren't in chronological order this is just kind of uh bit more of information of me just

waffling and talking and mumbling um yeah so we started off with the little screen it says there 240 by 320 LCD screen and it's driven by a an [Music] st77 anyway yeah so it's driv by a little chip it uh that allows you to draw on this bit here there is thankfully a library for the um the P SDK that will allow you to um allow you to just draw on the screen initially we did it with python um but I found it was a bit slow with the python library to draw to refresh um so we we then we went with basically uh writing it in C and then just building the firm and just buying

it on the device these are some of the hardware um prototypes we did because obviously once you start uh once you know what kind of microcontroller you're going to use that kind of thing you start then start to build and um use different bits and B so to test Buton functionality and stuff like before you start to sort things together excuse me lot of jumper wires lot of glue you know Hot Melt glue not solvents um so then you keep it together to that then uh so then you can figure out kind of what to do but then if it doesn't work you can change those bits quite quickly that only gets you so far

eventually you'll have to you know build the actual PCB so that's what the uh the PCB looked like as you can see it's what I've got right here I don't think yeah yeah there you go st7789 is the chip that drives the uh LCD screen um so once we built this we then started to make uh the the the phone right so we had we draw some menus uh use the buttons to interact with the menus we had the um accelerometer and then at the back we had the uh the the eom to save like the character data inventory that kind of stuff oh about it uh yeah the first problem we had uh was building it using

visual studio or if you were on Linux just cake I suppose you could use Visual Studio 2 it was a bit finicky at first to setup so once we did figured out how to build it for arm because not everybody uses arm and the Pico uses arm so if you're an ins machine it kind of you need to mess around and build a particular tool chain and that kind of stuff once that was done we po that in the repo so that was like the first problem that we came up with the excuse me the first problem we solved is that once the uh once we figured out exactly this is how you build this is the environment we pop the

instructions on how to do that in the GitHub repository so that then anybody else comes along they want to they want to make a new version of it they they can because the instructions on how to get the building environment to build the correct file to just drop on it's all in there then it comes yeah so these were the characters we made uh so uh they don't one one doesn't look like me anymore but it did they were modeled on the team uh I don't know if my Las is going to work here no it's not so I was the road because typically like if you seen me before one of these I normally have like a mohawk I don't

right now um that's why I'm wearing the heart because people will recognize me without it so we started with those four and those were like the initial classes for the things again if you're familiar with RPGs those are pretty standard sort of classes got different uh different stats and stuff and then they affect the way you get Loot and things like that um but that was kind of how we started as I was talking about before this was the trade um the trade uses the uh headphone jacket don't don't know that word this is the schematic here if you can see I don't know if you can all see that so the idea was um to trade

between two people you need we we use the uat protocol but if you're if you're using uat you need to have the uh the transmission and the receive pins flipped for one to the other so there's a couple ways we've looked at doing that the first way was basically uh in software initializing different pins but then we sort of decided against that and we went with I think was a bit more of an elegant solution we used a dpdt DP yeah dpdt switch a double pull double throw so that what that basically is is is a switch switch with two positions and when you move it from one to the other it reverses the polarity of the

the the the things you connected to it which then meant that we have like a little switch on the back here which has a zero and a one on it so the way it works is you when you're trying to trade with someone you flip that over on one of them and then as long as those are opposite it will allow you to talk rather than having like two separate connectors or anything like that it just so much easier to do it this way little problem was TRS and trrs are two different pin outs TRS has an extra pin which meant that using the TRS cable cause some uh usual behavior um we fixed that in the the second revision um but

there when we were testing in the first revision cuz we got the way we did it was we only got a few of these first and then after we figured out what was wrong we sort of made those tweaks to the schematic and then went from the rather than get a job lot of them and then them all be wrong and then a butcher bodge happens in here um so once we fix that those problems you could use a TRS or TR RS cable to do the trade work perfectly both ways did have some Easter eggs in here cuz you know badges need Easter eggs uh couple Easter eggs if you put it if you

created a character with any of the devs names in it you had access to a debug menu which will allow you to just give yourself items or bump levels and you know they're cheating right we also added a couple of extra um Sprites in for some people like uh online so I don't know if any of you know who th is for he's like a twitch streamer yeah so I actually met him and I gave him one of the badges but so then I put him as a Sprite in it so if you put Thor in as the name it would give you a little character based on him and these were the resulting ones so this one obviously

is th here you can see very well and then this one is the U it's the wrapper from from ju core cuz I gave him a badge to put him in it bit of fun you know so then we come to the bodge parts as I mentioned a little bit uh you know when when when you start doing this kind of thing you think you think of everything and then you get it and you're like Ah that's not how I expected that to behave which is uh what we did uh on the badge uh there's a couple of issues I mentioned the TRS one already uh the Pico footprint was another interesting one so where it is on

here it's quite hard to get the USB cable inside there because normally USB cables have got like a little bit of like a plastic shr around them uh you know to make them look cool or whatever so it kind of bent the uh the socket up a little bit so I end up doing with that uh I I'll show you in a minute uh was like basically I put it against a block of wood and a belt sander and very gingery so tapped it like this until it went flat this was the first BGE so this is this is actually this badge here so this is the accelerometer but there was a pin missing which meant

that the accelerometer didn't do anything which obviously was kind of a big issue with the badge um so what we ended up doing was there's a tiny little wire between this resistor and this capacitor which then bridges that connection which makes it work hence the bodge uh next as I said uh we had an issue with the TRS uh pin out and we fixed that later in this version we basically just cut one of the uh connections so then it it didn't make the connection it shouldn't have made and it it worked out um but then we sort of went back to the drawing board with the pin out and then made it so that the the top ring and the

tip both connected the same pin so depending on if you had a TR TRS or trrs cable it would work exactly the same because the tip and the first ring I don't know if you've seen TRS cables the ones with the microphones on as well they have two little rings around it you basic plug it in the top two made the same connection it didn't come great stuff it said you r a belt under and a piece of wood you can see here it's nice and smooth it was about uh 3 mm uh shaved off the end of it at first I started to do it without a block of wood and then I thought well this is a really crazy idea

because if if I touch my fingernail against that belt slander my fingernails just going to go so Safety First and all that uh then the the the sort of the final sort of panicky issue we had was obviously I don't understand any you're own software development um when you start to refactor things that other people have written you might not realize the what they've done so you might interpret something in the way that you think it works rather than the way it does work which is why comments are always great even know people always say things like cod should be its own comments and all that kind of stuff you know you need to As Long as You comments

find like don't put comment like this is a function because that's super obvious you need to sort of describe what the function does but this again this isn't like a programming sort of uh talk but good comments is the uh the takeaway here right um the idea was that when you do the trade you have an inventory as well as a um like a they call a paper doll like you know your characters wearing like a helmet or sort know armor Shield whatnot the idea was that you have two separate inventories one is your inventory for items you've collected and one is one for the items you've equipped now when somebody was refactoring I'm not going to point any

Fingers um when it was re being refactored um they' misunderstood one of the one of the uh lines and basically when they committed it uh it just showed like a garbled screen it wasn't you couldn't really tell what was happening and it was a bit of a mess and so what we ended up doing the day before death Cod we sat there after we all got our badges because we we had some of these badges to give away to people at deathcon we were trying to figure out what the problem was in the firw so we could fix it before we give these badges to people because can't very well go hang on a minute come give me a badge

back and we'll we'll sort it have to do it now and then right so what we end up doing was using a tool called get BCT very handy so the way that works is you start with one that you know works like a a point in time that you know works and then you end up with where you are it doesn't work then what you do is you it takes you somewhere around the middle you then do you build it again is it still broken if it's not then you know it's not in this bit and then you just sort of you you like a bin new treat reversal of here you go here you go here you go and

then we found out what it was this is the line of cord here basically they uh missed off the divide by two so in the memory where all the Sprites were stored there actually a lot bigger so that when it tried to read them and interpret them the uh the data was G because it was twice as big as it was expecting and everything bumped along so once that was done we sorted and we were able to uh apply and then go flash 50 badges in the uh the bar at the Sahara that was that was a lot of fun the only other problem we had was not enough badges a lot of people came

up to me during the weekend where do I get one of those said you can't cuz there's only like 30 of them now which then as the weekend went on dwindled and when I had some to give out I did give some out and have had people ask me how can I get one and I'm like I'll try and do another run at some point but we wanted to fix a couple of the issues like for example one thing that I don't think is on here is that these screens because they poke out they get bashed and when they get bashed They smash and I have a couple in my hotel room of them actually that are the uh the screen

obviously has an impact fracture which then means the screen's useless so the version two might be a bit more safe for the screen I think I think what we'll do is we'll syn it into the PCB so it's flat against it so then it's less lightly to impact it or maybe 3D print uh uh case for or something again as I just said screen oh and uh sometimes the buttons like this one here if you put it in your bag and think things hit it not the button straight off cuz they're not cuz they're quite small they're very delicate which is kind of a problem but I guess if you had the cover over it it wouldn't be so

these are all things like you know like I said like you you don't necessarily think about when you're making it you're like I want to make this cool thing and then when you get it you're like hm some parts of it aren't as cool as I was expecting or oh I could do that a better way thank you