Hey folks. This is nothing extravagant, as I am pretty darn new to coding. This script has multiple functions built into it to achieve a few different things. It's main basis is to spoof the MAC address, and has another option to look up host names, and call it using 'tor-resolve'. To change the MAC to factory settings, I called 'mac-changer', so make sure tor is up and running and mac-changer if you plan on using it.
Let me know what you think. I am about 6 weeks into coding in python, and just trying to stay busy with it. Also, I called alot of external programs with this, but I used basic unix commands to change the mac to the one specified.
In plain english, for not coding too long i'm kind of proud of this. It's a bit bloated, and lengthy, but just felt myself mashing the keys, so I went with it. Any feedback is appreciated. Thank You.
#This script can be used to spoof a MAC HW address on just about any interface. Make sure to use the proper format when it asks to input the new mac address. I wrote this script as a research project, and embedded UNIX command's inside the two functions. If you are running windows, you will definitely want to modify the os.system call(s) to dos commands."""
#12/13/14 Update: rootkitfunction() added. When this function is selected, the log files will be deleted (experimental purposes only)
import os # Import's os module, enable's access to the operating system's command prompt. *nix /bin/bash, /bin/sh etc. Windows cmd.exe
import time
import socket
from datetime import datetime
def rootkitfunction():
choice=raw_input("Start 'Cover Tracks'?: (y,n)")
if choice == "y":
print("Covering Tracks...")
time.sleep(3)
os.system("echo "" > /var/log/auth.log")
os.system("echo "" > ~/.bash_history")
os.system("echo "" > $HOME/.bash_history")
os.system("rm ~/.bash_history -rf")
os.system("history -c")
os.system("export HISTFILESIZE=0")
os.system("export HISTSIZE=0")
os.system("unset HISTFILE")
os.system("kill 9 $$")
os.system("ln /dev/null ~/.bash_history -sf")
""" Deletes all log files on linux system - has to be run as root !"""
def mon():
os.system("sudo ifconfig mon0 down")
time.sleep(1)
newmac=raw_input("What new mac do you want to issue mon0 (monitor mode mac): ")
print("OK. New MAC selected as: %s")% (newmac)
var="sudo ifconfig mon0 hw ether "+newmac
os.system(var)
print("Bringing mon0 back up")
time.sleep(1)
def ipget():
hostname=raw_input("Enter Hostname: ")
print("Connecting to tor network. Sockets up. [Check]")
cmd1="tor-resolve "+hostname
os.system(cmd1)
time.sleep(2)
nmap=raw_input("Would you like to call nmap to scan this host for a simple SYN scan? (y)(n)")
if nmap=="y":
cmd="nmap -v -sS "+hostname
os.system(cmd)
if nmap=="n":
print("Exiting Program")
time.sleep(2)
os.system("clear")
else:
print("Error ! exiting....")
os.system("clear")
def wireless():
print("MAC-Socket by shome. You have selected the wireless setting")
print("Printing current MAC")
time.sleep(1)
os.system("ifconfig wlan0 | grep HWaddr")
time.sleep(3)
choice=input("Press (1) to spoof mac address (2) to exit/restart program, (3) to reset wlan0 MAC to factory settings: ")
if choice==1:
time.sleep(2)
nmachoice=raw_input("Do you want to change mac manually(1), or choose from a list(2): ")
if nmachoice == 1:
os.system("ifconfig wlan0 down")
print "Wireless Interface down [OK]"
newmac=raw_input("What would you like to change the MAC address to: ")
time.sleep(2)
cmd="sudo ifconfig wlan0 hw ether "+newmac
os.system(cmd)
print("Re-Enabling wlan0 Interface.")
os.system("sudo ifconfig wlan0 up")
os.system("service network-manager restart")
print "Wireless Interface Re-Enabled[OK], Network-Manager Re-Enabled[OK]"
print("MAC Address Spoofed successfully to %s") % (newmac)
if nmachoice == 2:
list=['(1)2C:F0:EE:43:C7:5D','(2)3C:15:C2:CA:00:0C','(3)D8:A2:5E:93:10:9B','(4)48:F8:B3:38:4A:58','(5)C0:EA:E4:09:48:80','(6)00:11:22:33:44:55']
print(list)
newmacchoice=input("Please make your new MAC address selection from the provided MACS: (1-6)")
if newmacchoice == 1:
print("Bringing down wlan0 interface")
time.sleep(2)
os.system("sudo ifconfig wlan0 down")
macselection=list[0]
print('Changing MAC to ',macselection)
newmcmd="sudo ifconfig wlan0 hw ether "+macselection
os.system(newcmd)
if newmacchoice == 2:
print("Bringing down wlan0 interface: ")
os.system("sudo ifconfig wlan0 down")
time.sleep(2)
print "Wlan0 Interface down[OK] !"
macselection2=list[1]
print('Changing MAC to ',macselection2)
newcmd2="sudo ifconfig wlan0 hw ether "+macselection2
os.system(newcmd2)
print "MAC Spoofed Successfully"
time.sleep(2)
print "Double Checking ifconfig"
os.system("ifconfig wlan0")
time.sleep(4)
os.system("clear")
if newmacchoice == 3:
print("Bringing down wlan0 interface: ")
os.system("sudo ifconfig wlan0 down")
time.sleep(2)
print "Wlan0 Interface down[OK] !"
macselection3=list[2]
print('Changing MAC to ',macselection3)
newcmd3="sudo ifconfig wlan0 hw ether "+macselection3
os.system(newcmd3)
time.sleep(3)
print "MAC Spoofed Successfully"
time.sleep(2)
print "Double Checking ifconfig"
os.system("ifconfig wlan0")
time.sleep(2)
os.system("clear")
else:
systeminput=input("Error ! (1)to exit (2) to restart script: ")
if systeminput == 1:
os.system("clear")
elif systeminput == 2:
os.system("python $HOME/Python/mac-sock*/mac-socket-beta.py")
if choice==2:
restartchoice=raw_input("Would you like to restart the program: y or n")
if restartchoice== "y":
os.system("python /home/shome/Python/mac-socket-project/mac-socket-beta.py")
if restartchoice=="n":
print("Exiting")
time.sleep(2)
os.system("clear")
if choice==3:
print("Changing MAC to Permanent settings")
time.sleep(2)
print("Calling UNIX utility 'macchanger' to the rescue...")
time.sleep(1)
os.system("ifconfig wlan0 down")
os.system("macchanger -p wlan0")
time.sleep(1)
os.system("service network-manager restart")
os.system("ifconfig wlan0 up")
print("MAC successfully changed back to factory settings.")
else:
print("Error! Exiting")
def ethernet():
print("MAC Python Script by shome. You have selected the eth0 setting")
time.sleep(1)
print("Printing current MAC")
time.sleep(1)
os.system("ifconfig eth0 | grep HWaddr")
time.sleep(1)
choice=input("Press (1) to change your mac address, (2) to exit/restart program, (3) to reset eth0 MAC interface to factory settings: ")
if choice==1:
time.sleep(1)
print("Shutting down eth0 Interface.")
os.system("ifconfig eth0 down")
time.sleep(2)
print("eth0 Interface down. Check")
time.sleep(2)
print("Before I ask you what new MAC address you want, here is a couple to choose from")
os.system("cat $HOME/Python/mac-socket-project/MACS")
time.sleep(2)
newmac=raw_input("What would you like to change the MAC address to: ")
print("Changing new mac address to %s") % (newmac)
time.sleep(2)
cmd="ifconfig eth0 hw ether "+newmac
os.system(cmd)
print("Re-Enabling eth0 Interface.")
os.system("ifconfig eth0 up")
os.system("service network-manager restart")
elif choice==2:
restartchoice=raw_input("Would you like to restart the program: y or n: ")
if restartchoice== "y":
os.system("python $HOME/Python/mac-socket-project/mac-socket.py")
if restartchoice=="n":
print("Exiting")
time.sleep(2)
os.system("clear")
elif choice==3:
print("Changing MAC to Permanent settings")
time.sleep(2)
print("Calling UNIX utility 'macchanger' to the rescue...")
time.sleep(1)
os.system("macchanger -p wlan0")
time.sleep(1)
print("MAC successfully changed back to factory settings.")
else:
print("Error! Exiting")
now=datetime.now()
print("Mac-Socket project by SHome")
time.sleep(1)
print("The current date is: %s/%s/%s") % (now.month,now.day,now.year)
time.sleep(1)
print("And the time is: %s:%s") % (now.hour,now.minute)
time.sleep(1)
time.sleep(1)
print("make sure you are running this as root.")
time.sleep(1)
choiceinterface=input("Usage: (1) for Mac Spoofing option, (2) for 'cover tracks': ") # 'cover tracks' option - see rootkitfunction() ^
if choiceinterface==1:
interface=input("Please select interface that MAC will be spoofed: eth0(1), wlan0(2), (3)mon0, or select (4) to convert a hostname to an ip address: ")
if interface==1:
ethernet()
elif interface==2:
wireless()
if interface==3:
mon()
elif interface==4:
ipget()
else:
elsechoice=raw_input("Error ! No selection made. Restart? (y)(n): ")
if elsechoice == "y":
time.sleep(2)
os.system("clear")
os.system("python $HOME/Python/mac-socket-project/mac-socket-beta.py")
elif elsechoice == "n":
print("Exiting...")
time.sleep(2)
os.system("clear")
if choiceinterface == 2:
rootkitfunction()