Skip to content

Instantly share code, notes, and snippets.

View andyollylarkin's full-sized avatar
🏠
Working from home

Denis Davydov andyollylarkin

🏠
Working from home
View GitHub Profile
@andyollylarkin
andyollylarkin / dump_vk_request.py
Last active October 1, 2024 20:28
mitmproxy vk.com message stealing
from mitmproxy import http
def request(flow: http.HTTPFlow) -> None:
if "messages.send" in flow.request.pretty_url:
with open("requests.log", "a") as log_file:
if flow.request.content:
if "application/x-www-form-urlencoded" in flow.request.headers.get("Content-Type", ""):
if flow.request.urlencoded_form['message']:
log_file.write("Данные формы (URL-encoded):\n")
log_file.write(f"{flow.request.urlencoded_form['message']}\n")
#!/bin/bash
curr_date=${1:-$(date +"%Y")};
if [[ ${#curr_date} > 4 ]]; then
echo "Illegal year format: ${curr_date}"
exit 1;
fi
echo Grub working date of $curr_date year;

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@andyollylarkin
andyollylarkin / timeout_reader.go
Created August 22, 2023 07:06
golang reader that continue reads when socket timeout exceeded
type TimeoutReader struct {
r ReadDeadliner
extendReadDeadline time.Duration
}
// Return reader that reads from r. If i/o timeout exceeded reader continue read.
// If another error occurs reader return that error.
func NewTimeoutReader(r ReadDeadliner, extendReadDeadline time.Duration) *TimeoutReader {
tr := new(TimeoutReader)
tr.r = r
go mod edit -module {NEW_MODULE_NAME}
-- rename all imported module
find . -type f -name '*.go' \
-exec sed -i -e 's,{OLD_MODULE},{NEW_MODULE},g' {} \;
@andyollylarkin
andyollylarkin / bash_strict_mode.md
Created August 2, 2023 21:30 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation
@andyollylarkin
andyollylarkin / fanin.go
Created May 27, 2023 18:37
Go fanin pattern example
package main
import (
"fmt"
"time"
)
func FaninProducer(inChans ...chan int) <-chan int {
outCh := make(chan int, len(inChans))
for _, inCh := range inChans {
@andyollylarkin
andyollylarkin / composite_type_example.go
Created April 15, 2023 21:41
jackx pgx composite db type
package main
import (
"context"
"database/sql/driver"
"fmt"
"log"
"strconv"
"github.com/jackc/pgx/v5"
@andyollylarkin
andyollylarkin / api.md
Created March 5, 2023 11:32 — forked from zeburek/api.md
Чек-лист проверок API

Чек-лист API тестов

  • Корректность структуры данных
  • POST запросы
    • Заполнены все поля валидными данными
    • Заполнены только обязательные поля
    • Заполнены не все обязательные поля
    • Не заполнено ни одно поле
    • Валидация данных в полях (корректные и некорректные данные)
    • Пустой JSON
  • Дата создания объекта
@andyollylarkin
andyollylarkin / golang_mutex.go
Last active March 20, 2023 19:07
Golang classic mutex with loop implementation
type MyMutex struct {
state int32
}
const (
unlocked = iota
locked
)
func (m *MyMutex) Lock() {