Skip to content

Instantly share code, notes, and snippets.

View kbagher's full-sized avatar
👨‍💻

Kassem Bagher kbagher

👨‍💻
View GitHub Profile
@kbagher
kbagher / safare_scv_data_transformation
Created December 25, 2023 09:45
Simple script to change the title field in safari export passwords for consistency
import pandas as pd
import tldextract
def extract_domain(url):
extracted = tldextract.extract(url)
return "{}.{}".format(extracted.domain, extracted.suffix)
def consolidate_credentials(csv_path):
@kbagher
kbagher / mac_security_check.sh
Last active January 13, 2024 15:41
The script is a macOS security audit tool, checking vital features like System Integrity Protection, Gatekeeper, Firewall, and FileVault. It evaluates security settings, lists non-Apple kernel extensions, and logs failures for review, providing a quick, comprehensive security overview in an easily interpretable PASS/FAIL format.
#!/bin/bash
###### Tasks Requiring Manual Checking ######
# Review Installed Applications:
# Steps: Open Applications folder and Launchpad.
# Signs of Compromise: Unfamiliar or unexpected applications installed.
# Check App Permissions:
# Steps: System Preferences → Security & Privacy → Privacy tab.
# Signs of Compromise: Unusual permissions granted to unknown applications.
# Audit Browser Extensions:
#!/bin/bash
# Function to list all files except .txt files and allow user selection by number
select_file() {
echo "Available files:"
local i=1
for file in *; do
if [[ $file != *.txt ]]; then
echo "$i) $file"
files[i++]="$file"
@kbagher
kbagher / btc_chart.py
Last active July 14, 2024 12:37
This code fetches historical BTC/USD data from Binance API, calculates various technical indicators such as moving averages, Bollinger Bands, MACD, RSI, and MFI, and generates a plot showing the BTC/USD price with these indicators. Based on these indicators, the code also generates a recommendation for whether to buy, sell, or hold BTC/USD.
import textwrap
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from mplfinance.original_flavor import candlestick_ohlc
import requests
import ta
from reportlab.pdfgen import canvas
@kbagher
kbagher / Flask_app_apikey_and_signature.py
Last active June 7, 2024 03:39
This Flask code authenticates API requests using HMAC SHA256 signatures. The API headers include an apiKey and signature. The api_key_required decorator function checks the API key and signature for specified endpoints. An example POST endpoint is included.
"""
This code implements API key and signature authentication for
Flask API endpoints using HMAC SHA256 signatures.
The API headers require two parameters, `apiKey` and `signature`,
which are used to validate the request sender's identity and ensure
the integrity of the data being transmitted.
The `api_key_required` decorator function checks whether the requested
endpoint is in the `ENDPOINTS` list and performs the API key and
@kbagher
kbagher / App.cpp
Last active April 4, 2023 09:09
Passing callback function pointer to an enclave (Intel SGX)
void CallMe(int x) {
printf("Num %d\n",x);
}
int main() {
/* Setup enclave */
sgx_enclave_id_t eid;
sgx_status_t ret;
sgx_launch_token_t token = { 0 };
int token_updated = 0;