Skip to content

Instantly share code, notes, and snippets.

View pjbgf's full-sized avatar
🦎

Paulo Gomes pjbgf

🦎
View GitHub Profile
@pjbgf
pjbgf / EqualityTestShould.cs
Last active October 17, 2017 23:07
Assertion Equality Code Sample
using FluentAssertions;
using Xunit;
// To run this example you need to reference nuget packages: Xunit and FluentAssertions.
namespace EqualitySample
{
public class EqualityTestShould
{
[Fact]
@pjbgf
pjbgf / HijackingAppSettingsAndConnectionStrings.cs
Last active October 22, 2017 00:19
Dependencies being evil: 1 - Hijacking appsettings and connectionstrings.
using System;
using System.Configuration;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using SecurityTrap.DoNotUse;
[assembly: PreApplicationStartMethod(typeof(EvilCode), "RogueAction")]
@pjbgf
pjbgf / ConcealedHijackingAppSettingsAndConnectionStrings.cs
Last active October 22, 2017 00:19
Dependencies being evil: 2 - Concealed hijacking appsettings and connectionstrings.
using System;
using System.Configuration;
using System.Text;
using System.Web;
using SecurityTrap.DoNotUse;
[assembly: PreApplicationStartMethod(typeof(EvilCode2), "RogueAction")]
namespace SecurityTrap.DoNotUse
{
@pjbgf
pjbgf / WebApi_ByPassAuthorisation.cs
Created November 10, 2017 16:15
Bypassing authorisation on Web APIs
using System;
using System.Collections;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
@pjbgf
pjbgf / ZombieActivator.cs
Created November 13, 2017 09:31
Zombie Activator
[assembly: PreApplicationStartMethod(typeof(ZombieActivator), "Run")]
public static class ZombieActivator
{
public static void Run()
{
try
{
if (IsThisLikelyToBeProductionEnvironment())
System.Web.HttpApplication.RegisterModule(typeof(ZombieModule));
}
@pjbgf
pjbgf / aks-cluster-provisioning.yml
Created January 16, 2018 14:11
Circle CI config for AKS Cluster Provisioning
version: 2
jobs:
provision_cluster:
docker:
- image: azuresdk/azure-cli-python
environment:
RESOURCE_GROUP: aks-poc-euw-rg
CLUSTER_LOCATION: westeurope
CONTAINER_REPOSITORY: akspoc
@pjbgf
pjbgf / kubernetes-dotnetcore-deployment.yml
Created January 16, 2018 14:16
Circle CI Kubernetes Container Deployment
version: 2
jobs:
build_test_publish_image:
docker:
- image: paulinhu/netcore-docker-build:beta
environment:
ACR_NAME: akspoc
DOCKER_REGISTRY_URI: akspoc.azurecr.io
DOCKER_IMAGE_NAME_WITH_REGISTRY: akspoc.azurecr.io/template/sample-app-img
@pjbgf
pjbgf / k8s-security-challenge1-setup.sh
Last active December 28, 2019 05:13
Kubernetes Security Challenge 1.
# Login with your Azure subscription
az login
# Register providers required within the subscription
az provider register -n Microsoft.ContainerService
az provider register -n Microsoft.Network
az provider register -n Microsoft.Compute
# Create resource group to place AKS cluster.
az group create --name k8s-security-challenge-rg --location centralus
@pjbgf
pjbgf / disable-automount-service-account-default.yaml
Created March 8, 2018 22:01
Disable the auto-mount for the default Service Account
apiVersion: v1
kind: ServiceAccount
metadata:
name: default
automountServiceAccountToken: false
@pjbgf
pjbgf / aks-metadata.json
Created May 9, 2018 22:10
Azure AKS VM metadata sample
{
"compute":
{
"location": "westeurope",
"name": "aks-nodepool1-XXXXXXXXXX-1",
"offer": "UbuntuServer",
"osType": "Linux",
"placementGroupId": "",
"platformFaultDomain": "0",
"platformUpdateDomain": "2",