Skip to content

Instantly share code, notes, and snippets.

View jimbo8098's full-sized avatar

Jim Speir jimbo8098

View GitHub Profile
---
dependency:
name: galaxy
options:
requirements-file: molecule/default/requirements.yml
ignore-errors: True
driver:
name: vagrant
platforms:
- name: windows-generic-server

A script to run vagrant provision and check for idempotency. You could use this on ansible-playbook commands too since it just parses the output in the recap. This was used successfully within an Azure Pipeline.

withinRecap=0
returnCode=2
while read line; do
  echo "$line"
  if [[ "$line" =~ PLAY\ RECAP\ \** ]]; then
    withinRecap=1
  fi
@jimbo8098
jimbo8098 / revert.ps1
Created June 18, 2021 15:50
Revert Hyper-V VMs to their Last Commit
#Amend to taste
$RestoreVMs=@(
"Ubuntu Throwaway 1",
"Ubuntu Throwaway 2",
"Ubuntu Throwaway 3",
"Windows Throwaway 1",
"Windows Throwaway 2"
)
foreach($vm in $RestoreVMs) {
# Where:
# ~/.ansible-pass-files/token is the pass file
# token is the vault-id you want to use
# agent_token is the name of the
ansible-vault encrypt_string --vault-id token@~/.ansible-pass-files/token --encrypt-vault-id token --name agent_token 'string-to-encrypt'
@jimbo8098
jimbo8098 / KF2 Current Level Status.md
Last active January 11, 2022 02:07
A quick rundown on getting the current game status for a running KF2 webadmin instance

The webadmin page displays the current game status in the top right of the screen which includes:

  • Map
  • Current player count
  • Max player amount
  • Current wave
  • Maximum waves

This is returned in HTML format so needs to be parsed if you intend on doing something smart with the output. However getting it is a little tricky due to it being behind the webadmin's login wall.

curl http://server:8080/ServerAdmin/current+gamesummary -b authcred="<authcred>" -b sessionid="<sessionid>" -X POST
INFO global: Vagrant version: 2.2.18
INFO global: Ruby version: 2.7.4
INFO global: RubyGems version: 3.1.6
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_EXECUTABLE="/opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/bin/vagrant"
INFO global: VAGRANT_INSTALLER_VERSION="2"
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="/opt/vagrant/embedded"
INFO global: VAGRANT_LOG="debug"
WARN global: resolv replacement has not been enabled!
DEBUG global: Loading core plugin: /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/kernel_v1/plugin.rb
PS <home dir>> az pipelines runs artifact download --org https://dev.azure.com/<organisation> -p <project> --run-id <build run id> --artifact-name developers_release --path ./ --debug
cli.knack.cli: Command arguments: ['pipelines', 'runs', 'artifact', 'download', '--org', 'https://dev.azure.com/<organisation>', '-p', '<project>', '--run-id', '<build run id>', '--artifact-name', 'developers_release', '--path', './', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
Init colorama.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x03D64190>, <function OutputProducer.on_global_arguments at 0x03DE1028>, <function CLIQuery.on_global_arguments at 0x03DF7BB0>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'pipelines': ['azext_devops']
cli.azure.cli.core: Loading command modules:
# $ntlmUsername = "domain\username" formatted account name
# $ntlmPassword = "password"
# $urlToGet = "https://google.com"
$ntlmCred = New-Object System.Net.NetworkCredential($ntlmUsername,$ntlmPassword)
$getArr = @($urlToGet)
$client = New-Object System.Net.WebClient
$client.Credentials = $ntlmCred
@jimbo8098
jimbo8098 / injection.cs
Created October 25, 2022 09:14
SonarScanner SQL Injection Test
using System.Data;
using MySql.Data.MySqlClient;
var builder = new MySqlConnectionStringBuilder
{
Server = "127.0.0.1",
Database = "testing",
UserID = "root",
Password = "toor",
SslMode = MySqlSslMode.Preferred,
@jimbo8098
jimbo8098 / get-repositories.py
Last active November 17, 2022 21:09
Get All BitBucket Repositories (OAuth 2)
# pip install requests requests-oauthlib
# Quick run with:
# docker run -it --rm -v "${PWD}:/src" -v "C:\Projects\:/repos" -w /src python:3.11 bash -c "pip install requests requests-oauthlib && python ./update-repos.py"
#
# 1. Create a new OAuth consumer in BitBucket
# 2. Run the script. Either:
# a. A browser window will open
# b. An authorization URL will be shown
# In both cases the script will await your input
# 3. Log into BitBucket if necessary