<?xml version="1.0" encoding="utf-8" ?><transcript><text start="0" dur="2.88">SQL inj? No, no, no.</text><text start="9.28" dur="2.92">Let&amp;#39;s use a SQL injection
to hack into a website.</text><text start="12.2" dur="4.48">Here is our Target Al Toro Mutual and
online banking site that is totally real.</text><text start="16.68" dur="3.72">We&amp;#39;re going to use a SQL injection to
hack into this website and gain admin</text><text start="20.4" dur="2.56">privileges. You&amp;#39;ll be able to hack
this website in like 30 seconds.</text><text start="27.1" dur="0.42">Now,</text><text start="27.52" dur="4">one of the scariest uses of SQL injection
is that bad actors can use a simple</text><text start="31.52" dur="4">login form like this to dump a database
of user names and passwords and then put</text><text start="35.52" dur="2.8">them on the dark web with a for sale
sign and you&amp;#39;ll never know about it.</text><text start="38.32" dur="3.24">Nothing you can do. Well, actually,
you could probably try dalan,</text><text start="41.56" dur="0.96">the sponsor of this video.</text><text start="43.07" dur="3.45">Dashlane will actually monitor the
dark web and see if your usernames and</text><text start="46.68" dur="3.52">passwords are for sale. And if they are,
they will alert you. And I have a lot.</text><text start="50.63" dur="1.89">I need to fix that. And then using dalan,</text><text start="52.52" dur="2.44">you can generate a completely
random password, unique,</text><text start="54.96" dur="1.84">different from your
other passwords, right?</text><text start="56.8" dur="2.84">You don&amp;#39;t use the same password
for every website, do you? Anyways?</text><text start="59.64" dur="1.56">And Dalan will store for you.</text><text start="61.2" dur="2.52">And this right here is definitely
my favorite feature of Dashlane.</text><text start="63.72" dur="3.76">They&amp;#39;ll do passwords and they&amp;#39;ll also do
multifactor authentication right there</text><text start="67.48" dur="3.12">in a stinking app. I love that.
So all your stuff is in one place,</text><text start="70.6" dur="3.04">keeping you safe and making it a
bit more simple to log into sites.</text><text start="73.71" dur="3.45">I use Dashlane personally for
everything and also for my business.</text><text start="77.16" dur="0.72">And check this out,</text><text start="77.88" dur="3.24">I get an admin console giving me
a dashboard of all my employees,</text><text start="81.28" dur="0.76">password health scores,</text><text start="82.04" dur="3.32">and it&amp;#39;ll tell me whose passwords are
compromised so I can basically force my</text><text start="85.56" dur="2.8">employees to be secure, which you have
to do that. They&amp;#39;re not gonna listen.</text><text start="88.36" dur="2.92">So start securing your passwords
for free right now. Check it out.</text><text start="91.28" dur="3.44">Link below dashlane.com/network.
Chuck 50, use the code network,</text><text start="94.72" dur="1.72">Chuck 50 and you&amp;#39;ll get 50% off.</text><text start="96.44" dur="3.88">And did I mention you can secure your
passwords everywhere? Phone, tablet,</text><text start="101.32" dur="2.52">computer. Yeah, it&amp;#39;s awesome.
So again, here&amp;#39;s the website.</text><text start="103.84" dur="2.8">It&amp;#39;s a simple login form and
we won&amp;#39;t need any fancy tools.</text><text start="106.66" dur="4.74">All we&amp;#39;ll need is a keyboard
and some coffee. Chuck.coffee.</text><text start="111.4" dur="3.52">Now our goal with this login form is to
use it in a way that will give us access</text><text start="114.92" dur="2.84">to the underlying database. When
you try to log into this website,</text><text start="117.76" dur="2.04">or really any website when you hit enter,</text><text start="119.8" dur="3.96">the website will connect to a database
and run a search to see if your username</text><text start="123.76" dur="4.56">and password exist on the database. If
they do, you&amp;#39;re in log in successful.</text><text start="128.32" dur="2.8">So here is where a SQL injection
comes in, and it&amp;#39;s kind of crazy.</text><text start="131.17" dur="2.67">We know that a lot of websites
will do this very thing,</text><text start="133.84" dur="3.28">query a database and possibly have
a query that looks similar to this.</text><text start="137.12" dur="2.56">And this may look familiar if
you watch my previous SQL video,</text><text start="139.68" dur="2.64">we&amp;#39;ll use statements like this to
find information in a database.</text><text start="142.44" dur="3.36">But here we&amp;#39;re gonna use the beauty of
SQL against them. Now, in our scenario,</text><text start="145.8" dur="2.48">we don&amp;#39;t know the username and
passwords. So let&amp;#39;s take that out.</text><text start="148.28" dur="2.76">Now let&amp;#39;s first just brute force it.
Let&amp;#39;s guess, and maybe we&amp;#39;ll get lucky.</text><text start="151.04" dur="2.12">Now as I&amp;#39;m typing this, notice
what happens to our query.</text><text start="153.16" dur="2.84">This will be important for our next
step. The username could be admin,</text><text start="156" dur="3.8">it&amp;#39;s a popular username for administrative
accounts. And we&amp;#39;ll try the password.</text><text start="160.28" dur="4.4">Password, 1, 2, 3. Let&amp;#39;s click log
in. Oh, failed. It was worth a try,</text><text start="164.68" dur="1.44">but did you keep an eye on our statement?</text><text start="166.12" dur="3.88">Notice that whatever we typed in was
entered here in the query between single</text><text start="170" dur="3.44">quotes. Now here is why that&amp;#39;s important
and programming. And in sequel,</text><text start="173.44" dur="2.52">when you have a string of
characters between quotes,</text><text start="175.96" dur="3.56">like this can be single or double
quotes, that&amp;#39;s referred to as a string,</text><text start="179.52" dur="2.04">it&amp;#39;s a data type. So looking
at our query down here,</text><text start="181.88" dur="2.4">anything inside quotes
is going to be a string.</text><text start="184.28" dur="2.32">And everything outside
of it is a sequel query.</text><text start="186.6" dur="3.4">And we know that whatever we enter here
in the username field and the password</text><text start="190" dur="2.32">field will end up becoming
a string inside that query.</text><text start="192.5" dur="2.7">But what if we could make
it not do the &amp;lt;laugh&amp;gt;?</text><text start="195.2" dur="3.6">And this is where the hacking comes in.
What if we could send not just a string,</text><text start="198.8" dur="4.76">but some more sequel query to change?
What happens to hack? What happens?</text><text start="203.65" dur="3.47">So let&amp;#39;s try this. Let&amp;#39;s type in
our username once more geared admin.</text><text start="207.12" dur="3.92">But at the very end, we&amp;#39;re gonna
add a quote, a single quote,</text><text start="211.1" dur="3.34">and let&amp;#39;s try to log in. Okay, didn&amp;#39;t
work. We haven&amp;#39;t hacked it just yet.</text><text start="214.46" dur="0.94">But notice something.</text><text start="215.4" dur="3">And this will tell you if a website
is vulnerable to SQL injection,</text><text start="218.44" dur="2.52">that&amp;#39;s a great way to test that
and pay close attention to the air.</text><text start="220.96" dur="2.36">We have a syntax error because
if you look at our query,</text><text start="223.32" dur="3.16">did you notice what happened? We have
another quotation mark right here,</text><text start="226.71" dur="0.89">a floating quote.</text><text start="227.6" dur="3.76">And this is fantastic news for us because
the reason it got a syntax error is,</text><text start="231.36" dur="3.08">you know, a string is between two
quotes. If you only have one quote,</text><text start="234.44" dur="3.36">then it&amp;#39;s not complete. It&amp;#39;s we got a
syntax error, it&amp;#39;s like freaking out.</text><text start="237.9" dur="4.46">But now we know that we can insert
some extra stuff besides just our</text><text start="242.43" dur="3.93">string. So now that we
know this application is
vulnerable to SQL injection,</text><text start="246.68" dur="3.36">let&amp;#39;s try a few SQL injection payloads,
which is actually pretty easy.</text><text start="250.04" dur="2.48">It sounds scary, but it&amp;#39;s not too bad.
Now, before I show you the payload,</text><text start="252.52" dur="3.64">let&amp;#39;s reexamine why our first login
failed. I mean, it&amp;#39;s obvious, right?</text><text start="256.16" dur="1.92">The username and password word incorrect.</text><text start="258.08" dur="3.64">But I want you to look at the logic
of this query, this sequel statement.</text><text start="261.72" dur="4.88">What it&amp;#39;s saying is both the username
admin and the password, password 1, 2, 3,</text><text start="266.67" dur="4.05">have to exist together just like
this. If both of those are true,</text><text start="270.77" dur="3.27">it will evaluate to true and we get
a successful login. But in this case,</text><text start="274.04" dur="2.92">they&amp;#39;re not there. It&amp;#39;s a different
password. So it evaluates to false.</text><text start="277.33" dur="3.55">So now here&amp;#39;s where the magic comes
in. Here&amp;#39;s where our payload comes in.</text><text start="280.88" dur="4.36">What if we can make this sequel statement
always evaluate to true no matter what</text><text start="285.24" dur="1">we put in? Let&amp;#39;s try it out.</text><text start="286.24" dur="2.6">This first payload is what&amp;#39;s
known as an OR payload,</text><text start="288.84" dur="3.12">and it&amp;#39;s gonna look something like this.
Enter is your name field right here.</text><text start="291.96" dur="3">I&amp;#39;ll do our opening quote. I&amp;#39;ll
do a space and I&amp;#39;ll type in or,</text><text start="295.06" dur="3.58">and I&amp;#39;ll do another string. I&amp;#39;ll
do one as a string. One equals,</text><text start="298.64" dur="3.64">and another string one. Now obviously
something cool is happening here,</text><text start="302.28" dur="4">but what are we doing? Well, why are
we doing this? Two reasons. First,</text><text start="306.28" dur="4.12">notice that we added some more sequel
code in there by breaking outta the string</text><text start="310.4" dur="1">with our extra quote,</text><text start="311.61" dur="3.87">we were able to add some extra SQL
query language stuff here. Magic.</text><text start="315.48" dur="4">And here&amp;#39;s the fun fact about how
SQL will process the operators.</text><text start="319.48" dur="4.8">Like and, and or, and, and
or. Um, that&amp;#39;s confusing.</text><text start="324.28" dur="2.8">When evaluating a statement like this
to see if it&amp;#39;s gonna be true or false,</text><text start="327.08" dur="1.52">it will first do the,</text><text start="328.6" dur="4.84">and that&amp;#39;s the precedent and first and
then after that or so now when we try to</text><text start="333.44" dur="1.8">log in, here&amp;#39;s how it
will process this logic.</text><text start="335.24" dur="2.56">And this will all make sense right
here. It will first say, Hey,</text><text start="337.8" dur="4.76">does use your name equal admin
and password equal password?</text><text start="342.56" dur="2.96">1, 2, 3. Does it? Well, no. So false.</text><text start="345.66" dur="3.7">But it&amp;#39;s not done yet because we added
something extra. And this is the hack,</text><text start="349.47" dur="1.33">then it will say this.</text><text start="351.06" dur="4.82">But does the username equal
admin or one equal one?</text><text start="355.88" dur="4.76">Let me ask you a question. Does
uh, does one equal one? Duh. Yeah,</text><text start="360.64" dur="3.44">right? Will it? Will one
always equal one? Yes, &amp;lt;laugh&amp;gt;.</text><text start="364.08" dur="2.36">And that&amp;#39;s why we added this
nonsensical statement here.</text><text start="366.44" dur="4.48">This statement will always evaluate to
true because no matter what one equals</text><text start="370.92" dur="4.08">one &amp;lt;laugh&amp;gt;. So we added some extra
arguments in extra operators saying, Hey,</text><text start="375" dur="3.84">does one, oneika one? Then it&amp;#39;s true
&amp;lt;laugh&amp;gt;. And that&amp;#39;s the hack here.</text><text start="378.84" dur="2.8">When it comes to evaluate our or
statement, it&amp;#39;ll always be true.</text><text start="381.64" dur="4.4">Let&amp;#39;s try it out. Let&amp;#39;s click a log in.
Well, dang it, it didn&amp;#39;t work, but why?</text><text start="386.04" dur="2.52">It&amp;#39;s actually pretty easy. Watch
this. Let&amp;#39;s take a closer look at it.</text><text start="388.56" dur="2.12">Do you notice anything weird about
our query? Now here&amp;#39;s a hint.</text><text start="390.68" dur="2.84">Count the strings. So we have a
string here cuz we have two quotes.</text><text start="393.52" dur="4.32">We have a string here, two quotes
and a string here. Two quotes,</text><text start="397.84" dur="3.88">well &amp;lt;laugh&amp;gt;, there&amp;#39;s an extra quote
and that&amp;#39;s why we got that syntax error.</text><text start="401.73" dur="2.83">So let&amp;#39;s fix that. It&amp;#39;s actually not
too bad. &amp;lt;laugh&amp;gt; just right here.</text><text start="404.56" dur="1.64">It seems like we have an
extra quote at the end.</text><text start="406.2" dur="2.04">So let&amp;#39;s take that one off the end.</text><text start="408.25" dur="3.91">So now with our syntax looking nice and
clean, all complete strings, no errors,</text><text start="412.16" dur="3.44">let&amp;#39;s try to log in. Log in.
And we did it. We got in.</text><text start="415.6" dur="4.72">We successfully injected SQL query
code by tricking the login prompt.</text><text start="420.32" dur="3.04">That&amp;#39;s pretty nuts right? Now here&amp;#39;s
a bonus question. Your homework,</text><text start="423.36" dur="3.04">What if we didn&amp;#39;t know the username?
What if the username wasn&amp;#39;t admin?</text><text start="426.4" dur="1.56">Would this still work? Comment below.</text><text start="427.96" dur="3.52">How would you do it now using payloads
like or to sub birth the logic of this</text><text start="431.48" dur="3.16">query, I like it, but it&amp;#39;s complicated.
There&amp;#39;s another way we can do it.</text><text start="434.64" dur="1.88">And this way is kind of scary, powerful.</text><text start="436.76" dur="3.84">Watch this because instead of
using or to like mess the logic,</text><text start="440.6" dur="3.12">we&amp;#39;re gonna add a simple comment.
When you&amp;#39;re writing code,</text><text start="443.72" dur="2.96">whether it&amp;#39;s Python or sequel,
things can get kind of complex.</text><text start="446.68" dur="3">So you often want to make a comment
about what you&amp;#39;re doing with it.</text><text start="449.68" dur="2.12">So when people look at your
code, they&amp;#39;re not like what?</text><text start="451.8" dur="1.56">You can kind of tell
them why you&amp;#39;re crazy.</text><text start="453.36" dur="3.48">So you&amp;#39;ll use a special character like
the pound sign or in my sequel&amp;#39;s case,</text><text start="456.84" dur="1.04">which is what we&amp;#39;re using right now,</text><text start="457.99" dur="4.09">you&amp;#39;ll have two dashes and a space
and whatever comes after that,</text><text start="462.08" dur="2.6">no matter what it is, will be
ignored. It won&amp;#39;t be processed.</text><text start="464.68" dur="3.12">So what do you say? We use this
good thing for a bad thing, &amp;lt;laugh&amp;gt;.</text><text start="467.8" dur="3.56">We&amp;#39;re gonna turn a comment into a hack
and watch how simple this is here in our</text><text start="471.36" dur="2.72">username field. We&amp;#39;ll break out of our
string once more with an opening quote,</text><text start="474.08" dur="2.92">and then we&amp;#39;ll simply do
two dashes and a space.</text><text start="477.03" dur="3.49">Notice what it did to our query.
Let me blow it up real quick.</text><text start="480.52" dur="1.8">Right after username equals admin,</text><text start="482.32" dur="4.84">we have a character for comment and SQL
telling it to ignore the rest of the</text><text start="487.16" dur="4.56">code. So where before it
said the username, whatever
it is, and the password,</text><text start="492" dur="4.32">whatever it is, has to be in the
database. Now the statement is simply,</text><text start="496.62" dur="4.22">Hey, is the username admin cool?
Come on in, no password needed.</text><text start="500.84" dur="3.44">And that&amp;#39;s what&amp;#39;s happening. It&amp;#39;s
ignoring the rest of the the statement.</text><text start="504.34" dur="4.38">And when we try to log in, we&amp;#39;re in log
in successful. So here&amp;#39;s your homework.</text><text start="508.83" dur="3.29">I want you to break into Al
Toro Mutual. The link is below.</text><text start="512.14" dur="2.86">Can you break into this website
with what you learned in this video?</text><text start="515.06" dur="2.26">Try it out and let me know in the
comments if you actually do it.</text><text start="517.32" dur="3.28">I would love to hear that you did
this. It&amp;#39;s kind of fun right now,</text><text start="520.6" dur="2.28">I will say this. This
is basic SQL injection.</text><text start="522.88" dur="3.04">It&amp;#39;s often more complicated
and a lot crazier. And again,</text><text start="525.92" dur="3.36">while it is an old hacking technique,
it&amp;#39;s been around for a long time,</text><text start="529.28" dur="3.04">it still ranks number three in the
top list. It&amp;#39;s still crazy dangerous.</text><text start="532.38" dur="4.5">And the reason is because companies are
lazy or the company has coders that are</text><text start="536.88" dur="4.56">lazy and they may not even know what to
look for as far as SQL injection because</text><text start="541.44" dur="3.24">SQL injections can be avoided pretty
easily. I&amp;#39;ll have some links below,</text><text start="544.68" dur="3.44">but some things you can do are, hey,
use prepared statements with parameter.</text><text start="548.2" dur="4.44">Can&amp;#39;t say that parameterized queries,
use an allow list for input, validation,</text><text start="552.64" dur="2.44">escape user input before
putting it into a query.</text><text start="555.17" dur="1.51">So what we tried here in this video,</text><text start="556.91" dur="3.33">that would definitely stop
it and use store procedures.</text><text start="560.24" dur="2.88">I will not go into detail on all those
and frankly I don&amp;#39;t know how to do any of</text><text start="563.12" dur="2.8">that. So check the link below and you
can learn more. If you&amp;#39;re developing,</text><text start="565.92" dur="3.84">you&amp;#39;re like, Oh crap, do, am
I &amp;lt;laugh&amp;gt;? Am I vulnerable?</text><text start="569.86" dur="2.7">You should probably just double check
that real quick just to make sure if you</text><text start="572.56" dur="3.04">think you&amp;#39;re safe, you&amp;#39;re not. Now,
where do you go from here? Now again,</text><text start="575.6" dur="3.44">what we did here was basic, but there
are a lot more payloads like on here.</text><text start="579.25" dur="1.75">If you look at payloads, all the things,</text><text start="581.15" dur="2.81">look at all the different payloads
you could possibly try for a website.</text><text start="583.96" dur="2.08">And also there are different
types of SQL injection.</text><text start="586.04" dur="3.04">Like now we just did inand
error based SQL injection,</text><text start="589.08" dur="2.4">which is the easiest and most
common. But there&amp;#39;s union based,</text><text start="591.48" dur="2.36">there&amp;#39;s blind SQL injection,
there&amp;#39;s, it&amp;#39;s all kinds of things.</text><text start="594.06" dur="3.62">And I&amp;#39;m hoping that this video gave you
a taste for how cool sequel injection</text><text start="597.77" dur="4.27">is. And you can go off and learn a
lot more, dive deeper, get lost in it,</text><text start="602.04" dur="3.36">which union based queries are crazy cuz
you can add additional sequel queries on</text><text start="605.4" dur="3.28">top of what&amp;#39;s already there and possibly
dump all the information from a table</text><text start="608.68" dur="3">or just drop the table and watch the
world burn. Anyways, that&amp;#39;s all I got.</text><text start="611.68" dur="0.84">Get you guys later.</text></transcript>