Skip to content

Instantly share code, notes, and snippets.

View Sucareto's full-sized avatar

Sucareto

View GitHub Profile
@Sucareto
Sucareto / wsa_proxy.ps1
Created March 31, 2024 14:10
让 wsa 使用 windows 的 http 代理(已弃用)
# 启动任意 wsa 程序
Start-Process "wsa://jp.co.craftegg.band"
timeout 3 | Out-Null
Remove-NetFirewallRule -DisplayName "WSLCore" | Out-Null # 删除旧的防火墙规则并重新添加
New-NetFirewallRule -DisplayName "WSLCore" -Direction Inbound -InterfaceAlias "vEthernet (WSLCore)" -Action Allow | Out-Null
# 获取 WSA IP
$ip = Get-NetIPAddress -InterfaceAlias 'vEthernet (WSLCore)' -AddressFamily IPV4 | Select-Object -ExpandProperty IPAddress
Write-Output "添加端口映射"
netsh interface portproxy reset # 清除端口映射规则,然后重新添加,wsa 访问 28080 将会转发到 windows 的 127.0.0.1:8080
@Sucareto
Sucareto / ChangeIP.py
Last active April 10, 2023 02:43
电信宽带重拨号更换 IP 的自动化方式。适用于 WSL2。
from selenium.webdriver import Chrome, ChromeOptions
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from requests import get
from requests.exceptions import RequestException
# from selenium.webdriver import Remote
query_ip_url = "https://4.ipw.cn"
# query_ip_url = "https://ipinfo.io"
@Sucareto
Sucareto / 切换Hyper-V.bat
Created November 20, 2022 06:20
修改参数而不是添加启动项,切换启动时的 Hyper-V 状态,允许 VMware 使用嵌套虚拟化。
@echo off
pushd %~dp0
%1 start "" mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c ""%~s0"" ::","","runas",1)(window.close)&&exit
echo "判断当前状态..."
bcdedit /enum {default} | find /I "hypervisorlaunchtype Auto" > nul
if %errorlevel% == 0 (
bcdedit /set {current} HyperVisorLaunchType OFF
echo "Hyper-V 已关闭!"
) else (
@Sucareto
Sucareto / create-dell-key.sh
Last active May 26, 2024 11:10
使用 USB Gadget 功能,创建一个“键盘+鼠标+存储”复合设备,设备 ID 来自 Dell KB216 键盘。可配合 https://github.com/Sucareto/Android_HID_Keyboard 使用。
#!/bin/sh
# https://github.com/Sucareto/Android_HID_Keyboard
device_path="/config/usb_gadget/KB216"
ms_file="/data/data/com.termux/files/home/storage/tmp/mass_storage.img"
# create mass_storage image file
# dd if=/dev/zero of=$ms_file bs=1024MiB count=1
# fallocate -l 1G $ms_file
# loop_device=$(losetup -f)
@Sucareto
Sucareto / Mafuyu_Cursor_Install.inf
Last active June 10, 2022 14:26
Auto install custom mouse cursors for https://twitter.com/L9525/status/1531337918656446464. You can modify Mafuyu_Cursor in lines 61 and 62 to other names for distinction.
[Version]
signature="$CHICAGO$"
[DefaultInstall]
CopyFiles = Scheme.Cur
AddReg = Scheme.Reg,Wreg
[DestinationDirs]
@Sucareto
Sucareto / HID-Printer.py
Last active August 2, 2022 13:06
从控制台读取文字,通过HID打印。应用场景:Android识别文字后模拟键盘发送到PC。
from time import sleep
keycode = {
"KEY_1": '\x1e', # Keyboard 1 and !
"KEY_2": '\x1f', # Keyboard 2 and @
"KEY_3": '\x20', # Keyboard 3 and #
"KEY_4": '\x21', # Keyboard 4 and $
"KEY_5": '\x22', # Keyboard 5 and %
"KEY_6": '\x23', # Keyboard 6 and ^
"KEY_7": '\x24', # Keyboard 7 and &
"KEY_8": '\x25', # Keyboard 8 and *
@Sucareto
Sucareto / SerialDataCheck.py
Created January 29, 2022 08:09
某串口数据校验工具
str1 = "E0 06 00 0F 40 01 03 59"
REQ = str1.split(" ")
print(REQ)
rSYN, rESC, rLEN, rSUM, rESCsw = 0, 0, 0, 0, False
if REQ[0] == "E0":
rSYN = "E0"
rESC = "D0"
rLEN = int(REQ[1], 16)
@Sucareto
Sucareto / ArduinoMifare.ino
Created August 11, 2021 15:49
简单的穷举mifare密钥方法。
#include <Wire.h>
#include <PN532_I2C.h>
#include <PN532.h>
PN532_I2C pn532i2c(Wire);
PN532 nfc(pn532i2c);
#define SerialDevice SerialUSB //32u4,samd21
@Sucareto
Sucareto / svo2dds.py
Created May 14, 2021 06:18
从svo文件导出dds图像。
import os
for i in os.listdir('source'):
with open('source/' + i, 'rb') as f:
print(i + " : ")
data = f.read()
index = data[0:].find(b'DDS')
os.mkdir(i[:-4])
while True:
endindex = data[index+1:].find(b'DDS')
if endindex == -1:
@Sucareto
Sucareto / Make.bat
Last active February 7, 2021 10:11
一种Arduino上传HEX的方式。通过打包刷写程序和HEX,可以在没有IDE和源码的环境更新固件。
@echo off
echo "确保文件夹内包含 avrdude.exe,avrdude.conf,libusb0.dll,32u4Serial.ino.promicro.hex,Upload.py,Upload.spec,icon.ico 这些文件"
pause
pyinstaller -F -i icon.ico Upload.spec
pause