Autocoder

Ethical Hacking Interview Questions and Answers

Last updated 2026-11-19

Ethical hacking and penetration testing interviews check three things: method, technical understanding and professionalism. Method means you work through reconnaissance, enumeration, exploitation, post-exploitation and reporting in order, within a written scope. Technical understanding means you can explain why an attack works and how to fix it. Professionalism means you know the legal line, handle data carefully and write reports that engineers can act on.

This page has 15 worked questions. Commands are for use only in your own lab, in an intentionally vulnerable practice environment, or on systems where you hold written authorisation; unauthorised scanning or access is illegal, including under India's IT Act. For defence-side context see the cybersecurity questions and network security questions.

MethodScope and rules of engagement, recon, scanning, exploitation, post-exploitation, reporting, retest
Common toolsNmap, Burp Suite, Metasploit, sqlmap, Wireshark, Gobuster, John the Ripper, Hashcat
Legal basisSigned authorisation, defined scope, agreed testing windows and data handling

Where to practise legally

Build a home lab with virtual machines on an isolated host-only network: a Kali Linux attacker and intentionally vulnerable targets such as OWASP Juice Shop, DVWA or Metasploitable. Browser-based training platforms and capture-the-flag events give structured, legal practice. Keep notes of every technique you try and write a mock report for each target, because interviewers often ask you to describe one machine you compromised end to end and how you would remediate it.

Ethical Hacking Interview Questions and Answers: questions with worked answers

  1. 1

    What is ethical hacking and how does it differ from malicious hacking?

    easy

    Ethical hacking is authorised security testing that finds and demonstrates weaknesses so the owner can fix them. The differences are permission, scope and intent: you have a signed agreement defining which systems, techniques and times are allowed, you stop at the boundary, you protect any data you see, and you deliver findings with remediation advice. Malicious hackers act without consent for gain or harm. Even well-meaning testing without permission is illegal. Grey-hat behaviour, such as testing without permission and then disclosing, is still unlawful in many places. Bug bounty programmes are the legitimate route for testing public targets, within their published scope.

  2. 2

    Describe the phases of a penetration test.

    easy

    Pre-engagement defines scope, objectives, rules of engagement and emergency contacts. Reconnaissance gathers information passively (DNS records, certificates, public repositories, job posts) and actively. Scanning and enumeration identify live hosts, open ports, services, versions and users. Vulnerability analysis maps services to weaknesses. Exploitation gains access in a controlled way. Post-exploitation assesses impact: privilege escalation, lateral movement and data access, with minimal footprint. Reporting documents findings with evidence, severity and fixes, and a retest verifies remediation. Cleanup removes tools and test accounts you created.

  3. 3

    What is the difference between passive and active reconnaissance?

    easy

    Passive reconnaissance collects information without sending traffic to the target's systems, so it cannot be detected by them: WHOIS records, certificate transparency logs, search engine results, archived pages, public code repositories and breach disclosures. Active reconnaissance interacts with the target, such as port scans, banner grabbing and directory brute-forcing, and can appear in logs, so it needs authorisation. Starting passively reduces noise and shows the real exposure of an organisation. Output includes subdomains, technologies, email formats and exposed credentials, all of which are reported without misuse.

  4. 4

    Explain how Nmap scans work and give commands for common tasks.

    medium

    A TCP SYN scan (-sS) sends a SYN and waits: a SYN-ACK means open, an RST means closed, and no reply suggests filtered; it never completes the handshake, so it is faster and quieter than a full connect scan (-sT). UDP scans (-sU) are slower because open ports often give no response. -sV probes service versions, -O fingerprints the operating system, and -sC runs default NSE scripts. Timing templates run from -T0 to -T5, and aggressive timing can crash fragile devices or trip alarms. SYN scans need root. Only scan hosts you are authorised to test.

    bash
    # lab or authorised targets only
    sudo nmap -sS -p- --min-rate 1000 -oA full 10.10.10.5
    sudo nmap -sV -sC -p 22,80,443 -oN services.txt 10.10.10.5
    sudo nmap -sU --top-ports 50 10.10.10.5
    nmap --script vuln -p 443 10.10.10.5
  5. 5

    What is the difference between a vulnerability, an exploit and a payload?

    easy

    A vulnerability is a weakness in design, code or configuration. An exploit is the technique or code that takes advantage of it, for example a crafted request that triggers a buffer overflow. A payload is what runs after a successful exploit, such as a reverse shell, a bind shell or a command that adds a test account. In Metasploit terms, the exploit module delivers the payload. A CVE is a public identifier for a vulnerability, and CVSS scores severity, but the real priority depends on exposure, exploitability and asset value.

  6. 6

    What is a reverse shell versus a bind shell, and why do testers prefer reverse shells?

    medium

    A bind shell opens a listening port on the target that the tester connects to. A reverse shell makes the target connect back to a listener on the tester's machine. Firewalls usually block unsolicited inbound connections to a target but allow outbound traffic, so reverse shells more often work, and they do not require a reachable port on the victim. Defenders detect them by egress filtering, proxy logs, unusual outbound connections and endpoint detection. In a report you demonstrate access safely, for example with a harmless file proof, and explain the fix: patch the underlying flaw and restrict egress.

  7. 7

    How would you test a login form for common weaknesses?

    medium

    Check for user enumeration through different error messages or response times, missing lockout or rate limiting that allows password guessing, weak password policy, absence of MFA, session cookies without HttpOnly, Secure and SameSite flags, session fixation, predictable reset tokens, and SQL injection in the username field. Intercept requests in Burp Suite to examine parameters and test authorisation after login. Then the fixes: uniform error messages, rate limiting and lockout with care to avoid denial of service on real users, strong hashing, MFA and secure cookie attributes. Brute force attempts must stay within the rules of engagement.

  8. 8

    Explain IDOR (broken object-level authorisation) and how you test and fix it.

    medium

    An insecure direct object reference occurs when an endpoint such as /api/invoices/1042 returns data by ID without checking that the current user owns that object, so changing the ID exposes other customers' records. To test, log in as two different users and replay one user's request with the other's identifiers, and also try changing role or tenant fields in request bodies. The fix is a server-side authorisation check on every object access, tying queries to the authenticated user, with unpredictable IDs only as an additional layer. Add automated tests covering cross-user access.

    python
    # Vulnerable vs fixed Flask handler (illustration)
    @app.get('/api/invoices/<int:invoice_id>')
    @login_required
    def get_invoice(invoice_id):
        # vulnerable: return Invoice.query.get_or_404(invoice_id)
        inv = Invoice.query.filter_by(id=invoice_id, owner_id=current_user.id).first_or_404()
        return jsonify(inv.to_dict())
  9. 9

    What is SSRF and why is it dangerous in cloud environments?

    hard

    Server-side request forgery makes the server fetch a URL chosen by the attacker, letting them reach internal services that are not exposed to the internet. In cloud environments it can reach the instance metadata endpoint at 169.254.169.254 and steal temporary credentials from the instance's role. Defences: allow-list outbound destinations, resolve and validate the destination IP after DNS lookup to block private and link-local ranges, disable redirects or revalidate them, and enforce IMDSv2 on AWS so metadata needs a session token header that simple SSRF cannot add. Use least-privilege roles so stolen credentials do little.

  10. 10

    Describe common Linux privilege escalation checks, and how to prevent them.

    medium

    After gaining a low-privilege shell, testers enumerate: sudo -l for commands runnable as root, SUID binaries, writable scripts executed by root cron jobs, world-writable service files, weak file permissions on credentials, kernel version and unpatched local exploits, capabilities on binaries, and credentials in history or configuration files. Prevention is the mirror image: minimal sudo rules without shell-escape binaries, no unnecessary SUID files, tight permissions, patched kernels and packages, secrets kept out of files and history, and monitoring for unusual privilege changes.

    bash
    # on a lab machine you own
    id; uname -a
    sudo -l
    find / -perm -4000 -type f 2>/dev/null
    cat /etc/crontab; ls -l /etc/cron.*
    getcap -r / 2>/dev/null
  11. 11

    Explain password cracking: how hashes are attacked and defended.

    medium

    Given a stolen hash, attackers try guesses offline. Dictionary and rule-based attacks transform common passwords, brute force tries all combinations, and rainbow tables precompute hashes for unsalted values. Salting defeats rainbow tables and forces per-hash work; slow algorithms such as Argon2id, scrypt and bcrypt make each guess expensive, and GPUs gain far less against memory-hard functions. In a test you might crack hashes from an authorised dump to report weak passwords. Defences are long passphrases, breached-password checks, MFA and rate limiting online. Identify the hash type first, for example with hashid, then choose the right mode in Hashcat.

  12. 12

    What is the difference between black box, grey box and white box testing?

    easy

    In black box testing the tester has no internal knowledge, simulating an external attacker, which is realistic but spends time on discovery. Grey box gives partial knowledge such as a standard user account or an architecture diagram, which is efficient for finding authorisation flaws. White box gives full access to source code, configuration and documentation, enabling the deepest coverage including code review. Choose by objective: black box for exposure assessment, grey box for typical application tests, white box for thorough assurance of critical systems. Many engagements mix them.

  13. 13

    How does a wireless network attack on WPA2 work, and how do you defend?

    medium

    With WPA2-Personal, a tester can capture the four-way handshake or a PMKID from an access point and try offline guessing of the pre-shared key; success depends entirely on passphrase strength. Rogue access points and evil twin attacks trick clients into joining a fake network, and deauthentication frames were exploitable until management frame protection. Defend with a long random passphrase, WPA3 where supported, WPA2/WPA3-Enterprise with certificate-validated 802.1X, protected management frames, and wireless intrusion detection. Wireless testing must be tightly scoped, since signals reach neighbouring networks you have no right to test.

  14. 14

    What goes into a good penetration test report?

    easy

    An executive summary in plain language stating overall risk and top issues, the scope and methodology, then each finding with title, severity rated by a method such as CVSS plus business context, affected assets, step-by-step reproduction with screenshots or request and response evidence, impact, and specific remediation with references. Add a prioritised remediation roadmap, positive observations, and an appendix of tools and test dates. Keep sensitive data redacted, deliver the report securely, and offer a debrief and retest. A finding that engineers cannot reproduce or fix is not useful, however clever the exploit.

  15. 15

    You find a critical vulnerability that exposes customer data during a test. What do you do?

    medium

    Stop exploiting beyond what is needed to prove the issue, avoid downloading or retaining real personal data, and note the minimum evidence such as a redacted record count. Notify the client's designated contact immediately through the agreed secure channel rather than waiting for the final report, because a critical issue in production deserves out-of-band escalation, as set out in the rules of engagement. Document timestamps and actions, help them with containment advice, and keep the finding confidential. This shows professionalism, which interviewers weigh as heavily as technical skill.

  16. 16

    What are the legal and ethical limits in India, and how do you stay within them?

    easy

    Unauthorised access to computer systems is an offence under the Information Technology Act, 2000, including section 43 and section 66, and data protection law adds obligations around personal data. Stay safe by working only under written authorisation naming the systems and dates, respecting scope boundaries including third-party and cloud providers' own testing rules, never testing production without agreement, handling data under NDA and deleting it after the engagement, and disclosing vulnerabilities in public systems only through official channels such as CERT-In or a programme's published policy. When unsure, ask for scope clarification in writing. This is general information and not legal advice.

Frequently asked questions

Is CEH required to become an ethical hacker?

No. CEH is widely recognised in India and helps with screening, but employers also value OSCP-style practical certificates, CTF results, bug bounty reports and home-lab write-ups.

What programming languages should an ethical hacker know?

Python for tooling and automation, Bash for Linux work, JavaScript and SQL for web testing, and some C or assembly for exploit development and reverse engineering.

How do I practise without breaking the law?

Use your own virtual machines, intentionally vulnerable applications such as Juice Shop or DVWA, legal training platforms and CTFs, and bug bounty programmes within their stated scope.

What is the difference between ethical hacking and penetration testing?

Ethical hacking is the broader idea of authorised attacker-style testing. Penetration testing is a structured engagement with scope, methodology and a report, and is the most common job form of it.

Related guides

More in Role-wise Interview Questions by Job and Tech Stack

See all in this section