Static analysis is an automated technique used to examine source code and detect common programming errors such as buffer overflows, memory errors, and unsafe function usage, serving as a valuable tool for both security professionals and developers to identify potential vulnerabilities before they can be exploited; effective static analysis requires combining multiple tools to reduce false positives and maximize coverage, as no single tool can detect all types of security issues.
Static Analysis for Vulnerability Discovery | Bug Hunting
Added:all right so today we are talking about bug hunting and exploit development so this is quite an interesting topic and um from what we cover in today's lecture and the the labs related to this you will understand how exploit development works so you'll be able to go and find a vulnerability in a piece of software and write a Metasploit module to actually exploit that vulnerability that you've discovered so and there's there's obviously quite a lot of content and it's all quite interesting and also quite technical um but we're gonna I'm really focusing on the um beginner kind of level of writing an exploit and there are more technical um details that we could get into but that um that we're not essentially I'm going to give you an overview of some of the stuff like if you are trying to exploit um Windows 10 with all the latest security features and there are some extra things that you need to do while while developing exploits but all the stuff that I'm going to show you is going to work against a whole range of operating systems and I'm also going to mention which ones include protections that make things a bit more tricky so in order to avoid introducing software vulnerabilities when you're doing development you need to think about security and we talk to all about that last week and the sorts of steps you can do to try and avoid introducing bugs into your software in the first place but inevitably security mistakes get made as you know often it's like a one-line program mistake that results in security problems and so what we're talking about is existing code and maybe it's just code that is still in development but that we want to do some testing on to see if we can find something or we can take someone else's code and apply all these things to try and find bugs in existing software so this is the things you can do with or without access to the source code so um the fact that you don't have yourself have the source code doesn't stop you from finding security problems there are things you can do with the source code that you can't can't do without and we'll also talk about that a little bit as well so once you actually find a vulnerability you can go and produce some proof like a proof of concept code that demonstrates that it's a security problem so you can write an exploit for example for Metasploit to demonstrate yes look there's a problem and this is how you actually would take advantage of it to do something um or you could go and actually just write the code fix the code fix the problem and you could send that to the developers and go hey I found a problem and here's how you fix it so there are some advantages and disadvantages to each approach if you don't have an exploit a lot of people a lot of the time will just say that's not a security problem it's just a crash you know you can say look I've overwritten um the you know instruction pointer and therefore it's a security problem and they'll go no it's not I mean if they don't understand the problem you know if you write an expert and say look you know here I've attacked your code and this is what it can do that will get their attention a lot quicker than if you just say that there is a potential security problem there um so there are some advantages of writing exploit code um if you write a fix then obviously that is the perfect solution if you want the software to get fixed so um obviously and that has to do with whether or not the source code is available so if we're talking about free and open source software then obviously the source code is available and you can just fix it but if you're talking about something that's closed Source then you the you know you don't have the source code so you probably can't fix it you can sometimes write a binary patch which is basically you can make changes to the machine code like level lava and then you could apply that but that's not really that helpful to most people and it's not going to help the software developers probably anyway so if we're talking about open source software you can just go in and look at the code and fix it or if you obviously if you work for the company if it's closed Source if you are independent and um you find a problem in closed Source software then basically you just need to tell them about it and hope that they believe you that it's a security problem so zero day is obviously if we find something that's new so if you discover something that no one knows about before then you've just found a zero day vulnerability so obviously very serious security ramifications so if you've got a zero day or an O day then basically you could go and you know if you're a a blackout you could go and write a worm that basically you know spreads across the internet infecting computers and doing some you know doing things with those computers they might form a botnet and then you can use them to do your evil biddings or whatever or you could use them in some kind of targeted attack so you could um you know specifically attack um say a bank or something and start emailing staff members and or you know do something that specifically targeted at someone um and so there's all sorts of things you I mean you could sell it on the black market sell sell the vulnerability you've discovered and if you weaponize the attack then um you could basically create an exploit and that would be known as a zero day exploit so there's no fix possible but please don't do that so if you uh um find yourself a new vulnerability then please follow a responsible disclosure so you know as we've discussed in previous modules if you've done some of the other security modules and as you know basically that it's a heat hotly debated topic within security industry how do we go about dealing with new vulnerabilities so responsible or coordinated disclosure is basically when you contact the vendor and you basically give them a time limit so you say rather than just telling people you say you basically work with them and you don't go public straight away so often you give them a time limit so you say you know you've got two months and then after two months if you haven't fixed it gonna go public with that information um an alternative approach is full disclosure where you basically just publicly announce everything and um that doesn't actually give the opportunity the vendor an opportunity to fix it which means that you know basically black cat hackers can take that information and use it before the vendor has an opportunity to fix it so I guess you could say why don't you just give the vendor an infinite amount of hand fix it well like time has basically taught us that if you give them an infinite amount of time fix it and you basically there's no threat of going public often things won't get fixed basically so you say oh look I found this problem full stop some vendors will basically just sit on that um so yeah in terms of this module if you find a zero day while you are working on your assignment for this module here is a vulnerability disclosure policy for you to actually carry out so while doing this module this basically I've tried to make it as easy as for you as possible basically lay out some steps and I've created a template that basically is for you to fill out and then you can use to inform the company that you found a problem so just make it just to make it as straightforward as possible so basically there's a disclosure template document that's up on the module page basically you just replace the yellow Fields with a few details of the things the thing that you found and you can start by contacting the security Representatives within the company and if you're sending in emails and CC me in but basically you and the details of that are written in the template document there's more document information that isn't here basically you can contact the security Representatives tell them about the problem it tells them what the deadline is as well which is 15 days and then um cert cc is contacted which gives them an additional 45 days and then do the release themselves if they find if they believe that it is a serious security vulnerability so that takes it out of our hands in terms of like actually going public with information but they cert will do that for us basically and publish the information if they're fixed it in that amount of time so also you would then apply for a cve which will look great in your CV um and then after and not before 15 days after step two you'll report to cert the information if they haven't already like basically satisfied you um and then after that they they will release the the details publicly and then after that point you can blog about it or you know whatever write about it um release your export code or whatever so there is some more information on the module page and in the template if you want to do something different then um talk to me about it first before you do something so um yeah so how do you go about finding a bug so if you got access to source code you can obviously look at the source code and read it very carefully and see whether you can spot any of the types of security vulnerabilities that we've talked about you know in the last couple of weeks there's also a static analysis where you can basically use software to automatically analyze the code and look for problems and whether or not you've got access to the source code you can also do reverse engineering so you can take if you've got a binary of the program you can try and figure out what it does by looking at the the actual executable file and you can also do binary static analysis sometimes so you could try and reverse engineer you can use a disassembler to take the binary file and generate something approximating what the source code is and then you could run that through aesthetic analysis tool and you can do fuzz fuzzing which does like random testing and we're going to talk about that in detail so static analysis first is um basically it does its automatic way of detecting common programming mistakes it's really good for detecting certain types of programming errors so for example buffer overflows and memory errors and using functions you shouldn't be using and things like that they're very good at detecting that sort of stuff but some of the tools have very high positive rates for false positives so it will basically tell you there's a whole bunch of problems and actually when you look at it closely it's not a security problem but it does flag a lot of stuff up and some of the tools are designed to try not to have too many false positives but they're not going to detect everything but they are a really good thing to use so if you are a programmer and you're working to develop the sort you know some source code then you should can seriously consider using static analysis in the development stage of your project but also if you've got access to the source code you can run it through the tools so there are lots of tools some of them are open source others uh there's a loads of closed Source proprietary tools you can pay for as well some of the um the good fossils include CPP check which aims for zero false positive so it tries not to give you alerts that aren't true uh which isn't true of all of them there's like floor finder rats a visual code grapher and oink which includes a um aesthetic an answer still there's loads of other tools like seriously that so there's a Wikipedia link there which you can look at there are you know there there's just loads of tools you can use but because they all do this in different ways it is a really good idea to combine them so if you want to be more likely to find something you could use you know maybe choose two of the tools to run run it through or you know more than one basically um and it's just as a side note for your assignment um the it doesn't hurt to run thorough static analysis first to give you some ideas of the sorts of stuff to look at in your fuzz testing it's not going to give you extra marks but it will quite possibly make this make it easier for you to find something so there is also um God I don't know how to pronounce it coverity how do you pronounce that um it's it's a big it's a big commercial company that do static analysis and you can pay them to do to to use their tools to analyze your own source code um but it's free to use for open source projects so if you're a fast project you can basically use their online scanner and it's been used for um for a while um now for a few years to scan lots of projects including like the Linux kernel and you can see um it's been used to detect loads of loads of um errors flat floors that it's detected so you can see that that you know there are currently well over foot apparently 4761 outstanding issues whenever this was published in the Linux kernel they hadn't been fixed yet and whether every single one of those issues is a serious security problem I don't know but you know obviously interesting there are lots lots of code um so this is saying that the Linux kernel has about nine million lines of code and interestingly FreeBSD has even more code um so so yeah you can see that it's been used to detect all sorts of things so that's static analysis what about when you don't have access to the source code um buzzing so you can use fuzz testing or fuzzing um to basically feed in variations of input into a program so it tries to create unexpected input to try and uncover unexpected Behavior so software vulnerabilities that might be lurking in the code one way to find them is basically just to inundate the software with all sorts of weird requests
Up Next

Building a C++ Reflection Engine: Static & Dynamic Systems
@MeetingCPP
3.6K views•2017-01-16

BitTorrent Protocol Explained: Piece Selection & Peer Choking
@StevenGordonAU
481 views•2013-02-22

HTTP Requests Explained: GET, POST, PUT, DELETE
@codecademy
103.1K views•2021-10-07

Enigma Machine Mechanics: WWII Encryption Explained
@JaredOwen
13.2M views•2021-12-11
Related Study Plans & Knowledge Roadmaps
Structured learning paths in Computer Science












































