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 IP Address

Run this Python script on your kali terminal to find IP address of specified interface.

				
					  #!/usr/bin/env python

import subprocess
import optparse
import re

# function to get interface from user as argument
def get_arguments():
    parser = optparse.OptionParser()
    parser.add_option("-i","--interface", dest="interface", help="Interface to obtain router IP")
    (options, arguments) = parser.parse_args()
    if not options.interface:
        parser.error("[-] Please specify interface, use --help for info. ")
    return(options)

# function to read ip address from ifconfig with users specified interface
def get_ip(interface):
    try:
        ifconfig_result = subprocess.check_output(["ifconfig", interface])
        ip_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(ifconfig_result))
        if ip_result:
            return ip_result.group(0)
        else:
            print("[-] Can not read IP address.")
    except subprocess.CalledProcessError as e:
        return None

options = get_arguments()

ip_address = get_ip(options.interface)
print("Your IP address is " + str(ip_address))


				
			
setting up a virtual lab
All Blogs, Beginners, Network
Sceptre
On March 11, 2022
Setting Up A Virtual Lab
Read more
0
how and when to use monitor mode
All Blogs, Beginners, Hacking, Network, Python
Sceptre
On March 18, 2022
How And When To Use Monitor Mode
Read more
0
3-ways-to-change-your-mac-address
All Blogs, Beginners, Network, Python
Sceptre
On March 25, 2022
3 Ways To Change Your Mac Address
Read more
0
  • 1
  • 2
  • 3
  • …
  • 5

© 2022 Sceptre Security, All Rights Reserved.