当前位置:网站首页>Self-made a remote control software - VeryControl
Self-made a remote control software - VeryControl
2022-08-01 07:02:00 【Pan Daoxi】
文章目录
前言
前排提醒:This article is a bit long,If you want to see the effect directlyDownload here,Just look at the code.
_..._ .-'''-. .-'''-.
.-'_..._''. ' _ \ ' _ \ .---.
.----. .----. __.....__ .' .' '.\/ /` '. \ _..._ / /` '. \ | |
\ \ / /.-'' '. .-. .- / .' . | \ ' .' '. . | \ ' | |
' '. /' // .-''"'-. `. .-,.--.\ \ / / . ' | ' | '. .-. . .| .-,.--. | ' | '| |
| |' // /________\ \| .-. |\ \ / / | | \ \ / / | ' ' | .' |_ | .-. |\ \ / / | |
| || || || | | | \ \ / / | | `. ` ..' / | | | | .' || | | | `. ` ..' / | |
'. `' .'\ .-------------'| | | | \ \ / / . ' '-...-'` | | | |'--. .-'| | | | '-...-'` | |
\ / \ '-.____...---.| | '- \ ` / \ '. . | | | | | | | | '- | |
\ / `. .' | | \ / '. `._____.-'/ | | | | | | | | | |
'----' `''-...... -' | | / / `-.______ / | | | | | '.'| | '---'
|_| |`-' / ` | | | | | / |_|
'..' '--' '--' `'-'
I've been a little bit busy lately,Went out for a while two days ago,I've been thinking about it on the way,Made a prototype two days ago,Perfect today,Share with everyone to watch and play together.
This program feels okay,Made a web page.Although the design is not so good(我是初学者),But at least on the phone、Successful access and remote command execution on various devices such as computers.
用到的语言是 P y t h o n Python Python 和 H T M L HTML HTML,使用了 D j a n g o Django Django 框架,and some other small functions.
软件截图: 
软件下载
It is recommended to read the notes inside,很重要.
可能CSDNThe resource has not been reviewed yet,You can use the repository below to see the program.
软件下载地址:https://download.csdn.net/download/PanDaoxi2020/86265805
There is an open source address:https://pandaoxi.coding.net/public/pandaoxi/Projects/git/files/master/Very_Control

代码展示
Let's take a look at the source code of this little project~

H T M L HTML HTML 前端部分
H T M L HTML HTML Parts are mostly client side stuff,Access directly on the webpage,And return the corresponding content to the backend A P I API API .
1.客户端主页
最基本的内容,Forms that can be filled in commands directly from the home page,然后 P O S T POST POST 给后端的 A P I API API/run.
{ c o m m a n d = 普通执行命令 e c h o = 输入命令,and return the output c o d e = 执行批处理命令 r u n f = 运行应用程序(An application submission tool is required) \begin{cases} & \text command=普通执行命令 \\ & \text echo=输入命令,and return the output \\ & \text code=执行批处理命令 \\ & \text runf=运行应用程序(An application submission tool is required) \\ \end{cases} ⎩⎨⎧command=普通执行命令echo=输入命令,and return the outputcode=执行批处理命令runf=运行应用程序(An application submission tool is required)
<!--设置标题-->
<title>Very Control</title>
<!--CSS样式-->
<style> /*Add a background image to the page,还是随机的(This is a landscape wallpaperAPI)*/ .bg{
background-image: url(https://api.ixiaowai.cn/gqapi/gqapi.php); } /*This is to set the transparency of the input box,This setting is just right to see the text and appreciate the background*/ input,textarea{
filter:alpha(Opacity=30); -moz-opacity:0.4; opacity:0.6; } </style>
<!--设置的div,Display background and text-->
<div class="bg">
<!--表单-->
<form id="run" action="/run" method="post" enctype="multipart/form-data">
<h1>Very Control Many-to-one remote control platform</h1>
<p>输入命令: <input type="text" name="command" placeholder="输入 Windows 命令 "/></p>
<p>Command with echo:<input type="text" name="echo" placeholder="输入命令,and return the output "/>
<p>Submit the source code of the batch file:</p>
<p><textarea name="code" rows="10" cols="75" placeholder="输入你的 Windows Batch 代码"></textarea></p>
<p>或者使用<b><a href="https://pandaoxi2020.lanzouy.com/iCMJm07i76ti" target="_blank">Application Submission Tool</a></b></p>
<input type="submit" value="运行"/>
</form>
<br><br>
<p>Current software information:</p>
<p>版本: 1.3.0.0 [2022-7-22 Update]</p>
<p>开发者:<b><font face="Consolas"><a href="https://pandaoxi.github.io/" target="_blank">PanDaoxi</a></font></b></p>
<p>开源地址:<a href="https://pandaoxi.coding.net/public/pandaoxi/Projects/git/files/master/Very_Control">Click here to visit</a>!</p>
<p>开发者邮箱(Feedback and technical support are welcome):<a target="_blank" href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=5paHiIKHiZ6P1NbU1KaXl8iFiYs" style="text-decoration:none;"><img src="http://rescdn.qqmail.com/zh_CN/htmledition/images/function/qm_open/ico_mailme_02.png"/></a></p>
</div>
<hr>
<!--Hyperlinks to other functions-->
<center><p>其他功能:<a href="ss">截取屏幕</a> <a href="inf">View controlee information</a> <a href="cam">捕获摄像头</a> <a href="sendm">发送消息</a> <a href="rn">Read the official notice</a></p></center>
2.拍照、截图
The pages for both functions are basically the same.

<title>摄像头捕获</title>
<center>
<!--It's normal here,If there is a camera, it should display the screen of the default camera.为了保护隐私,I replaced the camera image by putting an image in developer mode.-->
<img src="https://pandaoxis.coding.net/p/pdxres/d/pdxres/git/raw/master/RESOURCE/20220729_picture.png" alt="摄像头捕获" height="450" width="800"/>
<br><br>
<p>This function may be relatively laggy;If the camera image cannot be displayed normally,Probably because the camera of the controlled device is inaccessible.</p>
<br><hr>
<a href="jump">回到主页</a> <a href="cam">重新拍照</a>
</center>
<title>Screen Shot</title>
<center>
<!--使用图片的base64显示,I won't write it because it's too long-->
<img src="data:image/png;base64, ..." alt="截图" height="576" width="1024"/>
<br><br><hr>
<a href="jump">回到主页</a> <a href="ss">重新截图</a>
</center>
P y t h o n Python Python 后端部分
目录树:
D:.
│ db.sqlite3
│ main.py
│ manage.py
│
└─VeryControl
asgi.py
settings.py
urls.py
wsgi.py
__init__.py
I made one for it on purposeApp version的,内置 第 1.3.0.0 1.3.0.0 1.3.0.0 的服务器版本 It will update itself,不用管它.
1. / m a i n . p y /main.py /main.py
The main function of this program is:
- 绘制 L O G O LOGO LOGO .
- 生成服务器,Make the front end accessible.
- 检查是否有更新,If not running the server directly;如果有,force an update.
The third quality feels like that W i n d o w s Windows Windows 的传奇色彩~
# Copyright 2022 by PanDaoxi. All rights reserved.
from socket import socket, AF_INET, SOCK_DGRAM
from os import system, name
from time import strftime, sleep
from colorama import init, Fore, Back
from requests import get
# 版本信息
version = "1.3.0.0 [2022-7-22 Update]"
# Update the name and network address of the file
updateFiles = {
"./manage.py": "https://pandaoxi.coding.net/p/pandaoxi/d/Projects/git/raw/master/Very_Control/manage.py",
__file__: "https://pandaoxi.coding.net/p/pandaoxi/d/Projects/git/raw/master/Very_Control/main.py",
"./VeryControl/asgi.py": "https://pandaoxi.coding.net/p/pandaoxi/d/Projects/git/raw/master/Very_Control/VeryControl/asgi.py",
"./VeryControl/settings.py": "https://pandaoxi.coding.net/p/pandaoxi/d/Projects/git/raw/master/Very_Control/VeryControl/settings.py",
"./VeryControl/urls.py": "https://pandaoxi.coding.net/p/pandaoxi/d/Projects/git/raw/master/Very_Control/VeryControl/urls.py",
"./VeryControl/wsgi.py": "https://pandaoxi.coding.net/p/pandaoxi/d/Projects/git/raw/master/Very_Control/VeryControl/wsgi.py",
}
# 用户代理
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.66 Safari/537.36 Edg/103.0.1264.44",
}
# 获取IP地址
def getIP():
try:
sock = socket(AF_INET, SOCK_DGRAM)
sock.connect(("8.8.8.8", 80))
ip = sock.getsockname()[0]
finally:
sock.close()
return ip
# If an update is found, update the files to the latest version one by one
def update():
for i in updateFiles.keys():
with open(i, "wb") as f:
f.write(get(updateFiles[i], headers=headers).content)
sleep(0.3)
if __name__ == "__main__" and name == "nt":
# 获取最新版本号
temp = get('https://pandaoxi.coding.net/p/pandaoxi/d/Projects/git/raw/master/Very_Control/VeryControl/VERSION',headers=headers)
temp.encoding = 'utf-8'
latest = temp.text
# 如果不一样就更新
if latest != version:
print('Please wait a moment, we are updating the software for you ...')
update() # 你挡都挡不住!
system('cls')
# 画一只 floor dog(logo)
print(
""" _..._ .-\'\'\'-. .-\'\'\'-. .-'_..._''. ' _ \ ' _ \ .---. .----. .----. __.....__ .' .' '.\/ /` '. \ _..._ / /` '. \ | | \ \ / /.-'' '. .-. .- / .' . | \ ' .' '. . | \ ' | | ' '. /' // .-''"'-. `. .-,.--.\ \ / / . ' | ' | '. .-. . .| .-,.--. | ' | '| | | |' // /________\ \| .-. |\ \ / / | | \ \ / / | ' ' | .' |_ | .-. |\ \ / / | | | || || || | | | \ \ / / | | `. ` ..' / | | | | .' || | | | `. ` ..' / | | '. `' .'\ .-------------'| | | | \ \ / / . ' '-...-'` | | | |'--. .-'| | | | '-...-'` | | \ / \ '-.____...---.| | '- \ ` / \ '. . | | | | | | | | '- | | \ / `. .' | | \ / '. `._____.-'/ | | | | | | | | | | '----' `''-...... -' | | / / `-.______ / | | | | | '.'| | '---' |_| |`-' / ` | | | | | / |_| '..' '--' '--' `'-' \n\n"""
)
# 配置 colorama
init(autoreset=True)
# Welcome information and server address(Highlighted in red)
print(
"Welcome to Very_Control (Version %s) !\nControlled end:" % version,
Fore.RED + "http://%s:%s/\n" % (getIP(), strftime("%Y")),
)
# 运行服务器
system("python manage.py runserver %s:%s" % (getIP(), strftime("%Y")))
# If present while the server is runningBUG,这样就不会退出了.
input()
2. / V e r y C o n t r o l / u r l s . p y /VeryControl/urls.py /VeryControl/urls.py
This is the heart of the server,We rely on it for a range of controls.
from django.urls import path as site
from django.shortcuts import HttpResponse
from os import system, remove, environ
from base64 import a85decode, b64encode
from sys import path
from requests import get
from pyautogui import screenshot
from tkinter import Tk
from time import strftime, sleep
from cv2 import VideoCapture, imwrite
def getVersion():
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.66 Safari/537.36 Edg/103.0.1264.44",
}
temp = get(
"https://pandaoxi.coding.net/p/pandaoxi/d/Projects/git/raw/master/Very_Control/VeryControl/VERSION",
headers=headers,
)
temp.encoding = "utf-8"
return temp.text
# 求最大公因数
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
# Adapt to the image ratio
def change(a, b):
x = gcd(a, b)
a /= x
b /= x
while a < 500 or b < 500:
a *= 2
b *= 2
return (a, b)
# 拍照
def get_photo():
cap = VideoCapture(0)
f, frame = cap.read()
imwrite("./photo.png", frame)
with open("./photo.png", "rb") as f:
temp = b64encode(f.read()).decode()
remove("./photo.png")
cap.release()
return "data:image/png;base64,%s" % temp
# 主页
def main(request):
return HttpResponse(
"""<title>Very Control</title> <style> .bg{ background-image: url(https://api.ixiaowai.cn/gqapi/gqapi.php); } input,textarea{ filter:alpha(Opacity=30); -moz-opacity:0.4; opacity:0.6; } </style> <div class="bg"> <form id="run" action="/run" method="post" enctype="multipart/form-data"> <h1>Very Control Many-to-one remote control platform</h1> <p>输入命令: <input type="text" name="command" placeholder="输入 Windows 命令 "/></p> <p>Command with echo:<input type="text" name="echo" placeholder="输入命令,and return the output "/> <p>Submit the source code of the batch file:</p> <p><textarea name="code" rows="10" cols="75" placeholder="输入你的 Windows Batch 代码"></textarea></p> <p>或者使用<b><a href="https://pandaoxi2020.lanzouy.com/iCMJm07i76ti" target="_blank">Application Submission Tool</a></b></p> <input type="submit" value="运行"/> </form> <br><br> <p>Current software information:</p> <p>版本: %s</p> <p>开发者:<b><font face="Consolas"><a href="https://pandaoxi.github.io/" target="_blank">PanDaoxi</a></font></b></p> <p>开源地址:<a href="https://pandaoxi.coding.net/public/pandaoxi/Projects/git/files/master/Very_Control">Click here to visit</a>!</p> <p>开发者邮箱(Feedback and technical support are welcome):<a target="_blank" href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=5paHiIKHiZ6P1NbU1KaXl8iFiYs" style="text-decoration:none;"><img src="http://rescdn.qqmail.com/zh_CN/htmledition/images/function/qm_open/ico_mailme_02.png"/></a></p> </div> <hr> <center><p>其他功能:<a href="ss">截取屏幕</a>\t\t<a href="inf">View controlee information</a>\t\t<a href="cam">捕获摄像头</a>\t\t<a href="sendm">发送消息</a>\t\t<a href="rn">Read the official notice</a></p></center> """
% getVersion()
)
# 阅读通知
def readNotice(request):
return HttpResponse(
"""<title>Read the official notice</title> <h1>官方通知</h1> <hr><br> <iframe src="https://pandaoxis.github.io/verycontrol/" width="800" height="450"></iframe> <p>It is normal for pages to load slowly,请耐心等候.</p> <br><hr> <center><a href="jump">回到主页</a></center> """
)
# 运行
def run(request):
system("chcp 65001 >nul")
text = request.POST.get("command")
code = request.POST.get("code")
runf = request.POST.get("runf")
echo = request.POST.get("echo")
if code: # 优先级最高的 执行批处理脚本
with open("temp.bat", "w", encoding="utf-8") as f:
f.write(code + "\nexit")
system("start %s\\temp.bat" % path[0])
if runf: # The next application
with open("temp.exe", "wb") as f:
f.write(a85decode(runf.encode()))
system("start %s\\temp.exe" % path[0])
if text: # Finally, execute the command directly
system(text)
if echo: # Execute command with echo
try:
remove("temp.txt")
except:
pass
system("%s >> temp.txt" % echo)
with open("temp.txt", "r", encoding="utf-8") as f:
ret = f.read().splitlines()
s = ""
for i in ret:
s += "<p>%s</p>\n" % i
return HttpResponse(
"""<title>程序运行结果</title> %s <br><hr><br> <center><a href="jump">回到主页</a></center>"""
% s
)
return HttpResponse('<meta http-equiv="refresh" content="0;url=jump"/>')
# 截图
def ss(request):
window = Tk()
window.withdraw()
width = window.winfo_screenwidth()
height = window.winfo_screenheight()
image = screenshot(region=(0, 0, width, height))
image.save("./screenshot.png")
with open("./screenshot.png", "rb") as f:
content = b64encode(f.read()).decode()
remove("./screenshot.png")
w, h = change(width, height)
return HttpResponse(
"""<title>Screen Shot</title> <center> <img src="data:image/png;base64,%s" alt="截图" height="%d" width="%d"> <br><br><hr> <a href="jump">回到主页</a>\t\t<a href="ss">重新截图</a> </center> """
% (content, h, w)
)
window.mainloop()
# 环境信息
def inf(request):
system("chcp 65001 >nul")
s1 = ""
for i in environ.keys():
s1 += "<p>%s\t%s</p>\n" % (i, environ[i])
try:
remove("temp.txt")
except:
pass
system("tasklist>>temp.txt")
with open("temp.txt", "r", encoding="utf-8") as f:
s2 = f.read().splitlines()
remove("temp.txt")
s3 = ""
for i in s2:
s3 += "<p>%s</p>\n" % i
return HttpResponse(
"""<title>Os_Environ</title> <h1>系统环境变量 </h1> %s <br><br><hr> <h1>运行的进程(For alignment you can see the source code of this page) </h1> %s <br><br><hr> <center><a href="jump">返回主页</a></center> """
% (s1, s3)
)
# 拍照
def camera(request):
return HttpResponse(
"""<title>摄像头捕获</title> <center> <img src="%s" alt="摄像头捕获" height="450" width="800"> <br><br> <p>This function may be relatively laggy;If the camera image cannot be displayed normally,Probably because the camera of the controlled device is inaccessible.</p> <br><hr> <a href="jump">回到主页</a>\t\t<a href="cam">重新拍照</a> </center> """
% get_photo()
)
# 发送消息文本
def sendMessage(request):
return HttpResponse(
"""<title>发送消息文本</title> <style> .bg{ background-image: url(https://api.ixiaowai.cn/gqapi/gqapi.php); } input,textarea{ filter:alpha(Opacity=30); -moz-opacity:0.4; opacity:0.6; } </style> <div class="bg"> <form id="show" action="/showm" method="post" enctype="multipart/form-data"> <h1>Very Control - 消息发送器</h1> <p>Enter the message to send to the controlled end,The message will start with <b>警示框</b>的形式表现:</p> <p><textarea name="msg" rows="25" cols="100" placeholder="输入你的 消息文本"></textarea></p> <input type="submit" value="发送"/> </div> <br><br><hr> <center><a href="jump">回到主页</a></center> """
)
# 显示信息
def showMessage(request):
msg = request.POST.get("msg")
with open("temp.py", "w+", encoding="utf-8") as f:
f.write("from easygui import msgbox\nmsgbox('''%s''',\"Very Control\")" % msg)
system("start /min cmd /c temp.py")
return HttpResponse("""<meta http-equiv="refresh" content="0;url=sendm"/>""")
urlpatterns = [
site("", main),
site("jump", main),
site("run", run),
site("ss", ss),
site("inf", inf),
site("cam", camera),
site("sendm", sendMessage),
site("showm", showMessage),
site("rn", readNotice),
]
最后
有些时候,有些BUG,It can never be changed.Still need professional power.
Thanks for the help of blog garden and rookie tutorial!
完美结束.
边栏推荐
- vsce package 后出现 Command failed: npm list --production --parseable --depth=99999 --loglevel=error异常
- CSP-S2019兴奋不已
- Windows taskbar icon abnormal solution
- 爆肝3万字,最硬核丨Mysql 知识体系、命令全集 【建议收藏 】
- Detailed explanation of the crawler framework Scrapy
- torch
- Offer刷题——1
- first unique character in characters
- Motion analysis and parameter optimization of crank-slider mechanism
- 【FiddlerScript】利用FiddlerScript抓包保利威下载
猜你喜欢

MATLAB program design and application of MATLAB 2.5

阿里三面:MQ 消息丢失、重复、积压问题,该如何解决?

NIO编程

"By sharing" northwestern university life service | | bytes a second interview on three sides by HR

leetcode43 string multiplication

Windows taskbar icon abnormal solution

爬虫基本原理介绍、实现以及问题解决

测试工具(四)Jenkins环境搭建与使用

mysql的行锁和间隙锁

我三本学历,五面阿里,被面试官“供”着出来了,拿了33*15的Offer
随机推荐
flinkcdc对mysql的date字段类型转化有什么解决思路么
Detailed explanation of the crawler framework Scrapy
Solve the problem of page flicker caused by browser scroll bars
Offer刷题——1
2022年牛客多校第四场补题
R语言使用tidyquant包的tq_transmute函数计算持有某只股票的天、月、周收益率、ggplot2使用条形图可视化股票月收益率数据、使用百分比显示Y轴坐标数据、使用不同的色彩表征正负收益率
JSON 与 JS 对象的区别
仿牛客网项目总结
从零开始—仿牛客网讨论社区项目(一)
R语言使用gt包和gtExtras包优雅地、漂亮地显示表格数据:gtExtras包的pad_fn函数与gt::fmt函数一起用于填充包含数值的特定列、对数据列的数值进行十进制对齐(从小数点对齐)
rhcsa 第三次
湖仓一体电商项目(一):项目背景和架构介绍
小白的0基础教程SQL: 安装MYSQL 03
weight distribution
return;代表含义
AspNet.WebApi.Owin custom Token request parameters
matlab simulink 粒子群优化模糊pid控制的电机泵
Jupyter shortcuts
Motion analysis and parameter optimization of crank-slider mechanism
响应式织梦模板园林花卉类网站