MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / _run_sqlmap_scan

Method _run_sqlmap_scan

advanced_vuln_scanner.py:1661–1709  ·  view source on GitHub ↗

Run SQLMap SQL injection scan

(self, scan_id: str, target: str, options: Dict)

Source from the content-addressed store, hash-verified

1659 Resolves the host, then `ip route get <ip>` and reads `dev <iface>`, so
1660 the UI can show whether a scan actually leaves over the Tailscale tunnel
1661 (tailscale0) or the box's own LAN. Scanner-agnostic — it's the OS routing
1662 decision, so it&#x27;s identical for nuclei, ZAP, nmap, etc. Best-effort."""
1663 try:
1664 import socket
1665 import urllib.parse
1666 host = (target or '').strip()
1667 if '://' in host:
1668 host = urllib.parse.urlparse(host).hostname or host
1669 else:
1670 host = host.split('/')[0].split(':')[0]
1671 if not host:
1672 return '', False
1673 try:
1674 ip = socket.gethostbyname(host)
1675 except Exception:
1676 ip = host # already an IP, or unresolvable — let ip-route decide
1677 out = subprocess.run(['ip', 'route', 'get', ip],
1678 capture_output=True, text=True, timeout=5).stdout
1679 m = re.search(r'\bdev\s+(\S+)', out or '')
1680 iface = m.group(1) if m else ''
1681 return iface, iface.startswith('tailscale')
1682 except Exception:
1683 return '', False
1684
1685 @staticmethod
1686 def _available_mib() -> Optional[int]:
1687 """Free RAM right now, in MiB (None if it can't be read)."""
1688 try:
1689 import psutil
1690 return int(psutil.virtual_memory().available / (1024 * 1024))
1691 except Exception:
1692 pass
1693 try:
1694 with open('/proc/meminfo') as f:
1695 for line in f:
1696 if line.startswith('MemAvailable:'):
1697 return int(int(line.split()[1]) / 1024)
1698 except Exception:
1699 pass
1700 return None
1701
1702 @staticmethod
1703 def _memory_cgroup_available() -> bool:
1704 """True when a hard memory cap via systemd-run will actually bite.
1705
1706 Needs systemd-run present and the cgroup-v2 memory controller enabled.
1707 On Raspberry Pi the memory controller is often off until
1708 `cgroup_enable=memory cgroup_memory=1` is added to the kernel cmdline,
1709 so this can be False even with systemd — in which case we don&#x27;t wrap
1710 (the flag would be silently ignored anyway).
1711 """
1712 if not shutil.which('systemd-run'):

Callers 1

_run_scanMethod · 0.95

Calls 6

_parse_sqlmap_outputMethod · 0.95
debugMethod · 0.80
killMethod · 0.80
getMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected