def test_idor(self, url, param='id'): """Test for Insecure Direct Object References""" current_id = self._get_param_value(url, param) if not current_id or not current_id.isdigit(): return # Test adjacent IDs for offset in [1, -1, 2, -2]: test_id = str(int(current_id) + offset) test_url = url.replace(f"param=current_id", f"param=test_id") try: response = self.session.get(test_url, timeout=5) # If response is similar but different content, potential IDOR if response.status_code == 200 and "login" not in response.url.lower(): soup = BeautifulSoup(response.text, 'html.parser') title_tag = soup.find('title') if title_tag and '404' not in title_tag.text.lower(): self._report_vulnerability(f'Potential IDOR (ID: test_id)', test_url) except Exception as e: print(f" [!] IDOR test failed: e")
# Crawl IDs from 1 to 50 valid_pages = auditor.crawl_ids(target_url, start=1, end=50) inurl index php id 1 shop
def crawl_ids(self, base_url, start=1, end=100): """Crawl through ID range to find valid pages""" parsed = urlparse(base_url) query_params = parse_qs(parsed.query) if 'id' not in query_params: print("[!] No 'id' parameter found in URL") return [] valid_urls = [] for i in range(start, end + 1): test_url = base_url.replace(f"id=query_params['id'][0]", f"id=i") try: response = self.session.get(test_url, timeout=5) if response.status_code == 200: # Check if it's a valid product page (not a 404/redirect) if "product" in response.text.lower() or "price" in response.text.lower(): valid_urls.append(test_url) print(f"[+] Valid product ID found: i") # Extract data immediately self.extract_product_info(test_url) self.test_sql_injection(test_url) self.test_idor(test_url) time.sleep(self.delay) # Be respectful to the server except Exception as e: print(f"[-] ID i failed: e") return valid_urls f"param=test_id") try: response = self.session.get(test_url
This transforms a simple search pattern into a powerful, actionable security and data extraction tool. end=50) def crawl_ids(self
def _extract_images(self, soup, base_url): images = [] for img in soup.find_all('img', src=True): img_url = urljoin(base_url, img['src']) if 'product' in img_url.lower() or 'item' in img_url.lower(): images.append(img_url) return images[:5]