Skip to content

Instantly share code, notes, and snippets.

@zAbuQasem
Created April 19, 2023 20:24
Show Gist options
  • Save zAbuQasem/be07335929beec759866dc8d4c9a68b9 to your computer and use it in GitHub Desktop.
Save zAbuQasem/be07335929beec759866dc8d4c9a68b9 to your computer and use it in GitHub Desktop.
# Written by zAbuQasem
# Usage: cat /proc/net/tcp | awk '{print $2}' |grep -E '[A-F0-9]' | python3 lfi-portscan.py
import sys
import struct
import socket
addresses = [i.strip() for i in sys.stdin]
for address in addresses:
hex_ip,port = address.split(":")[0],address.split(":")[1]
hex_ip = struct.pack("<I", int(hex_ip, 16))
ip = socket.inet_ntoa(bytes.fromhex(hex_ip.hex()))
port = int(port,16)
print(f"{ip}:{port}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment