Skip to content

Instantly share code, notes, and snippets.

View sokil's full-sized avatar
🇺🇦
sapere aude

sokil

🇺🇦
sapere aude
View GitHub Profile
@sokil
sokil / desc.md
Created April 3, 2022 11:17
Python pickle code execution
  • c: Read to the newline as the module name, module. Read the next line as the object name, object. Push module.object onto the stack.
  • (: Insert a marker object onto the stack. For our purpose, this is paired with t to produce a tuple.
  • t: Pop objects off the stack until a ( is popped and create a tuple object containing the objects popped (except for the () in the order they were /pushed/ onto the stack. The tuple is pushed onto the stack
  • S: Read the string in quotes up to the newline and push it onto the stack.
  • R: Pop a tuple and a callable off the stack and call the callable with the tuple as arguments. Push the result onto the stack.
  • .: End of the pickle.
@sokil
sokil / aes.php
Last active January 12, 2022 07:40
PHP And Python Compatible OpenSSL AES Encoding and decoding
<?php
$passphrase = 'some-passphrase';
$text = 'Hello world!';
$method = 'AES-256-CBC';
// passphrase
$passphrase = hash('sha256', $passphrase, true);
@sokil
sokil / pem.sh
Last active June 28, 2021 08:54
PEM generation
# create private key with passphrase
openssl genrsa -out config/jwt/private.pem -aes256 4096
# Write public key
openssl rsa -pubout -in private.pem -out public.pem
@sokil
sokil / StaticSiteGenerators.md
Last active May 6, 2021 20:33
Static Site Generators
@sokil
sokil / CryptPartition.sh
Last active February 8, 2021 20:15
Crypt Partition
# format in luks
sudo cryptsetup luksFormat --hash=sha512 --key-size=512 /dev/sda7
# create mapping
sudo cryptsetup open --type=luks /dev/sda7 SECURED
# check mapping
sudo cryptsetup -v status SECURED
# format partition
@sokil
sokil / Musql_Slow_query_log.sh
Last active January 14, 2021 10:50
Musql Slow Query Log
SET GLOBAL slow_query_log = 'ON';
select @@long_query_time;
SET GLOBAL long_query_time = 5;
select @@slow_query_log_file;
SET GLOBAL slow_query_log_file = '/path/filename';
SET GLOBAL slow_query_log = 'OFF';
git clone https://github.com/RinCat/RTL88x2BU-Linux-Driver
make
sudo make install
sudo modprobe 88x2bu
####
git clone https://github.com/morrownr/88x2bu
sudo ./install-driver.sh
@sokil
sokil / dateModify.php
Created November 4, 2020 15:44
PHP date modifications
<?php
function test($timeOffsetMS)
{
$modification = sprintf('-%s msec', $timeOffsetMS);
echo 'Modificator: ' . $modification . PHP_EOL;
$time = 1604503053.0000; // microtime(true);
$timeString = sprintf('%0.6F', $time);
echo 'Source: ' . $timeString . PHP_EOL;
@sokil
sokil / bash_awk_split.md
Created September 11, 2020 13:53
ark split
2020-01-01 12:13:14 8
2020-01-01 12:13:14 7
2020-01-01 12:13:14 8
2020-01-01 12:13:14 9
cat file | awk -F' ' '{split($1, date, "-"); print date[1] "-" date[2] "\t" $3}'
@sokil
sokil / mysqldump.aws.sh
Last active July 30, 2023 19:00
Backup mysql dtabase to Aamzon Web Services
#/bin/env bash
# First configure aws cli to authenticate on aws.
# See https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-creds
CURRENT_DIR=$(dirname $(readlink -f $0))
CURRENT_DATE=$(date +%Y%m%d%H%M)
source .env # path to MySQL credentials
mysqldump -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DB > /tmp/$CURRENT_DATE.sql