logo
logo
  • Home
  • Whoami
  • Services
    • Web Application Penetration Testing
    • Social Engineering Penetration Testing
    • Network Penetration Testing
  • Scripts
  • Blog
  • Shop
    • Clothing
    • Tech
    • Gifts
  • Contact
logo

Find Gateway IP

Run this Python script on your kali terminal to find your gateway IP using subprocess and regex modules.

				
					#!/usr/bin/env python

import subprocess
import re

#function to find gateway IP using subprocess and regex
def get_gateway():
    get_route = subprocess.check_output(["ip route"], shell=True)
    gateway_result = re.search(r"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]\
    |2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)", str(get_route))
    return gateway_result.group(0)

gateway = get_gateway()
print(gateway)
				
			
discover-devices-on-your-network
All Blogs, Beginners, Defend, Network, Protect
Sceptre
On April 2, 2022
Discover Devices On Your Network
Read more
0
starting-with-the-man-in-the-middle
All Blogs, Beginners, Hacking, Network
Sceptre
On April 9, 2022
Starting With The Man In The Middle
Read more
0
crack secure wifi passwords
All Blogs, Beginners, Hacking, Network
Sceptre
On April 16, 2022
Crack Wifi Passwords With Wordlists
Read more
0
  • 1
  • 2
  • 3
  • 4
  • 5

© 2022 Sceptre Security, All Rights Reserved.