Skip to content

Commit adc05fa

Browse files
authored
Merge pull request #7 from lordixir/main
v2.2: Firewall bypass, interrupt handling, and major improvements
2 parents 837fe13 + a25e9c7 commit adc05fa

7 files changed

Lines changed: 309 additions & 68 deletions

File tree

README.md

Lines changed: 66 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@
33
An open-source, cross-platform powerful network analysis tool for discovering websites hosted on specific IP addresses and ASN ranges.
44

55
## Features
6-
- ASN scanning (Autonomous System Number)
6+
7+
- ASN scanning (Autonomous System Number) with IPv4/IPv6 support
78
- IP block scanning (CIDR format)
8-
- HTTPS/HTTP support
9-
- DNS resolution
9+
- HTTPS/HTTP automatic fallback
10+
- Firewall bypass techniques (IP shuffling, header randomization, jitter)
11+
- Proxy support (HTTP/HTTPS/SOCKS5)
12+
- Custom DNS servers
13+
- Rate limiting (token bucket algorithm)
14+
- Dynamic timeout calculation
1015
- Text and JSON output formats
1116
- Configurable concurrent workers (1-1000)
1217
- Real-time progress bar
13-
- Graceful interrupt handling with result export
18+
- Graceful Ctrl+C handling with result export
1419

1520
## Installation
1621

17-
Download the latest version from [Releases](https://github.com/sercanarga/ipmap/releases) and run:
22+
Download the latest version from [Releases](https://github.com/lordixir/ipmap/releases) and run:
1823

1924
```bash
2025
unzip ipmap.zip
@@ -25,23 +30,27 @@ chmod +x ipmap
2530
## Usage
2631

2732
### Parameters
33+
2834
```bash
2935
-asn AS13335 # Scan all IP blocks in the ASN
3036
-ip 103.21.244.0/22 # Scan specified IP blocks
3137
-d example.com # Search for specific domain
32-
-t 200 # Request timeout in milliseconds
38+
-t 2000 # Request timeout in milliseconds (auto-calculated if not set)
3339
--export # Auto-export results
3440
-format json # Output format (text or json)
35-
-workers 100 # Number of concurrent workers
41+
-workers 100 # Number of concurrent workers (default: 100)
3642
-v # Verbose mode
3743
-c # Continue scanning until completion
44+
-proxy http://127.0.0.1:8080 # Proxy URL (HTTP/HTTPS/SOCKS5)
45+
-rate 50 # Rate limit (requests/second, 0 = unlimited)
46+
-dns 8.8.8.8,1.1.1.1 # Custom DNS servers
3847
```
3948

4049
### Examples
4150

42-
**Scan ASN:**
51+
**Basic ASN scan (auto timeout):**
4352
```bash
44-
ipmap -asn AS13335 -t 300
53+
ipmap -asn AS13335
4554
```
4655

4756
**Find domain in ASN:**
@@ -51,70 +60,75 @@ ipmap -asn AS13335 -d example.com
5160

5261
**Scan IP blocks:**
5362
```bash
54-
ipmap -ip 103.21.244.0/22,103.22.200.0/22 -t 300
55-
```
56-
57-
**Export results:**
58-
```bash
59-
ipmap -asn AS13335 -d example.com --export
63+
ipmap -ip 103.21.244.0/22,103.22.200.0/22
6064
```
6165

6266
**High-performance scan:**
6367
```bash
6468
ipmap -asn AS13335 -workers 200 -v
6569
```
6670

67-
## Proxy Usage
68-
69-
ipmap supports HTTP, HTTPS, and SOCKS5 proxies for anonymous scanning and bypassing network restrictions.
71+
**Export results:**
72+
```bash
73+
ipmap -asn AS13335 -d example.com --export
74+
```
7075

71-
### Proxy Parameters
76+
**JSON output:**
7277
```bash
73-
-proxy http://127.0.0.1:8080 # HTTP proxy
74-
-proxy https://127.0.0.1:8080 # HTTPS proxy
75-
-proxy socks5://127.0.0.1:1080 # SOCKS5 proxy
76-
-rate 50 # Rate limit (requests/second)
77-
-dns 8.8.8.8,1.1.1.1 # Custom DNS servers
78+
ipmap -asn AS13335 -format json --export
7879
```
7980

80-
### Proxy Examples
81+
## Proxy & Rate Limiting
82+
83+
ipmap supports HTTP, HTTPS, and SOCKS5 proxies for anonymous scanning.
8184

82-
**Basic HTTP proxy:**
85+
**HTTP proxy:**
8386
```bash
8487
ipmap -asn AS13335 -proxy http://127.0.0.1:8080
8588
```
8689

87-
**SOCKS5 proxy with Tor:**
90+
**SOCKS5 proxy (Tor):**
8891
```bash
8992
ipmap -asn AS13335 -proxy socks5://127.0.0.1:9050
9093
```
9194

92-
**Proxy with authentication:**
95+
**Proxy with auth:**
9396
```bash
94-
ipmap -asn AS13335 -proxy http://user:password@proxy.example.com:8080
97+
ipmap -asn AS13335 -proxy http://user:pass@proxy.com:8080
9598
```
9699

97-
**Proxy with rate limiting:**
100+
**Rate limiting:**
98101
```bash
99-
ipmap -asn AS13335 -proxy http://127.0.0.1:8080 -rate 50
102+
ipmap -asn AS13335 -rate 50 -workers 50
100103
```
101104

102-
**Proxy with custom DNS:**
105+
**Full configuration:**
103106
```bash
104-
ipmap -asn AS13335 -proxy socks5://127.0.0.1:1080 -dns 8.8.8.8,1.1.1.1
107+
ipmap -asn AS13335 -d example.com -proxy http://127.0.0.1:8080 -rate 100 -workers 50 -dns 8.8.8.8 -v --export
105108
```
106109

107-
**Full configuration example:**
108-
```bash
109-
ipmap -asn AS13335 -d example.com -proxy http://127.0.0.1:8080 -rate 100 -workers 50 -v --export
110-
```
110+
> **Note:** When using proxies, reduce worker count and enable rate limiting to avoid overwhelming the proxy.
111+
112+
## Firewall Bypass Features
111113

112-
> **Note:** When using proxies, consider reducing the worker count (`-workers`) and enabling rate limiting (`-rate`) to avoid overwhelming the proxy server.
114+
ipmap includes built-in firewall bypass techniques:
115+
116+
- **IP Shuffling:** Randomizes scan order to avoid sequential pattern detection
117+
- **Header Randomization:** Rotates User-Agent, Accept-Language, Chrome versions, platforms
118+
- **Request Jitter:** Adds random 0-50ms delay between requests
119+
- **Dynamic Timeout:** Auto-adjusts timeout based on worker count
120+
121+
## Interrupt Handling (Ctrl+C)
122+
123+
Press Ctrl+C during scan to:
124+
1. Immediately stop all scanning
125+
2. View found results count
126+
3. Option to export partial results
113127

114128
## Building
115129

116130
```bash
117-
git clone https://github.com/sercanarga/ipmap.git
131+
git clone https://github.com/lordixir/ipmap.git
118132
cd ipmap
119133
go build -o ipmap .
120134
```
@@ -125,6 +139,19 @@ go build -o ipmap .
125139
go test ./... -v
126140
```
127141

142+
## Changelog (v2.0)
143+
144+
- ✅ Added IP shuffling for firewall bypass
145+
- ✅ Added request jitter (0-50ms random delay)
146+
- ✅ Added header randomization (language, chrome version, platform)
147+
- ✅ Fixed Ctrl+C interrupt handling (immediate stop)
148+
- ✅ Added dynamic timeout calculation based on workers
149+
- ✅ Added IPv6 support for ASN scanning
150+
- ✅ Improved error logging
151+
- ✅ Fixed result collection bug with high workers
152+
- ✅ Removed gzip to fix response parsing
153+
- ✅ Added scan statistics at completion
154+
128155
## License
129156

130157
This project is open-source and available under the MIT License.

main.go

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"strconv"
1212
"strings"
1313
"syscall"
14+
"time"
1415
)
1516

1617
var (
@@ -46,7 +47,7 @@ func main() {
4647
}
4748

4849
// Setup interrupt handler
49-
interruptData = &modules.InterruptData{}
50+
interruptData = modules.NewInterruptData()
5051
setupInterruptHandler()
5152

5253
// Log configuration if verbose
@@ -84,9 +85,19 @@ func main() {
8485
return
8586
}
8687

88+
// Set default timeout if not specified and no domain to calculate from
8789
if *timeout == 0 && *domain == "" {
88-
fmt.Println("Timeout parameter( -t ) is not set. By entering the domain, you can have it calculated automatically.")
89-
return
90+
// Base timeout: 2000ms, scale up for high worker counts
91+
baseTimeout := 2000
92+
if *workers > 200 {
93+
// Add extra time for high concurrency (network saturation)
94+
baseTimeout = baseTimeout + (*workers / 100 * 500)
95+
}
96+
if baseTimeout > 10000 {
97+
baseTimeout = 10000 // Max 10 seconds
98+
}
99+
*timeout = baseTimeout
100+
config.InfoLog("Using auto-calculated timeout: %dms (workers: %d)", *timeout, *workers)
90101
}
91102

92103
if *domain != "" {
@@ -130,7 +141,15 @@ func setupInterruptHandler() {
130141

131142
go func() {
132143
<-sigChan
133-
fmt.Println("\n\n[!] Scan interrupted by user")
144+
fmt.Println("\n\n[!] Scan interrupted by user - stopping...")
145+
146+
// Signal all goroutines to stop immediately
147+
if interruptData != nil {
148+
interruptData.Cancel()
149+
}
150+
151+
// Give goroutines a moment to stop
152+
time.Sleep(100 * time.Millisecond)
134153

135154
if interruptData != nil && len(interruptData.Websites) > 0 {
136155
fmt.Printf("\n[*] Found %d websites before interruption\n", len(interruptData.Websites))

modules/interrupt_handler.go

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,43 @@ import "sync"
44

55
// InterruptData holds scan data for interrupt handling
66
type InterruptData struct {
7-
Websites [][]string
8-
IPBlocks []string
9-
Domain string
10-
Timeout int
11-
mu sync.Mutex
7+
Websites [][]string
8+
IPBlocks []string
9+
Domain string
10+
Timeout int
11+
Cancelled bool // Flag to indicate cancellation
12+
CancelCh chan struct{} // Channel to signal cancellation
13+
mu sync.Mutex
14+
}
15+
16+
// NewInterruptData creates a new InterruptData with initialized cancel channel
17+
func NewInterruptData() *InterruptData {
18+
return &InterruptData{
19+
CancelCh: make(chan struct{}),
20+
}
21+
}
22+
23+
// Cancel signals all goroutines to stop
24+
func (id *InterruptData) Cancel() {
25+
if id == nil {
26+
return
27+
}
28+
id.mu.Lock()
29+
defer id.mu.Unlock()
30+
if !id.Cancelled {
31+
id.Cancelled = true
32+
close(id.CancelCh)
33+
}
34+
}
35+
36+
// IsCancelled returns whether the scan has been cancelled
37+
func (id *InterruptData) IsCancelled() bool {
38+
if id == nil {
39+
return false
40+
}
41+
id.mu.Lock()
42+
defer id.mu.Unlock()
43+
return id.Cancelled
1244
}
1345

1446
// AddWebsite safely adds a website to the interrupt data

modules/request.go

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@ func createDialContext() func(ctx context.Context, network, addr string) (net.Co
125125
}
126126

127127
func createHTTPClientWithConfig() *http.Client {
128+
// Calculate connection pool size based on worker count
129+
maxConns := config.Workers
130+
if maxConns < 100 {
131+
maxConns = 100
132+
}
133+
maxConnsPerHost := maxConns / 10
134+
if maxConnsPerHost < 10 {
135+
maxConnsPerHost = 10
136+
}
137+
128138
transport := &http.Transport{
129139
TLSClientConfig: &tls.Config{
130140
InsecureSkipVerify: true,
@@ -138,14 +148,16 @@ func createHTTPClientWithConfig() *http.Client {
138148
tls.TLS_RSA_WITH_AES_128_GCM_SHA256,
139149
},
140150
},
141-
MaxIdleConns: 100,
142-
MaxIdleConnsPerHost: 10,
151+
MaxIdleConns: maxConns,
152+
MaxIdleConnsPerHost: maxConnsPerHost,
153+
MaxConnsPerHost: maxConnsPerHost * 2, // Allow more active connections
143154
IdleConnTimeout: 90 * time.Second,
144155
TLSHandshakeTimeout: 10 * time.Second,
145156
ResponseHeaderTimeout: 10 * time.Second,
146157
ExpectContinueTimeout: 1 * time.Second,
147158
DialContext: createDialContext(),
148159
ForceAttemptHTTP2: true,
160+
DisableKeepAlives: false, // Keep connections alive for reuse
149161
}
150162

151163
// Configure proxy if specified
@@ -210,18 +222,39 @@ func RequestFuncWithRetry(ip string, url string, timeout int, maxRetries int) []
210222
ua := uarand.GetRandom()
211223
req.Header.Set("User-Agent", ua)
212224
req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8")
213-
req.Header.Set("Accept-Language", "en-US,en;q=0.9,tr;q=0.8")
214-
req.Header.Set("Accept-Encoding", "gzip, deflate, br")
225+
226+
// Randomize Accept-Language to avoid fingerprinting
227+
languages := []string{
228+
"en-US,en;q=0.9",
229+
"en-GB,en;q=0.9",
230+
"en-US,en;q=0.9,tr;q=0.8",
231+
"de-DE,de;q=0.9,en;q=0.8",
232+
"fr-FR,fr;q=0.9,en;q=0.8",
233+
}
234+
req.Header.Set("Accept-Language", languages[time.Now().UnixNano()%int64(len(languages))])
235+
236+
req.Header.Set("Accept-Encoding", "identity") // No compression to avoid decompression issues
215237
req.Header.Set("Connection", "keep-alive")
216238
req.Header.Set("Upgrade-Insecure-Requests", "1")
217239
req.Header.Set("Sec-Fetch-Dest", "document")
218240
req.Header.Set("Sec-Fetch-Mode", "navigate")
219241
req.Header.Set("Sec-Fetch-Site", "none")
220242
req.Header.Set("Sec-Fetch-User", "?1")
221243
req.Header.Set("Cache-Control", "max-age=0")
222-
req.Header.Set("Sec-Ch-Ua", `"Chromium";v="120", "Not_A Brand";v="24"`)
244+
245+
// Randomize browser version fingerprint
246+
chromeVersions := []string{
247+
`"Chromium";v="120", "Not_A Brand";v="24"`,
248+
`"Chromium";v="119", "Not_A Brand";v="24"`,
249+
`"Chromium";v="121", "Not_A Brand";v="24"`,
250+
`"Google Chrome";v="120", "Chromium";v="120"`,
251+
}
252+
req.Header.Set("Sec-Ch-Ua", chromeVersions[time.Now().UnixNano()%int64(len(chromeVersions))])
223253
req.Header.Set("Sec-Ch-Ua-Mobile", "?0")
224-
req.Header.Set("Sec-Ch-Ua-Platform", `"Windows"`)
254+
255+
// Randomize platform
256+
platforms := []string{`"Windows"`, `"macOS"`, `"Linux"`}
257+
req.Header.Set("Sec-Ch-Ua-Platform", platforms[time.Now().UnixNano()%int64(len(platforms))])
225258

226259
resp, err := GetHTTPClient().Do(req)
227260

0 commit comments

Comments
 (0)