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


				
			
learn_sql_queries
All Blogs, Beginners, Website
Sceptre
On May 11, 2022
Learn SQL Queries
Read more
0
learn_sql_injection_basics
All Blogs, Beginners, Website
Sceptre
On May 18, 2022
Learn SQL Injection Basics
Read more
0
how to hack a website by uploading files
All Blogs, Beginners, Hacking, Website
Sceptre
On May 25, 2022
How To Hack A Website By Uploading Files
Read more
0
  • 1
  • 2
  • 3
  • 4
  • 5

© 2022 Sceptre Security, All Rights Reserved.