Skip to content

Instantly share code, notes, and snippets.

apiVersion: constraints.gatekeeper.sh/v1alpha1
kind: GCPIAMAllowedBindingsConstraintV3
metadata:
name: iam-restrict-editor-on-default-sa
annotations:
description: Default service accounts should not have editor privileges
spec:
severity: high
match:
target:
while read PROJECT_ID
do
SA_NAME="$PROJECT_ID@appspot.gserviceaccount.com"
echo "Downgrading $SA_NAME"
gcloud projects add-iam-policy-binding $PROJECT_ID --member "serviceAccount:$SA_NAME" --role roles/logging.logWriter
gcloud projects add-iam-policy-binding $PROJECT_ID --member "serviceAccount:$SA_NAME" --role roles/monitoring.metricWriter
gcloud projects add-iam-policy-binding $PROJECT_ID --member "serviceAccount:$SA_NAME" --role roles/monitoring.viewer
gcloud projects remove-iam-policy-binding $PROJECT_ID --member "serviceAccount:$SA_NAME" --role roles/editor
done < project_ids_to_disable_sa.txt
@janmasarik
janmasarik / iap-desktop-auth.py
Last active July 9, 2019 10:15
Script for desktop app flow authentication to IAP
import os
import requests
import json
import traceback
from webbrowser import open_new_tab
from time import sleep
other_client_id = os.environ["OTHER_CLIENT_ID"] # Other client id in the same project as IAP secured app
other_client_secret = os.environ["OTHER_CLIENT_SECRET"] # Other client secret in the same project as IAP secured app (not a secret actually)
@janmasarik
janmasarik / sumo.py
Created June 9, 2018 21:17
Source code of IA158 homework - Lego EV3(dev) sumo robot
#!/usr/bin/python3
from ev3dev.ev3 import LargeMotor, ColorSensor, InfraredSensor, TouchSensor, Button, Sound
from time import sleep
from threading import Thread
m1 = LargeMotor('outA')
m2 = LargeMotor('outD')
cl = ColorSensor()
ir = InfraredSensor()

sPyd3r

Lego MINDSTORMS EV3 SUMO robot

IA158 Real Time systems homework

Task performed

  • created robot from a scratch
  • flashed ev3dev debian based linux image to sd card and then booted it
  • implemented functionality of the robot in python
@janmasarik
janmasarik / sumo.py
Created May 15, 2018 22:06
Source code of IA158 homework - Lego EV3(dev) sumo robot
#!/usr/bin/python3
from ev3dev.ev3 import LargeMotor, ColorSensor, InfraredSensor, TouchSensor, Button, Sound
from time import sleep
from threading import Thread
m1 = LargeMotor('outA')
m2 = LargeMotor('outD')
cl = ColorSensor()
ir = InfraredSensor()
@janmasarik
janmasarik / execute.php
Created May 12, 2018 16:04
source code from DEF CON Quals 2018 - Easy Pisy challenge
<?php
include 'common.php';
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
print highlight_string(file_get_contents("execute.php"), TRUE);
exit(0);
}
$keys = get_keys();
@janmasarik
janmasarik / secret_pickle.py
Created May 7, 2018 11:30
Python source code for Blaze CTF 2018 - secret_pickle
#!/usr/bin/env python3
import pickle
import hashlib
import os
import sys
class Note:
def __init__(self, name, date, content):
self.name = name
self.date = date

Keybase proof

I hereby claim:

  • I am janmasarik on github.
  • I am sl4ve (https://keybase.io/sl4ve) on keybase.
  • I have a public key ASDtny5-gzswBO2UP71K3YNIrwomIrthIfX9PVp9iJH09go

To claim this, I am signing this object:

@janmasarik
janmasarik / vikend_task.py
Created September 21, 2016 13:28
review of python vikend task.
#!/usr/bin/env python3
import sys
import re
import datetime
# "kernel" of this script
# i use many parameters, so it's memory intensive, but i start this function recursively so i need it
def heart_of_script(data, which, length, string, future_destination, future_arrival_date, future_arrival_time,