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 / jwt_unpack.sh
Last active July 27, 2022 18:51
Unpack JWY in Bash
curl -XPOST -H 'Content-Type: application/x-www-form-urlencoded' \
http://localhost:8080/auth/realms/{realm}/protocol/openid-connect/token \
-d 'grant_type=client_credentials&client_id={client}&client_secret={sectet}' \
2>/dev/null | jq '.access_token | split(".") | .[0],.[1] | @base64d | fromjson'
@sokil
sokil / session.php
Created May 2, 2022 20:13
php session serializer
<?php
function sessionDataUnserialize($serializedData) {
$return_data = array();
$offset = 0;
while ($offset < strlen($serializedData)) {
if (!strstr(substr($serializedData, $offset), "|")) {
throw new Exception("invalid data, remaining: " . substr($serializedData, $offset));
}
@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;