My name is Justin Engler. I'm a senior security engineer at ISEC partners. This is Paul Vines. He's a security engineering intern for us for the summer. We both work for ISEC partners and we are here to talk about automated pin cracking. We will talk about R2B2 which you can see here moving on the stage. You won't see C3BO and we will talk about why. So quickly we're going to go over what your approach would be if you need to brute force something like this. We're going to talk about the robots we built to do it in specific and then we're going to talk about countermeasures and how the robots stack up against countermeasures. So everyone here know what a pin is? Anyone never heard of a pin? Okay, good. So if you need to get into something that has pin protection, so bypass whatever the pin is blocking you from doing, you have a few options. One, you could do a software approach where maybe you jailbreak the device, maybe you have a jailbroken device and you hack the app so it removes the protection. This would be your best plan. It's usually quicker, it's usually more direct route to do what you want to do. If for some reason you can't do the software approach, your next best option would be a hardware attack. Our example here is keyboard emulation. Darren Kitchen at hat five has a neat video where he plugs in a USB rubber ducky into an Android device and does something similar to what we're doing here. So that would be great. Other hardware attacks are also a good second choice so maybe you can pull the RAM and read it or things like that. The last thing you should try to do if you have no other options is to brute force the UI itself which is what we're doing. I'm a security consultant so I often work on engagements that have a set time period and I don't have time to sit and brute force out of pen it would take too long when I'm supposed to be doing other things. So the next option is to get an intern to do the button pushing for you. So you could have an intern just sit and push the buttons but sometimes interns do things wrong and we don't really have any way to guarantee that the intern gets it right. My boss Andrew really loves his coffee and if I take the intern to push buttons all the time he won't be able to get any coffee and I don't want to get fired for that. So a much better plan is to hire an intern and have him help you build the robot that will push the buttons and then he'll still have time for coffee later. So in order to build a robot to crack a pin you have a few things you need to be able to do. Somehow you need to be able to actuate the interface so you're going to need to make the device think that the button was pushed. You're going to have to keep track of where you are on the list of all the pins and you need to usually figure out whether you are successful or not. There are some cases where you just need the device open and you don't care what the pin was. So in that case you could do something even simpler than what we're doing. Just have it run through them all and keep going after that by the time you come back after you went away for the weekend or whatever then the device should still be unlocked because somebody's still been hitting the screen the whole time and you're in but you don't know what the actual pin was. We are doing a little better than that. So this thing is a Delta robot. That's the general class of robot that this is. Delta robots were originally for industrial work in the 80s are still used for that stuff today. There's a few rotational motors that through some math that we'll talk about later can turn rotational movement into X, Y and Z movement. It's also very fast but it doesn't have a lot of torque or a lot of lifting power but we don't care about those things. So this seemed like a good choice for us. And I said it's fairly simple to do the math but there are a lot of math involved. I set Kazone by NCC group which is a company in the UK so math are plural so that's why there's a bunch of them. But the good news for us is that we like open source and open projects and so not only do you guys not need to do the math but we actually didn't need to do the math either. We found a guy named Dan Royer had done a lot of this work for us in setting up a Delta robot that did most of what we wanted to do. He already had source code that would do the inverse kinematics which is the fancy roboticist term for turn what the robot motors do into the X, Y and Z motion. He also had 3D printed schematics and everything. He actually sells it as a kit. This one you're seeing here is built out of mostly his kit parts. The one that Paul built which is in the hotel room right now is actually completely built by us. We didn't want to be held hostage to them not selling it anymore. So we did build it from scratch from all other parts and it all works fine. So essentially what we've got is an Arduino, we've got the physical parts of the robot and we've got a computer and the computer is talking over serial to the Arduino and the Arduino knows how to move the robot around. So the original kit was missing a few things. It was just kind of an empty head. He didn't know what it was going to be used for. So we added a stylus to the tip and just adding a stylus makes it not work. You have to ground the stylus because the capacitive touch screen thinks that's what it touches is a changing capacitance. So we added that. We added a camera. So that helps us for configuration. We won't have time to show you guys that now but we can show it to you later. It also set up to recognize when the screen changes because that means that we successfully unlocked it. We are around moving at five presses per second but you'll notice there's a delay after each of the five. Most of the numbers I'm going to talk about assume that you can do one full pin so that's four or five presses in a second. There's some camera code that we can maybe modify to get rid of that delay in the middle. So all that stuff is done. We need to make some Python that makes it all work. So we have a serial port control in Python. Python makes that really easy. We used OpenCV to analyze the stuff on the camera and we have an easy interface for calibrating where all the buttons are. We originally tried to detect the buttons. It was too hard. Don't believe computer vision people when they tell you that they can just recognize anything anywhere. It's not true. And lastly it can detect you tell it where on the screen you want to say if this part changes then we definitely unlocked and then we watch for that to change and when it happens then we know that we were done. So we talked a minute ago about how you need to ground the stylus to make it actually detects a touch. So at some point when I was working on this I realized why don't we just hook up a bunch of wires to the screen on the buttons and then ground them selectively and then we don't need any moving parts. So you use a microcontroller connected to relays to trigger those in place that will then cause the touches to appear on the screen. And you don't need any moving parts. You don't need this complicated calibration. All you need to do is fire off the Python which fires the relays and it all works. Except it doesn't work. So the problem in my particular case the relays that I selected have enough capacitance by themselves that once you hook it up even if the relays open the screen sees it as a touch. I don't know anything about electronics. Does anyone here have an idea of what's wrong and how to fix it? Raise your hands. Yes there's all kinds of things we can try and I don't know what any of them are but if you let me know what they are we can try them. If we can get it fixed at DEF CON I will give someone a full R2B2 if we have C3BO working by the end of the time. So talking generally about brute forcing stuff. We don't want to just naively go through and start with 0, 0, 0, 0 and then go 0, 0, 0, 1. We got it. We cracked the pin. So what's the pin? We're looking for it. 7777? 1997? That was right before we pressed 7777. So what happens is we've got it actually multi-threaded so it's starting the next run before it's analyzed the picture to see if it's changed or not. So we can narrow it down but sometimes we're off by one. We actually saved the list of all the times that we think we got it so if we did get it wrong then you can go back and try the next few up. We almost got it. All right.  There was a guy named Nick Barry that did an analysis based on leaked password files to try to figure out which pins would be the most common. He had some really cool data visualizations but he wouldn't release his actual raw data. But what he did wasn't complicated so we did the same thing and in addition we pulled in more password files than he originally did to make sure we had more data. So we have the password list for that. It's included in the stuff we're going to submit to you guys so you can do this too. There's also a guy named Daniel Amitay. His was a little different. He wrote an app for the IOS that goes through and let someone add an extra lock screen to their phone and then he collected the pins that people were using for that and did aggregate statistics about those. So we asked him for his data and he graciously provided it. It turns out that it's a little different than the data that's just from password list because those are from people that are usually sitting at a computer. And so those guys don't do things as much where the position of the buttons matters. So 2580 is much more common in Dan's list than in the other list because it's just straight down the screen. Also corners, you know, anything else that makes a pattern or uses the letters. So another one that's popular is the one that spells out love. So it's interesting to look at those things. So the two datasets, the one that we synthesized and when I say we, I mean Paul, and it took him like a half an hour to write the code so I don't think we're really giving away any special secrets or anything. And we combined it with Daniel's list and the list that you'll have is the synthesis of the two. So this is what you need to know about pin frequency. So on the bottom we have the number of pins that you've guessed. On the top you have the percentage of phones that you've unlocked by the time you've guessed that many. So if you want to be more likely than not you have solved the problem and unlocked the phone, 670 pins is all you need out of 10,000. Assuming that the person that you are trying to crack is not some weird DEF CON person and actually follows the statistics. If you want an 80% chance that you've unlocked it, it's about 3700 which is still much less than the 8000 you would expect at 80%. Obviously R2B2 is also able to, because we're just a robot, we can push physical buttons as well as touch screen buttons. I don't have a demo for you because I couldn't find a good one. I almost brought an old tape calculator and had it push buttons but I couldn't fit it in my bag. We also think we might be able to do things that are completely mechanical. Like there's some padlocks that have buttons and things like that. If you've noticed all the doors around here seem to have codes on them. Sounds like everybody knows what it is already. So now that you know how to brute force something, how do we go the other direction and defeat brute forcing? So one thing you could do is have a delay after bad guesses. On Android, if all you've done is set a pin and you haven't set any other settings, all you've done is set a pin, then it makes you, every five bad guesses you do, you have to wait for 30 seconds. That 30 seconds is constant. So the next five you do, you have to wait another 30 seconds. That means that if you want to go through all 10,000, it's going to take you about 20 hours, which is not that bad for something that's important. And like we just talked about with the other ones, if you wanted to be more likely than not done, it's only going to take you 80 minutes. If you want 80% likely to be done, that's only seven hours. iOS is lock screen, handles things a little bit differently. So on iOS, you get your first five for free and after that it starts to scale up how long you have to wait between each guess. And it goes up crazy fast. If you take that 20 hours that we had for Android and you do the same thing here and you wait the required weights, you only have like a 20% success rate. So that's not 20% of the pins because that would be a lot more. That's 20% success rate. Another thing that's important to note here about Android is that there are many other settings you can set that will change this behavior. If you have a Google account set and you have two-factor authentication enabled on that, then after something like 20 guesses, you'll be prompted for your Google username and password instead of your pin. So that's good. If you're using your device for corporate email, hopefully your exchange, people have set up the wipe after 10 tries setting. So it's not like all hope is lost on Android. There's still a lot you can do. It's just a default. It's not as good as it could be. I'm mostly an app sec. So what I was more interested in is applications. We get a lot of clients that have a pin on their application separate from the lock screen. And it's that kind of situation where we most often find there's no brute force protection at all. And when we have an engagement and I tell them that there's no brute force protection, they say, well, did you break it? No, I didn't have time. And now we have the robot, so now we don't have that problem. We very briefly, because the robot was only stable, stably working as of a day or two ago, and even then we've still been tweaking code today. We only had time to test out a few apps from the app store. Things that are likely to have this are things like a financial apps habit, some antivirus apps habit, some things that are like store your secret pictures and notes habit. So out of 13 that we had time to try, four of them had something that was effective enough that we couldn't break it. The other nine had nothing that would really stop us. This is an interesting table. So this tells you if you can do one pin per second and there's no other brute force protections, how long it would take you to break something for various types of pins or passwords. And the other side shows you what it would be like on the Android style where it makes you wait 30 seconds every five bad guesses. So as you can see, it's not that hard if you do a four character password that includes all the printable ASCII characters, it's going to take me two and a half years, even if there's no brute force protection. And that's decent. If you can go up to seven, we're up to 20,000 centuries. My robot would be broken by then, I promise. So the last slide, this is my advice to developers of OSs or apps or whatever. You need to put some kind of brute force protection in place. This is my advice for users when you have to use an app that doesn't have any brute force protection in place, you need to pick a longer pin or one with better characters. This is not rocket science and this is something that the security community has known about forever, but at the same time, we still see apps with no protection. So I guess we have to talk about it some more. And maybe with this robot, we will finally get some traction on getting those things changed. I second NCC, thank you very much for giving us some money to build this robot. Dan Royer who did the original design that we modified, Daniel Amitay for giving us some data, and David Nichols who helped us with some app analysis. This is our contact information. That's my Twitter handle. Your CDs already have the kind of preliminary code that was working as of when they were due a couple months ago. It will run and it will move the robot. There's no camera code in there yet. The, I will tweet at this when we have the rest of it posted which will be sometime next week. And I think we can probably get it on the ISAC webpage. That's it. Thanks, guys. We have time for questions maybe? A couple? Yes, go. How many did we successfully break? How many guesses did it take? We're looking. We'll look. Next question. Paul is from Seattle. I am from close to Seattle. Yes. How much is the robot? Excellent question. If you have a 3D printer and you print the stuff yourself, it's less than 50 bucks for everything else. If you need to buy the 3D printed parts depending on what the pricing is from where you get it which seems to vary a lot, you're going to be probably just under 200 bucks, maybe 150. So not bad.


So, what we are going to do is we are going to quickly look at the next lecture, but I want to sort of discuss this lecture because now that you know about member functions, all that I am trying to say here is that there are two special member functions that are associated with every class or struct. These are called the constructor member function and the destructor member function. So, what is a constructor member function? Every time so think about that V3 class that we just talked about. So, every time you allocate an object of that V3 class, a constructor member function is immediately invoked. So, the moment an object of a class is allocated, the first thing that happens is the constructor member function gets invoked and then you have access to it and you want to do whatever you want to do with it. So, because this constructor member function gets invoked immediately after allocation of the object, therefore it is a very convenient way to initialize the various data members inside the allocated object because this is going to get called immediately after allocation before you can do anything else. And if you just remember that that you know constructor member functions, a special member functions which are invoked on the parent object immediately after the parent object is created, the rest of it is just like any other member function. For example, you know this is the class V3 and here I am trying to write a constructor member function of the class V3. The funny thing about this is that the name of this constructor member function is the same as the name of the class. So, this is what C++ requires that all constructor functions of a class must have the same name as the class and they do not have any return type. So, these are the two sort of quirky things there that the name of the member function is the same as the name of the class if it is a constructor member function and it does not have any return type. It can take parameters just like any other member function, it can do whatever any other member function does. So, typically we do initialization, so for example here I am reading in three values and I am setting the x, y and z values to those. Here is another constructor member function which is just setting the x, y and z values to 0.0 and note that both these constructor functions both have the same name, both do not have any return type and both of them are residing within the same class definition. And C++ actually allows you to do this. You can have multiple constructor functions within the same class. The only thing that you have to ensure is that this list of parameters must have different types for each of the different constructor member functions. What it means is that here the three parameters are double, double, double. I cannot declare another constructor function whose three parameters are also double, double. I can declare another constructor function which does not take any parameter like I have done here. I can declare another constructor function which takes just one double parameter or four double parameters or two double parameters but I cannot declare another constructor function which takes 3 double parameters. So, you can define as many constructor functions as you want, but they must differ on the types of the parameters, the type list of parameters. And now if there are multiple constructor functions, will there be a confusion about which one to invoke immediately after allocating an object? So, that is not the case because if you are allocating an object like this, let us say myobj1 of type b3, then I have not provided any parameters over here for the constructor function. So, this constructor function will get invoked, constructor function that does not require any parameters. But if I say you know myobj2 is new v3 something here. So, I am saying allocate a new object of type v3 and pass these as parameters to that constructor function. So, now this constructor function will get invoked because this is the only constructor function of v3 that can accept 3 double valued parameters. So, here is another example which sort of shows this more clearly. So, here is the same class v3, there are these 2 constructor functions, same name, but type list of parameters are different. This takes 3 double arguments, this takes no argument and here is the main function. So, in the main function I have declared an object a of type v3 and I have specified some parameters for the constructor function. So, it is obvious which one is going to get invoked, this one is going to get invoked because this does not accept parameters, this accept 3 double parameters and here I have provided 3 double parameters for the constructor function. So, note also the public declaration here, the constructor functions have been declared public because they are going to be invoked from the main function after the objects have been allocated. So, for any member function to be invoked from the main function, it has to be public. The moment you declare a function as private, it can be accessed only within that structure, member functions, it cannot be accessed from outside. So, in this case I am allocating object b of type v3, but no parameters have been passed. So, this constructor function is going to get invoked. Here I am dynamically allocating an object of type v3 passing these 3 as parameters, so that constructor function gets invoked. So, it does not matter whether you are doing dynamic allocation or static allocation, does not matter whether it is in the stack or it is in the heap. Whenever an object of a particular class is created, the first thing that happens is the constructor function gets invoked, which constructor function depends on what parameters you are passing when you are creating an object of that class. These are the parameters to the constructor function. So, if you are passing 3 double parameters, this will get invoked, if you are passing that. So, here I am just saying allocate an object of type v3, no parameters passed, so that constructor will get invoked. So, these are special member functions, they are just like any other member functions except that they are called immediately after the object gets created. And you cannot call them later on, you cannot call them explicitly later on in most circumstances, there are certain circumstances where we can call them, we will study that in the next class. But the way to think of these is that these are going to get invoked immediately after the object is created. And therefore, you can do all kinds of initialization with it after the object is created. And just like constructor functions, there are things called destructor functions. So, whenever an object of a particular class is being deallocated, memory for that is being freed up, the destructor function will be called immediately before freeing it up. So, constructor is called immediately after the object is allocated, a destructor is called immediately before the object is freed up. So, it is a convenient way to do some bookkeeping, cleaning up and similar tasks. And the thing to remember is that C++ mandates that a destructor function's name must be the same as the name of the class with a tilde before it. So, constructor function is the same as the name of the class, destructor function is tilde name of the class. And a destructor function does not take any parameters. And then within that you can do whatever you want, you can access other member functions, you can access data members, whatever. Remember the destructor is being called just before the object is deallocated. So, when the destructor is called, you still have access to everything in the object. After the destructor call after the destructor function returns, then the object is going to get deallocated. So, within the destructor function, you can access everything within the object. But that is sort of the last time you see that object. After that, that object will be gone. So, and of course, you know, because you cannot put different kinds of parameters here. So, therefore, you cannot have multiple destructor functions because then there would be confusion about which destructor function you are trying to invoke. They do not accept parameters, they all have the same name. So, here is a simple example. So, this class V3 has some constructors, has some destructors. So, here I am allocating an object A of type V3 on the stack. This is a local variable. And I am passing these parameters to the constructor. So, the constructor function for V3 will get invoked here and it will initialize the data members x, y, z of A to these values. Now, within this pair of braces here, I have defined another object V of type V3. So, once again the moment this object gets created, again the constructor function is invoked. But of course, this time there are no parameters to pass to the constructor. So, the constructor which does not require any parameters will be invoked. Then I am doing some operations here on A and B and then I am closing this brace. So, when I close this brace, basically this object is no longer accessible outside this. So, this brace is saying that this is the scope of this definition. This definition, this object can be used only within this. So, when I encountered the second brace, this object B has to go because it ceases to exist after that enclosing pair of braces is over. So, since it ceases to exist, therefore it must be deallocated and therefore the destructor for B will be called when you come here. And then here there is a new V3 something. So, here again the constructor for V3 will be called because you are allocating a new object of type V3. Immediately after allocation the constructor will be called with these as parameters.  So, once again you are deallocating an object of type V3. So, the destructor will be called before the deallocation. And finally, when you say return 0 and go back, then the activation record of the main function is going up, is being popped off the stack. So, all the local variables that were declared in main function are being deallocated now. So, A will be deallocated and again the destructor will be called. So, over here you have one constructor of V3 called here, another constructor of V3 called here, a destructor of V3 called here because this object is being freed up over here, a constructor called here, a destructor called here and finally a destructor called when main returns because this local variable has to be deallocated from the stack and every time an object of type V3 is deallocated just before the allocation destructor has to be called. Is that clear? So, all that you need to remember is that creation of an object is immediately followed by invocation of the constructor which constructed depends on what parameters you have sent and deallocation of an object is immediately preceded by a call to the destructor. So, are there any doubts? So, of course, the destructor also has to be public because it will get called from the main function when the objects are being allocated and deallocated. So, are there any doubts about that? For your purposes, the only difference between a struct and a class is that everything in a struct is public by default, everything in a class is private by default. You do have constructor functions for structs, you have destructor functions for structs, fine? Okay. So, now let us go to the quiz then. So, this is the first question. A private member function of a structure can be invoked from another member function of the same structure, a member function of another structure, an ordinary function which is a non-member function. Now, I can write functions in my program and I can write functions inside structures and classes. So, functions that are right in my program outside structures are non-member functions and the main function in the program, okay? Next one. So, consider the class definition, class CL, there is a data member which is private and there is a member function which is also private, then B is another data member which is public and F2 is a member function which is public. So, which of the following is or are true of the class CL? A and B both can be used in the body of B2, B but not A can be used in the body of B2, A cannot be used in the body of F2, B cannot be used in the body of F2. So, these are member functions defined within a class and the question is which data members can you access? Next one is, this should be easy. By default, everything in a struct is assumed to be what and everything in a class is assumed to be what. So, of course, if you have been awake, then you should be able to answer this very easily. So, accessor and mutator functions can be used to do which of the following. Read and write only private data members, read and write any data member, higher internal representation details of data members and expose internal representation details. Last one. So, class CL has three constructor functions, which of the following must be true. So, for some reason this color has come out to be different here, it does not mean that this is the right or the wrong answer. So, the constructor functions must have different names, the constructor functions must have different return types, the constructor functions must have different lists of parameter types and all of the above. Multiple constructors in the same class. Let us quickly look at the answers to these questions. So, a private member function of a structure, a private member function can be invoked from another member function of the same structure. So, private members are accessible within the structure freely, but they are not accessible outside that structure. So, private member function can be invoked from another member function of the same structure. It cannot be invoked from a member function of another structure, cannot be invoked by an ordinary function, cannot be invoked by the main function. Private things can only be invoked within member functions of the same structure. So, here A and B are data members. So, all member functions can make use of A and B because member functions have access to all the data members within the structure right. So, A and B can be used in the body of F2 the others are not correct. So, it does not matter whether the members are public or private within the body of the structure within the member functions of the structure you can make use of all the data members. Private and public only refer to accessing from outside the structure. So, this is simple you know everything instruct is public by default and in a class is private by default. So, access it in mutator functions can be used to read and write any data members not just private data members and they are really used to hide the internal representation details not to expose and if you have three constructor functions then all of them must have the same name the name of the class none of them have any return type, but they must have different lists of parameter types. That is what we just saw ok. So, now let us look at the practice question. So, in the last class we studied about directed graphs right. We basically used this struct my node as the representation of a node and we said that all the nodes in the graph are going to be in an array named nodes and the idea of a node is the index in the array. This is exactly the same as what we did in last class right and this was the struct my node that we used in last class. These are the two things that I had asked you to you know work it out yourselves and one possible way of doing this I mean some of you had made these arrays full blown arrays which is a bit wasteful of memory. So, one possible way of doing this is to define linked nodes like this right. So, you keep a node ID and then you have a next pointer which points to linked nodes again and then you can have an entire chain or entire list or entire queue whatever you want to call it of outgoing node identities of nodes to which we have outgoing edges and similarly you can have an entire chain of identities of nodes from which you have incoming edges. This is part of last class's question right. This is like the linked taxi. So, you can form a chain or queue of node IDs and outgoing will have the list of all node IDs to which there are outgoing edges and incoming will have the list of all node IDs from which there are incoming edges. So, now what we want to do in today's class is that we want each node and each edge to also have a weight and let us say that this weight is a float type. So, for example, if you think of you know these nodes as cities and these links as roads or some kind of maybe train lines between them. So, then this might represent the distance in kilometers and these numbers might represent maybe the population of the city or something in you know lax or something right. So, there are numbers that we want to associate with each node. It denotes some property of the node. It could be the total population of the city, the total amount of revenue collected by taxes whatever and you also want to associate numbers with the edges which could represent you know maybe the distance between the cities or you know the average time it takes to go from one city to another whatever there could be different kind of things one can interpret. So, what we want you to do is we want you to modify this my node and linked nodes definitions as is shown here to be able. So, in fact, instead of calling them structs I would encourage you to use classes and as I said for all practical purpose in this course struct and class are going to be the same except that in a struct everything is public by default in a class everything is private by default right. So, what you required to do is to modify the my node and linked nodes definitions define these to be classes. So, that we can represent graphs with weights or nodes and edges and what I want you to do is I want you to make all the data members private in both of these classes right. So, the weight of a node cannot be accessed directly from the main program the weight of an edge should not be directly accessible from the main program the ID of a node should not be accessible directly from the main program the list of incoming edges list of outgoing edges nothing I want all data members to be private ok. So, you have to modify these definitions clearly we will need to add some additional members right at least need to store the weight of a node I need to store the weight of an edge and so on, but I want all data members to be private no data member should be public I should not be able to access them from the main function how am I going to access them through appropriate member functions with appropriate access control ok. So, we want you to redefine that structure as a class where all data members are private and you have to add new member functions. So, that you can do whatever operations we were doing earlier you know reading in a graph initializing the graph. So, here is what I want to do. So, this is the same main program as before where I am allocating an array of nodes I read in the number of nodes allocate an array of nodes if it is null I say memory allocation failure and last time we had init nodes here now I have used new init nodes which is going to take the nodes array going to take the number of nodes and now since each node has a weight. So, within new init nodes you can ask the user for the weight of node 1 the weight of node 2 whatever right and it should go ahead and initialize all of the nodes in the array should set the ID right should set the weight right the incoming and outgoing right, but remember all of these are private data members you cannot access them directly from either the main function or from this function you have to access them through interfaces or through member functions. So, you have to write those member functions and then this is just like what we had last time we were reading in edges one at a time saying give start of edge give end of edge now I will also say give weight of edge and then instead of ad edge I will say new ad edge which takes the nodes array start edge end edge weight and it must store the information about that edge from where to where what is the weight of that edge, but once again all data members are private. So, you have to use appropriate public member functions to set the values of private data members and finally we want to you know last time we just printed out the set of incoming nodes and the set of outgoing nodes of every node here I want to calculate some metric for node and that could be some of in edge weights minus some of out edge weights divided by node weight. So, I want this to be a public member function of my node such that I can call this on each nodes I and should print out that metric is this clear. So, so your task like last time is to write these three functions. So, these are very similar to what you did in last class except that now there is I want weights on nodes weights on edges and more importantly I want all data members to be private. So, you have to write some member functions to be able to access those private data members the accessor functions mutator functions that we just saw you have to write some member functions to do that is this clear is the problem clear very similar to the last problem, but now I am putting some access control on it. So, try this you can start from these structures call them classes and build on top of those has anybody done this completed it here is Anuj's solution can't project that here. So, what he has done is he has said plus my node int id load weight linked nodes outgoing and incoming this part I believe for all of you got I mean if you did not get even this part then there is a problem when we are just trying to add a we are trying to remember a weight along with each node. So, we have to add a data member called weight I mean weight or whatever your favorite name is and because this is a class these are automatically by default private right and then there have to be some public member functions some public member functions and how will linked nodes look like. So, Anuj has defined it like this class linked nodes is how the member functions for linked nodes with the data members is a int node id load edge weight linked nodes next and then there are some public data members right. So, basically it's like the previous one except that now he has added something to keep track of the edge weight and there are they will have to be some public member functions. So, let me just try to illustrate what Anuj is trying to do. So, suppose I have a graph like this. So, let us say this is node 0 this is node 1 this is node 2 and let us say I have some edges like this and let us say the weight for this is 2.1 the weight for this is 5.2 the weight for this is 3.7 and the weights for these edges are let us say 4.1, 3.9 something 0.3. So, what you know Anuj's scheme seems to be is that this graph is going to be represented by an array of size 3, 3 nodes an array of size 3 where each element in that array will be of this class right. So, it will have an id data member of weight data member and some outgoing and incoming data members and then there will be some member functions. So, these are all member functions right. So, how is this going to look like? So, it will have some id it will have some weight this is the nodes array. So, this is nodes this is nodes 0 this is nodes 1 this is nodes 2 each nodes thing each element in the nodes array is an object of this class. So, it has id weight outgoing incoming. So, I am going to write it like this id weight and then outgoing and incoming each element will have this right id weight outgoing incoming id weight outgoing incoming and now the ith entry in this array should represent the ith node. So, here I really want to say id 0 id 1 id 2 weight this should be 2.1 this should be 5.2 and this should be 3.7 right this is representing the first node whose id is 0 weight is 2.1 this is the second node id is 1 weight is 5.2 id is 2 weight is 3.7 and now I will have to represent the outgoing edges from node 0 there are two outgoing edges from node 0 right. And so, these can be thought of as a chain like this remember the outgoing and incoming are pointers to linked nodes right and linked nodes has a node id and edge weight and a pointer to another linked nodes right. So, that is what we are going to use. So, outgoing is a pointer to linked nodes and this can store a node id it can store a weight and it can store another pointer to an object of linked nodes type right. So, in the id what should I store from 0 I have an edge going to 1. So, I will store that there. So, this is now representing that from 0 there is an outgoing edge to 1 what is the weight of that edge 4.1 and this is saying this is the next element in the list of outgoing nodes right. So, there is another outgoing edge here. So, from 0 to 2 weight is 3.7 and there are no further outgoing nodes. So, this is none. So, I would really like to store it this way right. And of course, in the incoming one I should say that for 1 there is an incoming node from 0 whose weight is 4.1 and there is for 1 there is another incoming node from 2 whose weight is 3.9 incoming edge from 2 whose weight is 3.9 and finally this is none right. And from 2 similarly there are 2 incoming things. So, I should have something from 0 weight 0.3 pointing to the next thing 1, 1.1 and this is none. So, and of course, there will be other things here you know I think 1 has 1 outgoing edge. So, that is going to 2 has weight 1.1 and only 1 outgoing edge and similarly 2 has 1 outgoing edge. So, 1, 3.9 and 9. So, this is the representation this is how I want to represent the graph right. Last time what we had we did not have this weight and here when I was storing the information about the edges I did not have the weights of the edges. But other than that everything is more or less the same. Is this clear how the graph has been represented? I mean that graph I want to represent like this and now the question is that. So, you know so these data members that Anuj has used are indeed correct I mean they are certainly in the right track. Now you have to write appropriate member functions because all of these are private. So, you cannot access them from outside. So, you have to put appropriate public member functions which when you are trying to initialize a node it will go ahead and set the ID set the weight maybe set all of these to null. Then when you are trying to add an edge the public member function should go and add to the appropriate outgoing and incoming lists right. So, you have to write appropriate accessor and mutator functions for both the class my node and the class linked nodes. So, that finally this graph as you read in the edges and read in the weights of the edges and the nodes can be represented like this. Is this clear? So, you know the data members are right here now you have to put the appropriate public member functions because all of these are private. In a class if you do not declare anything everything is private and we want to keep them as private that is the whole purpose of this question. Now you should write appropriate member functions. So, that you can do all the manipulations you want on the appropriate data members and from the main function there are those new init nodes will be called and that should ask for the weights of the nodes and initialize them new add edge will be called and finally print metric will be called. This print metric should be easy because this is a member function of the node and a member function has access to all the data members in that structure. So, it can just go through the outgoing list add up all the edge weights go through the incoming list add up all the edge weights and do all of this division and print it out. So, I would like all of you to do this you know I have sort of almost shown you how to do it just try to appropriate member functions as that nobody needs to access the data members directly and you know try it out program it on your computer when you come to the lab or in your laptop and see what is happening ok.


طللِ الُسائِلُه مُعدطَلَةٌ ما نازِلُه غدَتmemberائِثُه�� أعالِه أَسافِلُه و قُنتُورَاهُ مقةُولا but afterwards أهِلِه و grip هل ترى؟ هل ترى منسيبة؟ هل فعلت؟  وانت ماذا؟  How many times do I tell you? I can only remember probably like 3 I can remember 3 for sure Okay go on, which one? Yesterday, before you ate the other bone, rode a clip Move to your witness He was about to eat the chicken, he said you know I film in this? Okay, which one? Alright that time The other time, is when we were كيف حالك؟ لا لا لأنه فقط لأنه كان في الفيديو لذا عندما يقول محمين هل تعلمين أنه يقول أنه يقوم بعمل؟ لقد كنت أتحدث عن بيكي ما بيكي؟ لماذا يقوم بعمل في الفيديو؟ هذا هو كيف يمكن أن يكون في محمين؟ كيف يمكن أن يكون في محمين كيف يمكن أن يكون في فيديو؟ بشكل صفر سيكون في فيديو كيف يمكن أن يكون في محمين؟ لقد كنت أتحدث عن بيكي لا لكن أخطأ ليس بعمل مع محمين أو بمحمين يقول شيئا فلن يقول فلن يقول فلن يقول فلن يقول لن أذكر أنه يوجد مجموعة رائعة. هذا لا يعني البيت. هذا لا يعني شيء جانب. يوجد مجموعة من المجموعة. يوجد مجموعة من المجموعة. لكنهم يتخلقون بكي بشكل حجوك. ما يجب أن أفعله؟ تفني. سأرى ما تفعله. لن أرى ما تفعله. لن أرى. سأخبركم. لقد أخبرتكم. منذ كل هذا المجموعة. رأيتكم. رأيتكم في مجموعة. رأيتكم في مجموعة. سأعلمكم كيف أخبركم. رأيتكم في مجموعة. رأيتكم في مجموعة. رأيتكم في مجموعة. كما كل أحدا. لم أكن أحد من أرى ببعض. ليس أرى. ولكن أن أحب the editing skills. أشكر الكثير من المجموعة. في المتابع. فقط مرأ. كل مجموعة. فقط سأرى. هل تقول لهم غاية لماذا أنك تخفضون من للي أخسر؟ أو إذا كنت أصحبت كان أتكلم أنك غاية لماذا كنت أتكلم من للي أعلم؟ كما قلت أنه لا يوجد شيء بشكل جيد في الوصول على الوصول أو بشكل جيد في الوصول أو بشكل جيد في الوصول لا أعلم كيف أتحدث عنه إذا أحب the camera أنا فقط أخبره أو أخبره من my points 1,2,3 و هذا ما أعتقد و you guys can judge for yourselves حسنا، أعتقد أنه الكثير منه لم أكن أعلم أي قاعدة أو باطلة التي you guys made for it و I attributed it to me I never said I'm free from my lawmakers from those who do not love the camera I mean what am I supposed to do what am I supposed to do you guys have to ask Muhammad to post that video you guys have to ask him to post that video I know just ask him if you guys want that video I don't know let's roll the clip where Nurdin was laughing I've never seen Nurdin laughing that much yeah I was watching that video it was mad funny if you guys want to watch it if you guys want to watch that video if you want that video it's going to make your day I'm absolutely 100% sure what do you think Muhammad you want it هيا كلها أنا شيخ أنا أخي لا لا بأ when we asked him he said that's not much you thought he wasn't from you he doesn't fit me and Muhammad gets I don't know how many comments if it doesn't fit you I might give it to someone if it doesn't fit me maybe let's say 1000 comments I don't know I think we can get 250 or maybe I don't know follow my channel or maybe look at this plug he's learning now you know what you gotta do when I post a video you gotta be on the comment section look at that this is a different one this is a different breed this is a little bit of Taqlid not Taqlid look at this this one is exclusive exclusive now I thought it was at the front so I bought this jacket to put it on but then I don't know man you bought it just for that? no I got it from my house I didn't check it out it's gonna hide the hands up at the back though masha'Allah it's not hot it's not hot that's how you guys say it if I get that guy but yeah I don't know why I should have it on the front though now you're good man you know you athletic look good look good when I'm talking about his hoodie let me know how much are you gonna sell that you might give it to you if I don't like it I can give it to one of you guys but you guys how to I don't know how many comments I can just tell them how many comments you want I can do 250 comments 150 just type it that guy was typing I don't know how many 500 times they put my vlog down because of him and he was numbering it 1 2 3 4 in the beginning it was 1 2 3 4 just numbers then he edited all the comments youtube was like what is this guy doing and honestly you know just to know what Mr.Mank said I think that's just nosy people are asking what did he say to him what did he say to him it could have been private and Muhammad is just debating it could have been private it could have been something about his family and what he just told you that was that was snippets from the conversation it was longer than that right this book about other issues they were talking about for a long time why don't you call yourself which is not that I need to explain how I meant but you called me actually that's helping you to grow your followers why is that are you going to watch videos because you are in my videos because you are in my videos because I these videos because you are in my videos هل أنت بلغة كذلك؟ أنا بلغة كذلك أنا always born for that كفاية فيها الكفاية لذلك أنت بلغة من محمد الاندروسي السلام عليكم ورحمة الله هناك ما بوي ما بوي نردين الخلوي ما شاء الله انه خراوي أعلم you man أنا بلغة اليوم هل أنت تفهم؟ بل كما نقول بلغة الله شكرا لك ورحمة الله كذلك كذلك كذلك لأني أخبرك السؤال لذلك أكثر في الشباب لقد عملت لي انه صحيح جدا يجب ان يجب ان يكون هناك أسئلة ولكن ما سنفعل is we're going to ask اخذت نفسي one question then I'm going to let Notre Dame pick the other question since he is very you know picky and knows what is right and what's wrong so my question that I picked is from Ummu Waladun and the question says what is the ruling on continuously pick up on on a brothers joke or continuously like joke about you know roast basically continue to roast someone what's the ruling of it شغل are you ready شاء الله I would say and Allah knows best that a mockery of a Muslim making fun of a Muslim dishonoring him, shaming him coming off of someone's downfall of course is incorrect and it's going to be impermissible hurting your brother's feelings offending him attacking his honor that's serious there's no doubt about that the Quran and the Quran prevents us from many social vices and from those social vices is no people should make fun of another people no men should make fun of other men no women should make fun of other women etcetera women and women and men عسا يكونوا خيرا منهم they could be better than the people who are making the jokes a person may have better style or a person may have more knowledge or a person could be cooler or whatever stronger than the people who are actually making fun of them to talk about race to call people savages look at them they are kind of dressed but they may have more humanity in them than those who are calling them savages a lot of them can cut me he says cursing a believer is like killing a believer so the believer's honor of course is sacred there's no doubt about that making fun of him it's impermissible it's not lawful however when you're asking about vlogs or or anyone else when we have a friend or a companion and people are rinsing or roasting or you say bustling on someone then they're limits they're boundaries but it isn't the same as you attacking somebody and they're actually offended and they don't know you they don't like you they're not joking with you look at them look at them that's one thing versus my mate that's my man we're on a trip when the hotel traveling for long distances and it's only natural for there to be some type of road still rinsed but it doesn't mean that it isn't a level and it doesn't mean that it isn't a limit and it doesn't mean that it isn't a boundary and of course if a person doesn't have to laugh like that there's no doubt that that's better the professor said whenever he wanted to express some type of humor or some type of elated joy or some type of feeling of happiness or pleasure he would smile and he would never show all of his teeth all of the time and that's why there's certain a hadith which he says he smiled for بحيقه he laughed so if we actually look at the prophetic a hadith our whole entire culture is going to be in contrast with that how often we laugh how often we joke how often we have fun how often we do things that the professor never did or he only did them as a rarity whether that's roasting or other than roasting and there are many other cultural norms that we have which are in opposition to certain a hadith such as staying up after it's not in the class we're not talking about our wives we may be eating or traveling here or doing this traveling by ourselves there are many many many many things alright so I feel and I think that it's accurate to say is that it's a bit different than roasting or rinsing your friend your companion that you're traveling with or another way of looking at it is if the brother loves to get roasted and loves to get rinsed that's a fact that's a fact he said it this morning I got him on camera I know this is how you know someone is not telling the truth if it was true then it would come up like I said again and again I will say I mean it what do you like to see it's a quest for punishment let alone the fact that without fairness and me and everyone will say but we got our own beefs and stuff no doubt it doesn't mean we have to agree with everything that he do or every style or technique however they don't see off the camera what how he attacks okay so often times you only see the fruit of the aggression why you're roasting him so what he wants to eat the chicken bone like that but the people don't see they don't see the malicious attacks of Nudity can we agree on this moment there's no doubt about that so the top and the bottom line is is that we all know the ruling of humiliating a Muslim making jokes of anybody or just joking too much being a joke to too much which we're all guilty of I wouldn't say it etc but that does not mean that everything is just black and white there is a tough seed and there's a relationship that you have with a friend versus a stranger a relationship that you have with a close friend versus a normal friend an associate a relationship of someone who is attacking you and attacks people and everything that you have to do to roast them a little bit so that's what I think about that and I think we should keep things balanced and moderate and we shouldn't want either of the two extremes unnecessary laughing unnecessary joking unnecessary mockery and roasting and at the same time sincere piety and no one is going to say that how they deal with a friend or close friend especially on a trip you're driving, you're stressed how you would deal with some normal person I think that's what that's fair and balanced God bless you what do you think I know the deal do you have the answer yes God bless you and the end


We're never going to achieve the outcomes if we try and think in a traditional individualistic approach. So I joined the investment industry, focusing on ESG and sustainable investment, and I became very determined to use sustainability and capitalism as a first forget. What I've done and what my impact today is, it's a combination of highlighting and flagging quantifying risks to our investment that are related to society and environment, but also trying to direct capital into the solutions to these global challenges. And today I lead the ESG strategy for the private equity environment of a big European asset manager. And I'm very happy to say that I can have positive impact even though sometimes some days doesn't feel like that, but I can have positive impact over billions of AUM. I think I moved from idealism to what I call now pragmatic idealism. One individual can have a massive influence in the world, but there's things I just can't change. I can't change the capitalist structure. My future vision in my lifetime would be for corporates and investors to pay what we call today the true cost of capital. We operate as translators. We are there between ethics, science and investors. We understand these two words. There's very complex scientific context and the reality of the macro world and what ethics and society may need into, you know, the day-to-day of generating profit for ultimately pensions, older and financial stability. So that's where I think roles like mine play a massive role in sort of advancing the sustainability agenda for a macro level. I see my leadership as a tree, me almost the centre and then all the roots being the impact that I try to generate going back into nature and you've got this feedback loop that continues generating and seeding the need for sustainability. I don't think we want to look at leadership as an individual. We can't afford that. This is a multi-stakeholder's effort that is necessary. And this is where, to me, the concept of the tree and the seed with the roots that connects to the rest of the world within the ecosystem is very much needed and speaks to the type of leadership I try to implement. The time where I felt the most out of my comfort zone was when I moved to London. In context, my parents don't speak English. I didn't know any adult when I moved to the country. I was 18.  And then you go to London, which is not just English, it's international. I had to realise that there wasn't one version of reality, that there wasn't one way of doing things. And I think I was really scared at the beginning and it terrified me and then I completely fell in love with it. I challenge constantly the way I see the world and I think I've been very much more open to different views and perspective and I've become a lot more humble with my own views of reality because I've had to learn that everyone believes because of their own vision and perspective and upbringing. We're never going to achieve the outcomes that we're set to do if we try and think in a traditional individualistic approach. My key allies are believers in USG as well. I divide people by influence and knowledge. But if I think about outcome that I'm trying to achieve, then I would focus on the people that have the highest influence of the key stakeholders that are necessary for the outcome. And then within that sphere, I would focus out of them which one are my USG believers. And then I collaborate with them. They have roles that are completely different in my mind. They're not sustainability experts, but they are supporters of sustainability. And most importantly, they are influential within the business. And then finally I've got these other sphere of allies that are not influential. They might even be completely outside my industry. And they're basically people that are very knowledgeable in the outcome that I'm trying to generate. They are very knowledgeable about that topic specifically that helped me through that, but they're not going to directly impact my stakeholders. When I started this journey, I felt very lonely in it. As soon as I found the other people in this community, I straight away felt they were my people. So I would say first and foremost, trying the community. Also, I've got an amazing coach. She gave me a key piece of advice that I take with me daily, which is to connect my daily objectives to what I'm trying to achieve, to think about the big picture. It can feel quite overwhelming trying to tackle the global challenges in the world. I'd also say be patient, persevere, do not expect fast win. These are really big asks and they'll take time. So you need to persevere. And again, if you connect it to the big picture, that might help you with that. So I did the postgraduate in COVID, so that was a little remote. But I thought, okay, I'm going to try for this year and I'll do it part time and I'll see if I actually gain value out of it. I felt so in love with it that I continued to the master. I became an assessor for the short courses. I even did the CSL accelerator. So I think CSL for me is featured into so many aspects. There's this huge amount of knowledge and openness. People are willing to help. And there's this level of empathy, which you can get when you get yourself into the same room with people that come from a completely different background, completely different industry, yet struggling with the same topics and have the same alignment heart that just makes you feel stronger. And it's this invaluable body of knowledge and inspiration that is just magical. It gave me the confidence that I can face difficulties and have the credibility to do what I do.