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

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))
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.

Notifications