Final Internship project
Final Internship project
Defining function
scanHost() and
scanRange() :
The code initialises a print
lock `print_lock = Lock()` to
synchronise the console
output. This is utilised in
critical sections to ensure
orderly printing when
multiple threads are
involved, and prevents
potential issues with
concurrent printing during
TCP port scanning.
scanHost(ip, startPort,
endPort): This function
initiates a TCP port scan on a
single host identified by the
IP parameter. It iterates
through the range of ports
from startPort to endPort
and calls the tcp_scan
function to perform the scan.
It prints messages indicating
the start and completion of
the scan for that host.
scanRange(network,
startPort, endPort): This
function conducts TCP port
scanning on a range of hosts
within a network. It iterates
through host addresses in
the network range (e.g.,
“192.168.1.1”,
“192.168.1.2”, etc), calling
tcp_scan for each host within
the specified port range. It
prints a message indicating
the start of the scan on the
network.
Exception handling: It
includes exception handling
to catch any errors during
the connection attempt,
passing over them without
taking action. Figure 3
introduces the tcp_scan()
function for comprehensive
network analysis.
Figure 3: Defining function tcp_scan()
Defining function
network_scan()
ARP packet creation: Creates
an ARP packet with the
target IP address
(target_ip). Creates an
Ethernet frame with the
destination MAC address set
to broadcast.
Extracting
information: Iterates over
responses, extracting IP and
MAC addresses into a list of
dictionaries.
Phone Number
Information
Gathering - Uses an
API to fetch phone
info:
def phone_info(phone_number):
print(f"Fetching info for phone
number: {phone_number}") url =
f"http://apilayer.net/api/validate?a
ccess_key=YOUR_API_KEY&number
={phone_number}" response =
requests.get(url) if
response.status_code == 200:
phone_data = response.json()
print(json.dumps(phone_data,
indent=4)) else: print("Failed to
fetch phone number info")
Subdomain Checker
- Fetches
subdomains using
an online service
(API or scraping):
def subdomain_checker(domain):
print(f"Checking subdomains for
{domain}...") url =
f"https://api.hackertarget.com/hos
tsearch/?q={domain}" response =
requests.get(url) if
response.status_code == 200:
subdomains = response.text
print(f"Subdomains for
{domain}:\n{subdomains}") else:
print(f"Failed to fetch subdomains
for {domain}")
DDoS Attack
Simulation
(educational
purposes, only
sends requests
without real DDoS):
def ddos_simulation(target_url,
packet_count=100):
print(f"Simulating DDoS attack on
{target_url} with {packet_count}
packets...") for i in
range(packet_count): try:
requests.get(target_url)
print(f"Packet {i+1} sent") except:
print("Request failed") sleep(0.1)
print("DDoS simulation complete")
Display a welcome
banner:
def display_banner(): f =
Figlet(font='slant')
print(f.renderText("Recon
Automation Tool"))
Main program:
def main(): display_banner() while
True: print("\nSelect an option:")
print("1. IP Scanner") print("2. Port
Scanner") print("3. Barcode
Generator") print("4. QRCode
Generator") print("5. Password
Generator") print("6. Wordlist
Generator") print("7. Phone
Number Information Gathering")
print("8. Subdomain Checker")
print("9. DDoS Simulation")
print("10. Exit")
choice = input("Enter
your choice: ")
if choice == "1":
ip = input("Enter
the IP address: ")
ip_scanner(ip)
generate_qrcode(data)
generate_password(length)
wordlist_generator(words,
length)
phone_info(phone_number)
ddos_simulation(target_url,
packet_count)
else:
print("Invalid
choice. Please select a
valid option.")
if name == "main": main()