Skip to content

Instantly share code, notes, and snippets.

@0xack13
0xack13 / dh.c
Created January 17, 2021 11:52 — forked from cloudwu/dh.c
Diffie-Hellman Key Exchange
// The biggest 64bit prime
#define P 0xffffffffffffffc5ull
#define G 5
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
#include <stdlib.h>
// calc a * b % p , avoid 64bit overflow
@0xack13
0xack13 / lvn.md
Created March 3, 2021 10:46 — forked from mtds/lvn.md
Linux Virtual Networking

Virtual Networking on Linux

In the Linux Kernel, support for networking hardware and the methods to interact with these devices is standardized by the socket API:

                +----------------+
                |   Socket API   |
                +-------+--------+
                        |
User space              |
@0xack13
0xack13 / memory_layout.md
Created March 13, 2021 13:53 — forked from CMCDragonkai/memory_layout.md
Linux: Understanding the Memory Layout of Linux Executables

Understanding the Memory Layout of Linux Executables

Required tools for playing around with memory:

  • hexdump
  • objdump
  • readelf
  • xxd
  • gcore
Questions are not from any actual exam!!!
Q: Create a job that calculates pi to 2000 decimal points using the container with the image named perl
and the following commands issued to the container: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
Once the job has completed, check the logs to and export the result to pi-result.txt.
Solution:
redirect.c
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
/**
* Executes the command "grep Villanova < scores > out".
@0xack13
0xack13 / Route 53 Updater
Created April 4, 2021 03:11 — forked from hsiboy/Route 53 Updater
BASH Script to keep Route53 updated with your current external IP address
Roll your own dynamic DNS service using Route53
@0xack13
0xack13 / add-dns-record.sh
Created April 4, 2021 03:12 — forked from justinclayton/add-dns-record.sh
CLI to add DNS Records in Route53
#!/bin/bash -eo pipefail
## Allows for creation of "Basic" DNS records in a Route53 hosted zone
function main() {
record_name=$1
record_value=$2
[[ -z $record_name ]] && echo "record_name is: $record_name" && exit 1
[[ -z $record_value ]] && echo "record_value is: $record_value" && exit 1
@0xack13
0xack13 / main.go
Created April 18, 2021 23:35 — forked from raphink/main.go
Access environment variables in a Go template
package main
import (
"os"
"strings"
)
func main() {
const tmpl := `
USER={{.USER}}
@0xack13
0xack13 / crypto-pbkdf2-example.js
Created May 3, 2021 03:47 — forked from skeggse/crypto-pbkdf2-example.js
Example of using crypto.pbkdf2 to hash and verify passwords asynchronously, while storing the hash and salt in a single combined buffer along with the original hash settings
var crypto = require('crypto');
// larger numbers mean better security, less
var config = {
// size of the generated hash
hashBytes: 32,
// larger salt means hashed passwords are more resistant to rainbow table, but
// you get diminishing returns pretty fast
saltBytes: 16,
// more iterations means an attacker has to take longer to brute force an