2023-6-4 myluzh
系统运维
0x00 前言
接到用户报障,云主机ssh无法连接,并且主机状态不通。用户说在此之前运行过一个linux系统优化脚本init-server.sh。
0x01 尝试重启
通过后台vnc进入云主机后发现linux引导一直卡在:“ip_local_port_range: prefer different parity for start/end values.”,尝试重启后也是这样。
0x02 分析优化脚本
问用户要了优化脚本,大概看了下,优化脚本中的”sysctl -p /etc/sysctl.d/wpg.conf“就是修改了linux内核的一些参数。
感觉是优化脚本中的这一条内容导致的:“net.ipv4.ip_local_port_range=15000 65000”
0x03 进入单用户模式修复
尝试进入单用户模式,折腾了半天终于进去了,打算使用“sysctl -p /etc/sysctl.conf”把配置文件换成原来的,敲下命令提示“sysctl command not found”。
百度了下解决方法:原来单用户模式下需要执行”chroot /sysroot“,因为目前所在...
阅读全文>>
标签: linux grub 内核 故障
评论(0)
(19)
2023-5-25 myluzh
程序开发
是否可以使用 Chrome Headless 设置自定义位置坐标?我在里面找不到。
Is it possible to set custom location coordinates with Chrome Headless? I can't find it in the Devtools protocol API. Is there a workaround available?
解决方案
I googled it and got many methods. I try one by one, almost all of them turn out outdated. Then I find out a solution, use chrome devtools protocol to achieve that.
The small example code below, that it uses the most common tool selenium to execute chrome devtools protocol command.
import time
...
阅读全文>>
标签: selenium Chrome 传感器 位置 虚拟定位
评论(0)
(63)
2023-5-24 myluzh
程序开发
0x01 原始的Form表单
用户提交数据没有校验。
页面上没有错误提示。
页面上每个字段都要写一遍。
关联的数据还需要手动获取后循环展示在页面中。
0x02 Django组件-Form
views.py
from django.forms import Form
class MyForm(Form):
user = forms.CharField(widget=forms.Input)
pwd = form.CharFiled(widget=forms.Input)
email = form.CharFiled(widget=forms.Input)
def user_add(request):
if request.method == "GET":
form = MyForm()
return render(request, 'user_add.html', {"form": form})
user_add.html
<form method="post">
...
阅读全文>>
标签: django
评论(0)
(53)
2023-5-24 myluzh
学习笔记
0x01 前言
python有直接现成的OPENAI模块,为了锻炼下自己,写了个基础的调用类。
0x02 代码
需要更改成你自己的open_ai_key,还有就是要设置下http代理,因为目前GPT只能国外访问。
class OPENAI:
def __init__(self):
self.open_ai_key = "sk-DR5GkhpENIwerq9qfmYqT3BlbkFJXeWBFt4melgpmv8PFr"
self.open_ai_api = "https://api.openai.com/v1/chat/completions"
self.model = "gpt-3.5-turbo-0301"
def openai_reply_requests(self, message):
error_counter = 0
while error_counter <= 3:
headers = {
...
阅读全文>>
评论(0)
(18)
2023-5-24 myluzh
学习笔记
访达-应用程序-自动操作,选择“新建应用程序”-"实用工具"-“运行shell脚本”
cd /Applications/WeChat.app/Contents/MacOS && nohup ./WeChat > nohup.out 2>&1 &
保存成此app到桌面,两次双击就是两个微信了。
阅读全文>>
标签: macos
评论(0)
(14)
2023-5-23 myluzh
程序开发
import requests
# 设置代理,多用于爬虫
proxies = {"http":"http://12.34.56.79:9527",
"https":"https://12.34.56.79:9527"}
# 1.普通的代理
rqq= requests.get(url="http://www.baidu.com",proxies=proxies)
print(res.content.decode("utf-8"))
# 2.携带了登录的用户名和密码
# proxies1 = {"http":"http://用户名:密码@12.34.56.79:9527"}
# rqq = requests.get(url="http://www.baidu.com",proxies=proxies1)
阅读全文>>
标签: python requests
评论(0)
(16)