Python 3 Programming Tutorial - Sockets simple port scanner

Python 3 Programming Tutorial - Sockets simple port scanner


In this Python 3 tutorial, we cover using our newly found knowledge on sockets to create a port scanner. It's a pretty slow scanner, but allows us to see it in practice.

Sample code for this basics series: http://pythonprogramming.net/beginner...

Python 3 Programming tutorial Playlist: http://www.youtube.com/watch?v=oVp1vr...

http://seaofbtc.com
http://sentdex.com
http://hkinsley.com
https://twitter.com/sentdex

Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Closed Caption:

everybody and welcome to the second part
of our socket tutorial series in this
video what i'm gonna be showing you guys
a simple what's known as a port scanner
basically what a port scanner is going
to do is exactly what it sounds like it
just scans ports and it tells you
whether or not the port is open and
close and generally we kind of have an
idea of what the lower ports are in
their situation is gonna be but you can
quickly find out someone's using
something like FTP or three using ssh or
whatever and obviously port 80 will be
open for like websites and stuff but you
can use this on other people's computers
or you can even use on your own computer
to find out your own vulnerabilities
naturally with this even though this
isn't very as good port scanner not
responsible for how you decide to use a
port scanner I'm just showing you how
they work basically so with that let's
go ahead and we'll keep s equals will
keep what I want to keep the poor don't
need any server IP we're going to make
this request we don't need to send any
requests and we don't need a results and
we don't need any of this
so now what we can do here is we can say
define p scan for define port scan and
we can say the parameters port then we
define what s define s . connect and
then we're going to connect server and
then to port
we've defined server up here finally
mobile actually what we'll do here is
will say try and if that works will
return a true except return false
start8 falls and so what this is asking
basically is we're going to attempt to
connect if we can connect then we'll
make a connection and it's going to
return true for us if we cannot connect
it means the port is not open and it's
going to return false for us okay
and in fact well I will leave this up
here you can put any of anything up here
you can also allow for like employed or
something I got but anyway and now we'll
do is we'll say 4x in range and will say
zero actually say 12 26 ok so this will
test port number 13 port number 25 and
then we're gonna say if peace can ex
print 4x is open so basically what we're
doing is we're passing that x value
whichever x is in this list of power
almost dropped those wounds
anyway for x in this list of one through
26 it's going to throw that value
through the port parameter of our peace
can function and it's going to test it
and then if peace can XO that what we're
asking is if true so if peace can xxxx
either it peace canít x is either
returning true or false so we can ask if
true or if false wet right so if peace
can is true
print that poor texts open otherwise we
have no else statement here so nothing
else will run so will only tell us that
port is open so let's go ahead and save
and run this python programming on that
ok and it's currently running we don't
really see anything occurring at the
moment
really who knows how long this will take
in fact let's go ahead and write a quick
else seems like one second port so
anyway port x is closed and then we'll
add some explanations make this easy
save number okay
actually we saw that port 22 is open
right away so it's just runs one last
time and support was closed for two is
closed for three is close you can see
it's very slow and you know we could run
this through 65,000 ports / thing we're
searching for so obviously this is not
the most efficient port scanner it's
pretty poor so generally what people do
is they will thread the airport scanner
so I thought it'd be kinda neat to show
you guys opportunities open to show you
guys a threaded port scanner so you can
scan multiple ports at one time so
that's the next thing I wanted to show
you guys is a quick threaded port
scanner and then we'll actually get back
on are on the path of sockets and learn
some more about sockets
so anyways stay tuned for that as always
thanks for watching thanks for all the
support subscriptions and until next
time

Video Length: 05:08
Uploaded By: sentdex
Published: 8/17/2014
View Count: 90,823

Related Software Products
Open Ports Scanner
Open Ports Scanner

Published By:
Filesland

Description:
This utility monitors open TCP and UDP ports on your PC. It brings you an enhanced functionality of a similar tool that comes with Windows operating system: netstat. Open Ports Scanner in addition to the ports information available from your operating system, allows you to map an open port to the process running on your PC. You may easily catch spyware, malware and trojans when using this tool. Just search for suspicious TCP connections. You may instantly terminate unwanted connections right ...


Related Videos
NMap 101: Scanning Networks For Open Ports To Access, HakTip 94
NMap 101: Scanning Networks For Open Ports To Access, HakTip 94

Video Length: 08:51
Uploaded By: Hak5 (4/11/2014)
View Count: 278,691

Python 3 Programming Tutorial - Threaded port scanner
Python 3 Programming Tutorial - Threaded port scanner

Video Length: 09:36
Uploaded By: sentdex (8/19/2014)
View Count: 61,693

NMAP port scanning tool
NMAP port scanning tool

Video Length: 04:02
Uploaded By: Clyne Namuo (10/11/2007)
View Count: 48,903

Netcat 101: Port Scanning in Netcat, Haktip 85
Netcat 101: Port Scanning in Netcat, Haktip 85

Video Length: 08:29
Uploaded By: Hak5 (12/20/2013)
View Count: 42,650

Visual Basic - How To Create A Port Scanner
Visual Basic - How To Create A Port Scanner

Video Length: 09:52
Uploaded By: WizzTechCommunity (5/11/2011)
View Count: 25,942

Visual Basic 2008 Port Scanner + Source Code.avi
Visual Basic 2008 Port Scanner + Source Code.avi

Video Length: 06:40
Uploaded By: hacks1001 (3/18/2010)
View Count: 25,485

Copyright © 2026, Ivertech. All rights reserved.