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

[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

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

Get free Cambridge courses to prepare for IELTS, Starters, Movers
Tips

Get free Cambridge courses to prepare for IELTS, Starters, Movers

June 4, 2026
How to record reaction videos with Android phones, no app needed
Tips

How to record reaction videos with Android phones, no app needed

June 1, 2026
Instructions on how to get Google AI Pro 1 year for free for new accounts
Tips

Instructions on how to get Google AI Pro 1 year for free for new accounts

June 1, 2026
Top free AI tools to help write, test and optimize content
Tips

Top free AI tools to help write, test and optimize content

June 1, 2026
Instructions for receiving Lovable Pro 12 months for free
Tips

Instructions for receiving Lovable Pro 12 months for free

May 29, 2026
Instructions for receiving 1 month of ElevenLabs Creator for free worth
Tips

Instructions for receiving 1 month of ElevenLabs Creator for free worth $22

May 25, 2026
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

How to buy in-game items for free on iPhone

How to buy in-game items for free on iPhone

June 8, 2026
Practical use of Xiaomi 17T Pro: This is a good phone in 2026

Practical use of Xiaomi 17T Pro: This is a good phone in 2026

June 8, 2026
Instructions to receive 6 months of IObit Malware Fighter 13 Pro for free

Instructions to receive 6 months of IObit Malware Fighter 13 Pro for free

June 7, 2026
How to use free online textbooks from grades 1 to 12

How to use free online textbooks from grades 1 to 12

June 6, 2026
How to buy in-game items for free on iPhone

How to buy in-game items for free on iPhone

June 8, 2026
Practical use of Xiaomi 17T Pro: This is a good phone in 2026

Practical use of Xiaomi 17T Pro: This is a good phone in 2026

June 8, 2026
Instructions to receive 6 months of IObit Malware Fighter 13 Pro for free

Instructions to receive 6 months of IObit Malware Fighter 13 Pro for free

June 7, 2026
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

How to buy in-game items for free on iPhone

How to buy in-game items for free on iPhone

June 8, 2026
Practical use of Xiaomi 17T Pro: This is a good phone in 2026

Practical use of Xiaomi 17T Pro: This is a good phone in 2026

June 8, 2026
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

6789 kv999

No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

6789 kv999

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply