From c9cb6f0c8b19f7e4472201a56e89845de9e29f9f Mon Sep 17 00:00:00 2001 From: mohulvishnu Date: Thu, 9 Oct 2025 12:50:54 +0530 Subject: [PATCH 1/4] Updated README with clearer instructions and project details --- README.md | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 76420f2..ecb723c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ can analyse packets , decoding , scanning ports, pinging and geolocation of an Screenshots ---- -![Screenshot](https://github.com/medbenali/CyberScan/blob/master/images/demo.png) +![Screenshot](https://github.com/medbenali/CyberScan/blob/master/images/demo.png)+* Operating Systems Supported ---- @@ -17,16 +17,34 @@ Operating Systems Supported - GNU/Linux - MacOSX -Installation ----- +## Dependencies / Installation + +CyberScan relies on libpcap bindings (pcapy or compatible) and scapy. + +### Linux / macOS +1. Install system libpcap (Linux usually has it by default). +2. Create virtualenv (recommended): + $ python2 -m virtualenv venv # if you want Python 2 + $ source venv/bin/activate +3. Install Python packages: + $ pip install -r requirements.txt + +### Windows +1. Install **Npcap** (recommended) from https://nmap.org/npcap/ — choose "WinPcap API-compatible mode". +2. Install pre-built Python wheel for pcapy if needed (e.g. `pcapy-ng` or `pcapy` wheel). +3. Install requirements: + $ pip install -r requirements.txt -You can download CyberScan by cloning the [Git](https://github.com/medbenali/CyberScan) repository: +### Termux (Android) +- This project was written for Python 2. If your Termux environment uses Python3, run: + $ pkg install python2 + $ pip2 install -r requirements.txt +- If you run into `raw_input` errors, call the script with `python2 CyberScan.py` or use the compatibility shim in the code which maps `raw_input` to `input` on Python3. - git clone https://github.com/medbenali/CyberScan.git - cd CyberScan/ - python CyberScan.py -v +If you still see `ImportError: No module named pcapy`: +- On Linux try `pip install pcapy` or `pip install pcapy-ng` (or `pure-pcapy3` if building is an issue). +- On Windows, install Npcap first (see above), then install the appropriate pcapy wheel (or use pcapy-ng). -CyberScan works out of the box with [Python](http://www.python.org/download/) version **2.6.x** and **2.7.x**. # The CyberScan Module Usage From 84214175574ca7670909db73dd4756d8514b64a5 Mon Sep 17 00:00:00 2001 From: mohulvishnu Date: Thu, 9 Oct 2025 12:57:48 +0530 Subject: [PATCH 2/4] Updated README with clearer instructions and project details --- CyberScan.py | 746 +++++++++++++++---------------------------- doc/requirements.txt | 3 + 2 files changed, 259 insertions(+), 490 deletions(-) create mode 100644 doc/requirements.txt diff --git a/CyberScan.py b/CyberScan.py index 9bb7609..97557d9 100644 --- a/CyberScan.py +++ b/CyberScan.py @@ -1,540 +1,306 @@ -#!/usr/bin/python -# -*- coding utf-8 -*- -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, -# MA 02110-1301, USA. -# -# Author: Mohamed BEN ALI - -import os +#!/usr/bin/env python + import sys -import platform import argparse -import logging -logging.getLogger("scapy.runtime").setLevel(logging.ERROR) import time import socket -import pygeoip - -from scapy import * -from scapy.all import * -from libs.colorama import * -from libs import FileUtils - - -if platform.system() == 'Windows': - from libs.colorama.win32 import * +try: + from scapy.all import * +except ImportError: + print("Scapy is not installed. Please run: pip install scapy") + sys.exit(1) + +try: + import pygeoip +except ImportError: + print("pygeoip is not installed. Please run: pip install pygeoip") + sys.exit(1) + +try: + from colorama import Fore, Style, init + init(autoreset=True) +except ImportError: + print("colorama is not installed. Please run: pip install colorama") + sys.exit(1) __version__ = '1.1.1' -__description__ = '''\ +__description__ = f''' ___________________________________________ - CyberScan | v.''' + __version__ + ''' + CyberScan | v.{__version__} Author: BEN ALI Mohamed ___________________________________________ ''' def header(): - MAYOR_VERSION = 1 - MINOR_VERSION = 1 - REVISION = 1 - VERSION = { - "MAYOR_VERSION": MAYOR_VERSION, - "MINOR_VERSION": MINOR_VERSION, - "REVISION": REVISION - } - - PROGRAM_BANNER = open(FileUtils.buildPath('banner.txt')).read().format(**VERSION) + if not os.path.isfile('banner.txt'): + print(Style.BRIGHT + Fore.RED + "CyberScan Banner\n" + Style.RESET_ALL) + return + with open('banner.txt', 'r') as f: + PROGRAM_BANNER = f.read() message = Style.BRIGHT + Fore.RED + PROGRAM_BANNER + Style.RESET_ALL - write(message) + print(message) def usage(): - print (''' \033[92m CyberScan v.1.1.1 http://github/medbenali/CyberScan - It is the end user's responsibility to obey all applicable laws. - It is just for server testing script. Your ip is visible. \n - ___________________________________________ - - CyberScan | v.1.1.1 - Author: BEN ALI Mohamed - ___________________________________________ - - - \n \033[0m''') - -def write(string): - if platform.system() == 'Windows': - sys.stdout.write(string) - sys.stdout.flush() - sys.stdout.write('\n') - sys.stdout.flush() - else: - sys.stdout.write(string + '\n') - sys.stdout.flush() - sys.stdout.flush() + print(f'''\033[92m CyberScan v.{__version__} http://github/medbenali/CyberScan +It is the end user's responsibility to obey all applicable laws. +It is just for server testing script. Your ip is visible. -def geo_ip(host): + ___________________________________________ + + CyberScan | v.{__version__} + Author: BEN ALI Mohamed + ___________________________________________ + +\033[0m''') +def geo_ip(host): + if not os.path.isfile('GeoLiteCity.dat'): + print("[*] GeoLiteCity.dat file is missing!") + return try: + rawdata = pygeoip.GeoIP('GeoLiteCity.dat') + data = rawdata.record_by_name(host) + if not data: + print("[*] No geolocation data found for IP.") + return + for k, v in data.items(): + print(f"[*] {k.replace('_', ' ').title()}: {v}") + except Exception as e: + print("[*] Please verify your ip or GeoLiteCity.dat file!") - rawdata = pygeoip.GeoIP('GeoLiteCity.dat') - data = rawdata.record_by_name(host) - country = data['country_name'] - city = data['city'] - longi = data['longitude'] - lat = data['latitude'] - time_zone = data['time_zone'] - area_code = data['area_code'] - country_code = data['country_code'] - region_code = data['region_code'] - dma_code = data['dma_code'] - metro_code = data['metro_code'] - country_code3 = data['country_code3'] - zip_code = data['postal_code'] - continent = data['continent'] - - print '[*] IP Address: ',host - print '[*] City: ',city - print '[*] Region Code: ',region_code - print '[*] Area Code: ',area_code - print '[*] Time Zone: ',time_zone - print '[*] Dma Code: ',dma_code - print '[*] Metro Code: ',metro_code - print '[*] Latitude: ',lat - print '[*] Longitude: ',longi - print '[*] Zip Code: ',zip_code - print '[*] Country Name: ',country - print '[*] Country Code: ',country_code - print '[*] Country Code3: ',country_code3 - print '[*] Continent: ',continent - - except : - print "[*] Please verify your ip !" - - - def arp_ping(host): - print '[*] Starting CyberScan Ping ARP for %s' %(host) + print(f'[*] Starting CyberScan Ping ARP for {host}') ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=host), timeout=2) - ans.summary(lambda (s,r): r.sprintf("%Ether.src% %ARP.psrc%")) + ans.summary(lambda s_r: s_r[1].sprintf("%Ether.src% %ARP.psrc%")) def icmp_ping(host): - print '[*] Starting CyberScan Ping ICMP for %s' %(host) - ans, unans =srp(IP(dst=host)/ICMP()) - ans.summary(lambda (s,r): r.sprint("%IP.src% is alive")) - -def tcp_ping(host,dport): - ans, unans = sr(IP(dst=host)/TCP(dport,flags="S")) - ans.summary(lambda (s,r): r.sprintf("%IP.src% is alive")) - -def udp_ping(host,port=0): - print '[*] Starting CyberScan Ping UDP for %s' %(host) - ans, unans = sr(IP(dst=host)/UDP(dport=port)) - ans.summary(lambda(s, r): r.sprintf("%IP.src% is alive")) - -def superscan(host,start_port,end_port): - print '[*] CyberScan Port Scanner' - open_ports = [] - common_ports = { - '21': 'FTP', - '22': 'SSH', - '23': 'TELNET', - '25': 'SMTP', - '53': 'DNS', - '69': 'TFTP', - '80': 'HTTP', - '109': 'POP2', - '110': 'POP3', - '123': 'NTP', - '137': 'NETBIOS-NS', - '138': 'NETBIOS-DGM', - '139': 'NETBIOS-SSN', - '143': 'IMAP', - '156': 'SQL-SERVER', - '389': 'LDAP', - '443': 'HTTPS', - '546': 'DHCP-CLIENT', - '547': 'DHCP-SERVER', - '993': 'IMAP-SSL', - '995': 'POP3-SSL', - '2082': 'CPANEL', - '2083': 'CPANEL', - '2086': 'WHM/CPANEL', - '2087': 'WHM/CPANEL', - '3306' :'MYSQL', - '8443': 'PLESK', - '10000': 'VIRTUALMIN/WEBIN' - - - } - - starting_time=time.time() - if(flag): - print "[*] Scanning For Most Common Ports On %s" % (host) - else: - print "[*] Scanning %s From Port %s To %s: " % (host,start_port,end_port) - print "[*] Starting CyberScan 1.01 at %s" %(time.strftime("%Y-%m-%d %H:%M %Z")) - def check_port(host,port,result= 1): - try: - sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) - sock.settimeout(0.5) - r = sock.connect_ex((host,port)) - if r ==0: - result = r - sock.close() - except Exception, e: - pass - return result - - def get_service(port): - port = str(port) - if port in common_ports: - return common_ports[port] - else: - return 0 - try: - print "[*] Scan In Progress ..." - print "[*] Connecting To Port : ", - - if flag: - for p in sorted(common_ports): - sys.stdout.flush() - p = int(p) - print p, - response = check_port(host,p) - - if response ==0: - open_ports.append(p) - - sys.stdout.write('\b' * len(str(p))) - - - else: - for p in range(start_port,end_port+1): - sys.stdout.flush() - print p, - response = check_port(host,p) - - if response ==0: - open_ports.append(p) - if not p == end_port: - sys.stdout.write('\b' * len(str(p))) - - print "\n[*] Scanning Completed at %s" %(time.strftime("%Y-%m-%d %H:%M %Z")) - ending_time = time.time() - total_time = ending_time - starting_time - if total_time <=60: - print "[*] CyberScan done: 1IP address (1host up) scanned in %.2f seconds" %(total_time) - - else: - total_time = total_time / 60 - print "[*] CyberScan done: 1IP address (1host up) scanned in %.2f Minutes" %(total_time) - - - if open_ports: - print "[*] Open Ports: " - for i in sorted(open_ports): - service = get_service(i) - if not service: - service= "Unknown service" - print "\t%s %s: Open" % (i,service) - - else: - print "[*] Sorry, No Open Ports Found.!!" - - - except KeyboardInterrupt: - print "\n[*] You Pressed Ctrl+C. Exiting" - sys.exit(1) + print(f'[*] Starting CyberScan Ping ICMP for {host}') + ans, unans = sr(IP(dst=host)/ICMP()) + ans.summary(lambda s_r: s_r[1].sprintf("%IP.src% is alive")) + +def tcp_ping(host, dport): + ans, unans = sr(IP(dst=host)/TCP(dport=int(dport), flags="S")) + ans.summary(lambda s_r: s_r[1].sprintf("%IP.src% is alive")) + +def udp_ping(host, port=0): + print(f'[*] Starting CyberScan Ping UDP for {host}') + ans, unans = sr(IP(dst=host)/UDP(dport=int(port))) + ans.summary(lambda s_r: s_r[1].sprintf("%IP.src% is alive")) + +def superscan(host, start_port, end_port, flag): + print('[*] CyberScan Port Scanner') + open_ports = [] + common_ports = { + 21: 'FTP', 22: 'SSH', 23: 'TELNET', 25: 'SMTP', 53: 'DNS', 69: 'TFTP', + 80: 'HTTP', 109: 'POP2', 110: 'POP3', 123: 'NTP', 137: 'NETBIOS-NS', + 138: 'NETBIOS-DGM', 139: 'NETBIOS-SSN', 143: 'IMAP', 156: 'SQL-SERVER', + 389: 'LDAP', 443: 'HTTPS', 546: 'DHCP-CLIENT', 547: 'DHCP-SERVER', + 993: 'IMAP-SSL', 995: 'POP3-SSL', 2082: 'CPANEL', 2083: 'CPANEL', + 2086: 'WHM/CPANEL', 2087: 'WHM/CPANEL', 3306: 'MYSQL', 8443: 'PLESK', + 10000: 'VIRTUALMIN/WEBIN' + } + starting_time = time.time() + if flag: + print(f"[*] Scanning For Most Common Ports On {host}") + ports_to_scan = sorted(common_ports.keys()) + else: + print(f"[*] Scanning {host} From Port {start_port} To {end_port}: ") + ports_to_scan = range(start_port, end_port + 1) + print(f"[*] Starting CyberScan {__version__} at {time.strftime('%Y-%m-%d %H:%M %Z')}") + + def check_port(host, port): + try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(0.5) + r = sock.connect_ex((host, port)) + sock.close() + return r + except Exception: + return 1 + + print("[*] Scan In Progress ...") + print("[*] Connecting To Port : ", end='') + for p in ports_to_scan: + sys.stdout.flush() + print(p, end=' ') + response = check_port(host, p) + if response == 0: + open_ports.append(p) + print(f"\n[*] Scanning Completed at {time.strftime('%Y-%m-%d %H:%M %Z')}") + ending_time = time.time() + total_time = ending_time - starting_time + if total_time <= 60: + print(f"[*] CyberScan done: 1IP address (1host up) scanned in {total_time:.2f} seconds") + else: + print(f"[*] CyberScan done: 1IP address (1host up) scanned in {total_time/60:.2f} Minutes") + + if open_ports: + print("[*] Open Ports: ") + for i in sorted(open_ports): + service = common_ports.get(i, "Unknown service") + print(f"\t{i} {service}: Open") + else: + print("[*] Sorry, No Open Ports Found.!!") def pcap_analyser_eth(file): - pkts = rdpcap(file) - i=0 - for pkt in pkts: - i += 1 - print "-" * 40 - print "[*] Packet : " + str(i) - print "[+] ### [ Ethernet ] ###" - print "[*] Mac Destination : " + pkt.dst - print "[*] Mac Source : " + pkt.src - print "[*] Ethernet Type : " + str(pkt.type) - + pkts = rdpcap(file) + for i, pkt in enumerate(pkts, 1): + print("-" * 40) + print(f"[*] Packet : {i}") + print("[+] ### [ Ethernet ] ###") + print(f"[*] Mac Destination : {pkt.dst}") + print(f"[*] Mac Source : {pkt.src}") + print(f"[*] Ethernet Type : {pkt.type}") + def pcap_analyser_ip(file): - pkts = rdpcap(file) - i=0 - for pkt in pkts: - - if pkt.haslayer(IP): - i += 1 - print "-" * 40 - print "[*] Packet : " + str(i) - print "[+] ###[ IP ] ###" - IPpkt = pkt[IP] - srcIP = IPpkt.fields['src'] - dstIP = IPpkt.fields['dst'] - print "[*] IP Source : " + srcIP - print "[*] IP Destination : " + dstIP - verIP = IPpkt.version - print "[*] IP Version : " ,verIP - ihlIP = IPpkt.ihl - print "[*] IP Ihl : " ,ihlIP - tosIP = IPpkt.tos - print "[*] IP Tos : " ,tosIP - lenIP = IPpkt.len - print "[*] IP Len : " ,lenIP - idIP = IPpkt.id - print "[*] IP Id : " ,idIP - flagsIP = IPpkt.flags - print "[*] IP Flags : " ,flagsIP - fragIP = IPpkt.frag - print "[*] IP Frag : " ,fragIP - ttlIP = IPpkt.ttl - print "[*] IP Ttl : " ,ttlIP - protoIP = IPpkt.proto - print "[*] IP Protocol : " ,protoIP - chksumIP = IPpkt.chksum - print "[*] IP Chksum : " ,chksumIP - optionsIP = IPpkt.options - print "[*] IP Options : " ,optionsIP - print "[*] IP Dump : " - print hexdump(IPpkt) + pkts = rdpcap(file) + for i, pkt in enumerate(pkts, 1): + if pkt.haslayer(IP): + print("-" * 40) + print(f"[*] Packet : {i}") + print("[+] ###[ IP ] ###") + IPpkt = pkt[IP] + print(f"[*] IP Source : {IPpkt.src}") + print(f"[*] IP Destination : {IPpkt.dst}") + print(f"[*] IP Version : {IPpkt.version}") + print(f"[*] IP Ihl : {IPpkt.ihl}") + print(f"[*] IP Tos : {IPpkt.tos}") + print(f"[*] IP Len : {IPpkt.len}") + print(f"[*] IP Id : {IPpkt.id}") + print(f"[*] IP Flags : {IPpkt.flags}") + print(f"[*] IP Frag : {IPpkt.frag}") + print(f"[*] IP Ttl : {IPpkt.ttl}") + print(f"[*] IP Protocol : {IPpkt.proto}") + print(f"[*] IP Chksum : {IPpkt.chksum}") + print(f"[*] IP Options : {IPpkt.options}") + print("[*] IP Dump :") + print(hexdump(IPpkt)) def pcap_analyser_tcp(file): - pkts = rdpcap(file) - i=0 - SYN = 0x02 - FIN = 0X01 - RST = 0x04 - PSH = 0X08 - ACK = 0X10 - URG = 0x20 - - for pkt in pkts: - - if pkt.haslayer(TCP): - i += 1 - print "-" * 40 - print "[*] Packet : " + str(i) - print "[+] ###[ TCP ] ###" - TCPpkt = pkt[TCP] - sportTCP = TCPpkt.sport - print "[*] TCP Source Port : " ,sportTCP - dportTCP = TCPpkt.dport - print "[*] TCP Destination Port : " ,dportTCP - seqTCP = TCPpkt.seq - print "[*] TCP Seq : " ,seqTCP - ackTCP = TCPpkt.ack - print "[*] TCP Ack : " ,ackTCP - dataofsTCP = TCPpkt.dataofs - print "[*] TCP Dataofs : " ,dataofsTCP - reservedTCP = TCPpkt.reserved - print "[*] TCP Reserved : " ,reservedTCP - flagsTCP = TCPpkt.flags - print "[*] TCP Flags : " ,flagsTCP - windowTCP = TCPpkt.window - print "[*] TCP Window : " ,windowTCP - chksumTCP = TCPpkt.chksum - print "[*] TCP Chksum : " ,chksumTCP - urgptrTCP = TCPpkt.urgptr - print "[*] TCP Urgptr : " ,urgptrTCP - optionsTCP = TCPpkt.options - print "[*] TCP Options : " ,optionsTCP - nbrsyn=0 - nbrrst=0 - nbrack=0 - nbrfin=0 - nbrurg=0 - nbrpsh=0 - FlagsTCP=pkt[TCP].flags - if FlagsTCP==SYN: - nbrsun=1 - print "[*] TCP SYN FLAGS : " ,nbrsyn - elif FlagsTCP==RST: - nbrrst=1 - print "[*] TCP RST FLAGS : " ,nbrrst - elif FlagsTCP==ACK: - nbrack=1 - print "[*] TCP ACK FLAGS : " ,nbrack - elif FlagsTCP==FIN: - nbrfin=1 - print "[*] TCP FIN FLAGS : " ,nbrfin - elif FlagsTCP==URG: - nbrurg=1 - print "[*] TCP URG FLAGS : " ,nbrurg - elif FlagsTCP==PSH: - nbrpsh=1 - print "[*] TCP PSH FLAGS : " ,nbrpsh - print "[*] TCP Dump : " - print hexdump(TCPpkt) - + pkts = rdpcap(file) + for i, pkt in enumerate(pkts, 1): + if pkt.haslayer(TCP): + print("-" * 40) + print(f"[*] Packet : {i}") + print("[+] ###[ TCP ] ###") + TCPpkt = pkt[TCP] + print(f"[*] TCP Source Port : {TCPpkt.sport}") + print(f"[*] TCP Destination Port : {TCPpkt.dport}") + print(f"[*] TCP Seq : {TCPpkt.seq}") + print(f"[*] TCP Ack : {TCPpkt.ack}") + print(f"[*] TCP Dataofs : {TCPpkt.dataofs}") + print(f"[*] TCP Reserved : {TCPpkt.reserved}") + print(f"[*] TCP Flags : {TCPpkt.flags}") + print(f"[*] TCP Window : {TCPpkt.window}") + print(f"[*] TCP Chksum : {TCPpkt.chksum}") + print(f"[*] TCP Urgptr : {TCPpkt.urgptr}") + print(f"[*] TCP Options : {TCPpkt.options}") + print("[*] TCP Dump :") + print(hexdump(TCPpkt)) def pcap_analyser_udp(file): - pkts = rdpcap(file) - i=0 - for pkt in pkts: - - if pkt.haslayer(UDP): - i += 1 - print "-" * 40 - print "[*] Packet : " + str(i) - print "[+] ###[ UDP ] ###" - UDPpkt = pkt[UDP] - sportUDP = UDPpkt.sport - print "[*] UDP Source Port : " ,sportUDP - dportUDP = UDPpkt.dport - print "[*] UDP Destination Port : " ,dportUDP - lenUDP = UDPpkt.len - print "[*] UDP Len : " ,lenUDP - chksumUDP = UDPpkt.chksum - print "[*] UDP Chksum : " ,chksumUDP - print "[*] UDP Dump : " - print hexdump(UDPpkt) - + pkts = rdpcap(file) + for i, pkt in enumerate(pkts, 1): + if pkt.haslayer(UDP): + print("-" * 40) + print(f"[*] Packet : {i}") + print("[+] ###[ UDP ] ###") + UDPpkt = pkt[UDP] + print(f"[*] UDP Source Port : {UDPpkt.sport}") + print(f"[*] UDP Destination Port : {UDPpkt.dport}") + print(f"[*] UDP Len : {UDPpkt.len}") + print(f"[*] UDP Chksum : {UDPpkt.chksum}") + print("[*] UDP Dump :") + print(hexdump(UDPpkt)) def pcap_analyser_icmp(file): - pkts = rdpcap(file) - i=0 - for pkt in pkts: - - if pkt.haslayer(ICMP): - i += 1 - print "-" * 40 - print "[*] Packet : " + str(i) - print "[+] ###[ ICMP ] ###" - ICMPpkt = pkt[ICMP] - typeICMP = ICMPpkt.type - print "[*] ICMP Type : " ,typeICMP - codeICMP = ICMPpkt.code - print "[*] ICMP Code : " ,codeICMP - chksumICMP = ICMPpkt.chksum - print "[*] ICMP Chksum : " ,chksumICMP - idICMP = ICMPpkt.id - print "[*] ICMP Id : " ,idICMP - seqICMP = ICMPpkt.seq - print "[*] ICMP Seq : " ,seqICMP - print "[*] ICMP Dump : " - print hexdump(ICMPpkt) - + pkts = rdpcap(file) + for i, pkt in enumerate(pkts, 1): + if pkt.haslayer(ICMP): + print("-" * 40) + print(f"[*] Packet : {i}") + print("[+] ###[ ICMP ] ###") + ICMPpkt = pkt[ICMP] + print(f"[*] ICMP Type : {ICMPpkt.type}") + print(f"[*] ICMP Code : {ICMPpkt.code}") + print(f"[*] ICMP Chksum : {ICMPpkt.chksum}") + print(f"[*] ICMP Id : {ICMPpkt.id}") + print(f"[*] ICMP Seq : {ICMPpkt.seq}") + print("[*] ICMP Dump :") + print(hexdump(ICMPpkt)) def main(): - - global serveur - global level - global sport - global eport - global file - global flag - flag=0 - - try: - - parser = argparse.ArgumentParser(version=__version__,description=__description__,formatter_class=argparse.RawTextHelpFormatter,epilog='''\ -levels with ip adress: + parser = argparse.ArgumentParser( + description=__description__, + formatter_class=argparse.RawTextHelpFormatter, + epilog='''\ +levels with ip address: scan : scan ports arp : ping arp - icmp : ping arp + icmp : ping icmp tcp : ping tcp udp : ping udp geoip : geolocalisation levels with pcap file: eth : extract ethernet headers - ip : extract ip headers + ip : extract ip headers tcp : extract tcp headers udp : extract udp headers icmp : extract icmp headers + ''' + ) + + parser.add_argument("-s", "--serveur", dest="serveur", help="attack to serveur ip") + parser.add_argument("-p", "--level", dest="level", help="stack to level") + parser.add_argument("-d", "--sport", dest="sport", help="start port to scan") + parser.add_argument("-t", "--eport", dest="eport", help="end port to scan") + parser.add_argument("-f", "--file", dest="file", help="read pcap file") + + args = parser.parse_args() + serveur = args.serveur + file = args.file + level = args.level + sport = args.sport + eport = args.eport - ''') - - parser.add_argument("-s","--serveur", dest="serveur",help="attack to serveur ip") - parser.add_argument("-p","--level",dest="level",help="stack to level") - parser.add_argument("-d","--sport",dest="sport",help="start port to scan") - parser.add_argument("-t","--eport",dest="eport",help="end port to scan") - parser.add_argument("-f", "--file", dest="file", - help="read pcap file") - - - args = parser.parse_args() - serveur = args.serveur - file = args.file - level = args.level - sport = args.sport - eport = args.eport - - - if file is not None or serveur is not None: - - header() - usage() - - if file and level == "eth": - pcap_analyser_eth(file) - elif file and level == "ip": - pcap_analyser_ip(file) - elif file and level == "tcp": - pcap_analyser_tcp(file) - elif file and level == "udp": - pcap_analyser_udp(file) - elif file and level == "icmp": - pcap_analyser_icmp(file) - elif serveur is not None and level == "arp": - arp_ping(serveur) - elif serveur is not None and level == "icmp": - icmp_ping(serveur) - - elif serveur is not None and level == "tcp" and sport is not None: - port = sport - tcp_ping(serveur,port) - - elif serveur is not None and level == "scan" and sport is not None and eport is not None: - start_port = int(sport) - end_port = int(eport) - flag = 0 - superscan(serveur,start_port,end_port) - - elif serveur is not None and level == "scan" and sport is None and eport is None: - start_port = int(0) - end_port = int(0) - flag=1 - superscan(serveur,start_port,end_port) - - elif serveur is not None and level == "udp": - udp_ping(serveur,port=0) - - elif serveur is not None and level == "geoip": - geo_ip(serveur) - - - - else: - - print '''usage: CyberScan.py [-h] [-s SERVEUR] [-p LEVEL] [-d SPORT] [-t EPORT] - [-f FILE] -use cyberscan -h to help ''' - - except KeyboardInterrupt: - print "\n[*] You Pressed Ctrl+C. Exiting" - sys.exit(1) - - - -if __name__ == '__main__': - main() - - - - - - + try: + if file or serveur: + header() + usage() + if file and level == "eth": + pcap_analyser_eth(file) + elif file and level == "ip": + pcap_analyser_ip(file) + elif file and level == "tcp": + pcap_analyser_tcp(file) + elif file and level == "udp": + pcap_analyser_udp(file) + elif file and level == "icmp": + pcap_analyser_icmp(file) + elif serveur and level == "arp": + arp_ping(serveur) + elif serveur and level == "icmp": + icmp_ping(serveur) + elif serveur and level == "tcp" and sport: + tcp_ping(serveur, sport) + elif serveur and level == "scan" and sport and eport: + superscan(serveur, int(sport), int(eport), flag=False) + elif serveur and level == "scan" and not sport and not eport: + superscan(serveur, 0, 0, flag=True) + elif serveur and level == "udp": + udp_ping(serveur, port=0) + elif serveur and level == "geoip": + geo_ip(serveur) + else: + print('''usage: CyberScan.py [-h] [-s SERVEUR] [-p LEVEL] [-d SPORT] [-t EPORT] [-f FILE] +use cyberscan -h to help''') + except KeyboardInterrupt: + print("\n[*] You Pressed Ctrl+C. Exiting") + sys.exit(1) +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/doc/requirements.txt b/doc/requirements.txt new file mode 100644 index 0000000..fae0671 --- /dev/null +++ b/doc/requirements.txt @@ -0,0 +1,3 @@ +scapy +pcapy-ng +pygeoip From 0e189655d20a5c67f977d32c84a41be488a4a5ba Mon Sep 17 00:00:00 2001 From: mohulvishnu Date: Thu, 9 Oct 2025 14:03:26 +0530 Subject: [PATCH 3/4] Updated README with clearer instructions and project details --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ecb723c..3c278b6 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ CyberScan relies on libpcap bindings (pcapy or compatible) and scapy. $ pip2 install -r requirements.txt - If you run into `raw_input` errors, call the script with `python2 CyberScan.py` or use the compatibility shim in the code which maps `raw_input` to `input` on Python3. + If you still see `ImportError: No module named pcapy`: - On Linux try `pip install pcapy` or `pip install pcapy-ng` (or `pure-pcapy3` if building is an issue). - On Windows, install Npcap first (see above), then install the appropriate pcapy wheel (or use pcapy-ng). From f65ec218b81d57ea2c88edde856478c2f08d63d7 Mon Sep 17 00:00:00 2001 From: mohulvishnu Date: Thu, 9 Oct 2025 14:36:48 +0530 Subject: [PATCH 4/4] cleaned cyberscan --- CyberScan.py | 89 ++++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/CyberScan.py b/CyberScan.py index 97557d9..d7324ba 100644 --- a/CyberScan.py +++ b/CyberScan.py @@ -1,12 +1,13 @@ #!/usr/bin/env python import sys +import os import argparse import time import socket try: - from scapy.all import * + from scapy.all import sr, srp, rdpcap, Ether, ARP, IP, TCP, UDP, ICMP, hexdump except ImportError: print("Scapy is not installed. Please run: pip install scapy") sys.exit(1) @@ -25,49 +26,48 @@ sys.exit(1) __version__ = '1.1.1' -__description__ = f''' - ___________________________________________ - - CyberScan | v.{__version__} - Author: BEN ALI Mohamed - ___________________________________________ -''' +__description__ = ( + " ___________________________________________\n" + f" CyberScan | v.{__version__}\n" + " Author: BEN ALI Mohamed\n" + " ___________________________________________\n" +) def header(): - if not os.path.isfile('banner.txt'): + banner_file = 'banner.txt' + if not os.path.isfile(banner_file): print(Style.BRIGHT + Fore.RED + "CyberScan Banner\n" + Style.RESET_ALL) return - with open('banner.txt', 'r') as f: - PROGRAM_BANNER = f.read() - message = Style.BRIGHT + Fore.RED + PROGRAM_BANNER + Style.RESET_ALL + with open(banner_file, 'r') as f: + program_banner = f.read() + message = Style.BRIGHT + Fore.RED + program_banner + Style.RESET_ALL print(message) def usage(): - print(f'''\033[92m CyberScan v.{__version__} http://github/medbenali/CyberScan -It is the end user's responsibility to obey all applicable laws. -It is just for server testing script. Your ip is visible. - - ___________________________________________ - - CyberScan | v.{__version__} - Author: BEN ALI Mohamed - ___________________________________________ - -\033[0m''') + print( + f"\033[92m CyberScan v.{__version__} http://github/medbenali/CyberScan\n" + "It is the end user's responsibility to obey all applicable laws.\n" + "It is just for server testing script. Your ip is visible.\n\n" + " ___________________________________________\n\n" + f" CyberScan | v.{__version__}\n" + " Author: BEN ALI Mohamed\n" + " ___________________________________________\n\n\033[0m" + ) def geo_ip(host): - if not os.path.isfile('GeoLiteCity.dat'): + geo_db = 'GeoLiteCity.dat' + if not os.path.isfile(geo_db): print("[*] GeoLiteCity.dat file is missing!") return try: - rawdata = pygeoip.GeoIP('GeoLiteCity.dat') + rawdata = pygeoip.GeoIP(geo_db) data = rawdata.record_by_name(host) if not data: print("[*] No geolocation data found for IP.") return for k, v in data.items(): print(f"[*] {k.replace('_', ' ').title()}: {v}") - except Exception as e: + except Exception: print("[*] Please verify your ip or GeoLiteCity.dat file!") def arp_ping(host): @@ -236,22 +236,21 @@ def main(): parser = argparse.ArgumentParser( description=__description__, formatter_class=argparse.RawTextHelpFormatter, - epilog='''\ -levels with ip address: - scan : scan ports - arp : ping arp - icmp : ping icmp - tcp : ping tcp - udp : ping udp - geoip : geolocalisation - -levels with pcap file: - eth : extract ethernet headers - ip : extract ip headers - tcp : extract tcp headers - udp : extract udp headers - icmp : extract icmp headers - ''' + epilog=( + "levels with ip address:\n" + " scan : scan ports\n" + " arp : ping arp\n" + " icmp : ping icmp\n" + " tcp : ping tcp\n" + " udp : ping udp\n" + " geoip : geolocalisation\n\n" + "levels with pcap file:\n" + " eth : extract ethernet headers\n" + " ip : extract ip headers\n" + " tcp : extract tcp headers\n" + " udp : extract udp headers\n" + " icmp : extract icmp headers\n" + ) ) parser.add_argument("-s", "--serveur", dest="serveur", help="attack to serveur ip") @@ -296,8 +295,10 @@ def main(): elif serveur and level == "geoip": geo_ip(serveur) else: - print('''usage: CyberScan.py [-h] [-s SERVEUR] [-p LEVEL] [-d SPORT] [-t EPORT] [-f FILE] -use cyberscan -h to help''') + print( + "usage: CyberScan.py [-h] [-s SERVEUR] [-p LEVEL] [-d SPORT] [-t EPORT] [-f FILE]\n" + "use cyberscan -h to help" + ) except KeyboardInterrupt: print("\n[*] You Pressed Ctrl+C. Exiting") sys.exit(1)