This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get Local IP Address | |
* | |
* @returns Promise Object | |
* | |
* getLocalIP().then((ipAddr) => { | |
* console.log(ipAddr); // 192.168.0.122 | |
* }); | |
*/ | |
function getLocalIP() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/http" | |
"Regexp" | |
) | |
type route struct { | |
pattern *regexp.Regexp | |
handler http.Handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder