I'm Antoinette Stevens. I am a cyber security analyst at Principal Financial Group in
Des Moines, Iowa and I am the founder and executive director for Reboot Iowa, a
nonprofit I founded to help adults learn literacy, basic coding skills and
then they say personal security practices. I am a member of the Des
Moines City SEC. SEC DSN. An organizer for Besides Iowa. And I also help design
CTF challenges for them, from time to time. And then, I also work at a arcade bar
called Uptown, where I work on the games. Which is a new adventure for me. I'm not
really a hardware person, but I'm learning to be. So a quick disclaimer about learning
styles. The title of his talk mentions the word kinesthetic, which is a
reference to a learning style introduced in the early nineties by Fleming in
Mills in the vark questionnaire. S,o learning styles are traditionally
researched and used. Teachers learn how to help their students learn better.
But a recent research to actually point out that learning styles are a myth.
You don't actually learn better baseline auditory or visual or anything like that.
It's more of a holistic approach. Which is really fun to find out when you're
researching for a talk. That mentions the kinesthetic learning style. All basically
is bullshit. So for the purposes of this talk, we'll just be going that the
colloquial meaning. Which is just hands on so, it's just the hands-on approach to
learning English. All right, so I really wanted to learn encryption. But my job
doesn't require me to know it. I'm limited and am not a developer. And I
also really like doing capture the flag competitions and also never really
knew how to do the encryption challenge. So it really helped me to combine the two together and learning
encryption through CTS and specifically recreating them. So I decided to start looking up
old CTS challenges, specifically their write-ups. And the track I chose to kind
of recreate was the AES these level challenges and the essays short keelin
challenge. And I kind of got my methodology down to three steps which is
to scope, research and to recreate. So, I chose scoping your challenge really
important. Specifically because encryption is such a broad field. AES
alone has several different modes and several different key links. And so scoping
your challenge to something narrow helps you to learn in smaller, more in digestible
chunks. Instead of getting information overload by trying to learn
everything at once and not really knowing where to start. So make sure if you're
going to do that, just scope down to something very specific. And also define challenges to be pretty specific.
So, research the challenge. Which kind of speaks for itself. But you wanna start
reading about those concepts related to what you're looking at. So I looked a lot
at why prime numbers are important for the RSA challenge. And I looked at what ECP
mode even is, while looking at that. You want to look up tools to help. While
I was reading through these things you come across tools, you kind of want to
save those for later. Because they come in handy. And then most importantly, find write-up's.
But, have similar challenges for the focus is that you need. So I want to talk about
write-up's specifically and what a good write-up is. So for anyone here who reads CTF write-up's,
what do you think makes a good write-up? You can just shout it out. No one?
Okay cool. - I like seeing code examples. Antoinette - You like seeing code examples? Anyone else? Okay, so
for me, a good write-up provides details about the challenge itself. I know you can't
see this, it's OK. But this, this is, this is a snippet from a writ-up from enigma
2017, called broken encryption. And it's kind of like a double-oh-seven challenge
run. This program is running, you connect it to a server and have this program
that's like interior agent number and then it spits out a bunch of garbled
text which is your encrypted flag is in there. So you provided what was given to
him as the challenge, which is really helpful when you want t o build this later.
You really don't have to do much guesswork.
This code snippet comes from see-saw 2017 and it's called Bcrypt. So I think
good write-ups have diagrams, and really detailed explanations of the
concepts in them. So this specific one is pointing out how ECB mode encrypts
data in fourteen, I'm sorry, sixteen byte chunks.
It mentions tools that are helpful, and you can't see it in here. So this came
from our RSA article and mentions two tools Yahoo and vector DV. Which for
RSA short key length as you'll see later, it's really important people get
factors from a part of your public key. So those two tools really hope to make
that process a lot quicker. And then they have detailed explanations with their
solutions. So all of the write-ups that I chose to use to recreate my challenges
included the scripts that were used to solve the challenge. And also a detailed
explanation of why their scripts worked and why I chose to solve it in that way.
So recreating the challenge. I started both by generating the keys
necessary and making sure that I can encrypt and decrypt data before I went
ahead and tried to break it. The AES challenge was actually the easier one to
recreate. Simply the hardest part there was making sure I have the key
correct. Which is something that should have been a lot easier than it was, but
it took a while. The RSA challenge is the one that gave me the most trouble. And I
kept hitting three errors of note that I'll talk about in a moment.
So the RSA short key length challenge. RSA stands for Rivest,
Shamir, Adleman. And is a asymmetric cryptographic algorithm meaning. It has a
private key and a public key. So for the RSA challenge that I created, it
wasn't actually based on a CTF. More so it was based on a write-up I found from
Sebastian Neef on 0day.work where he kind of talks about why short key lengths
and RSA are bad. So the three issues I ran into were generating the
keys to begin with. A lot of things don't let you do short key lengths
for RSA. Whether to pad or not pad the data that I was encrypting. A nd then
finding the P and Q which would help you get the two prime numbers you need to
generate the private-key. All right, so this is a public and private key.
It's fine, it's not used anywhere. Normally you don't want to share your
private key with people. Usually you keep your private key and other people can
have your public key to encrypt data and you can decrypt it with the private key. So what you want to
pay attention here to here is the modulus, and the private exponent. So the
mod and the public key is what we'll use to get our PDQ which can later go
through another algorithm to get the private exponent, but I'll talk about
that a little more in a second. Generating this was not easy, specifically because I
originally tried to do it in Python and Python won't let you generate RSA keys
shorter than 1024 bits. So I wanted to do 256 bits, which meant I had to switch to open SSL.
The next wall I kept hitting was whether or not I wanted to pad the
data. So what we're looking at here is the PKCS1, a padding scheme. And what
it's basically saying is that you cannot encrypt more data than the size of your
mod. So my mod is 33 bytes, and so the algorithm goes, the size of your data
cannot be larger than 33 minus 11. So I can have 22 bytes of data and the rest
gets padded and then I can do encryption. Any more than that, and I'll get a lot of your data is too large
errors, which is what I was dealing with before I decided to look at how padding
works. If you don't want to deal with that, then you ca.n do the raw flag in
open SSL and then you can go pad it yourself.
but 22x of not a lot of data it's barely a sentence so it was really interesting
trying to do this it's just enough where flag though and then once I was able to
incresed the work begins to get European youth from modulus so if it's fairly
small for like 120 vid mods it's pretty orbit started 128-bit keys it's pretty
easy to use the factor DB or even Wolfram Alpha to calculate a human just
factor them but for 256 bits it took a lot longer so I ended up downloading a
program called Hennessey and so it's a conceived about 2 minutes to crack the P
and Q and you can go up to about 300 fix in an RSA key and it only take a few
minutes to crack any more than that and we started getting into the couple of
hours couple of things couple years range and then once you have your P and
Q it's pretty easy to just go around and run the extended Euclidean algorithm to
calculate the modular inverse which will give you the private exponent that you
need to generate your friend to keep RSA's punch map wait that's it and it's
not mad that means you know or know how to do by hand it's just math great need
to know the different parts that go into it so you can play into something else
so I'm Hong I'm someone else already broke so it yes 128 which is the key
size ECB mode which is for electronic codebook was actually pretty fun to try
to figure out so I began by replicating the double-oh-seven challenge that I had
before and I used Python and you sock it to the other server to connect to so
that I can kind of copy the way that you Challenge worked and it's a poem and I'm
proud to admit to generate the key simply because I didn't understand the
structure of the key needed but I ended up just doing an in divide which had on
to be eight bits in it which is super simple although I know for actual
implementations of AES 55 doesn't have enough engine people to work well and
well you probably not doing once we need anyway so just enough but once we keep
us properly generated I can imprint and I knew I could encrypt and decrypt both
ways the trick with AES PCB is to make sure your blocks online so like I said
before
ATS easy emote specifically doesn't add any padding to the plaintext before you
print it so what goes in as plain text it comes out as architects will always
be that same ciphertext so if you know part of the plaintext in something then
you can see what the cipher text looks like so the trick with AES 50p mode is
to manipulate your plain text and put in no plain text that's in the cipher text
and then look for matching blocks which you'll see in a minute what you need to
know to do this challenge specifically would be the padding schema if there was
one at it so this one added one and up to four teams growth and so since you
knew kind of what the structure of the encrypted data coming out was you could
begin to guess your flag so what you see here into red blocks it's matching the
pattern so once you're able to align your sixteen watch you can kind of begin
to guess what the flight is by reading through all the alphabets and all of
basically the full active range to get the flag which you don't have to do that
by hand there's a program Alberti I said you google around and find
scripts to do these things but that that's basically the challenge and what
this helps me understand is a 80s DCP hood is complete crap simply because it
would be easy for someone to do that and guess what you're thinking thing we
don't have any panic and then if they know any of the plain text that might be
in the cipher text so some of the lessons I've learned while doing this
take good notes it seems really trivial but you'd be
surprised how much you don't pay it into what you're doing while you're doing it
it took me several hours to even read some things when I should have coming
back to it so taking good notes is super helpful and also it helps to start
bookmarking things as you go you're not the type of person who likes to write
things down security be a nun security so this really helps me understand what
is in place and so we popular programs to kind of protect developers might
default like I said I find doesn't allow you to cherokees less than 1024 bits so
the same goes for me learning that our thing isn't even used to encrypt school
files he usually encrypts something else and
then encrypt the keys for that with RSA so it was really good for me to kind of
get that working knowledge which if you ever reach that goal flow there are a
lot of people in there who are more familiar and tell you how you're doing
things wrong learn beyond the challenge so like I said you are scoping which
means you're focusing on a very niche concept and that also means it won't
translate to every situation so just because you understand how to break RSA
share key light doesn't mean how to break other types of
vulnerabilities in the RSA doesn't mean you understand how to break ABS CDC move
so it really helps once you get the concept down and you're pretty
comfortable with it to keep trying to building on that knowledge so it's
basically don't stop here kind of in the future I'm really interested in learning
more about the different modes of es and also there are a lot of different
vulnerabilities with parts a it's really easy to mess up so I really it just fit
to learn about what else is there and then I really like doing this simply
because my job doesn't let me code a lot but a degree in computer science so I'd
like to do it from time to time not every day and blah blah but I like that
if I wanted to learn a new language I have something right with it that seems
to be a blocker for a lot of people and what I learn a groupie but I don't have
anything to build so recreate see touch I'll just gives you something to build
alright thank you if you want to follow me on Twitter it's
Internet 0 X 53 and then I also have a website it's when it's Akitas comm where
I do 68 great ups sometimes I'll walk through right out to the art side CTS
that I've written only after I knew it will use it again
and I also publish different talks that I give
you