Skip to content

Instantly share code, notes, and snippets.

View VariableExp0rt's full-sized avatar

Liam VariableExp0rt

View GitHub Profile
@VariableExp0rt
VariableExp0rt / playground.rs
Created April 24, 2024 15:23
Slicing with Rust
fn main() {
let boxed_array: Box<[u8]> = Box::new([0u8; 8192]);
let slice: &'static mut [u8] = Box::leak(boxed_array);
let factor = 4;
assert!(factor <= 8);
assert!(slice.len() % factor == 0);
let len = slice.len() / factor;
@VariableExp0rt
VariableExp0rt / playground.rs
Last active April 19, 2024 16:22
Memory and raw pointers
#![allow(unused)]
fn main() {
use std::{ptr, slice};
use std::boxed::Box;
let mut v1 = vec![0u8; 8];
let len = v1.len();
{
let mut boxed = v1.into_boxed_slice();
let this = Box::as_mut(&mut boxed);
@VariableExp0rt
VariableExp0rt / playground.rs
Last active April 19, 2024 15:33
Experimenting with Rust
use core::alloc::Layout;
use core::mem::MaybeUninit;
use std::alloc::{alloc, dealloc};
#[allow(unused_imports)]
use std::ptr::{addr_of_mut, copy_nonoverlapping};
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct IoVec {
iov_base: *mut usize,
@VariableExp0rt
VariableExp0rt / privileged.rego
Last active December 2, 2021 15:31
Rego rules to identify privileged pods
package k8sprivileged
is_deployment {
input.kind = "Deployment"
}
deny[msg] {
is_deployment
some i
containers[i].securityContext.privileged
@VariableExp0rt
VariableExp0rt / go.mod
Last active February 23, 2021 17:55
A crawler that takes an initial start site and crawls new URLs found on that page by queuing them
module crawler-new
go 1.15
require golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d
@VariableExp0rt
VariableExp0rt / users_permission_sets_mapping.py
Last active December 2, 2022 20:56
A script which takes a comma separated list of users and enumerates the permissions sets attached for AWS account access through AWS SSO
import boto3
import botocore
from collections import defaultdict
import argparse
import json
import sys
###############################################################
# Usage: supply IdentityStoreId to suit your use case #
import boto3
import botocore
import argparse
import sys
###############################################################
# Usage: change IdentityStoreId to suit your use case #
# change the Attribute Value to a list of all users #
# change InstanceArn to suit your usecase #
import boto3
import botocore
from botocore.exceptions import ClientError
ACCOUNT = ''
## Check security groups for any egress or ingress rules that have a CIDR range of 0.0.0.0/0 for any protocol
## Have included all protocols, as filter match is logical OR and wouldn't filter all
@VariableExp0rt
VariableExp0rt / download-filter-files.py
Created January 19, 2021 17:06
Quick script to download files from S3 based on their last modified date, useful for pulling CloudTrail files concurrently - change bucket (33) and prefix (28) before running
import boto3
from boto3.s3.transfer import S3Transfer
from boto3.s3.transfer import TransferConfig
from concurrent.futures import ThreadPoolExecutor
from concurrent import futures
import logging
from datetime import datetime, timedelta
boto3.set_stream_logger('boto3.resources', logging.INFO)
@VariableExp0rt
VariableExp0rt / cfn-stackset-waiter.go
Last active January 16, 2021 18:31
A quick program to create a template from code, marshal to JSON using goformation and implement a waiter for each stackset instance
package main
import (
"fmt"
"os"
"sync"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/endpoints"