Skip to content

Instantly share code, notes, and snippets.

View yesmar's full-sized avatar
💭
Another Fine Product From The Nonsense Factory

ɹɐɯsǝʎ yesmar

💭
Another Fine Product From The Nonsense Factory
  • /dev/funk
View GitHub Profile
@yesmar
yesmar / cvss.js
Last active January 27, 2018 01:04
Compute CVSSv3 score from vector
// cvss.js: Compute CVSSv3 score from vector.
// Copyright © 2018, Ramsey Dow. All rights reserved.
// SPDX-License-Identifier: BSD-2-Clause
// Developed under the influence of Rick and Morty. TINY RICK!
const vectorToObject = (string) => {
const metrics = {};
if (isEmpty(string)) throw 'Empty string';
const scratch = string.split('/');
@yesmar
yesmar / ua.js
Last active January 27, 2018 01:07
Generate random User Agent
const fs = require('fs');
const ua = fs.readFileSync('ua.txt').toString().split("\n"),
agent = ua[Math.floor(Math.random()*ua.length)];
console.log(agent);
@yesmar
yesmar / runWithDebugger.js
Created January 26, 2018 23:15
Run code through the Chrome debugger with an optional args parameter
(function() {
'use strict';
function runWithDebugger(f, args) {
if (typeof f !== 'function') { throw 'f must be a function' }
// The apply() method treats unspecified args or null or undefined args as 'no args'.
if (args === undefined || typeof args === 'object' && (args === null || Array.isArray(args))) {
debugger;
f.apply(null, args);
} else {
@yesmar
yesmar / dga.rb
Last active January 27, 2018 01:03
Domain Generation Algorithm inspired by Ranbyus (by way of Mirai)
#!/usr/bin/env ruby
# dga.rb: domain generation algorithm inspired by Ranbyus (by way of Mirai)
# Usage: ruby dga.rb [n]
# where n is an integer representing the number of days to span.
# -n indicates previous days, 0 and 1 indicate today, and 2+ indicates tomorrow and so on.
module DNS
LETTERS='abcdefghijklmnopqrstuvwxyz'.scan(/./)
@yesmar
yesmar / aapl_slurp.rb
Last active January 27, 2018 01:01
Bulk downloader for Apple open source projects
#!/usr/bin/env ruby
# aapl_slurp.rb: downloader for Apple open source projects
# Copyright © 2017, Ramsey Dow. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause
# mkdir /tmp/macOS-1013 && pushd !#:1
# curl -#LO https://opensource.apple.com/plist/macos-1013.plist
# SSL_CERT_FILE=$CURL_CA_BUNDLE ruby /path/to/aapl_slurp.rb macos-1013.plist
@yesmar
yesmar / argon2.go
Created December 22, 2017 18:59
Key derivation using Argon2
// https://godoc.org/golang.org/x/crypto/argon2
package main
import (
"crypto/rand"
"encoding/hex"
"fmt"
"golang.org/x/crypto/argon2"
@yesmar
yesmar / hexdump.go
Last active December 22, 2017 19:01
No frills hex dump
package main
import (
"fmt"
)
// HexDump the specified byte slice.
func HexDump(bs []byte, width int) {
for i, v := range bs {
fmt.Printf("%02x ", v)
@yesmar
yesmar / burn.c
Created December 8, 2017 22:27
Secure in-memory string erasure
/*
* burn.c
* Secure in-memory string erasure
*
* This is a modified version of the code originally posted to the
* Cryptograhy ML by Werner Koch:
* https://www.mail-archive.com/cryptography@metzdowd.com/msg08428.html
*
* By default, modern C compilers will pick up and use the static inline
* function. However, if you prefer your C to be pre-C99, compile with
@yesmar
yesmar / apt-update.bash
Last active July 24, 2019 19:58
Update Ubuntu
#!/bin/bash
sudo bash -c 'apt-get update && apt-get -y dist-upgrade && apt-get -y autoremove --purge && apt-get -y autoclean'
@yesmar
yesmar / showdefines.bash
Last active January 27, 2018 00:59
Display default compiler symbols
#!/bin/bash
# showdefines.bash: display default compiler symbols.
# Copyright © 2011,2017, Ramsey Dow. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause
# Usage: showdefines.bash [-c compiler] [-l language] [additional flags ...]
# Defaults to clang++, but works fine with C and groks the GNU and Intel compilers, as well.
# http://clang.llvm.org/