Created
April 21, 2011 15:11
-
-
Save hmert/934734 to your computer and use it in GitHub Desktop.
python port scanner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from socket import * | |
if __name__ == '__main__': | |
target = raw_input('IP: ') | |
targetIP = gethostbyname(target) | |
#scan reserved ports | |
for i in range(20, 1025): | |
s = socket(AF_INET, SOCK_STREAM) | |
result = s.connect_ex((targetIP, i)) | |
if(result == 0) : | |
print 'Port %d:' % (i,) | |
s.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#./scanner.py | |
Enter host to scan: localhost | |
Starting scan on host 192.168.1.1 | |
Port 80: OPEN | |
Port 445: OPEN |
@anejck007, that is a python2 programming, you should put print ("Port %d: ") % (i,), or ('port %d: "), hope i was helful <3
print('Hello World')
example
or in python2 - print 'hello, world'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi, im new to programming so i was wondering how to fix this syntax error