<?xml version="1.0" encoding="utf-8" ?><transcript><text start="0" dur="4.7">SQL engine no no no</text><text start="7.75" dur="4.19">[Music]</text><text start="9.36" dur="5.1">let&amp;#39;s use a SQL injection to hack into a</text><text start="11.94" dur="4.679">website here is our Target alturo Mutual</text><text start="14.46" dur="3.659">an online banking site that is totally</text><text start="16.619" dur="3.66">real we&amp;#39;re going to use a SQL injection</text><text start="18.119" dur="3.601">to hack into this website and gain admin</text><text start="20.279" dur="4.701">privileges you&amp;#39;ll be able to hack this</text><text start="21.72" dur="3.26">website in like 30 seconds</text><text start="26.48" dur="4.9">now one of the scariest uses of SQL</text><text start="29.039" dur="4.321">injection is that bad actors can use a</text><text start="31.38" dur="3.96">simple login form like this to dump a</text><text start="33.36" dur="3.359">database of usernames and passwords and</text><text start="35.34" dur="3.059">then put them on the dark web with a for</text><text start="36.719" dur="3.601">sale sign and you&amp;#39;ll never know about it</text><text start="38.399" dur="3.721">nothing you can do well actually you</text><text start="40.32" dur="3.78">could probably try Dashlane the sponsor</text><text start="42.12" dur="3.779">of this video Dashlane will actually</text><text start="44.1" dur="3.6">monitor the dark web and see if your</text><text start="45.899" dur="3.84">usernames and passwords are for sale and</text><text start="47.7" dur="4.199">if they are they will alert you and I</text><text start="49.739" dur="3.66">have a lot I need to fix that and then</text><text start="51.899" dur="3.121">using Dashlane you can generate a</text><text start="53.399" dur="3">completely random password unique</text><text start="55.02" dur="2.82">different from your other passwords</text><text start="56.399" dur="3.541">right you don&amp;#39;t use the same password</text><text start="57.84" dur="3.66">for every website do you anyways and</text><text start="59.94" dur="2.759">Dashlane will store it for you and this</text><text start="61.5" dur="3.119">right here is definitely my favorite</text><text start="62.699" dur="3.541">feature of Dashlane they&amp;#39;ll do passwords</text><text start="64.619" dur="3.18">and they&amp;#39;ll also do multi-factor</text><text start="66.24" dur="3.419">authentication right there in the</text><text start="67.799" dur="3.721">stinking app I love that so all your</text><text start="69.659" dur="3.541">stuff is in one place keeping you safe</text><text start="71.52" dur="3.959">and making it a bit more simple to log</text><text start="73.2" dur="4.32">into sites I use Dashlane personally for</text><text start="75.479" dur="3.601">everything and also for my business and</text><text start="77.52" dur="3.06">check this out I get an admin console</text><text start="79.08" dur="3.24">giving me a dashboard of all my</text><text start="80.58" dur="3.12">employees password Health scores and</text><text start="82.32" dur="3">it&amp;#39;ll tell me whose passwords are</text><text start="83.7" dur="3.66">compromised so I can basically force my</text><text start="85.32" dur="3.42">employees to be secure which you have to</text><text start="87.36" dur="2.82">do that they&amp;#39;re not going to listen so</text><text start="88.74" dur="3.059">start securing your passwords for free</text><text start="90.18" dur="3">right now check it out link below</text><text start="91.799" dur="3.78">dashlane.com forward slash network</text><text start="93.18" dur="4.079">chuck50 use the code Network chuck50 and</text><text start="95.579" dur="3.601">you&amp;#39;ll get 50 off and did I mention you</text><text start="97.259" dur="5.101">can secure your passwords everywhere</text><text start="99.18" dur="5.22">phone tablet computer yeah it&amp;#39;s awesome</text><text start="102.36" dur="3.719">so again here&amp;#39;s the website it&amp;#39;s a</text><text start="104.4" dur="3.539">simple login form and we won&amp;#39;t need any</text><text start="106.079" dur="5.22">fancy tools all we&amp;#39;ll need is a keyboard</text><text start="107.939" dur="5.341">and some coffee</text><text start="111.299" dur="3.6">now our goal of this login form is to</text><text start="113.28" dur="3.78">use it in a way that will give us access</text><text start="114.899" dur="3.841">to the underlying database when you try</text><text start="117.06" dur="3.419">to log into this website or really any</text><text start="118.74" dur="3.6">website when you hit enter the website</text><text start="120.479" dur="3.481">will connect to a database and Run a</text><text start="122.34" dur="3.72">search to see if your username and</text><text start="123.96" dur="4.92">password exists on the database if they</text><text start="126.06" dur="4.44">do you&amp;#39;re in log in successful so here</text><text start="128.88" dur="3.24">is where a SQL injection comes in and</text><text start="130.5" dur="3.9">it&amp;#39;s kind of crazy we know that a lot of</text><text start="132.12" dur="3.96">websites will do this very thing query a</text><text start="134.4" dur="3.66">database and possibly have a query that</text><text start="136.08" dur="3.6">looks similar to this and this may look</text><text start="138.06" dur="3.06">familiar if you watched my previous SQL</text><text start="139.68" dur="3.24">video we&amp;#39;ll use statements like this to</text><text start="141.12" dur="3.42">find information in a database but here</text><text start="142.92" dur="3.179">we&amp;#39;re going to use the beauty of SQL</text><text start="144.54" dur="3.18">against them now in our scenario we</text><text start="146.099" dur="2.881">don&amp;#39;t know the username and password so</text><text start="147.72" dur="2.82">let&amp;#39;s take that out now let&amp;#39;s first just</text><text start="148.98" dur="2.88">brute force it let&amp;#39;s guess and maybe</text><text start="150.54" dur="2.88">we&amp;#39;ll get lucky now as I&amp;#39;m typing this</text><text start="151.86" dur="2.94">notice what happens to our query this</text><text start="153.42" dur="3.36">will be important for our next step the</text><text start="154.8" dur="4.38">username could be admin it&amp;#39;s a popular</text><text start="156.78" dur="4.56">username for administrative accounts and</text><text start="159.18" dur="5.04">we&amp;#39;ll try the password password one two</text><text start="161.34" dur="4.32">three let&amp;#39;s click login oh failed it was</text><text start="164.22" dur="2.82">worth a try but did you keep an eye on</text><text start="165.66" dur="3.12">our statement notice that whatever we</text><text start="167.04" dur="4.199">typed in was entered here in the query</text><text start="168.78" dur="4.56">between single quotes now here is why</text><text start="171.239" dur="3.541">that&amp;#39;s important and programming and in</text><text start="173.34" dur="3.96">SQL when you have a string of characters</text><text start="174.78" dur="4.5">between quotes like this can be single</text><text start="177.3" dur="3.6">or double quotes that&amp;#39;s referred to as a</text><text start="179.28" dur="3.179">string it&amp;#39;s a data type so looking at</text><text start="180.9" dur="3.72">our query down here anything inside</text><text start="182.459" dur="4.14">quotes is going to be a string and</text><text start="184.62" dur="3.66">everything outside of it is a SQL query</text><text start="186.599" dur="3.241">and we know that whatever we enter here</text><text start="188.28" dur="3.36">in the username field and the password</text><text start="189.84" dur="3.899">field will end up becoming a string</text><text start="191.64" dur="4.26">inside that query but what if we could</text><text start="193.739" dur="3.601">make it not do that and this is where</text><text start="195.9" dur="4.38">the hacking comes in what if we could</text><text start="197.34" dur="5.46">send not just a string but some more SQL</text><text start="200.28" dur="4.8">query to change what happens to hack</text><text start="202.8" dur="3.96">what happens so let&amp;#39;s try this let&amp;#39;s</text><text start="205.08" dur="3.78">type in our username once more here at</text><text start="206.76" dur="5.16">admin but at the very end we&amp;#39;re going to</text><text start="208.86" dur="5.04">add a quote a single quote and let&amp;#39;s try</text><text start="211.92" dur="3.539">to log in okay didn&amp;#39;t work we haven&amp;#39;t</text><text start="213.9" dur="3.18">hacked it just yet but notice something</text><text start="215.459" dur="3.36">and this will tell you if a website is</text><text start="217.08" dur="3.06">vulnerable to SQL injection this is a</text><text start="218.819" dur="3.121">great way to test that and pay close</text><text start="220.14" dur="3.239">attention to the error we have a syntax</text><text start="221.94" dur="2.7">error because if you look at our query</text><text start="223.379" dur="3.661">did you notice what happened we have</text><text start="224.64" dur="3.84">another quotation mark right here a</text><text start="227.04" dur="3">floating quote and this is fantastic</text><text start="228.48" dur="3.839">news for us because the reason I got a</text><text start="230.04" dur="4.38">syntax error is you know a string is</text><text start="232.319" dur="4.14">between two quotes if you only have one</text><text start="234.42" dur="3.42">quote then it&amp;#39;s not complete it&amp;#39;s we got</text><text start="236.459" dur="4.261">a syntax error it&amp;#39;s like freaking out</text><text start="237.84" dur="5.459">but now we know that we can insert some</text><text start="240.72" dur="4.5">extra stuff besides just our string so</text><text start="243.299" dur="4.261">now that we know this application is</text><text start="245.22" dur="4.14">vulnerable to SQL injection let&amp;#39;s try a</text><text start="247.56" dur="3.239">few SQL injection payloads which is</text><text start="249.36" dur="2.879">actually pretty easy it sounds scary but</text><text start="250.799" dur="3.72">it&amp;#39;s not too bad now before I show you</text><text start="252.239" dur="3.9">the payload let&amp;#39;s re-examine why our</text><text start="254.519" dur="3.241">first login failed I mean it&amp;#39;s obvious</text><text start="256.139" dur="3.181">right the username and password were</text><text start="257.76" dur="3.96">incorrect but I want you to look at the</text><text start="259.32" dur="3.9">logic of this query the SQL statement</text><text start="261.72" dur="5.4">what it&amp;#39;s saying is both the username</text><text start="263.22" dur="6.72">admin and the password password123 have</text><text start="267.12" dur="4.74">to exist together just like this if both</text><text start="269.94" dur="3.72">of those are true it will evaluate to</text><text start="271.86" dur="3.24">true and we get a successful login but</text><text start="273.66" dur="3.12">in this case they&amp;#39;re not there it&amp;#39;s a</text><text start="275.1" dur="4.02">different password so it evaluates to</text><text start="276.78" dur="3.96">false so now here&amp;#39;s where the magic</text><text start="279.12" dur="3.299">comes in here&amp;#39;s where our payload comes</text><text start="280.74" dur="4.44">in what if we can make the SQL statement</text><text start="282.419" dur="4.201">always evaluate to true no matter what</text><text start="285.18" dur="3.78">we put in let&amp;#39;s try it out this first</text><text start="286.62" dur="3.54">payload is what&amp;#39;s known as an or payload</text><text start="288.96" dur="3">and it&amp;#39;s going to look something like</text><text start="290.16" dur="3.42">this in our username field right here</text><text start="291.96" dur="3.9">I&amp;#39;ll do our opening quote I&amp;#39;ll do a</text><text start="293.58" dur="3.96">space and I&amp;#39;ll type in or and I&amp;#39;ll do</text><text start="295.86" dur="4.86">another string I&amp;#39;ll do one as a string</text><text start="297.54" dur="4.5">one equals and another string one now</text><text start="300.72" dur="3.539">obviously something cool is happening</text><text start="302.04" dur="5.099">here but what are we doing why are we</text><text start="304.259" dur="5.101">doing this two reasons first notice that</text><text start="307.139" dur="3.721">we added some more SQL code in there by</text><text start="309.36" dur="3.6">breaking out of the string with our</text><text start="310.86" dur="4.8">extra quote we were able to add some</text><text start="312.96" dur="5.22">extra SQL query language stuff here</text><text start="315.66" dur="5.88">and here&amp;#39;s a fun fact about how SQL will</text><text start="318.18" dur="5.4">process The Operators like and and or</text><text start="321.54" dur="3.54">and and or</text><text start="323.58" dur="2.7">um that&amp;#39;s confusing when evaluating a</text><text start="325.08" dur="3.54">statement like this to see if it&amp;#39;s going</text><text start="326.28" dur="4.919">to be true or false it will first do the</text><text start="328.62" dur="4.859">ant that&amp;#39;s the Precedence and first and</text><text start="331.199" dur="3.901">then after that or so now when we try to</text><text start="333.479" dur="3.121">log in here&amp;#39;s how it will process this</text><text start="335.1" dur="3.78">logic and this will all make sense right</text><text start="336.6" dur="5.819">here it will first say hey does username</text><text start="338.88" dur="6.78">equal admin and password equal password</text><text start="342.419" dur="5.161">one two three does it well no so false</text><text start="345.66" dur="3.66">but it&amp;#39;s not done yet because we added</text><text start="347.58" dur="4.26">something extra and this is the hack</text><text start="349.32" dur="6.54">then it will say this but does the</text><text start="351.84" dur="5.699">username equal admin or one equal one</text><text start="355.86" dur="4.86">let me ask you a question</text><text start="357.539" dur="5.401">does uh does one equal one duh yeah</text><text start="360.72" dur="4.56">right well it will one always equal one</text><text start="362.94" dur="4.08">yes and that&amp;#39;s why we added this</text><text start="365.28" dur="3.66">nonsensical statement here this</text><text start="367.02" dur="5.459">statement will always evaluate to true</text><text start="368.94" dur="5.34">because no matter what one equals one so</text><text start="372.479" dur="3.421">we added some extra arguments and extra</text><text start="374.28" dur="3.54">operators saying hey does one equal one</text><text start="375.9" dur="3.42">then it&amp;#39;s true</text><text start="377.82" dur="3.18">and that&amp;#39;s the hack here when it comes</text><text start="379.32" dur="3.24">to evaluate our or statement it&amp;#39;ll</text><text start="381" dur="4.38">always be true let&amp;#39;s try it out let&amp;#39;s</text><text start="382.56" dur="4.8">click log in well dang it it didn&amp;#39;t work</text><text start="385.38" dur="3.48">but why it&amp;#39;s actually pretty easy watch</text><text start="387.36" dur="2.76">this let&amp;#39;s take a closer look at do you</text><text start="388.86" dur="3.36">notice anything weird about our query</text><text start="390.12" dur="3.419">here&amp;#39;s a hint count the strings let&amp;#39;s go</text><text start="392.22" dur="4.08">string here because we have two quotes</text><text start="393.539" dur="6.061">we have a string here two quotes now a</text><text start="396.3" dur="4.739">string here two quotes well there&amp;#39;s an</text><text start="399.6" dur="3.12">extra quote and that&amp;#39;s why we got that</text><text start="401.039" dur="3.72">syntax error so let&amp;#39;s fix that it&amp;#39;s</text><text start="402.72" dur="3.36">actually not too bad just right here it</text><text start="404.759" dur="2.461">seems like we have an extra quote at the</text><text start="406.08" dur="3.059">end so let&amp;#39;s</text><text start="407.22" dur="3.72">take that one off the end so now with</text><text start="409.139" dur="3.721">our syntax looking nice and clean all</text><text start="410.94" dur="5.099">complete strings no errors let&amp;#39;s try to</text><text start="412.86" dur="5.94">log in log in and we did it we got in we</text><text start="416.039" dur="4.861">successfully injected SQL query code by</text><text start="418.8" dur="4.14">tricking the login prompt that&amp;#39;s pretty</text><text start="420.9" dur="3.6">nuts right here&amp;#39;s a bonus question your</text><text start="422.94" dur="3.06">homework what if we didn&amp;#39;t know the</text><text start="424.5" dur="3.12">username what if the username was an</text><text start="426" dur="3.12">admin would this still work comment</text><text start="427.62" dur="3.6">below how would you do it now using</text><text start="429.12" dur="3.84">payloads like ore to subvert the logic</text><text start="431.22" dur="3.24">of this query I like it but it&amp;#39;s</text><text start="432.96" dur="3.12">complicated there&amp;#39;s another way we can</text><text start="434.46" dur="4.019">do it and this way is kind of scary</text><text start="436.08" dur="4.92">powerful watch this because instead of</text><text start="438.479" dur="4.62">using or to like mess the logic we&amp;#39;re</text><text start="441" dur="3.599">going to add a simple comment when</text><text start="443.099" dur="3.72">you&amp;#39;re writing code whether it&amp;#39;s python</text><text start="444.599" dur="4.141">or SQL things can get kind of complex so</text><text start="446.819" dur="3.301">you often want to make a comment about</text><text start="448.74" dur="3.179">what you&amp;#39;re doing with it so when people</text><text start="450.12" dur="3.12">look at your code they&amp;#39;re not like what</text><text start="451.919" dur="3">you can kind of tell them why you&amp;#39;re</text><text start="453.24" dur="3.54">crazy so you&amp;#39;ll use a special character</text><text start="454.919" dur="2.941">like the pound sign or in my sequel&amp;#39;s</text><text start="456.78" dur="4.319">case which is what we&amp;#39;re using right now</text><text start="457.86" dur="4.739">you&amp;#39;ll have two dashes and a space and</text><text start="461.099" dur="3.121">whatever comes after that no matter what</text><text start="462.599" dur="3.061">it is will be ignored it won&amp;#39;t be</text><text start="464.22" dur="3.539">processed so what do you say we use this</text><text start="465.66" dur="3.96">good thing for a bad thing</text><text start="467.759" dur="3.66">we&amp;#39;re gonna turn a comment into a hack</text><text start="469.62" dur="3.06">and watch how simple this is here in our</text><text start="471.419" dur="2.881">username field we&amp;#39;ll break out of our</text><text start="472.68" dur="4.019">string once more with an opening quote</text><text start="474.3" dur="5.1">and then we&amp;#39;ll simply do two dashes and</text><text start="476.699" dur="4.261">a space notice what it did to our query</text><text start="479.4" dur="3.84">let me blow it up real quick right after</text><text start="480.96" dur="4.44">username equals admin we have a</text><text start="483.24" dur="4.739">character for comment and SQL telling it</text><text start="485.4" dur="4.799">to ignore the rest of the code so where</text><text start="487.979" dur="4.921">before it said the username whatever it</text><text start="490.199" dur="5.641">is and the password whatever it is has</text><text start="492.9" dur="5.94">to be in the database now the statement</text><text start="495.84" dur="5.579">is simply hey is the username admin cool</text><text start="498.84" dur="4.44">come on in no password needed and that&amp;#39;s</text><text start="501.419" dur="4.021">what&amp;#39;s happening it&amp;#39;s ignoring the rest</text><text start="503.28" dur="4.74">of the the statement and when we try to</text><text start="505.44" dur="4.259">log in we&amp;#39;re in login successful so</text><text start="508.02" dur="4.139">here&amp;#39;s your homework I want you to break</text><text start="509.699" dur="4.501">into El Toro Mutual the link is below</text><text start="512.159" dur="3.481">can you break into this website with</text><text start="514.2" dur="2.639">what you learned in this video try it</text><text start="515.64" dur="2.579">out and let me know in the comments if</text><text start="516.839" dur="3.481">you actually do it I would love to hear</text><text start="518.219" dur="4.38">that you did this it&amp;#39;s kind of fun right</text><text start="520.32" dur="3.899">now I will say this this is basic SQL</text><text start="522.599" dur="4.021">injection it&amp;#39;s often more complicated</text><text start="524.219" dur="4.321">and a lot crazier and again while it is</text><text start="526.62" dur="3.48">an old hacking type technique has been</text><text start="528.54" dur="3.06">around for a long time it&amp;#39;s still ranks</text><text start="530.1" dur="3.299">number three in the top list it&amp;#39;s still</text><text start="531.6" dur="4.08">crazy dangerous and the reason is</text><text start="533.399" dur="4.44">because companies are lazy or the</text><text start="535.68" dur="4.26">company has coders that are lazy and</text><text start="537.839" dur="3.841">they may not even know what to look for</text><text start="539.94" dur="3.72">as far as SQL injection because SQL</text><text start="541.68" dur="3.3">injections can be avoided pretty easily</text><text start="543.66" dur="3.42">I&amp;#39;ll have some links below but some</text><text start="544.98" dur="3.96">things you can do are hey use prepared</text><text start="547.08" dur="4.259">statements with parameter I can&amp;#39;t say</text><text start="548.94" dur="4.62">that parameterized queries use an allow</text><text start="551.339" dur="4.141">list for input validation Escape user</text><text start="553.56" dur="3.959">input before putting it into a query so</text><text start="555.48" dur="4.32">what we tried here in this video that</text><text start="557.519" dur="3.841">would definitely stop it and use stored</text><text start="559.8" dur="2.82">procedures I will not go into detail on</text><text start="561.36" dur="2.76">all those and frankly I don&amp;#39;t know how</text><text start="562.62" dur="2.88">to do any of that so check the link</text><text start="564.12" dur="5.1">below and you can learn more if you&amp;#39;re</text><text start="565.5" dur="5.279">developing you&amp;#39;re like oh rap do am I am</text><text start="569.22" dur="2.82">I vulnerable you should probably just</text><text start="570.779" dur="2.461">double check that real quick just to</text><text start="572.04" dur="3">make sure if you think you&amp;#39;re safe</text><text start="573.24" dur="3.9">you&amp;#39;re not now where do you go from here</text><text start="575.04" dur="3.72">now again what we did here was basic but</text><text start="577.14" dur="3.66">there are a lot more payloads like on</text><text start="578.76" dur="3.24">here if you look at payloads all the</text><text start="580.8" dur="2.82">things look at all the different</text><text start="582" dur="2.94">payloads you could possibly try for a</text><text start="583.62" dur="3.42">website and also there are different</text><text start="584.94" dur="4.26">types of SQL injection like now we just</text><text start="587.04" dur="3.9">did in band error-based SQL injection</text><text start="589.2" dur="3.42">which is the easiest to most common but</text><text start="590.94" dur="3.06">there&amp;#39;s Union based there&amp;#39;s blind SQL</text><text start="592.62" dur="3.48">injection there&amp;#39;s all kinds of things</text><text start="594" dur="4.08">and I&amp;#39;m hoping that this video gave you</text><text start="596.1" dur="4.38">a taste for how cool SQL injection is</text><text start="598.08" dur="4.319">and you can go off and learn a lot more</text><text start="600.48" dur="3.72">dive deeper get lost in it which Union</text><text start="602.399" dur="3.241">based queries are crazy because you can</text><text start="604.2" dur="3.12">add additional skill queries on top of</text><text start="605.64" dur="3.66">what&amp;#39;s already there and possibly dump</text><text start="607.32" dur="3.48">all the information from a table or just</text><text start="609.3" dur="3">drop the table and watch the world burn</text><text start="610.8" dur="3.68">anyways that&amp;#39;s all I got catch you guys</text><text start="612.3" dur="2.18">later</text></transcript>