Skip to content

Instantly share code, notes, and snippets.

@HamdaanAliQuatil
HamdaanAliQuatil / Smart Contracts.txt
Last active June 22, 2022 12:02
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.26+commit.4563c3fc.js&optimize=false&runs=200&gist=
REMIX DEFAULT WORKSPACE
Remix default workspace is present when:
i. Remix loads for the very first time
ii. A new workspace is created
iii. There are no files existing in the File Explorer
This workspace contains 3 directories:
1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name.
@HamdaanAliQuatil
HamdaanAliQuatil / app.js
Last active August 25, 2023 08:44
prototype pollution example
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const { filter } = require('lodash');
const app = express();
app.use(bodyParser.json());
app.use(cors());
@HamdaanAliQuatil
HamdaanAliQuatil / app.js
Created January 2, 2024 23:59
Defending against SSRF attacks
const express = require("express");
const axios = require("axios");
const fs = require("fs").promises;
const path = require("path");
const app = express();
const port = 3000;
// Function to fetch private resource
const fetchPrivateResource = async () => {
@HamdaanAliQuatil
HamdaanAliQuatil / aa.controller.ts
Created March 11, 2024 08:50
hmac-diffie-hellman-merkle
import { generateKeyPair, generateSharedSecret, generateHMAC, KeyPair } from '../utils/crypto.utils';
import axios from 'axios';
let sharedSecret: Buffer;
export async function sendAAPublicKey(): Promise<Buffer> {
try {
const response = await axios.get('http://localhost:3000/init');
const boostPublicKey: Buffer = Buffer.from(response.data.boostPublicKey, 'hex');
@HamdaanAliQuatil
HamdaanAliQuatil / kanidm-log-wsl
Last active March 14, 2024 06:36
kanidm-log-wsl
root@LAPTOP-B88S065R:/mnt/c/Users/Hamdaan/Desktop/kanidm# cargo test
Updating git repository `https://github.com/kanidm/webauthn-rs.git`
Updating crates.io index
Updating git repository `https://github.com/dnaeon/rust-sshkeys.git`
Downloaded pin-project v1.1.4
Downloaded password-hash v0.5.0
Downloaded prokio v0.1.0
Downloaded overload v0.1.1
Downloaded asn1-rs-derive v0.1.0
Downloaded async-stream-impl v0.3.5
@HamdaanAliQuatil
HamdaanAliQuatil / kanidm-log-windows
Created March 14, 2024 06:35
kanidm-log-windows
PS E:\kanidm> cargo test
warning: unused variable: `path`
--> libs\file_permissions\src\windows.rs:21:22
|
21 | pub fn diagnose_path(path: &Path) -> Diagnosis {
| ^^^^ help: if this is intentional, prefix it with an underscore: `_path`
|
= note: `#[warn(unused_variables)]` on by default
warning: `kanidm_lib_file_permissions` (lib) generated 1 warning (run `cargo fix --lib -p kanidm_lib_file_permissions` to apply 1 suggestion)
@HamdaanAliQuatil
HamdaanAliQuatil / hmac.dart
Created May 5, 2024 13:07
Example code for webcrypto.hmac.dart
import 'package:webcrypto/webcrypto.dart';
import 'dart:convert';
Future<void> main() async {
// Generate a new key using SHA-256 and an optional length parameter.
final key = await HmacSecretKey.generateKey(Hash.sha256, length: 256);
// Sign the message.
final signature = await key.signBytes(utf8.encode('Hello World!'));
@HamdaanAliQuatil
HamdaanAliQuatil / flutter test --coverage
Last active June 19, 2024 02:21
dart test .\lib\src\testing\webcrypto\ecdh.dart
PS C:\Users\Hamdaan\Desktop\downloads\webcrypto.dart> flutter test --coverage
00:17 +1425: All tests passed!
@HamdaanAliQuatil
HamdaanAliQuatil / sdhi.go
Last active June 26, 2024 05:13
Strong Diffie Hellman Inversion using Cloudflare's CIRCL library
package main
import (
"crypto/rand"
"crypto/sha256"
"fmt"
"github.com/cloudflare/circl/ecc/bls12381"
)
type KDF struct {