dotfiles/scripts/fast-psweep.py
rpriven 5b6af65def
Organize scripts and clean up dotfiles
Changes:
- Added 80+ scripts with organized structure
  - payloads/ for third-party pentesting tools
  - pentesting/ for custom security scripts
  - Daily drivers remain flat for fast access
- Converted wes() function to proper script
- Removed .sh extensions from pentesting scripts
- Cleaned up aliases (removed 31 redundant lines)
- Added kanata/, build artifacts to gitignore
- Removed old fre.sh scripts and empty a.out
- Updated configs: helix, tmux, zsh, ulauncher, redshift

Security: All sensitive data excluded via gitignore
2025-11-07 14:48:21 -07:00

53 lines
1.4 KiB
Python
Executable file

import sys
import subprocess
import time
from concurrent.futures import ThreadPoolExecutor, as_completed
def ping_host(ip):
result = subprocess.run(
["ping", "-c", "1", "-W", "1", ip],
stdout=subprocess.DEVNULL
)
return ip if result.returncode == 0 else None
def ping_sweep(network_prefix, max_threads=100):
live_hosts = []
with ThreadPoolExecutor(max_workers=max_threads) as executor:
futures = [executor.submit(ping_host, f"{network_prefix}.{i}") for i in range(1, 256)]
for future in as_completed(futures):
result = future.result()
if result:
print(f"{result} is up.")
live_hosts.append(result)
return live_hosts
# ---- Entry Point ----
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python3 pingsweep.py <network_prefix>")
print("Example: python3 pingsweep.py 192.168.1")
sys.exit(1)
# Assume prefix like "192.168.1"
prefix = sys.argv[1]
timestamp = time.strftime('%Y%m%d-%H%M%S')
filename = f'{prefix}.0_24_{timestamp}.txt'
print(f"Scanning {prefix}.1 to {prefix}.255 ...")
hosts = ping_sweep(prefix)
print("\nLive hosts:")
for host in hosts:
print(host)
with open(filename, 'w') as f:
for host in hosts:
f.write(host + '\n')
print(f'Saved live hosts to {filename}')