Skip to content

Instantly share code, notes, and snippets.

View Ran-Xing's full-sized avatar
💭
I may be slow to respond.

星冉 Ran-Xing

💭
I may be slow to respond.
View GitHub Profile
@Ran-Xing
Ran-Xing / change.ps1
Last active November 10, 2022 17:24
Change Remote Desktop Port
$portvalue = 33891
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber" -Value $portvalue
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp' -name "PortNumber" -Value $portvalue
New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Program "%SystemRoot%\system32\svchost.exe" -Profile Any -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvalue
New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Program "%SystemRoot%\system32\svchost.exe" -Profile Any -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber"
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp' -name "PortNumber"
@Ran-Xing
Ran-Xing / brew.sh
Last active December 13, 2023 08:11
HomeBrew proxy Install
#!/usr/bin/env bash
/bin/bash -c "$(curl -fsSL https://mirror.ghproxy.com/https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | sed -e "s|https://github.com|https://mirror.ghproxy.com/https://github.com|g;s|https://raw.githubusercontent.com|https://mirror.ghproxy.com/https://raw.githubusercontent.com|g")"
@Ran-Xing
Ran-Xing / TransferGithub.sh
Created May 5, 2022 10:56
Transfer Github Repo To Other Owner
#!/usr/bin/env bash
#set -ex
Owner="$1"
GITHUB_API_TOKEN="$2"
NewOwner=$3
REPOS="$(
curl -s -H "Authorization: token $GITHUB_API_TOKEN" \
@Ran-Xing
Ran-Xing / chineseSupport.sh
Created May 3, 2022 11:19
ubuntu zh-cn language screen
#!/usr/bin/env bash
apt install -qq \
fonts-droid-fallback \
ttf-wqy-zenhei \
ttf-wqy-microhei \
fonts-arphic-ukai \
fonts-arphic-uming \
language-pack-zh-hans \
sudo fc-cache -f -v
@Ran-Xing
Ran-Xing / hardware.sh
Last active May 23, 2022 13:59
Linux hardware details
#!/usr/bin/env bash
clear
printf "\n%s\n\n" "-----------------------"
echo "CPU: $(grep -c processor /proc/cpuinfo) 核心"
echo "内存: $(($(free | grep Mem | cut -d " " -f 9) / 1024 / 1024)) G"
echo "网络: $(curl -s cip.cc | grep "数据二" | cut -d " " -f 2)"
echo "磁盘: $(lsblk -f | grep ext4 | cut -d " " -f 14 | tr -s "\n" " ")"
printf "\n%s\n\n" "-----------------------"
@Ran-Xing
Ran-Xing / ssh_del_known_hosts
Created May 3, 2022 03:49
ssh del known hosts
#!/usr/bin/env bash
if echo "$1" | tr -d " " | grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" > /dev/null; then
IP="$(echo "$1" | tr -d " " | grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$")"
VALID_CHECK=$(echo "$IP"|awk -F. '$1<=255&&$2<=255&&$3<=255&&$4<=255{print "yes"}')
if [ "${VALID_CHECK:-no}" == "yes" ]; then
echo "IP [$IP] available."
else
echo "IP [$IP] not available!"
exit 1
@Ran-Xing
Ran-Xing / HunterApi_Excel.py
Last active April 6, 2022 08:35
Hunter Api Excel export
#!/usr/bin/env python3
# -*- coding: UTF-8 -*
import requests
import xlwt
import datetime
import base64
def banner():
@Ran-Xing
Ran-Xing / api.py
Last active April 6, 2022 15:34
python api Detect interface usage times
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import json
import os
import socket
def server_init():
HOST, PORT = '0.0.0.0', 9999
@Ran-Xing
Ran-Xing / clean.sh
Last active July 16, 2022 19:07
Linux intrusion trace cleaning
#!/usr/bin/env bash
set -ex
# clean history
history -c
rm -f ~/.bash_history ~/.zsh_history ~/.sh_history ~/.ash_history
# clean login history
rm -f /var/run/utmp /var/log/wtmp /var/log/lastlog /var/log/btmp /var/log/auth.log /var/log/secure /var/log/maillog /var/log/message /var/log/cron /var/log/spooler /var/log/boot.log
@Ran-Xing
Ran-Xing / whilelist.sh
Created January 15, 2022 08:24
wazuh whilelist 微隔离
#!/usr/bin/env sh
set -ex
WHITELIST_FILE="$(
cd "$(dirname "$0")" || exit
pwd
)/.whitelist.txt"
read line
WHITELIST_COMMAND="$(echo "$line" | sed -e 's/":/\n/g' | grep alert | cut -d '"' -f 2)"
WHITELIST_ARGUMENT="$(echo "$line" | sed -e 's/":/\n/g' | grep alert | cut -d '"' -f 4)"