https://github.com/povzayd/ptrex
PTRex is a Bash script for performing reverse DNS (PTR) lookups on single IPs, CIDR ranges, or IP lists. It uses getent hosts, supports parallel execution for speed, and filters results to show only successful lookups.
https://github.com/povzayd/ptrex
dnsx-alternate info-gathering osint ptr ptr-analysis ptr-lookup website-pentesting
Last synced: 11 months ago
JSON representation
PTRex is a Bash script for performing reverse DNS (PTR) lookups on single IPs, CIDR ranges, or IP lists. It uses getent hosts, supports parallel execution for speed, and filters results to show only successful lookups.
- Host: GitHub
- URL: https://github.com/povzayd/ptrex
- Owner: povzayd
- Created: 2025-03-23T13:10:41.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-03-24T08:21:06.000Z (11 months ago)
- Last Synced: 2025-03-24T09:32:13.792Z (11 months ago)
- Topics: dnsx-alternate, info-gathering, osint, ptr, ptr-analysis, ptr-lookup, website-pentesting
- Language: Shell
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
๐ PTRex ๐ฆ Reverse DNS Lookup Script
This Bash script performs reverse DNS (PTR) lookups on a given IP, CIDR range, or a list of IPs from a file. It efficiently resolves hostnames using `getent hosts`, tracks progress, and runs queries in parallel for speed.
๐ Features
โ
Accepts a single IP, CIDR range, or file with multiple IPs
โ
Uses `getent hosts` for reverse DNS (PTR) lookups ๐
โ
Parallel execution (up to 50 requests at a time) for faster results โก
โ
Tracks progress dynamically ๐
โ
Filters and outputs only successful PTR lookups (hostnames only) ๐
๐ Installation
Ensure you have `prips` `git` installed for CIDR expansion:
```
bash
sudo apt install prips git
git clone https://github.com/povzayd/ptrex.git
cd ptrex && chmod +x *
./ptrex
```
๐ Usage
Run the script and enter an IP, CIDR range, or a file path when prompted:
```
bash
./ptrex
```
๐ Global Package
Making this shell script global will alow you to execute this in any directory
For that just move the file `ptrex` to `bin` or `sbin`
```
bash
mv ptrex /usr/bin
or
mv ptrex /usr/sbin
```
*๐ Example Inputs*
1๏ธโฃ Single IP: `8.8.8.8`
2๏ธโฃ CIDR Range: `192.168.1.0/24`
3๏ธโฃ File with IPs: `/path/to/ips.txt`
*๐ Output Example*
```
[+] Processing IPs from file: ips.txt
[+] Requests made: 12 / 100
[+] Completed!
โ
-> example.com
โ
-> mail.google.com
โ
-> somehost.net
```
๐ How It Works
1๏ธโฃ User Input
- Prompts user to enter an IP, CIDR, or file path
- Determines input type (single IP, CIDR, or file)
2๏ธโฃ IP Expansion (if CIDR)
- Uses `prips` to generate a list of IPs from the CIDR range
3๏ธโฃ Parallel Reverse DNS Lookups
- Uses `getent hosts` to fetch PTR records ๐ต๏ธ
- Runs up to 50 parallel lookups using `xargs -P 50`
- Displays live progress updates
4๏ธโฃ Output Processing
- Saves only successful hostname lookups ๐ฏ
- Hides IPs, displaying hostnames only
5๏ธโฃ Cleanup
- Deletes temporary files after execution ๐งน
โ ๏ธ Notes
โก Only successful lookups (resolved hostnames) are displayed
โก Parallel execution speeds up large queries
โก If `prips` is missing, CIDR expansion will fail
๐ฎ Future Improvements
โจ Add logging for debugging
โจ Implement timeouts for slow DNS responses
โจ Support custom concurrency levels
This script is great for security assessments, network mapping, and passive reconnaissance when identifying hostnames associated with an IP range. ๐
---
*PLEASE NOTE THAT THE SCRIPT GIVES OUTPUT IN THE FORM OF
```
-> some.pointer.record.abc.com
```
IF YOU WANT TO REMOVE IT FROM YOUR TXT FILE JUST USE THE COMMAND
```
sed -i 's/->//g' file.txt
```
THIS WILL REMOVE `->` FROM EACH & EVERY LINE OF YOUR FILE.