You are assigning a string to IP
:
try:
IP = gethostbyname(target)
print(IP) #trace
but you are also trying to use the scapy
IP()
object:
fin_scan_resp = sr1(IP(dst=dst_ip)/TCP(dport=dst_port,flags="F"),timeout=10)
The string masks the object. Rename the string to ip
(lowercase), everywhere in the portScan()
function:
try:
ip = gethostbyname(target)
print(ip) #trace
# ...
#for port in range(20, 25):
isopen = tcpconn.connect_ex((ip, port))
# ...
elif type == 4:
dst_ip = ip
Instead of the rather ridiculous line:
if (str(type(fin_scan_resp))=="<type 'NoneType'>"):
use:
if fin_scan_resp is None:
although you really should not use type
as a local variable as it masks the built-in function.