portune 0.1.18__tar.gz → 0.1.20__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of portune might be problematic. Click here for more details.
- {portune-0.1.18/portune.egg-info → portune-0.1.20}/PKG-INFO +2 -2
- {portune-0.1.18 → portune-0.1.20}/README.md +1 -1
- {portune-0.1.18 → portune-0.1.20}/portune/portune.py +32 -23
- {portune-0.1.18 → portune-0.1.20}/portune/version.py +2 -2
- {portune-0.1.18 → portune-0.1.20/portune.egg-info}/PKG-INFO +2 -2
- {portune-0.1.18 → portune-0.1.20}/.github/workflows/python-publish.yml +0 -0
- {portune-0.1.18 → portune-0.1.20}/.gitignore +0 -0
- {portune-0.1.18 → portune-0.1.20}/LICENSE +0 -0
- {portune-0.1.18 → portune-0.1.20}/portune/__init__.py +0 -0
- {portune-0.1.18 → portune-0.1.20}/portune.egg-info/SOURCES.txt +0 -0
- {portune-0.1.18 → portune-0.1.20}/portune.egg-info/dependency_links.txt +0 -0
- {portune-0.1.18 → portune-0.1.20}/portune.egg-info/entry_points.txt +0 -0
- {portune-0.1.18 → portune-0.1.20}/portune.egg-info/top_level.txt +0 -0
- {portune-0.1.18 → portune-0.1.20}/pyproject.toml +0 -0
- {portune-0.1.18 → portune-0.1.20}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: portune
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.20
|
|
4
4
|
Summary: Simple Python HTTP Exec Server
|
|
5
5
|
Author: Franck Jouvanceau
|
|
6
6
|
Maintainer: Franck Jouvanceau
|
|
@@ -36,7 +36,7 @@ Dynamic: license-file
|
|
|
36
36
|
[](https://shields.io/)
|
|
37
37
|
[](https://pepy.tech/project/portune)
|
|
38
38
|
[](https://shields.io/)
|
|
39
|
-
[]()
|
|
40
40
|
|
|
41
41
|
# portune
|
|
42
42
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://shields.io/)
|
|
4
4
|
[](https://pepy.tech/project/portune)
|
|
5
5
|
[](https://shields.io/)
|
|
6
|
-
[]()
|
|
7
7
|
|
|
8
8
|
# portune
|
|
9
9
|
|
|
@@ -708,7 +708,7 @@ def parse_input_file(filename: str, info_command: Optional[str] = None) -> List[
|
|
|
708
708
|
hosts.append((fqdn, sorted(ports), desc))
|
|
709
709
|
return (hosts, desc_titles)
|
|
710
710
|
|
|
711
|
-
def ping_host(ip: str, timeout:
|
|
711
|
+
def ping_host(ip: str, timeout: int = 2) -> bool:
|
|
712
712
|
"""Test if a host responds to ICMP ping.
|
|
713
713
|
|
|
714
714
|
Uses the system ping command to check host availability. The command is
|
|
@@ -729,7 +729,25 @@ def ping_host(ip: str, timeout: float = 2.0) -> bool:
|
|
|
729
729
|
except Exception:
|
|
730
730
|
return False
|
|
731
731
|
|
|
732
|
-
def
|
|
732
|
+
def is_ip(hostname: str) -> bool:
|
|
733
|
+
"""Check if a given hostname is an IP address.
|
|
734
|
+
|
|
735
|
+
Uses inet_aton to determine if the input string is a valid
|
|
736
|
+
IPv4 address.
|
|
737
|
+
|
|
738
|
+
Args:
|
|
739
|
+
hostname: The hostname or IP address to check
|
|
740
|
+
|
|
741
|
+
Returns:
|
|
742
|
+
True if the hostname is an IP address, False otherwise
|
|
743
|
+
"""
|
|
744
|
+
try:
|
|
745
|
+
socket.inet_aton(hostname)
|
|
746
|
+
return True
|
|
747
|
+
except socket.error:
|
|
748
|
+
return False
|
|
749
|
+
|
|
750
|
+
def resolve_and_ping_host(hostname: str, timeout: int = 2, noping: bool = False) -> Tuple[str, Dict[str, Union[str, bool]]]:
|
|
733
751
|
"""Resolve a hostname to IP and optionally check if it responds to ping.
|
|
734
752
|
|
|
735
753
|
Performs DNS resolution and ping check in a single function. For IP addresses,
|
|
@@ -749,25 +767,17 @@ def resolve_and_ping_host(hostname: str, timeout: float = 2.0, noping: bool = Fa
|
|
|
749
767
|
- 'hostname': Original resolved hostname (only if different from input)
|
|
750
768
|
"""
|
|
751
769
|
try:
|
|
752
|
-
# Check if hostname is already an IP address
|
|
753
|
-
try:
|
|
754
|
-
# Try to create an IP address object to validate format
|
|
755
|
-
socket.inet_aton(hostname)
|
|
756
|
-
is_ip = True
|
|
757
|
-
except socket.error:
|
|
758
|
-
is_ip = False
|
|
759
|
-
|
|
760
770
|
# If it's an IP, try to get hostname from reverse DNS
|
|
761
|
-
if is_ip:
|
|
771
|
+
if is_ip(hostname):
|
|
762
772
|
try:
|
|
763
|
-
|
|
773
|
+
ip = hostname
|
|
774
|
+
resolved_hosts = socket.gethostbyaddr(ip)
|
|
764
775
|
if resolved_hosts and resolved_hosts[0]:
|
|
765
776
|
hostname = resolved_hosts[0] # Use the resolved hostname
|
|
766
777
|
except (socket.herror, socket.gaierror):
|
|
767
778
|
pass # Keep the IP as hostname if reverse lookup fails
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
ip = socket.gethostbyname(hostname)
|
|
779
|
+
else:
|
|
780
|
+
ip = socket.gethostbyname(hostname)
|
|
771
781
|
if noping:
|
|
772
782
|
return hostname, {'ip': ip, 'ping': False}
|
|
773
783
|
ping_status = ping_host(ip, timeout)
|
|
@@ -776,7 +786,7 @@ def resolve_and_ping_host(hostname: str, timeout: float = 2.0, noping: bool = Fa
|
|
|
776
786
|
return hostname, {'ip': 'N/A', 'ping': False}
|
|
777
787
|
|
|
778
788
|
def ping_hosts(hosts: List[Tuple[str, List[int], str]],
|
|
779
|
-
timeout:
|
|
789
|
+
timeout: int = 2,
|
|
780
790
|
parallelism: int = 10,
|
|
781
791
|
noping: bool = False) -> Dict[str, Dict[str, Union[str, bool]]]:
|
|
782
792
|
"""Process DNS resolution and ping checks for multiple hosts in parallel.
|
|
@@ -839,7 +849,7 @@ def check_port(hostname: str,
|
|
|
839
849
|
port: int,
|
|
840
850
|
host_info: Dict[str, Union[str, bool]],
|
|
841
851
|
desc: list,
|
|
842
|
-
timeout:
|
|
852
|
+
timeout: int = 2) -> Tuple[str, str, int, str, bool]:
|
|
843
853
|
"""Check if a specific TCP port is accessible on a host.
|
|
844
854
|
|
|
845
855
|
Attempts to establish a TCP connection to the specified port. Uses pre-resolved
|
|
@@ -1101,12 +1111,10 @@ def compute_stats(
|
|
|
1101
1111
|
})
|
|
1102
1112
|
|
|
1103
1113
|
for hostname, ip, port, status, _, _ in results:
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
socket.inet_aton(hostname)
|
|
1107
|
-
# It's a valid IP address, use VLAN/16
|
|
1114
|
+
if is_ip(hostname):
|
|
1115
|
+
# For IP addresses, use VLAN/16 as domain
|
|
1108
1116
|
domain = '.'.join(hostname.split('.')[:2]) + '.0.0'
|
|
1109
|
-
|
|
1117
|
+
else:
|
|
1110
1118
|
# Not an IP address, extract domain normally
|
|
1111
1119
|
parts = hostname.split('.')
|
|
1112
1120
|
if len(parts) > 1:
|
|
@@ -1410,6 +1418,7 @@ def print_statistics(stats, timeout, parallelism):
|
|
|
1410
1418
|
first_row = False
|
|
1411
1419
|
if not first_row: # Only print separator between domains if domain had data
|
|
1412
1420
|
print(separator, file=sys.stderr)
|
|
1421
|
+
|
|
1413
1422
|
def format_table_output(
|
|
1414
1423
|
results: List[Tuple[str, str, int, str, bool]],
|
|
1415
1424
|
noping: bool
|
|
@@ -1482,7 +1491,7 @@ def format_table_output(
|
|
|
1482
1491
|
def main():
|
|
1483
1492
|
parser = argparse.ArgumentParser(description='Port accessibility report utility')
|
|
1484
1493
|
parser.add_argument('-p', '--parallelism', type=int, default=50, help='Number of parallel threads (default: 50)')
|
|
1485
|
-
parser.add_argument('-t', '--timeout', type=float, default=2
|
|
1494
|
+
parser.add_argument('-t', '--timeout', type=float, default=2, help='Timeout in seconds for port and ping checks (default: 2)')
|
|
1486
1495
|
parser.add_argument('-o', '--output', default=f'report_{HOSTNAME}.{time.strftime("%Y%m%d_%H%M%S")}.html', help='Output HTML report file')
|
|
1487
1496
|
parser.add_argument('-n', '--noping', action="store_true", help='No ping check')
|
|
1488
1497
|
parser.add_argument('-s', '--summary', action="store_true", help='Print scan summary information')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: portune
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.20
|
|
4
4
|
Summary: Simple Python HTTP Exec Server
|
|
5
5
|
Author: Franck Jouvanceau
|
|
6
6
|
Maintainer: Franck Jouvanceau
|
|
@@ -36,7 +36,7 @@ Dynamic: license-file
|
|
|
36
36
|
[](https://shields.io/)
|
|
37
37
|
[](https://pepy.tech/project/portune)
|
|
38
38
|
[](https://shields.io/)
|
|
39
|
-
[]()
|
|
40
40
|
|
|
41
41
|
# portune
|
|
42
42
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|