Skip to content

Instantly share code, notes, and snippets.

View rachejazz's full-sized avatar
🚩
bleh.

Divya Goswami rachejazz

🚩
bleh.
View GitHub Profile
@rachejazz
rachejazz / emulate.py
Created July 18, 2024 18:35
script to use unicorn to emulate x86 program while using external library
import ctypes
import os
from unicorn import *
from unicorn.x86_const import *
from capstone import *
import struct
main_start = 0x00400000
start = 0x00401255
end = 0x00401324
@rachejazz
rachejazz / append.sh
Last active October 17, 2023 11:41
nuxmv pull to bashrc
curl -Lo nuxmv.tar.gz https://nuxmv.fbk.eu/theme/download.php?file=nuXmv-2.0.0-linux64.tar.gz
gunzip nuxmv.tar.gz
tar -xvf nuxmv.tar
cat << EOF >> ~/.bashrc
export PATH="$PATH:$(pwd)/nuXmv-2.0.0-Linux/bin/"
alias nu="nuXmv"
EOF
source ~/.bashrc
@rachejazz
rachejazz / automate_error_jira.py
Last active August 22, 2022 22:52
Automate Error Reports from GCP to Jira along with attaching log file
#!/usr/bin/env python3
"""
This is a prototype for automating prod error tickets from GCP to Jira.
"""
import os
import json
import argparse
import subprocess
import logging as pylog
import datetime as d
@rachejazz
rachejazz / ssl-expiry.py
Created August 22, 2022 22:37
script to monitor ssl cert expiration on a given list of hosts
#!/usr/bin/env python
"""
This script is a prototype of a ssl monitoring system.
It checks for the expiration date and alerts whether cert is
1. Expired
2. About to expire in 2 weeks
3. Valid, with the expiration date
Script uses asyncio to speed up checking hostnames simultaneously.
"""
@rachejazz
rachejazz / sudo_notifier.sh
Created August 22, 2022 22:34
Sends an alert on webhook if an unprivileged user uses sudo on a machine
#!/bin/bash
while inotifywait -e modify /var/log/auth.log;
do
word=`tail -n1 /var/log/auth.log | grep 'user NOT in sudoers'`
if [[ $word ]]; then
echo '{"text":"'$word'"}' > sendtoslack
curl -X POST \
-H 'Content-type: application/json' \
--data @sendtoslack \
<webhook url>
@rachejazz
rachejazz / instance_logs.py
Created August 22, 2022 22:33
Retrieves logs from s3 bucket within the mentioned range of time and uploads it to sqs for display on kibana
import boto3
import json
import datetime
PREFIX = ""
client_1 = boto3.client('s3')
client_2 = boto3.client('sqs',
aws_access_key_id='KEY',
aws_secret_access_key='KEY'
)
@rachejazz
rachejazz / get_users.sh
Created August 22, 2022 22:31
Gets list of all users with access levels across gitlab organisation
#!/bin/bash
#Usage:
#./getusers.sh <TOKEN> <GROUP ID>
#
i=1
rm users ids final
while [[ $i -ne 10 ]]
do
curl -s --header "PRIVATE-TOKEN: $1" "https://gitlab.com/api/v4/groups/$2/projects?simple=true&order_by=last_activity_at&pagination=keyset&per_page=100&page=$i" | jq -r '.[]|.id' > ids
while read -r line
@rachejazz
rachejazz / s3_transfer.sh
Created August 22, 2022 22:30
transfers log files from an s3 bucket to another
#this script transfers log files from s3 bucket to desired remote server
DIR = '~/var/logs'
COPIED_TO = ''
ssh remote_user@<IP> find $DIR -maxdepth <max depth here> -mtime -$1 -mtime +$2 -type f > loglist.txt
while read -r line
do
rsync -chavzP --stats [email protected]:$line $COPIED_TO
done < loglist.txt
aws s3 cp $COPIED_TO s3://bucket/ --recursive \
@rachejazz
rachejazz / get_list_repo.py
Created August 22, 2022 22:28
Creates a neat markdown table with info of creation date, last activity and web_url
#!/bin/python
import requests
import sys
import json
def getlist(token, page_no = 10):
group_id = ""
data = ""
data_json = []
data_list = []
@rachejazz
rachejazz / purge_stale_gcp_iam.py
Created August 22, 2022 22:26
Cleanups expired iam permissions older than one month of same year or older than current year
#!/usr/bin/env bash
set -e
cleanup() {
rm -f "$iam_output_file" "$jq_output_file"
}
trap 'cleanup' 0 1 2 15 # cleanup tmp files in case script ends upbruptly.
usage() { # Function: Print a help message