Skip to content

Instantly share code, notes, and snippets.

View rikka0w0's full-sized avatar

Rikka0_0小六花 rikka0w0

  • UNSW
  • Sydney
View GitHub Profile
@rikka0w0
rikka0w0 / plot_ti.m
Created September 28, 2023 06:31
Plot TI's memory dump in matlab
% Specify the file path
file = 'D:\1.txt';
count = 4;
length = 256;
% Open the file for reading
fid = fopen(file, 'r');
% Read all lines from the file
data = textscan(fid, '%f', 'HeaderLines', 1);
@rikka0w0
rikka0w0 / udp46.ps1
Created September 7, 2023 17:10
Use powershell to allow a UDP IPv4 client to connect to an IPv6 host
Add-Type -TypeDefinition @"
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
public static class UDPForward
{
public static void Main(string[] args)
{
@rikka0w0
rikka0w0 / only_allow_local_remote_desktop.ps
Created August 8, 2023 07:09
Only allow local access to remote desktop
# Get the "Remote Desktop - User Mode (TCP-In)" rule
$rule = Get-NetFirewallRule -DisplayName "Remote Desktop - User Mode (TCP-In)"
# Get the associated firewall filter
$filter = Get-NetFirewallAddressFilter -AssociatedNetFirewallRule $rule
# Set the private IPv4 and IPv6 ranges, including full loopback and link-local addresses, for the Remote Address
Set-NetFirewallAddressFilter -InputObject $filter -RemoteAddress "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "fc00::/7", "fd00::/8", "127.0.0.0/8", "169.254.0.0/16", "fe80::/10"
# Set the port to 3389
@rikka0w0
rikka0w0 / ws_stream_echo.js
Last active June 22, 2023 15:09
An example Websocket endpoint on AWS Lambda that echos back the incoming text using streams
// To test this code, first create a new lambda with the AWS Cloudformation with the template below;
// Template URL: https://gist.github.com/rikka0w0/53a38add3c17e61744ff1806080e180d
// It not only handles the lambda creation, but also takes care of the required permissions.
// Then, create a Websocket service in the AWS API Gateway and point the $defsult handler to the lambda function we just created.
// Finally, replace the content of index.js of the lambda function with this file.
// Dont forget to DEPLOY it each time after you make changes. Test with 'wscat -c'
const AWS = require('aws-sdk');
const stream = require('stream');
const util = require('util');
@rikka0w0
rikka0w0 / ws_server.yaml
Created June 20, 2023 19:35
Use AWS CloudFormation to config a Simple Websocket server, need manual API Gateway configuration
AWSTemplateFormatVersion: 2010-09-09
Metadata:
'AWS::CloudFormation::Designer':
64bc413f-6802-42a9-a2f0-3f88801aef87:
size:
width: 60
height: 60
position:
x: 390
'y': 110
@rikka0w0
rikka0w0 / eclipse_browser_wsl2.md
Created June 8, 2023 15:20
Fix Eclipse browser issue on Ubuntu 22.04 WSL2

sudo apt install libwebkit2gtk-4.0-37

@rikka0w0
rikka0w0 / openssh.sh
Last active April 14, 2023 06:20
Compile OpenSSH on Linux
#!/bin/bash
mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
apt install build-essential zlib1g-dev libssl-dev libpam0g-dev libselinux1-dev
wget -c http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.0p1.tar.gz
tar -xzf openssh-8.0p1.tar.gz
rm openssh-8.0p1.tar.gz
cd openssh-8.0p1
./configure --with-md5-passwords --with-pam --with-selinux --with-privsep-path=/var/run/sshd/ --sysconfdir=/etc/ssh
make -j2
make install

Add repo

Seehttps://pkg.cloudflareclient.com/install

Install Official Warp Client

sudo apt install cloudflare-warp

Find the best address

wget -N https://gitlab.com/Misaka-blog/warp-script/-/raw/main/files/warp-yxip/warp-yxip.sh && bash warp-yxip.sh

Start Warp in Socks5 mode with best ip

@rikka0w0
rikka0w0 / mount_maps.sh
Last active October 30, 2023 02:14
[L4D2] Use squashfs to save disk. This is an script that auto mounts images and create symbolic links.
#!/bin/bash
# To make squashfs images, run:
# $ mksquashfs *.vpk /tmp/maps.squashfs -comp xz -all-root
# xz has the best compression ratio, lz4 is faster.
# The destination system should have losetup and kmod-loop to mount squashfs in kernel.
# Run this script as root.
# Debian/Ubuntu prerequisite: apt install squashfuse
# OpenVZ: make sure /dev/fuse exists, otherwise see https://iserversupport.com/forum/virtualization/enable-fuse-on-openvz/
# Point to the L4D2 addons directory
@rikka0w0
rikka0w0 / Win11_22H2_Menu_Contrast.md
Last active September 22, 2023 08:30
Improve visibility of Win11 22H2 context menu
  1. Download mssstyleEditor and install UxThemePatcher, then reboot.
  2. Open the msstyle to be patched, usually C:\Windows\Resources\Themes\colored\colored.msstyles or C:\Windows\Resources\Themes\aero\aero.msstyle, no need to make a backup, as the software wont overwrite the existing one.
  3. Replace the image of Part 27 in "Menu" and POPUPITEM in "ImmersiveStart::Menu".
  4. Change the FILLCOLOR of 2-Hot to white (0,0,0)
  5. Save the modified msstyles to somewhere else
  6. Make a copy of the system one
  7. Replace the system one
  8. Swith to the new theme, and done!

Note: