• Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
AnonyViet - English Version
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
AnonyViet - English Version
No Result
View All Result

[PyHack] Lesson 2: Check if the MAC the user has changed is correct

AnonyViet by AnonyViet
December 29, 2024
in Tips
0

Continue lesson 1after we have written the function to change the MAC address on the terminal. We need to check whether the current MAC matches the MAC address specified by the user or not.

Join the channel Telegram belong to AnonyViet 👉 Link 👈

To do that, first, we must get the result of the “ifconfig” command and assign it to a string variable. Then, we will find the MAC in that pile of data.Check the MAC that the user has changed to see if it is correct

Get the results of the ifconfig command

In module subprocess there is a function called check_outputthis function will test your command and possibly assign the result to another variable.test mac with pyhack

[PyHack]  Lesson 2: Check if the MAC the user has changed is correct
It's a bit poorly printed, please help me take a look and see where the MAC is located (hihi). We fix this problem by adding the command decode('utf-8')[PyHack]  Lesson 2: Check if the MAC the user has changed is correct[PyHack]  Lesson 2: Check if the MAC the user has changed is correct

After successfully getting the results of the ifconfig command, we will find the MAC in this pile of data.

FIND MAC

In programming, there is an algorithm called Regular Expressions also known as RegEx for short. RegEX is a regular expression used for advanced string processing through its own expressions. These expressions will have their own rules and you must follow those rules for your expression to work. .

You guys come in Pythex So you can test this algorithm online. Click on the text Regular expressions cheatsheet to learn more about the expressions available in Pythex.Find mac address using Regular Expression

You copy the text that the ifconfig command returns and paste it in place Your test string. On section Your regular expression then enter \w\w:\w\w:\w\w:\w\w:\w\w:\w\w[PyHack]  Lesson 2: Check if the MAC the user has changed is correct

Ta da! We have found MAC's location, isn't it easy?

Using RegEx in python

The RegEx algorithm is included in the module re of python. We use functions re.search("cú pháp", biến)Using RegEx in python

[PyHack]  Lesson 2: Check if the MAC the user has changed is correct

Now we add an if statement to check whether the interface's MAC can be read or not.

[PyHack]  Lesson 2: Check if the MAC the user has changed is correct

When the program cannot read the MAC of the interface.

[PyHack]  Lesson 2: Check if the MAC the user has changed is correct

Compact code

We will put in the code from before hàm get_current_mac()and return the result to the current_mac variable, then print it out. Because curret_mac is a Non-type, I just forced it to a string.[PyHack]  Lesson 2: Check if the MAC the user has changed is correct

[PyHack]  Lesson 2: Check if the MAC the user has changed is correct

Check MAC

After getting the current MAC address, we will compare it with the new MAC address specified by the user. To see if when changing MAC, the current MAC address is the same as the MAC address the user entered. If they are the same, they will succeed, if they are different, they will fail.

check mac address python[PyHack]  Lesson 2: Check if the MAC the user has changed is correct

And this is when you enter the wrong interface.[PyHack]  Lesson 2: Check if the MAC the user has changed is correct

Remember the error of not being able to change MAC when the first pair of numbers is an odd number? Last time the error still appeared, but this time it's gone.[PyHack]  Lesson 2: Check if the MAC the user has changed is correct

Previous Post

How to use ChatGPT on WhatsApp: Did you know?

Next Post

How to use Deepseek V3: Chinese AI for free

AnonyViet

AnonyViet

Related Posts

4 ways to remove Ask Copilot from the right -click menu on Windows 11
Tips

4 ways to remove Ask Copilot from the right -click menu on Windows 11

May 15, 2025
How to write long status with color background on Facebook
Tips

How to write long status with color background on Facebook

May 15, 2025
Facebook ad blocking utilities and converted into hotgirl photos
Tips

Facebook ad blocking utilities and converted into hotgirl photos

May 14, 2025
How to detect IRQ conflict – Hardware conflict on Windows
Tips

How to detect IRQ conflict – Hardware conflict on Windows

May 13, 2025
How to use Auto Share Facebook to increase the article sharing
Tips

How to use Auto Share Facebook to increase the article sharing

May 12, 2025
Instructions for installing Facebook Lite on super light iPhone
Tips

Instructions for installing Facebook Lite on super light iPhone

May 10, 2025
Next Post
How to use Deepseek V3: Chinese AI for free

How to use Deepseek V3: Chinese AI for free

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

4 ways to remove Ask Copilot from the right -click menu on Windows 11

4 ways to remove Ask Copilot from the right -click menu on Windows 11

May 15, 2025
How to write long status with color background on Facebook

How to write long status with color background on Facebook

May 15, 2025
What is Vibe Coding? – Anonyviet

What is Vibe Coding? – Anonyviet

May 14, 2025
6 simple ways to know who blocked you on Instagram

6 simple ways to know who blocked you on Instagram

May 14, 2025
4 ways to remove Ask Copilot from the right -click menu on Windows 11

4 ways to remove Ask Copilot from the right -click menu on Windows 11

May 15, 2025
How to write long status with color background on Facebook

How to write long status with color background on Facebook

May 15, 2025
What is Vibe Coding? – Anonyviet

What is Vibe Coding? – Anonyviet

May 14, 2025
AnonyViet - English Version

AnonyViet

AnonyViet is a website share knowledge that you have never learned in school!

We are ready to welcome your comments, as well as your articles sent to AnonyViet.

Follow Us

Contact:

Email: anonyviet.com[@]gmail.com

Main Website: https://anonyviet.com

Recent News

4 ways to remove Ask Copilot from the right -click menu on Windows 11

4 ways to remove Ask Copilot from the right -click menu on Windows 11

May 15, 2025
How to write long status with color background on Facebook

How to write long status with color background on Facebook

May 15, 2025
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí SHBET bongdaso

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí SHBET bongdaso