PortScan | multithreading command line port scan utility , pip package | TCP library
kandi X-RAY | PortScan Summary
kandi X-RAY | PortScan Summary
PortScan is a light-weight command line utility that allows user to conduct scanning over a range of IP addresses and port ranges with multi-threading. Install: pip install portscan. Upgrade: pip install portscan --upgrade. Usage: portscan [192.168.1.0/24] [-p 22,80-200 [-t 100 [-w 1 [-e]]]]. By default the command checks for your Local Area Network IP first, and then initiate a block wise search. specify IP if you want to search any other IP blocks. Note: This is not available before 0.2.1, please update or specify IP if you're using 0.2.0 and older. Use -w [float] to change timeout settings from default of 3 seconds: for LAN, this can be as low as 0.1. 1 is usually good enough for continental level connection. To show more potential connection, use -e, this will show you all ports that are not timed out.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Work out worker threads
- Ping a port
- Start the worker thread
- Get local IP address
PortScan Key Features
PortScan Examples and Code Snippets
192.168.1.0 # single IP
192.168.1.0/24 # A 24 block, from 192.168.1.0 to 192.168.1.255
[192.168.1.0/24,8.8.8.8] # The aforementioned 24 block and 8.8.8.8.
"[192.168.1.0/24, 8.8.8.8]" # if you want to use space in the command, wrap in quotes.
sock.connect_ex((ip, port))
import socket
import concurrent.futures
def _scan(params):
ip, port = params
scanner = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
scanner.settimeout(1)
try:
scanner.connect((ip, port))
scanner.close(
mode = int(input(" Press 1 for reserved ports \n Press 2 for all ports \n Press 3 for Critical ports \n Press 4 for manual ports \n"))
mode = input(" Press 1 for reserved ports \n Press 2 for all ports \n Press 3 f
WiFi.mode(WIFI_STA); // this line was missing in main.c of Esp
WiFi.begin(ssid, password)
try:
for port in range(1, 1024):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(10) #timeout set for wait up 10 seconds.
result = sock.connect_ex((serverIP, port))
sock.settimeo
sum = lambda x, y : x + y
sum(3,4) #Returns 7
def sum(x,y):
return x + y
sum(3,4) #Returns 7
Community Discussions
Trending Discussions on PortScan
QUESTION
I'm new in python And I have a problem that I haven't been able to solve for a couple of days and I don't understand what the error is at all. I am writing a program based on the Nmap program and the library of the same name, the functionality of which is to scan open ports of some list of ip addresses. I'm trying to implement this through a dictionary, when I did everything on a static variable of ports, everything was fine, but when the program scans ports for each address, such an error is issued on the second iteration of the scan cycle.
...ANSWER
Answered 2022-Mar-24 at 20:08The unmodified scan_command
method returns an xml.etree.ElementTree.Element object representing an XML tree that looks like this:
QUESTION
I got a notification from my kaspersky antivirus on my windows 10 (which is always on) Apparently, there was a port scan and it was blocked.
...ANSWER
Answered 2022-Jan-20 at 11:07So from what i understand of what you published, 104.152.52.xxx
made a scan. What's odd is how could he effectively reach your machine at 192.168.0.10
, so i believe you have port forwarding enabled on your router. *-{see edit}
I also assume that the IP address of your VM is bind directly to your home network 192.168.0.0\24
(and not in a sub network on Windows 10). So your router should be accessible at 192.168.0.1
(or 192.168.0.254
sometimes)
Consequences of a scan ?
- most likely, none, except if you have some port opens, kaspersky blocked the 1701, but probably other ports have been scanned. So verify the configuration of your router
Is it normal ?
- Yes. Every device accessible from internet is constantly scanned. Always.
What to do next ?
- Make sure no port-forwarding is enabled on your router
- If port forwarding is enable, and needed. Make sure the software behind it is secured and up to date. if you have a password access, the password should be strong. If you have an SSH server, deactivate the authentication by password and activate the authentication by public key.
== EDIT ==
Other possibility than port forwarding and seems to be the answer:
If the VM is in a DMZ, then all unassigned ports on the router may be (depends on the router) redirected to the VM, therefore, a scan on the public ip address, would result on a scan on the VM.
QUESTION
I am trying to fit my data using my feature selection but whenever I try I get this error
...ANSWER
Answered 2021-Nov-29 at 22:40This might not be the answer you want to hear, but it has some validity.
A good practice when trying to do almost any type of training or data analysis is to first clean the data. One of those steps can include removing or treating 'Nan', 'infinity', or otherwise out-of-place outliers.
There is a multitude of ways to do this, but for your case, I would suggest doing all of these to start with:
- Remove rows with Nan values.
- Remove rows with infinity values.
- Move all values so that they are within the float64 data size, or remove rows that contain numbers outside of the float64 data size.
- Remove columns that have an excessively large range.
Here is a function I use often to first inspect data for cleaning.
QUESTION
I have this code:
...ANSWER
Answered 2021-Sep-09 at 11:58Is this giving you what you want?
QUESTION
I am trying to do the port scanner from the Violent Python and I ran into following problem. This post will be similar to this post ("https://stackoverflow.com/questions/17807992/violent-python-port-inputs-not-being-seperated") but it is a different problem. I want to run multiple port like this
python PortScanner.py -H www.google.com -p 21, 22, 80
but it scanned only the initial first port (21) then exited the program So I want to know how can I fix this code to run multiple ports.
Note: It also said that args in (option, args) = parser.parse_args()
is not accessible by Pylance so is it concern to it or how can I fix it as well.
ANSWER
Answered 2021-Aug-21 at 13:08I managed to solve the problem by changing the type of tgtPort from int
to string
and use quote as following at the command line python PortScanner.py -H www.google.com -p "21, 22, 80"
.
QUESTION
so first thing there is no error in the code but the problem is I thought that it would be fast but it took same time without multiprocessing So is there a way to make it faster? so I tried multiprocessing and threading together but cant see a goodd result this is a port scanner tool that I am trying to make fast and also thanks in advance.
...ANSWER
Answered 2021-Aug-10 at 07:01Note, multiprocessing is used for CPU heavy computations where multi-threading is used (often) for I/O bound tasks i.e when fetching data from a database etc.
To be honest, I don't know what your code is doing, but it seems it does a lot of non-CPU-heavy scans/stuff thus I might just stick to multi-threading
QUESTION
I'm creating a program that can do two things, it will calculate a range of odd number IP addresses or scan an IP address for open ports.
I have having issues with the code on lines 58 to 73. The issue is the end user must input thier choice twice before the program registers the choice, i only want the end user to input their choice once
for example:
- the program asks the user if they wish to calculate a network IP address, or scan ports.
- the user enters their choice
3. the program, then asks AGAIN for the user to enter their choice #this is this issue
4.the user enters their choice AGAIN
- the program runs.
I want the program to only ask the user to enter their choice once, then run the program.
full code, issues on lines 58-73
...ANSWER
Answered 2021-Feb-02 at 00:03So this should be fairly obvious. In your code on line 58 you ask for input and then you run a while
loop which also includes and input
statement:
QUESTION
It's been a while since I used python (been studying CISCO IOS) so I'm bit rusty. I have forgotten how to assign a function to an IF statement.
...ANSWER
Answered 2021-Jan-29 at 04:38Replacing str(network)
with "network"
and str(port)
with "port"
should work.
QUESTION
I know there are similar questions to my question, still can't find the solution to my specific case.
I'm trying to program a portscanner in python:
...ANSWER
Answered 2021-Jan-20 at 21:54Reverse the order of your arguments.
QUESTION
I'm trying to write a basic JSON interpreter in PowerShell for a scheduled external port scanner which outputs open ports via JSON, but I'm having a lot of trouble getting it to display the data as a comma separated string. The reason for the comma separated string is so that it can be passed to my documentation tool to make notes of client networks.
My PHP Code (working fine, just for reference):
...ANSWER
Answered 2020-Nov-06 at 22:54# Invoke-RestMethod automatically parses the JSON result into
# a [pscustomobject] graph.
# In a manner of speaking, *ConvertFrom-Json is built in*.
$Results = Invoke-RestMethod -Uri "https://mywebsite.com/portscan.php"
# Get the objects representing open ports.
# Note: `Where-Object Status -eq open` is the equivalent of:
# `Where-Object { $_.Status -eq 'open' }`
$OpenPorts = $Results | Where-Object Status -eq open
# Synthesize the output string.
$Message = "Open ports = " + ($OpenPorts.Port -join ', ')
# Output (echo) it.
# Output that isn't redirected or captured is *implicitly* echoed in PowerShell.
$Message
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install PortScan
You can use PortScan like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page