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

#8 Functions || MAC Changer || Python For Hacking

#8 Functions || MAC Changer || Python For Hacking

Python for Ethical Hacking

MAC Changer

Functions


                     Functions is used in almost all the program. We also use functions in our MAC Changer tool before like input() , print(), and more. These functions are known as Build in function. We will discuss that below

Build-in or predefined functions:

                                Built in functions are functions already built into python interpreter and are readily available for use.

Example:

  • print()           #Print objects to the stream 

User defined function:

                                The function defined by the users according to their requirements are called user-defined functions. The user can modify the function according to their requirements.

Syntax:

                def function_name(parameters):
            "function_docstring"
            function_suite
            return[expression]


                                A function can be executed by calling it from another function or directly from the python prompt by its name

Syntax

                  function_name(parameters)


Now, we will create function for mac changer called change_mac all commands below

Commands:

def change_mac(interface, new_mac):
    print("[+]Changing MAC Address of " + interface + "to " + new_mac)
   subprocess.call("ifconfig " + interface + "down", shell=True)
    subprocess.call("ifconfig " + interface + " hw ether " + new_mac, shell=True)
    subprocess.call("ifconfig " + interface + "up", shell=True)


I think this commands are not arrange in correct order due to lack of space. Please check the video below to get better understand.







No comments:

Post a Comment