Latest
Loading...

Python for Ethical Hacking

Command Prompt

Featured Post

#5 Jarvis

Jarvis      Now we are going to create some functions. With the help of this functions we are going to make our Play music Open website...

#4 Variables || MAC Changer || Python for Ethical Hacking

#4 Variables || MAC Changer || Python for Ethical Hacking

 Python for Ethical Hacking

MAC Changer

4th Lesson

As we create a simple MAC Changer tool but it have some values that will be change for using that tool i.e., Internet Interface - eth0, wlan0, ...  and the new MAC Address to change the current MAC.

It is not a good practice to come and change the Interface name and new MAC Address. For that we will use Variables


Variables

A Python variable is a reserved memory location to store values. In other words, a variable in a python program gives data to the computer for processing. Like Maths, it is a name that store information

To use variable for our program we use some variable names

First we will specify a variable for the internet interfaces, we can use x, y as a variable for this but it will make our program to become confusing when we check over after some days. To avoid that we use a variable name that related to our purpose for that we use a name "interface" for internet interfaces.
  • interface = "eth0"
Next we use a variable to specify MAC Address that is "new_variable"
  • new_mac = "00:11:22:33:44:01"
Now we created two variables to specify Internet interfaces & MAC Address. To check that the variables that return the value in it we use "print" statement
  • print ("[+] Changing the MAC Address of " + interface + " to " + new_mac)
Make sure that the variable should not placed inside the double quotation mark. If it is inside the quotation mark it will not return the value of that variable, it is consider as a string. So it return the name as we mention i.e., If we place interface inside quotation mark it return interface not eth0.




In next post we will use variables inside the command that used for MAC Changer

No comments:

Post a Comment