Skip to content

Instantly share code, notes, and snippets.

View kalharbi's full-sized avatar

Khalid Alharbi kalharbi

  • Saudi Arabia
View GitHub Profile
@kalharbi
kalharbi / Encryption-using-ECB-mode-in-CyberChef.md
Last active October 14, 2024 16:20
This is a step-by-step demonstration using CyberChef on encryption using ECB mode and the diffusion problem

ECB's lack of diffusion

The Penguin picture ECB Problem

The Penguin AES ECB problem demonstrates the vulnerability of the Electronic Codebook (ECB) mode of AES encryption when applied to images that have large regions of similar colors. ECB mode encrypts each block of data independently, which means identical plaintext blocks are encrypted into identical ciphertext blocks. This characteristic can reveal patterns in the encrypted data, making it impractical for encrypting images or other data with repeating patterns.

This example is a demonstration of why ECB is vulnerable to simple attacks, and how ECB can reveal plaintext patterns in ciphertext. In this example, we use AES with ECB to encrypt a bitmap image that has large regions of uniform color. Although each pixel's color is meant to be encrypted, the overall image can still be recognized, as the arrangement of identically colored pixels in the original remains visible in the encrypted output.

Steps:

  1. Go To CyberChef at [https://gchq.git
@kalharbi
kalharbi / Vagrant on arm64 Apple Silicon with VMWare Fusion Pro as a provider.md
Created May 21, 2024 07:36
Starting a Vagrant box on arm64/Apple Silicon (M1, M2 chips) with VMWare Fusion Pro as a provider

Starting a VM (Vagrant Box) on Apple Silicon/arm64/M-chips

  • Download and install Vagrant
brew tap hashicorp/tap
brew install hashicorp/tap/hashicorp-vagrant
@kalharbi
kalharbi / GeoCoordinates.java
Created September 28, 2023 09:13
Java Map lookup example
package geoCoordinatesMap;
final class GeoCoordinates {
private final double latitude;
private final double longitude;
public GeoCoordinates(double latitude, double longitude) {
this.latitude = latitude;
this.longitude = longitude;
}
@kalharbi
kalharbi / OuterClass.java
Last active May 3, 2023 15:44
what seems to be a bug in getDeclaredConstructors(). Will check back later.
public class OuterClass
{
private int x;
private OuterClass(int x){
this.x =x;
}
public static void main( String[] args )
{
// Should print 1 constructor not 2
System.out.println(OuterClass.class.getDeclaredConstructors().length); // prints 2
@kalharbi
kalharbi / .env.development
Created August 29, 2019 20:44
User Authentication and Private Routes in React, React-Router, Redux, and Firebase
REACT_APP_DEV_API_KEY=XXX
REACT_APP_DEV_AUTH_DOMAIN=XXX
REACT_APP_DEV_DATABASE_URL=XXX
REACT_APP_DEV_PROJECT_ID=XXX
REACT_APP_DEV_STORAGE_BUCKET=XXX
REACT_APP_DEV_MESSAGING_SENDER_ID=XXX
REACT_APP_DEV_ID=XXX
@kalharbi
kalharbi / dummy-dataframe-example.ipynb
Created September 25, 2016 17:04
Python Pandas - Expand cells containing lists into columns (dummy/indicator matrix)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kalharbi
kalharbi / folder_splitter.py
Created August 29, 2016 21:37 — forked from zupo/folder_splitter.py
Split a folder with many files into subfolders with N files.Usage: python folder_splitter.py path/to/target/folder
# -*- coding: utf-8 -*-
# @author: Peter Lamut
import argparse
import os
import shutil
N = 500 # the number of files in seach subfolder folder
@kalharbi
kalharbi / httprouter-middleware-example.go
Last active May 27, 2022 01:42
Example of using a middleware with [httprouter](https://github.com/julienschmidt/httprouter)
package main
import (
"fmt"
"github.com/julienschmidt/httprouter"
"log"
"net/http"
)
// The type of our middleware consists of the original handler we want to wrap and a message
@kalharbi
kalharbi / zookeeper-solr-cloud.md
Last active February 22, 2022 02:58
Setting up an external Zookeeper Solr Cluster

Setting up an external Zookeeper Solr Cluster

This is a step by step instruction on how to create a cluster that has three Solr nodes running in cloud mode. These instructions should work on both a local cluster (for testing) and a remote cluster where each server runs in its own physical machine. This was tested on Solr version 5.4.1 and Zookeeper version 3.4.6

Installing Solr and Zookeeper

  • Download and extract Solr:
    • curl -O http://archive.apache.org/dist/lucene/solr/5.5.3/solr-5.5.3.tgz
    • mkdir /opt/solr
@kalharbi
kalharbi / gulpfile.js
Created August 20, 2015 19:58
gulpfile.js with browserify, babelify, watchify, sourcemaps, gulp-connect, and node-notifier
var gulp = require("gulp");
var gutil = require("gulp-util");
var open = require("gulp-open");
var sourcemaps = require("gulp-sourcemaps");
var notifier = require("node-notifier")
var connect = require("gulp-connect");
var buffer = require("vinyl-buffer");
var source = require("vinyl-source-stream");
var chalk = require("chalk");
var browserify = require("browserify");