Python 3 Programming Tutorial - Sockets simple port scanner

preview_player
Показать описание
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.

Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Рекомендации по теме
Комментарии
Автор

def pscan(port):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)# I put newly
s.connect((server, port))
return True
except:
return False

This code worked for me properly.

Your Python tutorials are very nice and interesting for me!!
I'll do your Python tutorials and contents of your website. Thank you!

jyxxrsu
Автор

I want to ask for help....I need to make a program with Python program that should test the given host and it should generate a list of

all the TCP Open ports within the range of 1 to 1025. You are required to accomplish this task by using

standard Python’s “socket” library. Following are the functional requirements:

1. On execution of program system should prompt “Enter a host to scan”. User will provide a host

name

2. System should look for all the ports between the range of 1 to 1025

3. If the Ports is open it should create a file and add an entry for port number

4. In case of any exception for instance “host is not available”, “host name could not be resolved” or

due to any other error you need to write that exception into same file

5. You also need to record starting and ending date and time at the beginning and ending of file

accordingly. It should also show the total time it took in port scanning process

rafy-ivanmorales
Автор

FYI, if you want to use this on local computer, use 127.0.0.1. it runs really really fast also. :-)

normanlove
Автор

your teaching style is really simple to understand. you have a gift. thanks for creating these.

relikpL
Автор

you actually made a program like nmap...cool

assasin
Автор

"if pscan(x):" is the same as "if pscan(x) == True:" right? Just the implicit form?

ThisGuyDakota
Автор

Could you please add an episode number to these videos? I was having a hard time finding the correct order due to the lack of episode numbers combined with the fact that they're not in a playlist. Other than that, awesome work on this series!

Nick-tvpu
Автор

nice i love ur videos desde Ecuador gracias !!!

TheSldsnake
Автор

+sentdex, code has a little problem, once you got a socket connection, the following port connection is blocked, so after you scanned port 22, the following ports scanning are aborted (Transport endpoint is already connected). if you print the exception, looks like this:

Scanning 50
[Errno 111] Connection refused
Scanning 51
[Errno 111] Connection refused
Scanning 52
[Errno 111] Connection refused
Scanning 53
Port 53 is Open
Scanning 54
[Errno 106] Transport endpoint is already connected
Scanning 55
[Errno 106] Transport endpoint is already connected
Scanning 56
[Errno 106] Transport endpoint is already connected
Scanning 57
[Errno 106] Transport endpoint is already connected
Scanning 58
[Errno 106] Transport endpoint is already connected

duchenpaul
Автор

Hello sir. Can you tell me how to get port address without using the range() function? I want to find my computer's port address.

md.ruhenhossainbhuiyan
Автор

Can anyone let me know that.. I have one problem...my boss told me to find the com ports which are accessible an inaccessible so can we use socket for serial com port scanning?

omkardumbre
Автор

the in range does not work for me. When I scan a specific port it's working but not in range. Can somebody help me?

komediwata
Автор

Hi, does someone knows how can we manipulate any field from a frame ? I supposed in this video, the scan uses a tcp handshake to create a session.How can we manipulate any field from a frame for having a more control of the transmitted packets.

darnaxux
Автор

For some reason, if my programme finds an open port, it doesn't check more ports. It behaves like this

Port 22 is open
(doesn't check any more. Even if port 80 is open as well. It says port 80 is closed)

okletsbegin
Автор

How would i make it support persistent connections and also how do i Send large files using chunked transfers?

di_nerd_apps
Автор

Very nice!

( I just noticed you should not write http:// but go straight to the address. )

RealMcDudu
Автор

My firewall asks if I want certain ports open, even if I turn it off, any idea how to bypass this problem?

levpavlov
Автор

What does a server have anything to do with the ports I have open? Why do I need to have a server?
Thanks

KittenCorner
Автор

Is there a way by which i can do NAT Port forwarding using python.

amitnair
Автор

can I make it a random server connection like a servers scan something like that ?

warlord
visit shbcf.ru