start	end	text
1260	3500	Hello everyone, and welcome to my DEF CON talk
3500	7100	all about locks and keying systems and how to hack them.
7200	9080	There's going to be a lot of math and problem solving
9080	10600	involved in what we're talking about today.
10600	12320	So for those of you who like that sort of thing,
12320	14240	I think you're going to really like this talk.
14240	16560	For those of you who don't like that as much,
16560	18720	I'll be releasing a number of software applications
18720	21220	that will do all the hard work for you.
21620	23480	This is all about decoding locks,
23480	25260	despite the very verbose title.
25260	26860	So taking all the information available
26860	28600	and creating a key for a lock
28600	30160	where we didn't otherwise have one.
30640	32340	It's a fairly long talk.
32860	34460	So if you're watching this on YouTube after,
34460	37100	I'll put a comment below with links to times in the video
37100	39060	so you can skip to the parts of the talk
39060	40720	that happened to interest you.
41360	43820	I will just mention that this feels incredibly weird.
43820	45880	The energy is so low compared to giving a main
45880	48220	or a talk on the main stage at DEF CON.
48220	50780	So I will do my absolute best to stay engaged
50780	53100	and keep you awake and to stay awake myself.
53340	56340	But the good news here is that this talk involves
56600	57880	a lot of software demos
57880	60040	and me going through the software I'll be releasing.
60040	62560	That would have been absolutely terrifying
62560	65040	to do on a main stage at DEF CON.
65220	67520	So what you get out of that is the speaker
67520	69060	who is going to be a lot less stressed out
69060	71460	and making a lot fewer mistakes.
72580	75720	So take a look at your key ring and see the keys on there
75720	78180	and see how much you understand about what they are
78180	79820	beyond just shapes of metal
79820	82060	and how they interact with the lock.
82060	83740	And that's what we're going to be talking about
83740	85320	all through today.
85460	86700	The way we're going to attack that
86700	88860	is looking at how locks and keys work
88860	90840	and the introduction of the tools I'm releasing
90840	92240	to analyze them.
92240	94420	We'll look at the economics and practicality
94420	96080	of brute forcing all possible keys
96440	99680	and reading the pins in a lock to get information from that.
99680	101340	We'll improve on impressioning
101340	103660	by applying the extra information that we have.
103660	105260	And we'll look at key-like systems
105260	107580	and lock disassembly to get information.
107840	110260	We'll then formally introduce information theory
110260	113060	and see how it applies to mechanical locks and keys.
113060	115040	We'll introduce master keying systems
115040	118120	and derive master keys from multiple low-level keys
118120	120620	and perform other rate-samplification attacks
120620	124020	to create a master key where we didn't have one before.
124040	125440	We'll look at a couple of special cases
125440	127640	like construction keying, IC cores,
127640	129220	and high-security secondary systems
129220	131000	like Medeco and Multilock.
131000	133280	And finally, we'll talk about what the blue team can do
133280	135620	to remediate from these attacks.
135820	137480	All of the software that I'm releasing
137480	140640	as a part of this talk can be found at these links here,
140640	143400	both a version that you can try right in your web browser
143400	145580	as well as the source down below.
145580	147300	So before we jump into the new content,
147300	149500	we'll give a very brief overview of how locks work
149500	151300	for those who might not be familiar.
151560	154140	So we have a key and it enters the lock
154140	157060	and interfaces with a number of pins.
157060	159320	We have key pins close to the key
159320	161160	and driver pins higher up.
161160	164660	And if they all line up with the top of this plug,
164660	166520	it will allow the plug to turn.
166780	167880	What do I mean by that?
167880	169280	Well, let's take a look at a 3D model
169280	170840	for what this is representing.
170840	172720	So here's a familiar lock
173320	178100	and this inner insert called the plug,
178100	181560	when all those pins line up, it allows it to turn.
181560	186280	So if we look at the cross section of it here,
186280	188360	when those pins line up as I showed
188360	190260	in the two-dimensional diagram,
190260	193600	that's what then allows that to happen.
193600	196200	And if any of those pins are not at the right height,
196200	199200	so we have a driver pin into the plug
199200	202240	or a key pin up into the housing,
202240	203820	then that will not allow it to turn
203820	206320	and the lock remains locked.
206480	210040	Within the plug, we have holes for the key pins to go into
210520	212600	and those holes don't go all the way down.
212600	214280	So that's what stops the pins
214280	216200	from falling right out of the lock.
217360	220240	And so in this cross section we see here,
220240	221380	this is where the key enters
221380	223140	and then this is where the pins are.
223140	224460	And that's what we're representing
224460	230320	in our two-dimensional facsimile that we have here.
230320	231780	So the key goes in,
231780	234940	it raises the pins to the right height, the lock opens.
235280	238060	If some of these pins are,
238060	241260	or these key cuts are too high or too low,
241260	244840	then it will not open because we have a driver pin
244840	246560	or a key pin in the way.
246560	249680	And we can see these shear lines are now binding,
249680	251380	the lock does not open.
251920	255460	It's worth noting that the positions in the key
255460	257460	are all discrete.
257460	261480	So we can have a set number of intervals
261480	264200	for depths that these positions can take on.
264260	268320	And that is defined by what type of lock it is,
268320	270660	as well as the position of the pins, of course,
270660	272920	is defined by what type of lock it is.
272920	274760	So you can play around with this software yourself
274760	277520	to understand what that top profile of a key
277520	283360	actually means in terms of what key code it creates.
285300	289640	So this is an example of what a plug cut in half
289640	290800	actually looks like.
290800	292240	So we can see where the pins go
292240	294400	and where the key goes in here.
294980	298500	A key itself is just mechanically encoded information.
298780	301960	So I showed how we can change the code to different heights.
302180	304520	Key codes are a number that represents that.
304520	305940	So this is a Schlage key.
305940	308200	We read it from shoulder to tip.
308260	312560	So in pin one, we have from zero down to nine.
312560	316120	We have eight cut and we can get seven, et cetera.
316120	318280	So here's a two, we have zero, one, two.
318280	320600	And from that, we can get the full bidding code
320600	323020	of eight, seven, five, two, seven.
323120	324400	And that makes sense.
324400	328100	When we look at the profile of this key,
328100	330280	deep, shallower, shallower, very shallow,
330280	332020	and back to deep again.
332260	334060	The thickness of the key from the base
334060	337060	to the points of this cut here
337060	340280	is given by this chart for the Schlage system.
340280	344600	So an eight cut is going to be 215 thousandths of an inch
344600	346220	from these two positions.
346860	348640	Here's another example we can see.
348640	350440	So five, two, eight, six, four.
350460	352380	We can see it makes about sense.
352380	355420	There's a five in the middle, a two is high up,
355420	358500	eight is low cut, and then it's increasing from there.
358860	360420	One thing we need to be aware of
360420	362920	is the maximum adjacent cut specification.
363060	366760	We can't have a very shallow cut beside a very deep cut.
366820	369580	Or in one case, it's going to be too steep
369580	371880	and we can't put the key in or get it out.
371880	372980	Or in another case,
372980	377040	we're going to start impinging on the neighboring cuts.
377040	380000	So if you look at how a key is actually originated.
382000	385040	So we can see in this lower left corner here,
385040	388560	this cutter wheel that's taking bites out of the key.
388620	389740	And so we're moving it along
389740	391920	to predefined positions along the key,
391920	394880	and then cutting down to predefined depths into the key.
394880	396020	In this case, we're cutting it
396020	398960	to the bidding code one, two, three, four, five.
398960	401340	So here we are on the fifth position,
401340	403920	cutting it down to a five depth.
404400	407340	We can see that the way that cutter wheel cuts
407340	413140	into the pins actually creates a sloped angle.
413240	415560	And so here's an example of one key
415560	419100	where we have a code zero, four, zero, three, seven.
419100	421660	So that's again from shoulder to tip.
422000	425120	If we wanted to bring pin two down
425120	427880	so that it matches not this shear line, but this upper one,
427880	430440	we can start cutting the four down and it works,
430440	432640	down to a five, down to a six is fine.
432640	437900	But now these shallow slope sides around it
437900	439940	are getting very close to the neighbors.
439940	442120	And in fact, when we put it down to a seven,
442120	445340	those neighbors are now lowered by that.
445340	448200	So that's a bit of a problem for us.
448460	453720	It means that we cannot have a zero cut next to a seven cut.
453720	456080	Zero next to six is okay, but not seven.
456080	460620	So that's our maximum adjacent cut specification is six.
460620	463020	Likewise, we can't have a one next to a seven
463020	465820	or next to an eight, but it can be next to a seven.
465820	466980	So the difference there is six.
466980	469340	That's okay because it's maximum.
469780	473900	And that's a property of almost all pin tumbler locks.
473900	478000	And that's gonna limit what our key space is as well.
480860	483800	Here's a chart of the most common max that we see.
483800	485500	So most of them are seven.
485500	489120	They have, in the case of Schlage, Sargent, Yale and Weiser,
489120	491280	they have 10 different depths that are allowable.
491280	493480	So at seven, that's fairly permissive.
493520	494980	Kwikset only has six.
494980	498480	So that means that our max is a little bit less at four.
499940	501400	Now that we understand max,
501400	503880	we can start to look at the key spaces.
503880	505860	So the total number of differs,
505860	509260	or number of possible keys that exist on a system.
509300	511540	And naively, it's the number of depths
511540	513700	to the power of the number of spaces.
513700	514920	So for a Schlage key,
514920	518000	there are 10 depths to the power of five or six spaces,
518000	521560	for five or six pins, is 100,000 or a million.
521560	524820	And for Medeco, it's six depths to the power of five or six,
524820	527140	so seven or 46,000.
527380	530480	So we can calculate that fairly easily here.
530520	533160	A Schlage system with five pins and 10 depths,
533160	535780	we have 100,000 possibilities.
536100	539020	And six pins is going to be a million.
539160	542760	And if it's a Medeco lock with six pins, six steps,
542760	546500	that's 46,000 and that's six to the power of six.
546780	549240	We can also add in our max here.
549240	552260	So let's say that this is a Kwikset key
552260	555300	with five pins and six depths.
555300	559180	We can now scroll down and add some rules to this system
559180	561240	to limit what our key space would be.
561240	563200	So we start with 7,000.
563200	566760	We find under max and add a max of four,
566760	569140	for it being a Kwikset system.
569140	573220	And that now limits it to 6,306.
573220	577440	And we can see that the number of possible differs
577440	581880	is less with cuts very shallow and very deep.
581880	585940	So this number here, 941, means that 941 total differs
586340	588800	have a zero cut in pin one.
588940	590380	That's smaller than the number
590380	592140	that can have a one cut in pin one.
592140	596740	Because a zero cut can go up to four, that's within max,
596740	598820	but it can't go all the way to a five.
598820	600940	That would be too much of a difference.
600940	602560	That would be a max violation.
602780	604620	This one here can go to anything
604620	606520	because it's close enough to everything
606520	608740	that it will not violate max.
609220	613640	To take this to the extreme, we can reduce max down to one.
613720	615700	And so we now see the impact that has.
615700	618400	We're down to only 340 possible keys.
618860	622400	And if by some decoding that we'll talk about going forward,
622400	625280	we know that say the shear line in pin one is a three,
625280	629740	we now see the pin two can only be a two, three, or four.
629740	631240	Anything else is too far from it.
631240	634320	It's a max violation and that extends outwards.
634320	636360	So that is severely limiting now
636360	639240	the number of possible keys that are in our key space.
639240	641100	And we'll look at how to drive these rules
641100	643000	throughout the rest of this talk.
643000	646460	In this case, we're down to 74 possible keys in our space.
646460	649620	And so it's enumerating all of those key codes here.
649620	650980	So these are the bidding codes.
650980	653360	We could cut a key to these and try them.
653360	656020	And it might work in this lock.
659020	661780	We can take a brief look at keys versus passwords
662330	664900	in terms of the brute force ability of them.
665000	668400	So the cost to try a password is very close to zero,
668400	669580	not quite negligible.
669580	671340	In the case of a key, it's quite expensive.
671340	673400	We have to pay for the blank and cutting the key
673400	676480	and our time to actually go and physically try it.
676480	679300	That's all quite expensive and time consuming.
679880	681840	Keys can be, or passwords can be
681840	683800	an unlimited length and complexity.
683800	687140	Keys are severely limited in both length and complexity
687600	690540	due to the mechanical nature of them.
690700	694240	In a password, if it gets compromised, it's easy to change.
694240	696720	And a key is very costly and time consuming.
696720	699220	So what this means is with mechanical keys,
699220	701980	things are harder for both the red team and the blue team.
701980	703620	It's harder to brute force
703620	705740	and try a whole bunch of combinations.
705820	711680	But if a vulnerability is discovered by the red team,
711680	713060	it's a lot harder for the blue team
713060	715860	to actually mitigate it and work against that.
717360	719760	To try brute force attack economically,
719760	722480	if we look at just the cost of the blank,
722480	725100	and we assume that if we own a code cutting machine,
725100	728180	the marginal cost of cutting a new key on it
728180	729620	is just your time.
730100	732860	So keys are not particularly expensive in that case,
732860	734620	between 13 cents and $3.
734900	737520	And if you don't, you would have to use a locksmith
737520	739240	who might do it for three to 10,
739240	741500	possibly more for high security keys.
741500	744000	So for instance, if we can reduce the key space
744000	746680	of a given lock down to 1,000 possible keys,
746680	748300	using the software that I showed you
748300	750960	and applying rules that we're going to learn about soon,
750960	756320	we might be able to try all of those 1,000 keys for $450.
756320	760000	If we own a code machine, if the blanks are 45 cents each,
760000	763200	if we have to go to a locksmith to get them cut,
763200	766520	then he might charge $4 each for $4,000.
766920	768100	And at that price,
768100	770260	we're better off just buying our own code machine.
771780	773600	What's important about this though,
773600	776280	is that if whatever's being protected within that room
776280	779080	is worth less than $4,000,
779080	781020	it now becomes an economical attack
781020	784080	to actually brute force all of these possible keys
784080	785800	in the key space.
786300	789320	One really good example of a lock where this is
789320	792020	not just possible, but imminently feasible,
792020	795640	is the Sargent and Greenleaf Environmental Padlock.
795640	798600	It's a very well-built, beefy padlock
798600	801500	meant for highly punishing outdoor environments.
801540	804720	And there's very few small parts inside as well.
804720	805920	It's a disc detainer lock,
805920	807120	so it looks a bit different than the keys
807120	808520	we've looked at so far,
808520	810760	but we can analyze it exactly the same.
810760	812640	It has three different discs
813060	815960	and the key can be cut to either 180 degrees,
815960	820580	as we see in the middle here, 135 or 90 degrees.
820580	824280	So three discs and three different positions
824760	826920	that each one can be cut to.
827660	830320	Let's put that into our key space software.
830320	831940	So get rid of those rules.
831940	834700	And this is a disc detainer,
835260	840080	one based with three discs and three possible depths each.
840080	843720	And we see 27 is our total key space.
843720	845780	That is everything that that Sargent
845780	848940	and Greenleaf Environmental can possibly take on.
850260	852020	And that's three to the third power.
852020	852740	That makes sense.
852740	855480	And we see them all enumerated here.
856280	859040	It's a little bit more complicated than that,
859040	861920	because if we insert this key
861920	864160	and we turn it and open that lock,
864160	867120	one design feature is that they want it to be key retaining.
867120	869640	We can't pull the key out if the lock is open.
869700	873140	If this were, say, cut 180, 180, 180,
873140	876400	that would be possible to do, and we don't want that.
876680	879880	So we actually want to remove all of these key combinations
879880	881620	that would not be key retaining
881620	884260	that we can pull that key out of the lock for.
884260	886400	So 1, 1, 1 is no good.
886540	889960	1, 1, 2 is no good because 2 is lower than 1.
889960	892120	So it has to go up at least once.
892120	893840	So 1, 2, 1 is good.
894300	895640	1, 3, 1 is good.
895640	897780	1, 3, 2 is, but 1, 3, 3 is not,
897780	901200	because it doesn't go back up at least once throughout it.
901580	904220	So we can add a rule for that under max and stuff.
904220	906340	We can add a rule for key retaining,
906340	909400	and that's going to reduce those,
909400	912640	that key space to remove differs
912640	914840	that are not going to be key retaining
915440	917340	in this particular case.
917620	920040	And so we can see now that there's more
920040	922260	with a deeper cut in disc one
922260	924600	and a shallower cut in disc three.
924600	928900	And that's because if it steps down from 1, 2 to 3,
928900	931660	that's not going to be key retaining.
931760	935960	So we could create all 17 of these possible keys,
935960	937180	and that might make sense
937180	938480	because it'll work on all Sergeant
938480	940540	and Greenleaf environmental locks.
940620	942480	If we have, say, a budget limitation,
942480	944540	and we don't want to pay for 17 blanks,
944540	947540	which would be, we've put 41 here,
947540	948500	it would actually be a bit more
948500	950360	because these blanks are worth more,
950360	952860	but this is just an order of magnitude calculation.
953200	956360	We can click down here and click brute force save blanks,
956360	957500	where it'll run a little algorithm
957500	959680	to try to optimize for you,
959680	962040	cutting one blank and then filing it down.
962040	965560	So 1, 2, 1 follows 1, 3, 1 to 1, 3, 2, et cetera.
965760	968160	And that way we can test out the entire key space
968160	969960	in as few blanks as possible.
969960	972440	This particular algorithm here,
972440	974120	to find the optimal solution,
974120	976620	turns out to be an NP complete problem.
976620	981120	It ends up being reducible to the set cover problem,
981730	985560	but we have a somewhat suboptimal greedy algorithm
985560	987100	that I've implemented here,
987100	989220	that empirically I found is good enough
989220	992180	for getting us a decent algorithm
992630	994940	of saving ourselves some blanks.
994940	997260	So in this case, it goes from $41
997760	1001520	to get all 17 blanks down to just 12,
1001520	1004400	since we only need five blanks now.
1004420	1007420	So that's the Sargent Greenleaf Environmental Padlock.
1007420	1009900	It's a very good padlock for what it's designed for.
1009900	1013320	It's not really designed for security of the key space,
1013320	1014620	and that's okay.
1014620	1017220	It was used for a number of years
1017220	1018840	back before people knew this.
1018840	1021580	And so it sort of benefited from security by obscurity.
1021580	1023400	But for that reason,
1023400	1025100	this particular lock is not used
1025100	1028000	for high security applications anymore.
1028540	1029960	So let's shift gears a little bit
1029960	1033940	and look at locks where we can try the entire key space,
1033940	1036680	not by reducing possible differs,
1036680	1038920	but by trying multiple at once.
1039040	1042100	So this is the Kwikset Smart Key Lock.
1042100	1043360	It's smart key, so to speak,
1043360	1045740	because it has this hole you can insert a special tool
1045740	1048920	to rekey the lock without ever taking it apart.
1048920	1050600	Kind of a cool design.
1050600	1052180	Unfortunately, it's manufactured
1052180	1054700	with extremely loose tolerances.
1055100	1058620	And what that allows is us to actually try half heights.
1058880	1061200	So normally, if you have a one cut
1061200	1063940	in a particular pin position,
1064460	1066100	that will work if the pin is a one
1066100	1067920	or a two will work for two.
1067920	1070060	What this lets you do is cut it to one and a half,
1070060	1072940	and that will work for both a one and a two.
1074500	1076420	So by allowing us to do that,
1076420	1081580	we can reduce it down to 200 and some odd possibilities.
1081580	1087080	So let's simulate that in our Keyspace software here.
1087080	1090680	So Kwikset locks, so it has five pins and six depths.
1090680	1096100	And then six to the five is 7,700, as we looked at before,
1096100	1098860	when we have to try all of one through six.
1098920	1100300	When half heights work though,
1100300	1102620	it turns into three to the five,
1102620	1105820	because we can use 1.5, 3.5, and 5.5
1105820	1108760	to try everything from one to six.
1108960	1110680	And so we can see here that trying out
1110680	1112880	all of these half height keys
1112880	1114500	to exhaust the entire Keyspace
1114500	1118220	would cost about $500 to make all of them.
1118480	1122800	And there actually exists commercial sets you can buy
1122800	1124900	that costs on that order as well
1125740	1129080	to try all of these different options.
1129080	1131600	So that is something that's out there
1131600	1134560	for the Kwikset keys,
1134560	1137000	the Kwikset SmartKey in particular.
1137000	1140380	And that is something that usually
1140380	1142500	wouldn't be your go-to attack methodology
1142500	1144240	because the Kwikset SmartKey,
1144240	1149480	by virtue of those loose tolerances, is easy to pick.
1149540	1152560	But if you wanted to use it to, say,
1152560	1154040	determine the key for one lock,
1154040	1156600	and then you could get in very quickly in future,
1156600	1160540	or if you had multiple locks
1160540	1161900	that you know are all keyed alike,
1161900	1163240	once you figure out the key for one,
1163240	1164540	it's going to work for the rest.
1164540	1166300	That's something that you can do.
1166300	1168560	Let's examine for a few minutes
1169300	1171320	why this actually works
1171320	1174260	and why locks sometimes accept keys
1174260	1176800	that are cut incorrectly.
1177020	1179280	So in this particular case,
1179280	1182520	we have a set of probability distributions.
1182520	1186840	So this is the one cut, two, three, four to six
1187720	1190500	for a Kwikset lock.
1190740	1194280	And we can notice that this is where it's supposed to be,
1194280	1195540	where it's supposed to be cut at.
1195540	1198540	And if we're a little bit above that or below that,
1198540	1201200	the probability falls off relatively slowly
1201760	1205180	so that if we go exactly between two cuts,
1205180	1207020	it still has a very high chance
1207020	1210700	of actually working on either the lower or the upper.
1211020	1214600	This distribution here, a fairly normal looking one,
1215140	1218020	exists because the Kwikset smart key lock
1218020	1220760	is a type of wafer tumbler.
1220760	1223980	So wafers are symmetric in what they'll actually accept.
1223980	1228160	And it's also one with very bad tolerances.
1228580	1231360	If we pump that down a little bit,
1231680	1235140	we start to get it accepting less and less.
1235140	1237680	And so a lower probability of actually having a key
1237680	1240600	that's cut halfway in between work.
1240880	1243760	And we can also look at what happens
1243760	1245200	with a pin tumbler lock.
1245200	1248780	In particular, when we have pins involved,
1248780	1251960	it becomes a much faster fall off
1252760	1255260	when the key is cut too high.
1255260	1259460	And the reason for that is because if we look at
1260500	1265020	what a pin tumbler lock looks like on the inside,
1265020	1267500	if that pin is too high,
1267500	1271740	it's going to stick out above this core here.
1271740	1274100	And when it sticks out above that core,
1274100	1278340	it is now physically blocked by the housing.
1278340	1281700	It needs to stick up into this.
1281700	1284020	And we cannot turn that core at all
1284620	1287680	if it's more than one or two thousands of an inch too high.
1287840	1291040	So both the fall off on the probability distribution
1291560	1293660	is significantly faster,
1293660	1296360	as well as the amount too high it can be
1296360	1301080	before it starts falling off is also significantly lower.
1301080	1303000	Whoops, that was the wrong slider there.
1303100	1306220	And so we get a probability distribution
1306220	1309960	that looks something a lot more like this
1309960	1312020	for a pin tumbler lock.
1312020	1314740	So this would be a quick set probability distribution
1314740	1319200	for accepting a one cut key.
1319200	1321480	So if it's a little bit too high, it falls off quickly.
1321480	1323560	If it's a bit low, it works out okay.
1323560	1326480	And then two through six as well.
1327840	1331300	In the case of a Schlage, we have 10 cuts
1331300	1333920	and they're much more closely spaced together.
1334040	1336420	So now we have, even though it's a pin tumbler lock,
1336420	1338340	which generally has better tolerances,
1338340	1342680	now we have a much higher probability of it working
1342680	1347220	if we are somewhat between these two positions.
1347220	1350020	As that Schlage lock gets worn out,
1350020	1353540	that increases as well significantly.
1353540	1358560	So a very worn out pin tumbler lock will now accept,
1358560	1360760	even if it's a full height below,
1360760	1364140	it'll still let it work a lot easier.
1364140	1366660	The way that that actually happens
1367100	1371880	is if we look at a lock here and we cut one height too low,
1371880	1374380	we can see that as that key jiggles
1374380	1377100	and moves in and out of the lock a little bit,
1377100	1379980	it only has to bump this driver pin up a tiny bit
1379980	1383160	for it to actually get lodged in the housing
1383160	1385220	and allow this key to turn.
1385300	1387220	And so that's something that does not have
1387220	1390000	this hard mechanical constraint of housing.
1390000	1391800	It just has to bump up a bit.
1391800	1393720	And that's why if a key is cut too low
1393720	1395100	for a pin tumbler lock,
1395100	1398760	it's a lot more permissive for what it will actually allow.
1398820	1401440	So for a very worn Schlage lock,
1401440	1403540	these are very close together.
1403540	1405420	And so being close together means that
1406800	1410420	the probability distributions overlap by a lot,
1410420	1413340	as well as it's quite wide in a worn lock.
1413340	1417160	We get it to be somewhat permissive as well
1417160	1418720	for what it will accept.
1422410	1424730	So that's lock tolerances.
1424730	1426990	That's sort of an interesting aside there.
1426990	1429730	This particular mathematical model that we've derived
1429730	1433470	is from both theoretical and then empirical confirmation
1434650	1437390	that this is actually how locks behave
1437390	1440550	when the keys are slightly too high and too low.
1440550	1442850	And this is of course an n-dimensional distribution
1442850	1444350	where there are n pins.
1444350	1447430	So what I was showing here is a slight simplification
1447910	1449330	of that.
1449830	1453410	So 243 keys is possible to brute force,
1453410	1456710	but not practical in many situations.
1456710	1458870	So what can we do to actually reduce
1458870	1460410	that key space even further?
1460410	1461770	One thing we can possibly do
1461770	1464310	is get a photograph of that key.
1464310	1466470	So oftentimes you see security guards
1466470	1468610	and users leaving keys lying out on the desk
1468610	1469970	in the public view.
1469970	1472010	This is one of the most egregious cases
1472010	1474870	of these key watchers with transparent windows
1475430	1477970	behind a publicly accessible desk
1477970	1479790	with the facility's keys visible
1479790	1482330	and photographable through that.
1482610	1484190	And of course, people like to wear keys
1484190	1485190	on their belt as well,
1485190	1487270	and that can be photographed as well.
1487350	1489330	If you can get a good enough photograph,
1489330	1492530	you can superimpose these depth and spacing lines
1492530	1494630	and determine directly from the photo
1494630	1496290	what that key code is.
1496290	1498610	And this is something that I've got another talk coming
1498610	1500710	in the next year or so about,
1500710	1501990	all about how to do this
1501990	1505310	and how to work with poor quality photographs
1506010	1508830	and releasing software to do this as well.
1508830	1510750	But that's not this talk.
1511410	1516830	What happens though if that photograph is not great quality
1517290	1518950	and how can we use other information
1518950	1521290	to help deduce what it is?
1521290	1524270	So here's an example of a vehicle key
1524270	1526510	that's left on a desk photographed
1526510	1528750	at a distance of about 10 feet.
1528990	1531510	We can try zooming in, but that doesn't do much for us.
1531510	1532870	This is incredibly grainy.
1532870	1535630	There is not a whole lot that we can tell from it.
1535630	1537450	So what can we do?
1537890	1542930	So let's first recognize that this is a Ford vehicle key.
1543110	1544930	And by looking it up,
1544930	1549890	we can find that it is eight positions
1549890	1553450	by five possible depths.
1554150	1558490	And it is a wafer tumbler lock.
1558890	1561530	And of course, Half-Lights will visit
1561530	1563530	in a few minutes about this.
1563530	1565230	We will come back to that.
1565230	1569930	But we have naively now 390,000 possible key differs
1569930	1571990	for this particular key.
1572190	1575210	Based on the photo, we can't get a whole lot,
1575210	1576650	but we can get something from it.
1576650	1579010	So we can go on over to our photos tab here
1579930	1583590	and add a rule, basically looking at that picture
1583590	1586270	and saying, well, we know that one pin
1586270	1588070	is a little bit high cut, one is low,
1588070	1591790	and see if we can narrow it down a little bit from there.
1592370	1594330	So we have eight pins here.
1594330	1596950	We can see in the middle,
1596950	1599810	these two, this is number four and five,
1599810	1604310	are lining up with the top blank height.
1604350	1607310	So this four and five, we can be relatively confident
1607310	1610690	even from this poor quality picture is a one cut.
1610730	1614010	And then six, seven, eight is beyond that.
1614010	1615750	Six is fairly deep.
1615950	1619190	It looks to be a three or deeper,
1619190	1620370	but it's not the deepest
1620370	1622270	because we have one that's deeper here.
1622270	1623690	So this is a three or a four.
1624050	1627030	And then beyond that, it's fairly shallow.
1627030	1629550	It might be a one, it might be a two.
1629550	1632250	It's likely not a three or anything deeper than that.
1632250	1635830	So we can start adding those rules in.
1635830	1639750	So four and five are both one cuts.
1639830	1644510	Six is fairly deep, but not the deepest.
1644590	1648630	And then seven and eight are fairly high cut,
1648630	1651350	but we don't know exactly what.
1651410	1652930	Popping back to our picture
1652930	1655210	and looking at the first few pins,
1655210	1656370	we see one, two, and three
1656370	1658350	kind of make this bite pattern here.
1659150	1662390	So this pin two is fairly deep.
1662390	1664270	We don't know if it's the absolute deepest,
1664270	1666630	but it's say a three, four, or a five.
1666690	1669830	And then pin three, well, we know it's not the shallowest.
1669830	1670810	We know it's not the deepest.
1670810	1672370	That's about all we can tell.
1672790	1675450	And pin one, well, we know it's fairly shallow.
1675530	1679030	So we can add that here as well.
1679030	1681630	So pin two is quite deep, a three, four, or five.
1681630	1684950	Pin three, we know it's not the shallowest or the deepest.
1684970	1687630	And pin one is quite shallow.
1687790	1689970	And we can add that rule here.
1690130	1693610	And we now get this 390,000 possibilities
1693610	1695670	reduced to 216.
1695750	1700730	That's pretty good, but that's still a lot to try.
1700730	1702850	The other thing that we can look at doing
1702850	1705490	is recognizing that this system
1705490	1708970	is actually on what's called code books.
1708970	1712190	So this particular type of Ford key
1713050	1716910	is one of only a few different differs
1716910	1721870	that will be manufactured, not all 390,000 possible ones.
1722350	1726630	And that's just done to make keying the locks up
1726630	1729090	easier at the factory effectively.
1729130	1732750	So we can add a rule for that as well under code books.
1732750	1737030	This is a Ford fleet keying system.
1737030	1740790	And by adding that, we now see that there's only one key
1740790	1742810	that's actually in the code books
1742810	1745630	that follows these rules that we determined.
1745730	1748590	And that's the 0151X.
1749070	1751810	And so getting a better picture,
1751810	1753970	if we're able to come back and get one,
1753970	1756810	we would see that it is indeed an 0151X
1756810	1758190	that we were photographing.
1758190	1760870	And we can see now from this much better picture,
1760870	1762430	we can read off the code.
1762570	1766150	So we have a two cut here, it's slightly below the blank,
1766150	1768870	followed by a very deep, this is a four or a five,
1768870	1772670	followed by three, one, one, three, two, two.
1772790	1776170	And so we can see from looking at it here
1776170	1781250	that that is indeed what we found for this particular key.
1781250	1783590	So that is a combination of both
1783590	1787330	the photograph limitations that we found,
1787330	1790370	as well as knowing that it must be in the code books.
1790530	1791630	So if you remove this rule,
1791630	1792750	we can see that the code books
1792750	1795970	actually only have 1,700 possibilities.
1795970	1798270	And that gives us a lot of narrowing down
1798270	1800890	of what that particular key can be.
1800890	1803350	And in pin eight, it can never be a one depth
1803350	1807250	because it starts to taper off at the tip of the key there.
1807250	1810710	So a one will not physically fit on that key.
1811350	1812730	So that's sort of a cool example
1813370	1816750	of combining code books with photographs
1817230	1821450	to determine what a key's final code is.
1821970	1824630	We can also combine it with these half heights
1824630	1826750	that we talked about before.
1826750	1829050	So if half heights are available
1829050	1832570	for this particular type of key,
1832570	1834550	if cutting it halfway between a one and a two
1834550	1836670	will work for both a one and a two,
1836670	1838630	we can see the effect that would have,
1838630	1842910	and that would reduce it from 1,700 possibilities to 460
1843350	1845890	that would try out all possible locks
1845890	1849030	that would be manufactured based on these code books.
1849250	1851250	And for many vehicle locks,
1851250	1852610	because they're wafer tumblers,
1852610	1854770	they have relatively loose tolerances,
1854770	1856250	that is actually the case.
1856250	1860210	You have both code books and half heights will work.
1860210	1863110	And so you have many of what's called try out key sets
1863110	1864670	for vehicle locks,
1864670	1868150	which is a number of keys that will try out
1868810	1872210	most or all of the code book keys that are possible
1872750	1875550	that will let you then determine what key is used
1875550	1879770	in a particular vehicle or a particular fleet of vehicles.
1880550	1885330	Auto jigglers are sort of the next stage down from that.
1885330	1887570	And so they are not keys at all.
1887570	1890390	They allow you to move them up and down and angle them
1890390	1892590	and sort of do some fuzzing
1892590	1895590	to try even more combinations quickly.
1895590	1898210	And the high quality auto jigglers
1898210	1900630	were somewhat intelligently designed
1900970	1904570	to be effectively these try out key sets,
1904570	1907530	except adding that degree of freedom
1907530	1911210	for up, down, in, out, tilt, tilt,
1911210	1914310	so that we have rather than just,
1914310	1916290	or rather than 80 or 400,
1916290	1918910	we have only 10 of them that can work on
1918910	1921350	many, many automotive locks
1921350	1923850	and not manufacturer specific either.
1923850	1927050	And of course, further down that continuum is raking,
1927050	1929350	which works in a similar way.
1929350	1931430	So what happens if we don't have a key to photograph
1931430	1933410	or other information like that?
1933410	1936650	Well, then we can decode by looking at the lock itself.
1936650	1938190	So here's sort of a funny example
1938190	1940390	where the key pin is visible in its entirety
1940390	1942070	through the front of the lock.
1942070	1944030	And so from this, we can tell the length of the key pin
1944030	1947050	and therefore the depth of the first cut on that key.
1947110	1950290	We can look deeper in the lock using this device here,
1950290	1951570	which is called a lock scope.
1951570	1953430	So it's like the autoscopes that are used
1953430	1956390	to look into your ear at the doctor's office.
1956390	1959590	And they shine light through the back of this lock.
1959590	1961830	And we can see then every pin through it
1961830	1964190	with a little magnifier that's inside of it.
1964390	1965850	So this is cool.
1965850	1967550	We can't tell a whole lot from this.
1967550	1968910	Wouldn't it be nice if just by looking
1968910	1969830	at the bottom of the pins,
1969830	1971670	we could actually tell how long they were
1971670	1973710	in terms of their total length?
1974070	1976990	Well, enter colored painting kits.
1977470	1980210	I kid you not, and they are colored,
1980210	1982690	I kid you not, by length.
1982810	1985730	So by seeing the color of the pins
1985730	1987830	that we actually look at in this lock scope,
1987830	1990390	we can tell how long our key pins are
1990390	1993070	and therefore the key code.
1993810	1998350	So that last picture was a locksmith's rekeying version.
1998350	2001290	This is for an end user and we see colored pins as well.
2001290	2003090	It makes it a little bit easier to use,
2003090	2005490	but you can read the pins from that.
2005730	2008590	So here's an example of looking down a sergeant lock
2008590	2010110	with that lock scope.
2010110	2014310	And we can see there's gold, green, gold, green, gold.
2014310	2015550	It's a little hard to see at the end,
2015550	2018210	but that's a purple pin at the very end.
2018730	2020750	Looking at the sergeant chart,
2020750	2022390	we can see that a gold bottom pin
2022390	2025310	must be a one, four, seven, or zero,
2025310	2028510	which is what sergeant calls its 10 depth.
2028510	2032390	Green is three, six, nine,
2032390	2035330	and purple is two, five, eight.
2035330	2037490	So based on that, we can actually go ahead
2037490	2040810	and severely limit what the key could possibly be
2040810	2043410	for this particular system.
2043650	2048530	This is a sergeant system, it has six pins and 10 depths,
2048530	2051010	and we use one base numbering.
2051870	2054010	And we'll go ahead, and under photos,
2054010	2056350	we can add that particular rule.
2056490	2059430	And so we tell it that it is a sergeant system
2059430	2067110	and that we have gold, green, gold, green, gold, purple.
2067110	2069450	And that reduces our key space from a million
2069450	2071710	down to 1728.
2071990	2073410	It's worth noting, incidentally,
2073410	2075290	that half height is not gonna help us here,
2075290	2077810	even if this lock accepts it, which it doesn't,
2077810	2080630	because half height would not be able to try
2080630	2083310	both of two combinations three apart.
2083310	2085650	And so we get 1728 as well,
2085650	2088150	with just a slightly squished chart there.
2088670	2091570	So this is not bad, it's a lot better than a million,
2091570	2093090	but we need to do a bit better than that
2093090	2095170	to get a single working key.
2095470	2098690	One thing we can notice is that if this pin one is a zero,
2098690	2100770	then pin two cannot be a nine,
2100770	2102470	that would be a max violation.
2102590	2104670	So sergeant has a max of seven.
2104670	2107610	We can go ahead and add that on in there.
2107830	2109810	And so now we've reduced to 1166,
2109810	2111430	that's getting a little bit better.
2111690	2112850	What else can we do?
2112850	2114890	Well, remember looking at this lock,
2114890	2116750	we have this shear line visible.
2116770	2119390	And so that tells us that this is a zero cut
2120010	2122550	in this particular position.
2122550	2128910	So a very high cut depth on that key.
2129070	2131410	We can go further and use a lock pick
2131410	2134150	to lift up that first pin and look at the second
2134150	2136250	to see if we can see something similar.
2136290	2138110	And we don't, but...
2138110	2140070	So here's the lock pick in there.
2140090	2142590	But on the third pin, we do.
2142590	2147030	We can see a shear line at that same position
2147030	2149670	telling us that that third pin is also a one cut.
2149670	2152050	And we can continue backwards through the lock,
2152050	2154370	seeing that there are not any visible shear lines
2154370	2155750	beyond that.
2156090	2160450	So how does that apply to the lock that we have here?
2160590	2162410	Well, we can go to known shear lines
2162410	2165450	and we know that pin one has a one as a shear line,
2165450	2166690	pin three has a one.
2166690	2167930	We can add that rule.
2167930	2170890	And now that severely limits our key space down to 44.
2171290	2173290	Moreover, because we looked all the way back,
2173290	2176530	we know that pin five does not have a shear line at one.
2176530	2180390	So it's only possibilities are four, seven, and 10.
2180830	2184490	So we can put that into there.
2185250	2188250	And now we're down to 32 different keys.
2188250	2190730	This is something that's very brute forcible.
2190730	2193130	It's easy to make 32 and try it.
2193130	2195990	That'll cost us about $10 and take three minutes
2195990	2197890	to try 32 keys out.
2197890	2200810	Not bad, but we can do better than that.
2200810	2203150	And the way we can do better than that is impressioning
2203150	2205490	in particular with this extra information
2205490	2207150	that's available to us.
2207710	2210310	Before we talk about how to impression this particular lock
2210310	2211710	with extra information,
2211710	2214150	let's talk a little bit about how impressioning works
2214150	2215290	in general.
2215550	2220290	So we put the key in, we put a blank key in.
2220290	2223470	We cut all zero-bidded, the highest possible cuts.
2223690	2226050	And when we turn the key, there's a couple pins that bind
2226050	2228330	that don't let the lock turn.
2228350	2231030	If we turn it really, really hard,
2231030	2234330	then those pins are going to bind really, really hard.
2234330	2236790	And if we then wiggle the key in and out,
2236790	2238130	up and down a little bit,
2238130	2240430	those pins that are binding really hard
2240430	2242350	are gonna leave a mark on the key
2242350	2245010	that we can then look at.
2245490	2247190	So if we impression this,
2247190	2250430	one of these pins that's binding is gonna leave a mark.
2250630	2252830	Can we take the key out and look at that mark
2252830	2254870	and see it's in position two?
2255110	2257390	So cut two is not a zero cut,
2257390	2259590	because if it were, if that were a shear line,
2259590	2261010	then the pin would not have bound,
2261010	2262430	wouldn't have left that mark.
2262590	2265910	So we cut it down, put the key in and impression again.
2266090	2268870	And we take it out and we see now there's no more mark
2268870	2270830	on pin two, but there's one on pin four,
2270830	2272670	which tells us that pin four is binding.
2272670	2273910	It's not a zero.
2273910	2277050	We cut it down and we repeat the process.
2277550	2280270	And so pin four is still leaving an impression mark.
2280410	2283650	So we file it down one more time, impression it,
2283650	2286210	take it out, pin four is still leaving an impression mark,
2286210	2289730	file it down one more time, take it out, impression it.
2289730	2292290	And now we see that pin five is the only one binding.
2292290	2294450	So pin four has stopped leaving an impression mark
2294450	2296390	and pin five is now.
2296430	2299190	So we know it's not a zero cut, we file it down
2299190	2301750	and then we're going to repeat that process,
2301750	2305810	until when we try to impression and it's the right code,
2305810	2308050	the lock is just going to open.
2308590	2310250	So that's how impressioning works in general,
2310250	2314050	starting from a blank and ending with any particular lock
2314610	2316830	or with a key for that particular lock.
2316830	2321250	One piece of software that I'm releasing a modification
2321250	2323350	of this is a little game that you can try.
2323350	2325750	So you put it in and you could make the lock visible
2325750	2328490	or not as you see fit, impression it
2328490	2330470	and take the key back out again.
2330470	2332850	And then you can sort of practice your impressioning
2332850	2335590	that way until you eventually get the key for it.
2335590	2337270	So that's something you might enjoy.
2337330	2338770	But let's look at how that applies
2338770	2341210	to this particular system here.
2341730	2344150	If we wanted to impression this lock,
2344150	2346430	so let's start by creating a lock here.
2347070	2349430	We don't actually need to start with a blank
2349430	2353350	because if we look at our key space,
2353510	2357090	a one, one, one, et cetera, cannot possibly be the code.
2357090	2360470	The highest cut our code can be is one, three,
2360470	2362870	one, three, four, two.
2363190	2365910	And in our impressioning tab, it tells us that.
2365910	2367730	So that's what we actually wanna start
2368230	2369870	by cutting our key to.
2369870	2371730	One, three, one, three, four, two.
2371910	2374110	And we put it into the lock.
2374330	2376950	Now this lock, to give it a couple examples
2376950	2381470	for what our actual code is inside the lock
2381470	2386330	might be a one, six, one, three,
2388470	2390670	four, eight.
2391630	2394490	So that's what the key is we're ultimately searching for,
2394490	2396250	but of course we don't know that yet.
2396810	2400050	So we're gonna impression this key and take it out.
2400050	2403270	And we see that position two is binding.
2403390	2407570	So position two is not actually the correct cut.
2408010	2410110	And so what we'll do is scroll on up
2410650	2413870	and say that pin two is not at depth three.
2413870	2416430	It's not at depth three because it was cut to depth three
2416430	2418010	and it's leaving an impression mark.
2418010	2419350	So we'll add that rule.
2419350	2422310	That's telling us to try a six next.
2422310	2423850	And we know a six is going to work
2423850	2426990	because it's the only position left that pin two can be.
2427270	2429810	So our impression mark should show up somewhere else.
2429810	2432630	So we're gonna file our key down to a six depth,
2432630	2437090	put it in and impression it and take it out again.
2437090	2439990	And we now see that pin five is binding
2439990	2442550	and pin five is now leaving a mark.
2442550	2446930	So we can scroll on up and tell it that pin five,
2446930	2451650	which was cut to a two has, sorry, not pin five,
2451650	2453710	my apologies, pin six, the last pin.
2454090	2457450	So pin six that was cut to a two has no shear line there
2457450	2459290	because it leaves an impression mark.
2459290	2461470	And so we'll add that rule to the system,
2461470	2462770	no shear line there.
2462850	2466810	And it tells us the next tryout is one, six, one, three,
2466810	2469270	four, five, because five is the next value
2469270	2471230	that pin six can take on.
2471830	2472910	So we try that.
2472910	2475450	Pin six, we'll cut it down from a two to a five
2476050	2479510	and we'll put it in and impression it.
2479590	2480690	And when we take it out,
2480690	2483230	we'll see this impression mark left on pin six.
2483230	2486690	So we know that pin six is not a five depth either.
2487270	2490250	And so we'll tell it that, no shear line at depth five.
2490290	2492710	And so it tells us to try an eight now.
2492770	2495130	And we can see that this has to be what pin six is.
2495130	2497370	So if this doesn't work, we've done something wrong.
2497370	2499690	So we'll file it down to an eight
2500070	2502490	and we'll put our key in and we'll hit impression.
2503190	2504770	And this time the lock opens
2504770	2506850	because we found the correct code.
2506850	2510590	So as we can see, one, six, one, three, four, eight.
2510790	2514890	This was done in only three impressioning steps,
2514890	2517890	whereas it would have taken 19 to get down
2517890	2521430	to this particular code using impressioning
2521430	2522950	with no other information,
2522950	2526230	just going down one at a time at a time.
2526230	2531210	So very, very powerful tool that will let us decode locks
2531210	2533470	with the impressioning technique.
2533550	2534850	So let's look at another arrangement
2534850	2537570	that can be useful to us, which is key to like systems.
2537570	2541130	So password reuse is generally accepted to be a poor form.
2541170	2543410	Key reuse is common and called key to like
2543410	2545090	and seen in many cases.
2545230	2547670	So there's a whole big old list here.
2547690	2550110	Many of them, if you're interested in this,
2550110	2551150	I encourage you to check out
2551150	2553850	Howard Payne and Devia Toloff's amazing talk,
2553850	2556750	This Key is Your Key, This Key is My Key at Hope 11.
2556850	2559770	And it touches on a whole bunch of these and what they do.
2559910	2561230	Here's a couple that I've discovered
2561230	2562990	that wasn't mentioned in that talk
2562990	2564390	that I think are interesting.
2564410	2567170	So one is construction cores.
2567370	2569490	So if you ever see an interchangeable core
2569490	2573490	that's got a color on it, black, red, or green,
2573970	2575970	that's usually a construction core.
2575970	2577750	It's just used when the building's under construction
2577750	2579870	and it gets swapped out once it's done.
2579870	2581470	These are all key to like.
2581470	2584950	So if you find, say, a green best or a black Schlage,
2584950	2587930	you can look up what the code is and cut a key for that
2587930	2590770	without doing any more decoding.
2591030	2593610	Traffic controller boxes are like that as well.
2593610	2596150	This little upper box is for emergency services
2596150	2597910	to manually control the light.
2597910	2600570	And those keys are universal across North America.
2600570	2603730	And then this lower keyhole is for maintaining the system.
2603730	2606010	And there's only a couple of those different keys
2606010	2608890	that are used across North America.
2608890	2611970	Here's a great example of a bunch of key to like systems.
2611970	2613890	So we have an enter phone box here.
2613890	2615310	This is a Miracom box.
2615310	2617390	So opening it up to service the box,
2617390	2619610	this is a Miracom 549 key,
2619610	2622770	and that's universal for all of these Miracom boxes.
2622770	2624790	It's also got a postal key here
2624790	2627130	so that the post worker can open the box
2627130	2631450	or can open the door and get in and deliver your mail.
2631510	2634310	This box beside it is a little key box
2634310	2636730	that the power company uses to get in
2636730	2639070	because presumably this particular facility
2639070	2641430	will have a customer-owned transformer vault
2641430	2642930	somewhere with inside.
2643190	2647150	We also see these two building-owned keys.
2647150	2648150	We don't know what they're for,
2648150	2650370	but lots of ways to get through this door,
2650370	2652730	three of which are key to like systems.
2653050	2655470	Here's an example of a postal lock box.
2655470	2658550	This one is a Abloy postal lock.
2658550	2661610	So in Canada, our coastal service uses Abloy.
2661610	2663190	Very, very good choice.
2663190	2667130	It's somewhat negated by this door king lock here,
2667130	2669990	which is not only a poor tolerance wafer lock,
2669990	2671730	but it's also key to like.
2671870	2675710	And these door king keys, any of them will open it.
2676190	2678430	If it's not something that we already know
2678430	2680510	what the key is for the key to like system,
2680510	2683590	we can determine what that key is by disassembling the lock.
2683590	2685570	And then once we get the key for one lock,
2685570	2688190	it's gonna work for all of them if they're key to like.
2688470	2693170	So to do that, we need to get the lock out somehow.
2693170	2695130	So once the door is open,
2695130	2697130	you can unscrew the retaining screw
2697130	2698450	and then unscrew the lock,
2698450	2701230	at which point we can take off the tail piece
2701690	2704290	and get these pins to shear line somehow,
2704290	2706810	either shimming through the back or picking.
2706850	2709130	And then we can look at what the pins are
2709130	2710630	on the inside of it.
2710710	2714210	So in this particular case, we have a lock.
2714210	2716530	We can see how long these pins are.
2716690	2719030	And that particular pattern that the pins make,
2719030	2721030	if we invert it, so it's upside down,
2721030	2723170	that's gonna give us what the key looks like.
2723170	2724570	And so we can see we put the key in
2724570	2726130	and it doesn't need work.
2726130	2727770	And we can figure out what exactly
2727770	2730650	that key is going to look like from the lock.
2731210	2733370	If you don't wanna have to shim through the back,
2733370	2735210	you can also take off this brass plate,
2735210	2738010	which is an awful task to do, but it does work.
2738810	2740790	And if you wanna have a bit more time
2740790	2743210	to do this decoding and disassembly,
2743210	2746190	one thing you can do as well is replace it,
2746190	2749530	temporarily at least, with a lock that looks like this.
2749530	2753570	And that's going to work no matter what key enters the lock.
2753630	2757470	So anyone that tries to get in is not going to be blocked
2757470	2758790	and no one's gonna be the wiser
2758790	2761970	while you have the lock out for disassembly.
2763370	2765070	Metakos are very nice to us.
2765070	2767590	They have these nice set screws at the top.
2767590	2770310	And so we can pull that out and dump the pin stack.
2770310	2771990	And so we can see in this pin stack here,
2771990	2773230	we have a key pin.
2773230	2778030	We can read both the angle and the depth of it from that.
2778030	2779890	This one happens to have some master wafers,
2779890	2780950	so it's not key to like,
2780950	2782550	and we'll talk about how to handle that later,
2782550	2786930	but we can see a 25 thousandths of an inch one wafer
2786930	2788670	and a 50 thousand two wafer.
2788670	2790950	In this case, we only needed to remove
2791530	2792790	these first two pin stacks
2794230	2797070	because we got some information about the lock already
2797070	2799670	and the first two pin stacks were the only things
2799670	2802030	that we needed more information about.
2802550	2804790	And of course, because of these set screws,
2804790	2806950	we don't have to worry about this awful brass piece
2806950	2808870	or shimming it, et cetera.
2809010	2810790	If you're interested in this sort of thing,
2810790	2813650	I strongly recommend you check out Molok's amazing talk,
2813650	2815830	Please Do Not Duplicate Attacking the Knox Blocks
2815830	2817190	from DEF CON 26.
2817430	2819910	It's all about doing attacks like this,
2819910	2823110	taking locks apart and looking at the Knox block systems,
2823110	2826190	which is key to like across many jurisdictions
2826190	2827990	in North America.
2828610	2830350	So that's key to like systems.
2830350	2834370	What we can do with that is start to analyze everything
2834370	2836030	that we've looked at so far
2836030	2839110	and figure out how to formalize it
2839110	2842110	and how to determine what the best next step is.
2842110	2845170	And we can do that by looking at information theory.
2846390	2848570	So you've likely heard of the concept
2848570	2851090	of the entropy of a password before.
2851090	2853410	We'll talk a bit about what exactly that means.
2853410	2855570	So information is stuff we know
2855570	2858350	and entropy is stuff we don't know.
2858530	2860670	So in the case of a stoplight, it's either red or green
2860670	2862370	and that is information.
2862370	2865790	That's in the case of red or green, one bit of information
2865790	2868770	because it's a zero or a one, that's ignoring yellow.
2869430	2871470	When it's a random variable,
2871470	2873830	that's something we don't know and so that's entropy.
2874130	2876030	And so a key or a password has entropy
2876030	2877730	because we do not know it
2877730	2878890	and we're trying to determine it
2878890	2881410	to get into that particular lock.
2882250	2884210	So how do we measure the entropy?
2884350	2885330	So it's in bits.
2885330	2887030	So a coin flip is a zero or a one,
2887030	2888550	so it has one bit of entropy.
2888570	2891810	A random number from zero to 255 is eight bits,
2891810	2896010	since eight bits can encode number zero to 255.
2896050	2900250	A random number one to 10 has 3.32 bits.
2900250	2903730	Well, how do we have a fractional number of bits?
2903730	2906130	Well, we can think of it like the following.
2906170	2908150	We have three random numbers, one to 10,
2908150	2910510	that is a three digit number.
2910510	2912770	And so that can be encoded with one to a thousand
2912770	2914650	or zero to 999.
2914690	2917130	And that fits very well into 10 bits,
2917130	2919430	which can encode zero to 1023.
2919430	2921750	So two to the 10 minus one.
2922370	2925750	So 10 bits will easily encode zero to 999
2925750	2928050	with not a whole lot left over.
2928050	2930110	And so 10 bits divided by three,
2930110	2932550	because we're storing three random numbers inside of it,
2932550	2936710	is 3.33, which is very close to that 3.32 figure.
2936710	2939430	If we extend the number that we're storing,
2939430	2940730	so instead of three random numbers,
2940730	2942630	we try to store six or nine or a thousand
2942630	2944570	as that tends to infinity,
2944570	2947670	this number tends to 3.32.
2949450	2953170	This is mathematically represented with a log.
2953170	2956610	So the entropy of a piece of information
2956610	2958310	can be thought of as the number of bits
2958310	2960350	it takes to write it down,
2960350	2965470	or write down a number from zero to the total value
2965470	2968510	that that information can possibly be.
2968510	2972230	And so that would be the log base two of that number.
2972790	2974550	So the number of bits of entropy,
2974550	2976450	which is represented by the Greek letter eta,
2976450	2978490	or eta in modern Greek,
2978490	2980490	for a random variable with n outcomes
2980490	2983610	is just log base two of n.
2983610	2986550	So a fair coin flip has two possible outcomes.
2986550	2988770	Log base two of two is,
2988770	2992090	that should not say two bits, that is a typo, one bit.
2992230	2994930	A random number from zero to 255
2995430	2997390	is log base two of 256,
2997390	2999550	because zero is not counted here,
2999550	3001470	so, or is counted here.
3001470	3005470	So that's 256 possible options, which is eight bits.
3005530	3006770	And a random number of one to 10
3006770	3010890	is log base two of 10, which is 3.322,
3010890	3012310	what we looked at before.
3012710	3015550	So a couple of examples of entropy within keys.
3016790	3019670	That is the number of bits in the piece of information,
3019670	3020510	so the key to the password,
3020510	3022130	once we do have that information.
3022370	3024310	So an eight character ASCII password,
3024310	3027770	so that's eight bytes times eight bits per byte
3027770	3030030	is 256 bits of entropy.
3030510	3033310	This, many of you will be screaming at your monitor,
3033310	3036770	is wrong, because some characters
3036770	3038290	are more likely than others.
3038290	3042050	Some characters are not used at all in most passwords.
3042050	3045070	And of course, dictionary attacks exist,
3045070	3047990	so certain passwords are more common than others.
3048030	3049750	And so that does reduce the entropy.
3049750	3052290	We'll look at why in a little bit.
3052350	3054810	For a 10 digit passcode, three characters long,
3054810	3056930	assuming all combinations are equally likely,
3056930	3059990	we have 9.97 bits, which makes sense.
3059990	3062910	A thousand combinations is a little bit shy of 1024,
3062910	3064930	which would be exactly 10 bits.
3065210	3069310	An EVA MCS, so that's the magnetic coding system key.
3069310	3073230	It has four rotors and eight positions each for each rotor.
3073230	3075050	So that's eight to the power of four,
3075050	3078450	4,096, or 12 bits exactly of entropy.
3078450	3080970	And a Schlage five pin system has five to the power
3080970	3083050	of 10 or 100,000 combinations,
3083050	3086770	log two of 100,000 is 16.6 bits.
3086770	3089490	So that's a couple of examples
3090070	3092550	of how much entropy is in a system.
3092910	3094930	In the software that we have here,
3094930	3097650	it gives you that at the start
3097650	3099850	and at the end of the rules that you've applied.
3099910	3103570	So in this particular case, if we look at a Schlage system,
3103570	3107910	whoopsies, five pins with 10 possible depths,
3107910	3112330	so 100,000, and then we have 16.6 right there.
3112330	3114390	And you can play around with that to see what happens
3114390	3118350	as you change the number of depths and pins.
3119750	3121410	So if there are N possibilities
3121410	3124550	and all possibilities are equally likely,
3124550	3127490	then the entropy is given by log two of N.
3127690	3130870	But if some possibilities are more likely than others,
3130870	3132050	entropy goes down.
3132050	3135330	So in a dictionary based attack on passwords,
3135330	3137590	because they follow these dictionaries,
3137590	3139790	it is easier to guess that there's less entropy
3139790	3141610	in those passwords.
3142090	3144630	And so in the example of keys,
3145430	3148170	we see many key systems avoiding very deep cuts
3148170	3151270	because that makes the key more prone to breaking.
3152350	3155350	And there's other ways that you can do keys
3155350	3156690	to make it harder to pick.
3156690	3158170	And so that does slightly reduce
3158170	3160550	the amount of entropy present in your key.
3160550	3163930	The fact that certain differs are less probable than others.
3164130	3166970	So to look at a very simple example here,
3166970	3170710	we have a master key that we've decoded
3170710	3175450	as either a 14767 or a 94767.
3175450	3177550	So looking at these two options naively,
3177550	3180910	we have, or we could say there might be a 50-50 chance
3180910	3183510	of each of these two options.
3183510	3186030	And so since there's two, it's a zero or a one,
3186030	3188010	this is one bit of entropy.
3188130	3190550	We can expand this calculation a little bit
3191450	3194570	by looking at the individual probabilities.
3194570	3199090	So there's a probability of 0.5 of it being 14767
3199090	3201570	and 0.5 of nine.
3201590	3205710	So we have minus 0.5 log two of 0.5.
3205710	3207750	So that's the probability of the first one.
3207750	3209110	Then the exact same thing,
3209110	3211650	because the probability of the second is the same.
3211650	3215430	And we do a little bit of arithmetic using our log rules.
3215430	3216770	And we find that that simplifies
3216770	3220270	to log base two of two or one bit.
3220650	3223810	The question is though, are these equiprobable?
3223810	3229070	And so if this were a non-master key, then it might be,
3229070	3230730	but knowing that this is a master key,
3230730	3232650	there's a couple of cues we can take.
3232750	3234930	So here's our 14767.
3235010	3237470	This is very typical of what master keys
3237470	3239370	very frequently look like.
3239730	3241350	When we take this down to a nine,
3241350	3242970	there's a number of problems with it.
3242970	3245790	One is it has a very deep cut in pin one.
3245790	3248150	This is prone to breaking off in the lock.
3248210	3251090	And I generally want to avoid keys breaking off in locks,
3251090	3253090	but especially master keys,
3253090	3254910	because if that gets stuck in there
3254910	3257090	and a bad actor is able to get it out,
3257090	3258770	that's a problem for you.
3258770	3260030	The other thing that happens here
3260030	3262650	is this is now a very low cut key.
3262690	3264670	And for reasons we'll talk about shortly,
3264670	3268090	having a low cut master key is something you want to avoid.
3268470	3272390	So it's highly unlikely that this 94767
3272950	3275190	would be the code that the locksmith chose
3275190	3277390	to be the master key.
3277630	3281370	So we can assess perhaps a 95% chance
3281370	3284510	that it's this one cut and a 5% chance
3284510	3286690	that it's this nine cut.
3286690	3289790	And crunching those numbers, we have 0.95.
3289790	3291890	So our probability times log two of 0.95
3292970	3296270	plus 0.05 times log two of 0.05.
3296270	3302070	And we find our entropy is now 0.2 bits, 0.3 rounding.
3302070	3304230	So that is significantly lower
3304230	3308210	owing to this high difference in probabilities
3308210	3310310	between these two options.
3310310	3311730	In the extreme case,
3311730	3314010	so we can sort of intuitively understand this,
3314010	3315250	if one option is certain
3315250	3317350	and the other option is impossible,
3317350	3318730	well, that's zero bits of entropy
3318730	3322570	because there's nothing unknown in this case.
3322930	3327350	So in general, the entropy where the probabilities
3327350	3332350	are not equal is going to be the sum of each probability
3332870	3335490	times the log two of each probability,
3335490	3337030	and then minus that,
3337030	3339250	because log of a number less than one
3339250	3340990	is going to be a negative.
3340990	3346010	And so this definition is a fairly beautiful derivation
3346010	3349430	of it that I won't go into now for obvious reasons,
3349430	3351450	but I encourage you to look it up.
3351450	3353210	So we can now extend this concept
3353790	3356130	and do a little bit more useful with it
3356130	3358610	by looking at joint and conditional entropy
3358610	3361510	and mutual information for different rules
3361510	3363590	in terms of which ones are giving us
3363590	3365830	more and less information.
3365890	3368630	So let's just get rid of this block to start.
3368630	3371750	So what we'll do here is consider a very simple system
3371750	3376770	with only three pins and only two possible depths for each.
3376770	3379850	And so we can see that this has three bits of entropy in it,
3379850	3381030	and that makes sense.
3381030	3384210	We have a zero or a one, zero, one, zero, one,
3384210	3386250	three times over, so that's three bits.
3386250	3389310	And we've enumerated all of the eight possible options here.
3389390	3392110	And of course, log base two of eight is three,
3392110	3394370	so that also makes a lot of sense.
3395050	3396750	So let's say that we have,
3396750	3399090	let's say a photograph of the key or something,
3399090	3401770	but that photograph only shows us pin one.
3401770	3404890	And that tells us that pin one is a zero.
3406090	3408670	So that now tells us, well, pin one is a zero.
3408670	3410790	We don't know anything about pin two or pin three.
3410790	3412710	That gives us one bit of information.
3412710	3413670	It makes sense.
3413670	3416130	And we're now down to two bits of conditional entropy.
3416130	3419750	That's conditional on this rule being the case here.
3420030	3422510	And then we get another photo and it's a bit better.
3422510	3426070	It shows us that pin one is a zero and pin two is a zero.
3426430	3429690	And so now we've limited pin one and pin two to zero, zero.
3429690	3432310	And so we have one bit of entropy left
3432310	3434610	because this rule has given us two.
3436170	3439630	And if we have a third photograph,
3439630	3441810	say that shows that pin three is limited to zero,
3441810	3443770	but we can't see pin one or pin two.
3443990	3445470	Now we have the final key
3445470	3448450	because we know that they're all zero, zero, zero.
3448930	3452050	So this is fairly simplistic and fairly obvious, I assume,
3452050	3454910	but we can analyze it in terms of the information content
3454910	3457490	provided in each of these three rules.
3457890	3459750	So looking at it intuitively,
3459750	3462470	rule one gave us one bit of information,
3462470	3465370	rule two gives us two, and rule three gives us one,
3465370	3471410	as well as rule two shares one bit with rule one.
3471410	3475170	In terms of the conditional entropy given by rule one
3475170	3477070	relative to rule two.
3477170	3479190	So given everything that rule two gives us,
3479190	3481290	rule one gives us nothing extra.
3481330	3483310	Given everything that rule one gives us,
3483310	3485790	rule two gives us one bit extra,
3485790	3489630	and they share one bit, common to both of them,
3489630	3492590	and rule three, of course, shares nothing with the other two.
3492590	3496690	So we can analyze this automatically with the software here
3496690	3500310	by clicking calculate conditional entropies down below.
3500390	3504630	And let's compare rules one and two, just to start.
3504630	3507210	And we see exactly what I mentioned there.
3507210	3511430	So rule one, within this circle, we see it gives us one bit,
3511430	3516070	and rule two, within its circle, gives us two bits.
3516270	3519690	One bit is shared with rule one, and one bit is on its own.
3519690	3522690	And so that one on its own is, of course, position two,
3522690	3523750	where this is the only one
3523750	3526130	that tells us anything about pin two.
3527230	3529930	And then the total information given by both
3529930	3531330	is the sum of what's in here.
3531330	3535110	So that's the joint entropy reduction, which is two bits.
3535890	3538250	Comparing rule one and rule three,
3538250	3540210	we see that they both give us one bit,
3540210	3542790	and there's nothing shared between them, which makes sense.
3542790	3545150	We have pin one, pin three, nothing shared.
3545430	3547450	And we can compare all of them.
3547670	3549390	And so we see now that within these,
3549390	3552410	we have a total of three bits given.
3552410	3554590	And for the system that started out as three bits,
3554590	3556990	that will reduce us to a final key.
3557410	3559270	And those three bits,
3559270	3562370	one of which is shared between rules one and two,
3563430	3566690	one of which is just given by rule two,
3566690	3569070	one of which is just given by rule three.
3569070	3570510	And then there's nothing, say, that's shared
3570510	3571610	by all three of them,
3571610	3575090	or that's just given by rule one, et cetera.
3575970	3578930	So this is a fairly useful way of analyzing
3578930	3581550	the rules that we've determined that limit the system
3581550	3584970	and determining which one is most useful to us.
3584970	3587150	And are we sharing a lot of information?
3587150	3588330	If we are, that indicates
3588330	3590070	that we're not being particularly efficient
3590070	3591870	with what work we're doing
3591870	3594510	to find out this information put into this system.
3594510	3597290	Ideally, the less shared information,
3597290	3599990	the more total information we're actually going to get
3600380	3604410	out of all of the rules in this particular system.
3605780	3609290	So that is conditional entropy.
3609290	3610730	Mutual information, by the way,
3610730	3615390	is the term that we use to talk about the information
3615390	3617470	that is, well, mutual between
3618160	3619790	two different random variables,
3619790	3621630	or in this case, two different rules
3621630	3624390	that impose a constraint on the system.
3627730	3629670	So in the case that we looked at before
3629670	3632750	with this 0151X key,
3632750	3637490	we have the conditional entropy given by the code book
3637490	3639790	is a lot, almost nine bits,
3639790	3640590	which makes sense.
3640590	3644830	We're going from 390,000 to 1,700 possibilities.
3644910	3647390	And given by the photo is a fair bit as well,
3647390	3650810	because we were able to determine some severe limitations
3650810	3652870	on many of the pins that exist.
3652870	3655150	And there's not a lot of shared information.
3655150	3657890	The result of that is between these two rules,
3657890	3661990	they give us all of the entropy that existed
3661990	3663790	in that particular key.
3664790	3665770	There's a good reason
3665770	3667430	that they don't share a lot of information.
3667430	3668930	And that's because, well,
3668930	3672090	what is the uncertainty that exists in a photo?
3672090	3673510	Well, the uncertainty is, you know,
3673510	3675470	is this a two or a three?
3675470	3677810	You know, is one position off?
3677990	3679670	In the case of a code book,
3679670	3681850	what they do with code books is very different.
3681850	3683470	They're not going to make a code
3683470	3687570	that's off by just one cut and one pin
3687570	3689570	from another item in the code book.
3689570	3691270	They're all going to be wildly different
3691270	3694590	if you're reducing 390,000 possible differs
3694590	3697430	into 1,700 in the code book.
3697430	3699430	So because they're wildly different,
3699430	3701410	the information given to us by the code book
3701410	3704490	is very, very different than the information
3704490	3705690	given by the photo.
3705690	3707430	There's not a lot of overlap.
3707430	3708870	And as a result there,
3709670	3711490	these two rules put together
3711490	3714770	are very useful to give us a lot of information
3714770	3716710	about this system.
3716710	3718690	So we've talked about loads of techniques
3718690	3720170	to determine the key for a lock
3720170	3721750	when we don't have a key at all.
3721750	3723530	How about if we have a key for some lock
3723530	3725290	on some master system,
3725290	3728130	and we want to turn it into a grand master key
3728130	3730170	that's going to work for all of those locks?
3730170	3731870	To understand how to do that,
3731870	3735090	let's look a little bit at how mastering works in general.
3735090	3736910	Any lock on a master system
3736910	3739330	is going to accept multiple keys.
3739330	3741670	And it does that by having more than one shear lines
3741670	3743490	in at least some of the pins.
3743590	3746750	So in this case, we have two shear lines in every pin stack.
3746750	3748630	One of these shear lines in each pin stack
3748630	3750830	is for the change key,
3750830	3753670	and one is going to be for the master key.
3753670	3755530	So there's two different shear lines,
3755530	3758290	and a different one is always gonna be used,
3758290	3760850	one for change and one for master.
3761310	3763790	Master key actually is necessary
3763790	3766610	in the context of multiple locks.
3766690	3768590	So in here we have Alice's lock
3768590	3770250	and her key A1,
3770250	3773350	and it's going to work in her lock.
3774210	3779050	And we're also going to have a sub master, MKA,
3779050	3781830	that will work in her lock and a grand master.
3781850	3784330	But Bob can't put his key in her lock.
3784330	3785710	It's not going to work.
3785710	3787410	It binds in pin three,
3787410	3789450	and Charlie's is completely off.
3789450	3791290	It's also not going to work.
3791290	3793330	So that's what works in Alice's lock.
3793330	3797730	In Bob's lock, Alice's key is not going to work
3797730	3801010	because it's not the right key.
3801010	3802270	It's just a change key.
3802350	3804730	But Bob's key, of course, will.
3805530	3807170	Charlie's key won't.
3807390	3809470	And the master MKA will,
3809470	3811150	because Bob is on the A system.
3811150	3812390	He's A2.
3812650	3816530	And the grand master is going to work as well.
3817070	3819770	In Charlie's lock, he's on the B system.
3819770	3823150	So MKA is not going to work.
3825010	3826410	Alice's key, of course,
3826410	3830210	and Bob's key are both also not going to work.
3830410	3832210	Charlie's key will, of course.
3832510	3835610	And the grand master will as well.
3835810	3839610	So what we have is a two-level hierarchy system
3839610	3841670	where we have a master key MKA
3842250	3844470	that works for Alice's and Bob's lock,
3844470	3845770	which are on the A system,
3845770	3848250	but not for Charlie's, which is on the B system,
3848250	3851530	and a grand master key that works for all of them.
3851550	3854010	The way that this happens is the grand master key
3854010	3855770	uses the grand master shear lines
3855770	3858090	in all positions on all locks.
3858310	3861470	The MKA uses the grand master shear lines
3861470	3863450	in just these last three positions,
3863450	3864930	but not the first two.
3864930	3866230	So that way you can tell,
3866230	3868150	is this on the A system?
3868350	3871270	And all A system locks start with 3-1.
3871270	3875110	So Alice's key does as does Bob's key.
3875110	3876670	It starts with 3-1,
3876670	3880530	and therefore MKA, which also starts with 3-1,
3880530	3882770	is going to work on Bob's lock.
3882770	3886270	If we try MKA in Charlie's lock,
3886270	3888150	it's going to work on the last three pins
3888150	3892710	because MKA is at the master level on these three pins.
3892710	3894970	Notice that it shares the last three pins
3894970	3896730	with the grand master key,
3896730	3899330	but it is not going to work in Charlie's lock
3899330	3902210	because MKA is not the master depth
3902210	3903850	in these first two pins.
3903850	3906710	We need the grand master key for that.
3906710	3910510	So we have a multi-level mastering system
3910510	3915970	that allows certain master keys to open only some locks,
3915970	3918010	the individual keys only open their own,
3918010	3921990	and a top-level master key that opens everything.
3922070	3925650	So that is an example of a three-level system.
3925650	3927530	This is two-level with just a master
3927530	3929370	and change keys below it.
3929370	3930910	This is what we just looked at.
3930910	3934150	So a grand master key under which we have MKA,
3934150	3936690	and there would be hypothetically an MKB as well,
3936690	3938610	and then change keys under that.
3938610	3942630	So here's Alice and Bob, and Charlie is somewhere over here.
3942830	3945030	We can have higher levels,
3945030	3947430	and this requires splitting up the pins more
3947430	3949210	in the way that we showed you,
3949210	3951930	or using secondary locking elements.
3953230	3956590	So looking at our sergeant lock again,
3956590	3959950	it had this visible shear line here,
3959950	3962190	and above it is this red pin.
3962290	3966970	A red driver pin is only used for key pin 456.
3966970	3968130	We see that this is a zero,
3968130	3970990	so we know that it's actually a master pin.
3970990	3973890	So we can start to determine what the other shear line is
3973890	3976710	in this particular sergeant lock.
3976710	3979110	And once we know what both shear lines are,
3979110	3980530	we can then start to determine
3980530	3982230	which one is going to be the master
3982230	3984730	and deducing the master key from that.
3984810	3986550	When we lift up the first two pins
3986550	3992630	and see that the master wafer on pin three is gold,
3992630	3993890	we can do the same thing
3994350	3997410	and determine that the second shear line
3997410	4001510	is going to match one of three, four, or eight,
4001510	4004490	plus the one that we know is in there already.
4005790	4009210	If we have a lock on a master system
4009210	4010710	and a key for that lock,
4010710	4014350	we can use that key to actually disassemble the lock.
4014350	4015430	And it's a whole lot easier
4015430	4017130	because we can use the key to open the door
4017630	4020410	and to then unscrew the lock from an open door.
4020410	4021630	We can also put the key in
4021630	4024790	and use it to remove the core from the lock.
4024790	4025970	And then we can look at the pins
4025970	4028250	and see what they actually say.
4029030	4031010	So to look at a demo,
4031010	4032850	in this case, we have our mastered system
4032850	4034450	and our change key here.
4034710	4038690	And the mastered pin depths that we find
4038690	4040790	are two, eight, two, four, et cetera.
4040790	4043390	And we get this for reading these pins here.
4043630	4046950	If we put that into our analysis software,
4046950	4049490	two, eight, two, four, three, five, et cetera,
4049490	4051150	we find that now the master key
4051150	4056390	can take on one of each of these two positions in the lock.
4056390	4058990	And so there's five bits of entropy, which makes sense.
4058990	4061910	There's two positions in five pins.
4061910	4064950	And that gives us 32 possible keys
4064950	4069210	that could work as the master key for this locking system.
4069450	4073350	We can, of course, create all 32 and try them.
4073350	4076330	We can create only some, 10,
4076330	4080150	and then file them down until we've tried all 32 of these.
4080150	4081610	But we can do better than that
4081610	4085230	because we have the change key code
4085230	4089690	and we know that it's a change key, two, four, five, three, one.
4089690	4092030	And so we know that whichever shear lines
4092590	4095570	that change key interacts with when it's using the lock
4095570	4097890	is not going to be the master shear lines.
4097890	4101330	Therefore, the other shear lines will be the master.
4101730	4103770	So if we take eight, two, three,
4103770	4108210	sorry, if we take a change key, two, four, five, three, one,
4108210	4112090	and we put that into our analysis software,
4112090	4116670	so known change key, two, four, five, three, one,
4116670	4120270	it's going to remove two, four, five, three, and one
4120270	4128250	from the possible depths that this master key could be.
4128250	4129250	And it's going to leave us
4129250	4131410	with the other remaining one in each pin stack,
4131410	4134950	which will be a single master key left, eight, two, three,
4134950	4135990	nine, nine.
4135990	4139210	And in fact, that is what we find as the master key
4139210	4141370	in this particular system.
4141490	4143290	So that's pretty neat.
4143630	4148170	Given just a key for a mastered lock
4148170	4150050	and access to the lock itself,
4150050	4153790	we can actually derive the master key entirely from that.
4153910	4154870	The other thing we can do
4154870	4156550	if we don't want to disassemble locks
4156550	4158790	is we can combine information
4159310	4162250	from a number of these low-level change keys
4162250	4163950	and use that to determine
4163950	4167890	what the master key could possibly be in a system.
4168110	4171310	So let's say we have a Schlage system,
4171310	4174630	so five pins and 10 depths each,
4174630	4176730	and Schlage is zero base numbering.
4177530	4179190	The master key in this system
4179190	4182150	could be any one of a hundred thousand possibilities.
4182410	4184470	If we know what one change key is,
4184470	4187630	let's say it's two, six, three, five, zero.
4189170	4192250	And we go ahead and add that as a rule.
4193950	4196950	We now have, instead of 10 to the five,
4196950	4198110	we have nine to the five.
4198110	4199930	So a little better, but not great.
4200370	4204470	What we do see though is that in a Schlage system,
4204470	4207250	remember I talked about how if we have a pin
4207250	4210170	that's one too low or a little bit too high,
4210170	4213430	the lock might still accept it for a very worn out lock.
4213430	4215090	And that would be a bad thing
4215090	4217630	for a lock to accidentally accept
4218130	4220710	a key that's not a master key as if it were.
4220870	4222550	So what Schlage does to avoid that
4222550	4224970	is uses what's called the two-step system.
4225410	4231350	Every position that any key in this system will take
4231350	4234670	in pin one is going to be even, pin two will be even,
4234670	4236490	pin three will be odd, et cetera.
4236490	4239510	So we're always skipping every other depth
4239510	4242050	to make sure that we don't have anything that's too close
4242050	4243570	and is going to create problems
4244110	4247490	with keys operating locks they're not supposed to.
4248030	4250650	So what that means when we turn on the two-step system here
4250650	4254030	is it severely limits our key space.
4254330	4258870	Now pin one must be even, so zero, two, four, six, eight,
4258870	4261850	but it can't be a two because that's what our change key is.
4261850	4263470	And we do that for the rest of the pins
4263470	4268270	and we get 1024 possibilities, so four to the power of five.
4268630	4271290	We can get another change key.
4271770	4274590	And so this is going to be two-step as well, of course.
4274790	4279790	So that's, let's say, six, four, one, three, two.
4279790	4282550	If we have another person conspiring to get in on this plan
4282550	4284030	to derive the master key.
4284030	4287290	And now we have only three possibilities each.
4287290	4292650	And if two more people sign on, so four, two, seven, nine,
4292650	4297330	six, and we've eliminated even more of the possibilities.
4297650	4303230	And finally, eight, six, three, one, eight.
4303690	4306970	And we've now got it down to only four possible master keys.
4306970	4308670	So we could absolutely just make these four
4308670	4311430	and try them out and hope that one is going to work.
4311610	4313150	Well, we know one's going to work,
4313570	4315130	but we can do better than that.
4315330	4318130	We know that pin one is a zero cut.
4318250	4320450	Pin two is a zero or an eight,
4320450	4322550	but an eight is a max violation.
4322550	4325190	It's too far from pin one, which is zero.
4325190	4327110	So we know it's zero as well.
4327450	4329010	And now if you look at pin three,
4329010	4330590	it could be a five or a nine,
4330590	4333310	but a nine now is too far from a zero,
4333310	4334770	which we know pin two is.
4334770	4339890	So in fact, the master key is going to be 00574.
4339890	4342690	And if we add this max rule of seven,
4342690	4344710	we find that that's the case.
4344750	4346990	So by combining these multiple change keys,
4346990	4348890	we've been able to derive the master key
4348890	4350750	without taking a lock apart,
4350750	4354950	just by using the information on those change keys.
4355230	4357710	From an information theory perspective,
4358110	4360370	we can calculate these conditional entropies
4360370	4362810	from the rules that we've been looking at.
4362810	4365710	And we see that we have a lot of shared information
4365710	4366590	between them.
4366590	4368730	That's because each of these rules tells us
4368730	4370050	that it's on a two-step system,
4370050	4373110	which knocks out one out of every two position
4373110	4374810	in every single pin.
4374810	4377250	So that's a lot of information that gives us,
4377250	4378310	four and a half bits,
4378310	4381870	as well as we're knocking out an additional depth
4381870	4385090	from each pin from each of these keys that we have.
4385090	4386930	And so that's these two bits here.
4386930	4388310	So between all that,
4388310	4390230	it gives us a lot of information
4390230	4392230	that we can then use to determine
4392690	4395610	what that master code actually is.
4395610	4398730	So we can actually derive the master key for a system
4398730	4402130	using just one lock and one key for that lock
4402130	4404330	without ever taking that lock apart,
4404330	4407350	using a technique called Wright's amplification.
4407350	4409430	So this has been known to locksmiths for decades.
4409630	4412590	And it was first made known in the InfoSec community
4412590	4415610	with the 2003 paper by Matt Blaze.
4415650	4418190	The general technique looks like this.
4418190	4420510	So Alice has a key for her lock.
4420510	4422210	And of course it works on her lock.
4422210	4424030	And she knows that the master key,
4424030	4425090	whatever it is,
4425090	4427670	is going to operate on different shear lines
4427670	4429290	than her key does.
4429290	4431610	So she needs to find what the other shear lines are
4431610	4432970	in her lock.
4432970	4435090	The way she can do that,
4435090	4436750	is while looking at her key,
4436750	4438870	it has a zero cut in pin three.
4438870	4440210	So that's a good place to start
4440210	4442270	because we can start varying
4443090	4445930	what that depth is just in pin three.
4446310	4448170	And if we leave everything else to say,
4448170	4448970	it's going to work.
4448970	4450750	So if the lock does not open,
4450750	4452630	it's only because of the pin three.
4452630	4453490	And if it does,
4453490	4455670	we know we found a shear line in pin three.
4456130	4458350	So cut zero is what her key is.
4458350	4460250	So it's definitely going to work.
4460250	4461950	She brings it down to a cut one.
4461950	4463150	Can we try it?
4463290	4464670	And it doesn't work.
4464670	4465630	So she pulls it out
4466210	4467470	and tries a cut two
4467470	4469390	and tries it in her lock.
4469750	4471230	And it does work.
4471290	4473390	So now Alice knows that she's actually deduced
4473390	4477190	the master shear line in pin three.
4478950	4481230	And that's because it's the other shear line
4481230	4482970	that works in her lock.
4482970	4485070	So she can take her modified key.
4485070	4485930	So Alice's key
4486570	4488950	and file it down to a two
4488950	4490930	and try it in Bob's lock.
4490930	4492330	And it also works
4492330	4494550	because Bob's lock is very close to hers
4494550	4495930	on the same system.
4495930	4497990	Bob is a two, she's a one.
4499150	4501810	Alice can then go and take her modified key.
4502130	4504410	So we take Alice's key
4505050	4509450	and we modify it from a zero down to a two.
4509510	4511610	And we can try it in Charlie's lock.
4511610	4513610	And it doesn't work, which is no surprise.
4513610	4515650	Charlie's lock is B34.
4515650	4517650	It's very far from Alice's.
4517730	4520710	And she's only found one of the master deaths.
4520710	4522870	So she's going to need to repeat this.
4523130	4526710	Her new sub master key is 31234.
4527350	4531250	She can get a new key cut that's at 01234
4531850	4536210	and try the zero cut to see if it might be a shear line.
4536210	4538030	And as it turns out, it is.
4538510	4544050	So we now have a master death in pin one and pin three.
4544050	4548990	So now we get a key cut 00234.
4549290	4550750	And we try that.
4551790	4554390	It does not work in her lock.
4554390	4556570	So she pulls it out and files it down to a one
4556570	4558870	to try the next position.
4559410	4560670	And of course it does work,
4560670	4564450	which we knew because that was what her key was originally.
4564450	4568170	So we take it down to a two and we try it.
4568270	4569890	It doesn't work.
4570550	4573870	Take it down to a three, try that in her lock.
4573870	4575030	And it does work.
4575030	4580150	So now we found the master depths for pin one, two,
4580150	4584730	and three in Alice's lock by finding the other shear lines.
4584730	4586210	We can keep going.
4586790	4587790	03234.
4587790	4592050	We're going to get a new key cut with four as the highest.
4592050	4597870	So 02304, and we'll put that in.
4597930	4600130	And she tries it and it doesn't work.
4600130	4602850	And so she files it down to a one, tries it.
4602850	4604010	It doesn't work.
4604010	4606150	Two tries, doesn't work.
4606170	4607830	Three tries.
4607830	4610470	It does work, but we sort of knew that
4610470	4613630	that was what her key was originally.
4613630	4615050	So we keep going.
4615050	4618490	A four, we try it, doesn't work.
4618530	4621270	File it down to a five, we try it and it does work.
4621270	4623870	So now Alice has found the master depth
4623870	4627950	in pins one through four using her lock.
4628370	4632590	And so now we have 0325 is our master depths.
4632590	4635810	And then we want to find out what the master is
4635810	4637050	in pin five as well.
4637050	4640110	So we put it to a zero, but that's a max violation.
4640110	4643330	So we put it to a one and we try that.
4643330	4645510	And it does not work.
4645770	4648690	You put it down to a two and it does work.
4648690	4650550	And Alice's key originally was a four.
4650550	4655770	So we now have a two as our master depth in pin five.
4655770	4660670	So our master code should be 03252.
4661030	4664630	Alice can try this in Bob's lock as a sanity check.
4669270	4673310	So 03252, and she tries it and it does work.
4673330	4674970	So that's a very good sign.
4674970	4677290	And then Charlie's lock is the real test.
4682510	4683630	03252.
4684630	4688310	And she tries that and it works in Charlie's lock as well.
4688390	4693890	So by sweeping all possible depths in each pin
4694490	4697550	within Alice's lock and seeing if it still works
4697550	4700010	on each depth, Alice is able to discover
4700010	4702430	what the other shear lines are in her lock
4702430	4704950	by modifying her currently working key
4705330	4708310	and in doing so deduce the grand master key
4708950	4713030	that is going to work in every lock on this system.
4713150	4715110	So one additional interesting lock configuration
4715110	4716610	that gives us a little bit of information
4716610	4718850	is a construction keyed system.
4718850	4721810	So let's take a look at what that actually is.
4721970	4723650	In a construction lock system,
4723650	4727930	we have instead of one master wafer, a smaller ball bearing.
4727930	4729790	And that acts as a master wafer
4729790	4731970	while the building is under construction,
4731970	4734450	being used by the construction master key.
4734450	4736270	So it goes in and it works
4736270	4738450	and that ball bearing is below the shear line.
4738450	4741870	And so it operates as a master wafer.
4741890	4745050	What happens though, when construction is done
4745050	4747970	and the user comes along with the grand master key
4747970	4752370	is it is a little bit higher by that ball bearing
4752370	4754130	than the construction master.
4754190	4756430	And it goes in and it lifts that ball bearing
4756430	4758090	above the shear line.
4758090	4760130	Well, what happens then,
4760130	4764010	the construction core is a little bit special as well.
4764390	4768770	It contains a number of holes in it
4768770	4773110	that are going to line up with the top of the pin stack
4773110	4775550	when that core starts to get turned.
4775550	4778750	That ball bearing that's now in the upper pin stack
4778750	4783170	is actually going to get dropped into one of these holes,
4783170	4786770	at which point it stays trapped there forever.
4789310	4792370	So in the lock, when the new user of the building
4792370	4795530	turns this key, this ball bearing is going to drop out
4796170	4798210	and it stays gone forever,
4798210	4800030	or it stays trapped in that hole,
4800030	4802430	at which point it's like that ball bearing
4802430	4805510	or that shear line no longer exists.
4805510	4807850	So the grand master key continues to work,
4807850	4810310	but if the construction worker ever comes back
4810310	4813050	and tries to get the construction master to work,
4813050	4815450	it's not going to, it's going to bind in this shear line
4815450	4817290	because that ball bearing is gone.
4818090	4820130	So there's two things we can do with this.
4820170	4822130	One is, if a construction worker
4822130	4823690	still has the construction master
4823690	4825410	and wants to make it work again,
4825410	4828230	all he has to do is know that there was a ball bearing
4828230	4830750	in pin one and its depth was four.
4830970	4833570	And so from six, four, nine, four, three,
4833570	4839070	we can get a key cut to two, four, nine, four, three.
4839070	4840930	So that's four higher in pin one.
4841330	4845550	And that is now going to match the new GMK shear line
4845550	4847810	and it is going to work.
4847810	4849290	The second thing that we can notice
4849290	4852890	is that for our new grand master key,
4852890	4856790	it can't be deeper than a cut six,
4856790	4860090	because if it is deeper than a cut six,
4860090	4862190	then the construction key that must have gone with it
4862190	4864050	is four less than that.
4864050	4866110	Well, four less than six is a 10 cut,
4866110	4869390	and that's not possible in this particular system,
4869390	4871090	which goes from one to 10.
4871750	4875330	So we can add that to our rule set.
4875330	4877070	And we have 10,000 possibilities
4877070	4879270	reduced to 80,000 after max.
4879390	4881430	And we add a construction key and rule
4881430	4884930	that in pin one, there was a ball bearing with thickness four
4885570	4886910	and the master construction key
4886910	4889850	also has to have a max of seven.
4890150	4892730	And it'll take the computer a few seconds to crunch that.
4892730	4894770	And we see that these bottom four positions
4894770	4896550	cannot be that master key
4896990	4899370	because there would have been no possible construction key
4899370	4901250	to make from it.
4901390	4904310	The max requirement for the construction key
4904310	4905470	and the grand master key
4905470	4907310	with a difference of four in pin one
4907950	4911470	further limits what lock or what key differs
4911470	4914690	are available to be our master key.
4915510	4918510	So that's one interesting type of system.
4918510	4921950	Another is what's called interchangeable core systems.
4922070	4924330	So if you have ever seen locks that look like this,
4924330	4926810	they have a figure eight shape around them.
4926810	4928590	That's because that figure eight shape
4928590	4929910	is actually removable.
4929910	4932670	And there's a little locking log that keeps it in place,
4932670	4934890	but with a special key called a control key,
4934890	4936630	we can remove it.
4936830	4938110	So the way that this works
4939210	4945610	is we have our IC core that looks something like this.
4945870	4948750	And when we normally operate it,
4950090	4952530	it's going to turn just the plug
4952530	4954430	and the core stays in place.
4954430	4956490	But when we use a special control key,
4956490	4958030	it's going to turn slightly
4958030	4962530	and retract this IC locking log.
4963410	4967390	The way that that works is if we look at
4970610	4973410	just the core and the IC collar,
4973410	4975310	we have two shear lines.
4975310	4979410	One is matching where the plug is,
4979410	4981510	and one is a little bit higher,
4981510	4984430	and it's going to be just for the IC collar.
4984430	4988310	So if our pins have a shear line all matching the plug,
4988310	4991110	then the plug is going to turn,
4992050	4993630	but the collar will not.
4993630	4996730	And so this is a standard unlocking of this lock.
4996730	4999410	If however, the pins extend up
4999410	5001630	and we have a shear line across these two pins,
5001630	5005970	and then the upper shear line on the IC collar,
5005970	5007850	and then these two as well,
5007850	5010610	then what happens is our interchangeable collar
5010610	5013150	gets retracted and it allows us
5013150	5015730	to remove this particular lock.
5016570	5020710	This is very interesting when we look at systems
5020710	5022290	that do not have an IC collar
5022290	5024230	that extends across all the pins.
5024230	5027730	In this case, it only uses pins three and four,
5027730	5031170	and that creates a number of interesting properties.
5031790	5034190	So one of those properties is,
5034190	5037710	let's make this into a Medeco system.
5041100	5043860	We can see this collar here.
5043960	5047800	And so we have this lower shear line with the plug
5047800	5050180	and this upper shear line for the IC collar.
5050180	5051640	And that's what we're going to look at
5051640	5054020	when we examine how these locks work
5054020	5055920	in terms of the bidding.
5058180	5060800	So what's powerful about how they work
5060800	5062600	in terms of the bidding,
5062960	5064860	in terms of getting us information,
5064860	5067260	is the way many locksmiths do it up.
5067260	5069240	And so we'll use Medeco as an example,
5069240	5070420	because as we'll see,
5070420	5073800	it creates a very restricted set of possible master keys
5073800	5077240	for IC core systems in many, many cases.
5077240	5081460	So we have our change key and we put it into the lock
5082300	5087440	and it unlocks to the regular shear line.
5087440	5090760	And so we turn the key, it unlocks regularly.
5090840	5094940	And our master key is completely different bits, of course,
5094940	5096080	completely different heights,
5096080	5099040	but it also unlocks to our regular shear line
5099040	5102740	and the interchangeable shear line binds.
5102740	5104980	So that does not actually open.
5104980	5108720	However, when we put in our core remove key,
5108720	5112200	it now binds between the core and the IC collar,
5112200	5115560	but has a shear line at the top of the IC collar.
5115800	5118020	So when we turn that, it's going to turn the IC collar
5118980	5122440	and release it and allow us to remove that IC core.
5122440	5126060	And we see now that it works on this upper shear line,
5126060	5127060	as well as, of course,
5127060	5130260	the lower ones have to work for the plug to turn as well.
5131360	5133100	What many locksmiths do
5133100	5136260	in order to avoid having to have multiple shear lines
5136260	5137180	in a pin stack,
5137180	5140600	and also avoid limitations on the mastering system,
5140600	5143600	is they will have the change key,
5143600	5145760	or sorry, the core remove key,
5145760	5149400	simply be three positions higher than the master key
5149400	5152980	in those two IC collar control pins.
5152980	5155380	It doesn't have to be done this way.
5155600	5158260	We could do something a little bit different.
5158260	5159920	We could have our core remove key,
5159920	5163200	say be something a bit lower,
5163200	5171660	and then have our core control position be at an eight cut.
5171660	5174300	So that wouldn't be ever possible to create a key that deep,
5174300	5176140	but it will remove the core.
5176700	5179460	But many locksmiths don't do that
5179460	5181080	because it requires more pins,
5181080	5185800	as well as it restricts the size of your mastering system.
5185800	5188480	And this is true, particularly for Medeco.
5189040	5191720	We see empirically about two thirds of the time
5191720	5194660	this being done with the grandmaster key
5194660	5198140	and the core remove key just being three positions different
5198520	5201760	in those two middle positions.
5202180	5205820	In Medeco, that becomes incredibly powerful actually
5206400	5211700	for deducing what the master key is going to be.
5212300	5216080	So in a 12 cut Medeco key,
5216080	5220080	so Medeco can have two cuts, double cuts in some positions
5220080	5223260	or all of them to create a high level master key.
5223260	5224600	And we'll talk a little bit more later
5224600	5227120	about what that specifically means.
5227120	5229360	But because these double cuts are so wide,
5229360	5231440	the max is very small.
5231440	5235680	It's a two between a double cut and a double cut.
5235680	5239320	And so that already, that max of two severely limits
5239320	5242180	what a Medeco system can take on.
5242180	5245880	So Medeco system would have six depths, usually six pins
5247320	5250700	and it has a max of only two.
5252040	5254600	And so that reduces us from 46,000
5254600	5260060	down to only 7,300 possible combinations.
5260060	5265240	But what the IC core does is significantly more restrictive
5265960	5271460	because if we want to make the IC control key three higher
5271460	5273500	than the master key,
5273500	5276220	that means that the master key can't be a one, two or three
5276720	5279060	in pins three and four.
5279480	5282400	And so we'll add that rule there as well.
5282420	5287160	And the master control key has to adhere to max in addition.
5287160	5289900	So we'll see the effect that that has when we add this rule
5290280	5292300	and it'll take a second to compute.
5292840	5294700	And so what we see is,
5294700	5296880	these three positions cannot be held
5296880	5299080	by pins three or four in the master system.
5299080	5302060	So the master is forced down to four, five and six.
5302160	5304740	In addition, pin two can't be a one
5304740	5306860	because that's a max violation.
5306860	5308580	Master must be four or lower.
5308580	5311740	So it can't go up three, the max is two.
5312180	5316520	Pins six or pin two and pin five can't be a six depth
5316520	5318240	because that would be a max violation
5318240	5321340	for the interchangeable core control key.
5321340	5325400	If our grand master key is the deepest, it's a six cut.
5325400	5328700	That means our IC core is three higher or a three cut.
5328700	5330900	And we can't have a six beside a three
5330900	5334080	in our interchangeable core master key.
5334080	5337360	So that significantly reduces the key space available
5337360	5340120	in these types of medical systems.
5340260	5343520	Right now, it's down to 784.
5343640	5345820	It gets even more restricted than that
5345820	5347600	for the following reason.
5348080	5349340	It's generally a good idea
5349340	5352780	to have our master key use at least one pin
5352780	5354580	in the highest position.
5354580	5357480	And that way we can make sure that none of our change keys
5357480	5360800	will be able to be filed down into a master key.
5360800	5362320	We could have one a bit lower,
5362320	5364020	but that's then gonna restrict how large
5364020	5367640	our master system can grow while adhering to that rule.
5367740	5369980	If we look at the limitations imposed
5369980	5371840	by this particular system,
5371840	5373620	we'll see that there's only two places
5374000	5379320	that that one cut can go, pin one or pin six.
5379340	5384900	So if we add a requirement that one pin must be high cut,
5384900	5387460	and it'll take a minute to compute that as well,
5387460	5389180	we're gonna see that we're now down
5389180	5393160	to 159 possible master keys.
5393160	5395700	That is a significant limitation,
5395700	5398540	and that's given very little information
5398540	5401540	about our Medeco system.
5401540	5406440	It's given that we have a large facility,
5406440	5408040	so we can assume that they were planning
5408040	5411920	for potentially needing to expand to a master key
5411920	5414160	that's double cut in all positions.
5414300	5417040	And we see at least one interchangeable cord
5417040	5419260	somewhere on that system.
5419420	5420720	And that's it.
5421220	5423240	Knowing those two things,
5423240	5426240	we can infer that with about a two thirds probability,
5426240	5428180	our master key is going to be limited
5428180	5430660	to one of these 159.
5430660	5432560	It gets even less than that,
5432560	5436840	because it usually makes sense to put
5436840	5439600	your one depth in pin one,
5439600	5441340	and that way the key is nice and sturdy,
5441340	5442400	it's not gonna break.
5442400	5444720	We don't wanna put a very deep cut in pin one,
5444720	5448260	or that grand master key is liable to break off.
5448520	5452360	And so when we add that particular requirement,
5453500	5457780	it then is only 84 differs that follow through in pin one,
5457780	5461560	and we can see max restricts this incredibly tightly.
5461580	5465480	So there's the 84 possible situations that could exist
5466040	5469280	if locksmiths do what a lot of them do
5469280	5471000	when designing medical systems,
5471000	5472660	which is follow these constraints.
5472660	5475320	It limits the key space significantly.
5475320	5476620	Now they don't need to.
5476620	5480040	They don't need to use a pin at the highest one.
5480040	5482160	They could put it in pin six instead.
5482160	5484360	And of course they could do up their IC system
5484360	5487240	so that it doesn't require their master key to be low
5487240	5488980	in pins three and four.
5489240	5491660	But most locksmiths don't really think about
5491660	5494320	the key space reduction that they are creating
5494320	5496900	in terms of brute forcing this master key
5496900	5499180	when they're designing that system.
5499180	5502900	And so that's why this is something that's so common to see.
5503840	5505980	A couple other things that we can note
5505980	5507620	about this particular system
5507620	5512780	is that if we have a master key or even a change key,
5512780	5514400	so just this change key,
5514400	5517920	now all we need to do is vary and do right simplification
5517920	5520760	on these two middle pins
5520760	5523320	to determine what the core remove key is.
5524180	5526660	Pin three is a five.
5526660	5531140	And so if we add three to it, it goes to four, three, two.
5531140	5535100	And now we've hit the IC control line.
5535100	5539820	And then pin four, we can vary in either direction
5539820	5543300	to try to hit the IC control line for it as well.
5543300	5545200	So we only actually have to vary one pin
5545200	5550420	to go from our change key to an operable control key.
5550420	5552340	It's just going to be for this lock.
5552340	5555240	But what it lets us do is remove the IC core
5555240	5556640	and then we can take it apart
5556640	5558080	and disassembly of the lock
5558080	5562460	then will let us derive the master key from that.
5563140	5566420	Other types of locks have a similar situation.
5567160	5571940	So Schlage and Yale control keys
5571940	5574120	use a slightly different technology.
5574120	5576740	They have a special seventh pin in the back
5576740	5578800	where if the key is a bit longer,
5578800	5579740	in the case of Schlage,
5579740	5582380	it has this special nose on it sticking out.
5582380	5584940	It's going to actuate that seventh pin,
5584940	5587680	which will pull in this little retaining lug.
5587680	5590400	And when it does that, you can then remove the core.
5590520	5594440	So if you have an operable key for this particular lock,
5594440	5596540	all you need to do is copy that key
5596540	5598360	onto a slightly longer blank
5598360	5601360	that contains this little nose on it.
5601360	5603580	And you can use that key to remove the core,
5603580	5605960	at which point you can then disassemble it
5605960	5607980	and deduce the master key.
5607980	5610420	Let's look at some right-samplification attacks
5610420	5613340	in some special secondary locking systems.
5613360	5614780	So we'll start with Multilock,
5614780	5617720	which has got a nice pin-in-pin system
5617720	5619920	that we can attack using all the other techniques
5619920	5621520	that we've talked about in this talk.
5621560	5625580	But it also has side pins that are used for mastering.
5625780	5627160	And effectively, these side pins
5627160	5629160	are going to fit into these side dimples
5629160	5630620	drilled into the key.
5630900	5633200	And in this case, we have a correct key.
5633200	5634740	The side dimples are all there,
5634740	5637480	so the side pins are able to fit into it.
5637480	5640780	And they don't impede rotation of the plug.
5640780	5642720	When an incorrect key is inserted,
5642720	5644200	there are no dimples,
5644200	5646720	and so the side pins are forced out into the plug.
5646720	5648100	And that's actually going to stop us
5648100	5649860	from rotating that key.
5650000	5651820	This is used for mastering.
5651900	5653160	So we have, in this case,
5653240	5656280	a key that's got four of the five holes drilled.
5656280	5658120	This is its correct lock.
5658120	5660420	So these four pins are present,
5660420	5662200	and the key is able to turn.
5662200	5664820	For a lock that is not supposed to be able to open,
5664820	5667160	there'll be a pin populated here as well.
5667160	5669580	And this lack of a hole prevents that pin
5669580	5672760	from moving out of the housing,
5672760	5675480	and it will stop the key from turning.
5675960	5679160	This is, of course, a trivial thing to amplify.
5679160	5681100	We just drill an additional hole,
5681100	5684280	and now all of the mastering that's done
5684280	5686460	with these side pins has been defeated.
5686460	5687840	This key will work in anything
5687840	5689320	regardless of the side pins.
5689320	5691240	And then we just have to use the other techniques
5691240	5695360	to right-samplify the top cuts as well.
5695360	5699300	So that's a very simple right-samplification attack.
5699300	5700860	You can do something very, very similar
5700860	5703700	by filing metal off of sectional keyways.
5703700	5706700	So sometimes mastering is done by having a keyway
5706700	5709820	that will not enter the keyway of some other lock
5709820	5712520	that's not supposed to open, or a key that won't.
5712520	5714700	But then we have a master blank
5714700	5716720	that's going to enter both of these locks
5716720	5719180	because it's got metal missing from it.
5719400	5721940	And so all we need to do to right-samplify there
5721940	5724060	is take our key that works on
5724060	5727120	one of the low-level keyways
5727120	5731140	and just copy that bidding code onto our all section blank
5731140	5734620	at which point it's going to then enter all of these locks
5734620	5737300	and we'll be able to open them as well.
5737560	5741860	With Medeco Biaxial, we see something quite similar.
5742500	5746880	So Medeco Biaxial has potential for double cuts.
5747360	5751200	And what we can have is in a particular pin position,
5751200	5754380	the pin has got this beveled edge to it,
5754380	5756440	so it goes to one side or another.
5756440	5759640	It can bevel towards the shoulder of the key and be a forecut
5759640	5763080	or towards the tip of the key and be an aft cut.
5763300	5766300	In a master key that's got double cuts,
5766300	5768100	regardless of whether the lock that we're in
5768100	5771000	has a forepin or an aft pin,
5771000	5775780	it's going to interact with that key properly and open it up.
5776060	5778540	And Medeco uses this for mastering as well.
5778540	5781220	So a lower level key or a lower level master
5781730	5784140	might be missing one of these cuts.
5784480	5789740	We can very easily right-samplify that if we have some mid-level master.
5789740	5791120	So here's MKA.
5791120	5795400	It's got five single cuts and a double cut in pin six.
5795400	5799040	And then we have any old key on the B system.
5799360	5803200	And so what we see, for instance, is this pin six,
5803200	5805540	that is a double cut.
5805540	5809520	Pin five, we have an aft and it's a right cut.
5809960	5813400	In this key on the B system, in pin five,
5813400	5816500	we have a fore and it's a left cut.
5816600	5820860	So what we can do is take a left cut and add it to the fore position
5821460	5824740	on our MKA at these same master depths.
5824740	5828560	And that's actually going to amplify this key into a full GMK
5829100	5831480	that's going to work on all locks,
5831480	5834560	even if it has an aft pin in that position.
5834560	5836560	Sorry, a fore pin in that position.
5836640	5838920	And so we do that for all other positions
5838920	5844140	where the fore-aft of our B key differs from our MKA.
5844140	5850520	And we've effectively now amplified the power of our MKA key to be a full GMK
5851120	5856860	using the information of these angles that we see on this key here.
5857000	5861220	So now that we understand how the basics of Medico Biaxial works,
5861220	5865980	we can add a few tools to our arsenal to decode non-mastered Medico systems.
5866300	5868520	So if we start with a six-pin Medico system,
5868520	5872740	if it's non-mastered, it's going to follow Medico's code books.
5873000	5875260	And so the depths are going to follow those code books.
5875260	5877260	Give the computer a second to compute.
5877580	5881700	And what we see immediately is that pin one, two, five, and six
5881700	5884940	will never be a one in a non-mastered system,
5884940	5887440	at least for this older version of code books
5887440	5889260	that we're going to be looking at today,
5889260	5894800	which is true for just about every Medico system created before 2008.
5895320	5899520	So immediately we see that if we wanted to impression this lock,
5899520	5901480	and you can impression Medico locks,
5901480	5904460	we'd start with two, two, one, one, two, two.
5904460	5906600	And as we went through impressioning this,
5906600	5908940	we would end up skipping a whole bunch,
5908940	5912840	increasingly so as we get closer and closer to the final key.
5913320	5915360	So the code books helps with that.
5915360	5917720	And of course, if we have a photo that's close
5917720	5921640	but isn't quite enough to get the exact fitting,
5921640	5923800	combining that with code books is usually enough
5923800	5927200	to determine what the depths are.
5927660	5933260	Medico also has angles though, and the angles also have code books.
5933600	5936220	So if we add that the code books must follow
5936220	5938940	Medico's non-mastered angle books,
5938940	5942720	we see that right away, some of them are given already.
5942720	5946720	So if we happen to have a pin three in the aft position,
5946720	5948640	it's going to be a right cut.
5949740	5952680	This can be useful now that we have this,
5952680	5959000	if we know whether a particular lock is a four or an aft in each position.
5959160	5960740	How do we tell that?
5960740	5965020	Well, here's a little device that we designed that does exactly that.
5965020	5968280	So here's one version where you take a blank,
5968280	5971280	you cut a little notch into the six aft position,
5971840	5975220	and then you stick it into the lock and it will clunk, clunk, clunk
5975220	5978400	all the way along as each pin fits into it.
5978560	5983280	Based on how far it clunks, if it aligns with these lines for the fours or not,
5983280	5985400	you can tell which is for an aft.
5985400	5988920	Here's another design that can be cut down from any key, not just a blank.
5988920	5993920	We have a little tip at the end with a notch in it, again, in the six aft position.
5993920	5999700	And we can clunk, clunk, clunk it along and make some marker marks on the key,
5999700	6003960	and then decode it afterwards and determine whether this means
6003960	6006770	for an aft in each of these positions.
6008080	6013340	So for instance, if we know that we have a lock in front of us,
6013340	6019040	and we've decoded the for and aft, and if we find it to be, let's say, aft,
6019040	6027840	for, aft, for, for, aft, in that particular case, what actually happens is
6028250	6033940	we completely get the angle sidebar code figured out for us.
6033960	6037640	I'm just going to remove the depths because they kill the compute time for now.
6039140	6043100	If we aren't so lucky, this is the only case of fors and afts where that happens.
6043100	6046120	Let's say we get a for here and an aft there.
6046120	6048120	So now we have a number of possibilities.
6048360	6053260	We can help to decode what those angles are based on an innovation that
6053780	6057780	Mark Webber Tobias and Tobias Bluzmanis came out with a number of years ago,
6057780	6062740	which is Medeco bump keys, which takes advantage of flaws in their angle codebooks.
6063960	6066360	But these bump keys, there's a set of four of them.
6066360	6069980	And if we can get one of them to work once on this lock,
6069980	6074380	then we can use that to create a key that will work very easily forevermore
6076280	6079260	by identifying, well, one of these bump keys worked.
6080620	6086160	And that's going to go ahead and figure out what those remaining unknown angles are
6086160	6090520	based on the fact that that particular version of the bump key happened to work.
6091080	6094080	If, say, even that isn't enough for us.
6094080	6100840	So in this case, pin six, it could be a Q, which is a right cut or a B, which is a center cut.
6101180	6104560	Right is 20 degree angle and center is zero.
6104560	6108960	And another thing that Tobias has found out is that, like I mentioned before,
6108960	6113220	with some blocks being able to accept half height cuts in the heights,
6113220	6115260	it'll accept half angle cuts.
6115260	6119800	So I can make a key at 10 degrees, halfway between center and right.
6119800	6122980	And that will actually operate this lock.
6123140	6128900	So a number of techniques that we can use to decode Medeco systems.
6129080	6133760	So we've covered a lot of techniques for how to use various sources of information
6133760	6136020	to come down to a bidding code.
6136020	6140760	So a number that represents what the key should be cut to, what depth that should be.
6140760	6144460	But how do we take that and turn that into an actual usable key?
6144520	6147940	Well, we could start with the key blank and file it down ourselves manually.
6147940	6149780	That's a perfectly valid way of doing it.
6149800	6155560	We can also use a machine if we happen to own a key machine, but many of us don't.
6155820	6158320	And we could also try using a locksmith.
6158320	6162000	So the general procedure for that is to identify the blank.
6162000	6163540	It's often printed right on it.
6163540	6167220	So WR5 for this Weiser or Y1 for this Yale.
6167840	6171000	Determine the bidding code that you want using the techniques we talked about
6171000	6174860	and go to a locksmith, so not a hardware store or a 7-Eleven,
6174860	6176980	and ask if they can cut a key by code.
6176980	6181380	If they say yes, give them the blank name and the code, such as a Schlage SC1
6181380	6188420	with bidding code 04285, and they will usually cut it for you for the duplicating rate.
6188500	6192320	If they happen to say that key is restricted, I can't cut you that.
6192320	6196060	Check out the talk that myself and my brother Bobby gave last year entitled
6196060	6200080	Duplicating Restricted Mechanical Keys at DEF CON 27.
6201100	6206580	We'll talk a little bit about defenses, which is a huge field and could be a talk on its own.
6206580	6212340	But the most salient points there is avoid very large mastering systems.
6212340	6215900	If the only reason you have building A and building B mastered together
6215900	6219860	is so that the superintendent can carry one GMK instead of two,
6219860	6223840	that's really not worth the added risk for that added convenience.
6224060	6228700	You also don't want to master high security and low security facilities on one system.
6228700	6235300	So I've seen cases where a nuclear facility was mastered together with public washrooms.
6235300	6238940	The access control of those public washrooms is significantly less,
6238940	6243440	and information from those locks can be used to infiltrate the nuclear facility.
6243440	6247480	That's absolutely something that you want to be separating in your mastering system.
6247820	6251240	A missing lock is as bad as a missing GMK.
6251240	6253920	So if a lock goes missing and it can't be accounted for,
6253920	6256200	you need to consider the possibility that someone has
6256820	6259520	disassembled and decoded it and made the key.
6259700	6262160	You can consider alternatives to the two-step system
6262160	6265860	and other various systems that we've talked about that can be exploited.
6266440	6268020	Specific to those attacks,
6268020	6271700	this is somewhat dependent on whether it's actually in your threat model.
6271700	6275780	This is not in the threat model for the majority of applications.
6275780	6279680	You can use a restricted keying system that won't stop a determined attacker,
6280160	6283020	but it can slow them down and it can drive the cost up
6283020	6289960	and potentially deter them from carrying out the attack in certain cases.
6289960	6294540	Your facility ultimately should be secure even if an attacker has the GMK.
6294540	6298220	So you want to use secondary security systems,
6298220	6302660	such as guards and alarms and a proper detection and response mechanism.
6303000	6306520	All that a mechanical lock does is keep honest people honest,
6306520	6308340	and there's loads of ways past it,
6308340	6315980	both keying and forcible entry and all sorts of other methods that DEFCON is all about.
6316540	6320540	And use interchangeable core or electronic components or something
6320540	6325100	to make re-keying easier if that becomes necessary.
6325100	6329320	You want to have a response plan in place for if the unthinkable happens
6329320	6335820	and your GMK or a key to a particular important area gets compromised.
6336820	6339680	If you see something like this, so a lock goes missing
6339680	6344040	and you're not sure how that happened, you want to take that seriously.
6344040	6347620	And for heaven's sakes, don't do this.
6347940	6352520	So thank you very much. I encourage you to go try it.
6352520	6355160	Here are all the links to the applications that I'm releasing.
6355160	6358260	Try them out for yourself and see what you can discover with them.
6358260	6362360	I'd like to extend an enormous thank you to Josh, Karen, Jenny and Bobby
6362360	6364740	for their help in getting this talk prepared.
6364740	6367360	In particular to Jenny, she absolutely saved the day
6367360	6370360	with editing this video at the last minute.
6370420	6372560	And I'd be happy to take your questions.
6372560	6373740	Thank you very much.
