πŸ‘¨β€πŸ’»
Jawad's Notes
  • πŸ‘¨β€πŸ«INFOSEC
    • πŸ•ΈοΈWeb
      • Burp Suite: Setting Foxyproxy
      • XSS
      • Wappalyzer
      • Directory Traversal
      • LFI
        • PHP Wrappers
        • RFI
      • Reverse Shell
        • Command Injection Quick Tips
      • File Upload
      • WPScan
      • SQL Injection
        • Schemas
        • SQLmap
        • MSSQL
        • MySQL
        • PostgreSQL
    • πŸ”§Tools
      • Whois
      • DNSRecon
      • DNSenum
      • nslookup
      • Netcat
        • Powercat
      • Nmap
        • Nmap Scripting Engine
        • Test-NetConnection
        • Grep
      • Server Message Block (SMB)
      • SNMP
      • SMTP
      • ExifTool
      • Search Engine Hacking
      • Source Control Hacking
      • Nessus
      • Canarytokens
      • Qualys SSL Server Test
      • Security Headers
      • theHarvester
      • Shodan
      • Gobuster
        • Dirb
      • Searchsploit
      • Password Cracking
        • Hashcat
        • John The Ripper
        • Hydra
        • hashID
        • CPU vs GPU
    • 🐧Linux
      • Symbols
      • cat
      • curl
      • openvpn
      • tcpdump
      • Remote Desktop
      • SmbShare
      • Tmux
      • Convert Windows-style line endings (CRLF) to Unix-style (LF)
      • SSH
    • πŸ–₯️Macros in Office
    • 🍎Enhancing Your MacOS Terminal Experience
    • 🚩CTF
      • SQL Injection
        • WHERE clause allowing retrieval of hidden data
        • Allowing login bypass
        • UNION attack, determining the number of columns returned by the query
        • UNION attack, finding a column containing text
        • UNION attack, retrieving data from other tables
        • UNION attack, retrieving multiple values in a single column
        • Querying the database type and version on Oracle
Powered by GitBook
On this page
  1. INFOSEC
  2. Tools
  3. Nmap

Grep

grep is a powerful command-line utility in Unix-based systems that allows users to search and filter text. When combined with Nmap, it becomes a valuable tool for extracting relevant information from scan results, enabling users to focus on specific details.

Usage with Nmap:

  • Nmap often generates detailed output, and grep is employed to extract specific information, making it more manageable.

Common Grep Examples with Nmap:

  1. Filtering Open Ports:

    nmap example.com | grep "open"

    Identifies and displays only the lines containing open ports from Nmap scan results.

  2. Extracting Hostnames:

    nmap -sn 192.168.1.0/24 | grep "report for" | cut -d" " -f5

    Filters and extracts hostnames from a ping scan.

  3. Finding Specific Services:

    nmap example.com | grep -E "80|443"

    Filters services on ports 80 or 443 from the Nmap scan output.

Why Grep is Useful:

  • Precision: Allows users to focus on specific details in the extensive Nmap output.

  • Customization: Enables tailored extraction of information based on user requirements.

  • Efficiency: Streamlines analysis by highlighting relevant data.

Examples of grep commands:

  1. Search for a String in a File:

    grep "search_term" filename

    Searches for the specified "search_term" in the content of the specified file.

  2. Case-Insensitive Search:

    grep -i "pattern" filename

    Performs a case-insensitive search for the specified "pattern" in the content of the file.

  3. Count the Number of Lines Matching a Pattern:

    grep -c "pattern" filename

    Counts and displays the number of lines in the file that match the specified "pattern."

  4. Recursive Search in Directories:

    grep -r "pattern" directory/

    Recursively searches for the specified "pattern" in all files within the specified directory.

  5. Display Line Numbers with Matching Lines:

    grep -n "pattern" filename

    Displays line numbers along with lines that match the specified "pattern" in the file.

  6. Exclude Lines Containing a Pattern:

    grep -v "pattern" filename

    Displays lines in the file that do not contain the specified "pattern."

  7. Search for Whole Words:

    grep -w "word" filename

    Searches for the whole word "word" in the content of the file.

  8. Show Only Matching Part of Lines:

    grep -o "pattern" filename

    Displays only the part of lines that match the specified "pattern."

These are just a few examples, and grep offers a variety of options for customizing searches based on specific requirements.

PreviousTest-NetConnectionNextServer Message Block (SMB)

Last updated 1 year ago

πŸ‘¨β€πŸ«
πŸ”§