1

I have made a simple port scanner in Python (code below the question). I'm running the scanner on a virtual Kali Linux against a virtual Windows 10. I'm using VMware Workstation 15 Player with both virtual machines having bridged network adapters. All computers are on the same lan.

The problem is that it seems like the Windows Firewall is slowing down the scan and I can't figure out why. With the firewall activated each port takes minutes to scan. When I disable the firewall it scans the ports within seconds. Same behaviour when I run the scanner from my host (also Windows 10) against my virtual Windows 10.

I've been playing around with the firewall rules but haven't found anything that would let the scanning go quickly with the firewall activated.

So my question is, is there a Windows Firewall rule or something else that I can enable to make the scanning go quickly, even with the firewall activated?

Code for the scanner:

#!/usr/bin/python

import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.setdefaulttimeout(1)

host = raw_input("[*] Enter The Host To Scan: ")

def portscanner(port):
        if sock.connect_ex((host, port)):
                print ("[!!] Port %d is closed" % (port))
        else:
                print ("[+] Port %d is open" % (port))

for port in range(1,100):
        portscanner(port)
5
  • Isn't the whole question and approach a bit strange? Why would you change your firewall in order to accommodate your scanner? If you're in control of both ends you don't need a scanner?
    – Seth
    Aug 7, 2019 at 12:36
  • 1
    You are absolutely correct, it does not make much sense but that is not my intension right now. I'm making this scanner just to learn how it works and I got interested in what was happening in the firewall since it was slowing it down, and not blocking the scan completely.
    – Razze
    Aug 7, 2019 at 12:43
  • If you do have the option to monitor the connection state have a look what state it transitions into. Also you're scanning the lowest 100 ports which can be considered somewhat special. Also check which rules you actually have enabled in your Windows firewall.
    – Seth
    Aug 7, 2019 at 13:00
  • Could you explain what you mean by monitoring the connection state? I suppose that would be on the vWindows 10, but I'm not sure what you mean. As for the rules, I have everything on default settings except for "File and Printer Sharing (Echo Request - ICMPv4 -In) on Domain, Private and Public, which I've enabled.
    – Razze
    Aug 7, 2019 at 15:27
  • You're trying to establish a TCP connection and as such it can have a number of states that you should be able to see on either side. Depending on which ones you're seeing you will get some more information about what is actually happening. You might be able to view that state directly within python, netstat or a packet sniffer.
    – Seth
    Aug 8, 2019 at 9:40

0

You must log in to answer this question.

Browse other questions tagged .