Reputation: 132
I am learning hacking from this tutorial on youtube. Around 1:11:30 (timestamp), he tries to check for open ports on the ip of his own router and on http://testphp.vulnweb.com. He gets 4 ports as open for each. When I run my code I only get port 80 open on my router and none on http://testphp.vulnweb.com.
This is my Code:
import socket
from IPy import IP
def check_ip(address):
try:
IP(address)
return address
except ValueError:
return socket.gethostbyname(address)
def scan(target):
ip_address = check_ip(target)
print(f"\n[-_0 Scanning Target] {str(target)}")
for port in range(1, 100):
scan_port(ip_address, port)
def scan_port(ipaddress_, port_):
try:
sock = socket.socket()
sock.settimeout(0.5)
sock.connect((ipaddress_, port_))
print(f'[+] Port {str(port_)} is open')
except:
pass
targets = input("[+] Enter Target(s) to scan (split multiple targets with , ): ")
if ',' in targets:
for target in targets.split(','):
scan(target.strip(' '))
else:
scan(targets)
And this is the output:
[+] Enter Target(s) to scan (split multiple targets with , ): 192.168.1.1 , testphp.vulnweb.com
[-_0 Scanning Target] 192.168.1.1
[+] Port 80 is open
[-_0 Scanning Target] testphp.vulnweb.com
So, where am I going wrong? Is it a problem with my connection? my code? or is this normal, and if it is then why is the guy on youtube getting a different result?
Any help is greatly appreciated!
Upvotes: 1
Views: 833