Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Simple Port Scanner -Python-

Hey Everyone Decided to Release a very easy Port Scanner
Code
from socket import *
import os

if os.name == 'nt':
    os.system('cls')
else:
    os.system('clear')

#it is Very Slow So don't Think it doesn't work
print "Simple Port Scanner"


if __name__ == '__main__':
    targetserver = raw_input('Enter host to scan: ')
    targetIP = gethostbyname(targetserver)
    print 'Ready to scan Host ', targetIP

    #scan reserved ports
    for i in range(1, 1025):
        s = socket(AF_INET, SOCK_STREAM)

        result = s.connect_ex((targetIP, i))

        if(result == 0) :
            print 'Port %d: OPEN' % (i,)
        s.close()

print "Scanning Done"
Enjoy 👍 🎉
(Jan 24, 2017 08:57 PM)Goombis Wrote:   Hey Everyone Decided to Release a very easy Port Scanner
Code
from socket import *
import os

if os.name == 'nt':
    os.system('cls')
else:
    os.system('clear')

#it is Very Slow So don't Think it doesn't work
print "Simple Port Scanner"


if __name__ == '__main__':
    targetserver = raw_input('Enter host to scan: ')
    targetIP = gethostbyname(targetserver)
    print 'Ready to scan Host ', targetIP

    #scan reserved ports
    for i in range(1, 1025):
        s = socket(AF_INET, SOCK_STREAM)

        result = s.connect_ex((targetIP, i))

        if(result == 0) :
            print 'Port %d: OPEN' % (i,)
        s.close()

print "Scanning Done"
Enjoy 👍 🎉

But who wants beginner scanning script when we haz nmap?
(Jan 24, 2017 09:25 PM)captainspalding Wrote:  But who wants beginner scanning script when we haz nmap?

its more directed to people new to python and away from pre made scripts etc.
Nice Gesture!

Would be cool if you could do some explaining or so along with what you've done, granted you have the time, etc.
It'd really help out the beginners.

Nevertheless,
Good Contribution :)

Cheers,
Crypto Investors -->> /pumpgroup]Check this out!
(Jan 24, 2017 11:45 PM)null™ Wrote:  Nice Gesture!

Would be cool if you could do some explaining or so along with what you've done, granted you have the time, etc.
It'd really help out the beginners.

Nevertheless,
Good Contribution :)

Cheers,
im pretty new here myself and trying to get better but that'd make sense and i apologize ! will do that from now on
😉
Code
from socket import *
check_port = lambda ip, port_start, port_max: [[socket(AF_INET, SOCK_STREAM).connect_ex((ip, port)), port] for port in range(port_start, port_max+1)]

Checked on 127.0.0.1 and Python27, apparently SMB was open because it returned a 0 instead of a 10061; regardless most of your code can be just simplified to one line -- but kudos for trying :)
Contact for professional programming services.
unazed#5906
(Jan 25, 2017 02:14 PM)Infamia Wrote:  
Code
from socket import *
check_port = lambda ip, port_start, port_max: [[socket(AF_INET, SOCK_STREAM).connect_ex((ip, port)), port] for port in range(port_start, port_max+1)]

Checked on 127.0.0.1 and Python27, apparently SMB was open because it returned a 0 instead of a 10061; regardless most of your code can be just simplified to one line -- but kudos for trying :)
well like i said this thread is to help newer people to python :)
How about making it scan a list of known ports first?


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Bass_ReevesAug 20, 2023 01:44 AM 9 632 Aug 20, 2023 01:44 AM
Last Post: Lucky4L
[Python] by x1n5h3nNov 11, 2019 11:37 AM 8 208 Nov 11, 2019 11:37 AM
Last Post: x1n5h3n
[C#] by basisJun 1, 2018 05:59 AM 9 791 Jun 1, 2018 05:59 AM
Last Post: Dalvik