-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-api-advanced.js
More file actions
77 lines (68 loc) · 2.57 KB
/
test-api-advanced.js
File metadata and controls
77 lines (68 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* Advanced test to inspect the website structure
*/
const https = require('https');
const fs = require('fs');
// Fetch and analyze the main page
https.get('https://landrecords.karnataka.gov.in/service3/', (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
// Save HTML for inspection
fs.writeFileSync('website-content.html', data);
console.log('Saved website content to website-content.html');
// Look for JavaScript files that might contain API endpoints
const jsMatches = data.match(/<script[^>]*src=["']([^"']+\.js[^"']*)["']/gi);
if (jsMatches) {
console.log('\nFound JavaScript files:');
jsMatches.forEach(match => {
const src = match.match(/src=["']([^"']+)["']/i);
if (src) console.log(` ${src[1]}`);
});
}
// Look for AJAX calls or fetch requests
const ajaxMatches = data.match(/(fetch|ajax|xmlhttp|\.post|\.get)\(["']([^"']+)["']/gi);
if (ajaxMatches) {
console.log('\nFound potential API calls:');
ajaxMatches.forEach(match => console.log(` ${match}`));
}
// Look for form fields
const inputMatches = data.match(/<input[^>]*name=["']([^"']+)["']/gi);
if (inputMatches) {
console.log('\nFound form input fields:');
const uniqueFields = new Set();
inputMatches.forEach(match => {
const name = match.match(/name=["']([^"']+)["']/i);
if (name) uniqueFields.add(name[1]);
});
uniqueFields.forEach(field => console.log(` ${field}`));
}
// Look for select/dropdown fields
const selectMatches = data.match(/<select[^>]*name=["']([^"']+)["']/gi);
if (selectMatches) {
console.log('\nFound select/dropdown fields:');
selectMatches.forEach(match => {
const name = match.match(/name=["']([^"']+)["']/i);
if (name) console.log(` ${name[1]}`);
});
}
// Look for any URL patterns that might be API endpoints
const urlPatterns = data.match(/["']([^"']*\/[^"']*\.(php|aspx|jsp|do|action)[^"']*)["']/gi);
if (urlPatterns) {
console.log('\nFound potential endpoint URLs:');
const uniqueUrls = new Set();
urlPatterns.forEach(match => {
const url = match.match(/["']([^"']+)["']/i);
if (url && !url[1].startsWith('http')) {
uniqueUrls.add(url[1]);
}
});
uniqueUrls.forEach(url => console.log(` ${url}`));
}
console.log('\n---\nCheck website-content.html for full HTML structure');
});
}).on('error', (err) => {
console.error('Error:', err.message);
});