Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

IP_Grabber (external, active interfaces, machines IP) 2 years ago

In my early coding days. I created a script that will grab certen IP's like external IP, the machine's IP, the active interfaces and the IP associated with the active interface. I made this code for training. I just found this code on my HDD recently and I find it interesting wich command's I used to grab the IP's. I dont know maybe you find this interesting and usefull in a way.


Code
"""IP_grabber by The_R (2011)"""
import socket
import os

print "\033[1;32m[+] \033[1;m External IP: "
cmd = "wget -q -O - http://myexternalip.com/raw"
print
os.system(cmd)
print
Interface_ip = socket.gethostbyname(socket.gethostname())
print "\033[1;32m[+] \033[1;m Machine's IP: "
print
print Interface_ip
print
print "\033[1;34m[!]\033[1;m Active interfaces:"
active_interfaces = "ifconfig -a | grep 'Link encap' | awk '{ print $1 '}"
os.system(active_interfaces)
print

cmd1 = "ip -4 addr show wlan0 | grep inet | awk '{print $2}' | cut -d/ -f1"
cmd2 = "ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'"

interface = raw_input("\033[1;31m[?]\033[1;m What is your interface? ")
if interface == 'wlan0':
    print
    print "\033[1;32m[+] \033[1;m IP associated with your interface: %s" % (interface)
    print
    os.system(cmd1)
elif interface == 'eth0':
    print
    print "\033[1;32m[+] \033[1;m IP associated with your interface: %s" % (interface)
    print
    os.system(cmd2)
else:
    print
    print "\033[1;31mNo IP found\033[1;m"


Regards,
Bro, post the script on pastebin. Don't center the code, it fucks up the formatting.
Why bother making a Python script if you're just going to use system calls? Why not bash?
(Sep 16, 2014 11:48 AM)botnetswatnet Wrote:  Bro, post the script on pastebin. Don't center the code, it fucks up the formatting.

Theres been many threads where posters tell him this, but Im not sure he speaks "common sense" or can hardly understand us :/ but it would be nice


Plus python is meant to be cross-OS, so to use system calls specific to linux is also not very...pleasant
Ok this guy is just not even trying anymore like, everyone tells him to put his code in pastebin yet he never does it, and then he gets neg repped for not doing it and yet he does it again. I am wondering if he even can read english....
Thanks For Alll i t s Simple script :D
(Sep 24, 2014 07:27 AM)Ahmed X Blade Wrote:  Thanks For Alll i t s Simple script :D

You Are Welcomeeee! C o u l d You fucking read the feedback before replying :D
Ok Brother After New Thread I WIll Paste In Pastebin
I coded this script. And posted this on Vip--Hackforums. If you are explaining my script please give credits.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by pmtobefriendJul 27, 2018 06:21 AM 12 400 Jul 27, 2018 06:21 AM
Last Post: pmtobefriend
[Python] by Blackshield_realMay 13, 2018 03:21 AM 0 64 May 13, 2018 03:21 AM
Last Post: Blackshield_real
[C#] by severosJul 5, 2017 09:24 AM 2 188 Jul 5, 2017 09:24 AM
Last Post: severos