Skip to content

Instantly share code, notes, and snippets.

View zema1's full-sized avatar
💭
I may be slow to respond.

koalr zema1

💭
I may be slow to respond.
View GitHub Profile
@ripx80
ripx80 / main.rs
Created March 24, 2021 14:19
example for serde to implement serialize_with and deserialize_with for a u8 array
extern crate serde;
use base64;
use hex::FromHex;
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use std::convert::TryFrom;
#[derive(Serialize, Deserialize, Debug)]
pub struct Config {
#[serde(serialize_with = "as_base64", deserialize_with = "from_base64")]
key: [u8; 32],
use std::thread;
use std::net::SocketAddr;
use socket2::{Socket, Domain, Type};
use std::net::Shutdown;
use std::sync::Arc;
fn main() {
let socket = Arc::new(Socket::new(Domain::ipv4(), Type::stream(), None).unwrap());
socket.bind(&"127.0.0.1:8080".parse::<SocketAddr>().unwrap().into()).unwrap();
@VillanCh
VillanCh / yaml_load_env.py
Created April 7, 2018 03:19
Using PyYaml load env vars
#
# load yaml by env variables
#
import yaml, os, re
pattern = re.compile( '^\$\{(.*?)(:(.*))?\}$' )
yaml.add_implicit_resolver ( "!env", pattern )
def env_construction(loader, node):
value = loader.construct_scalar(node)
env_var_name, _, default = pattern.match(value).groups()
@GuilloOme
GuilloOme / background.js
Last active March 24, 2023 20:05
Puppeteer (v.0.12.0) navigation blocking workaround
(function() {
'use strict';
// keep track of all the opened tab
let tabs = {};
// Get all existing tabs
chrome.tabs.query({}, function(results) {
results.forEach(function(tab) {
tabs[tab.id] = tab;
@virusdefender
virusdefender / ssl.sh
Last active March 17, 2020 02:51
openssl 创建 CA 然后签发服务器证书 (仅供测试)
#!/bin/bash
set -ex
company="Chaitin"
subj="/C=CN/ST=Beijing/L=Beijing/O=$company Tech/OU=Service Infrastructure Department"
domain="vulndb"
# Create CA
openssl genrsa -out ca.key 2048
openssl req -new -x509 -nodes -sha256 -subj "$subj/CN=$company Root CA" -days 7500 -key ca.key -out ca.crt
@phith0n
phith0n / fpm.py
Last active July 20, 2024 11:18
Fastcgi PHP-FPM Client && Code Execution
import socket
import random
import argparse
import sys
from io import BytesIO
# Referrer: https://github.com/wuyunfeng/Python-FastCGI-Client
PY2 = True if sys.version_info.major == 2 else False
@hectorguo
hectorguo / getLocalIP.js
Last active March 18, 2024 06:21
Get local IP address through Javascript
/**
* Get Local IP Address
*
* @returns Promise Object
*
* getLocalIP().then((ipAddr) => {
* console.log(ipAddr); // 192.168.0.122
* });
*/
function getLocalIP() {
@0xBADCA7
0xBADCA7 / pickle_exploit_generator.py
Last active August 1, 2022 02:08
Python cPickle/pickle exploit generator
#!/usr/bin/env python
'''
0xBADCA7
Vodka goes down the throat better with pickle.
This script generates pickled object representation. Good for CTFs.
Params: [1] function, [2] parameter, [3] pickle type
Sample run:
@iamphill
iamphill / RegexHandler.go
Last active May 9, 2022 02:12
Very basic golang HTTP server
package main
import (
"net/http"
"Regexp"
)
type route struct {
pattern *regexp.Regexp
handler http.Handler
@alanhamlett
alanhamlett / api.py
Last active June 28, 2024 08:15
Serialize SQLAlchemy Model to dictionary (for JSON output) and update Model from dictionary attributes.
import uuid
import wtforms_json
from sqlalchemy import not_
from sqlalchemy.dialects.postgresql import UUID
from wtforms import Form
from wtforms.fields import FormField, FieldList
from wtforms.validators import Length
from flask import current_app as app
from flask import request, json, jsonify, abort