Skip to content

Instantly share code, notes, and snippets.

View yarick's full-sized avatar

Yarick Tsagoyko yarick

View GitHub Profile
@yarick
yarick / get_aws_token.py
Created October 15, 2020 23:55
Update my aws credentials with token using my MFA Code and save as local aws credentials
#!/usr/bin/env python3
### #!/usr/bin/python3
import sys
from pprint import pprint
import subprocess
# stdoutdata = subprocess.getoutput("cat /root/.aws/credentials")
# print("stdoutdata: " + stdoutdata.split()[0])
@yarick
yarick / keybase.md
Created July 16, 2020 21:20
keybase.md

Keybase proof

I hereby claim:

  • I am yarick on github.
  • I am yarick (https://keybase.io/yarick) on keybase.
  • I have a public key ASAwKpyFjVlNDo5CXpZ2knGffxAgpjTcqS-RH77O1Paftgo

To claim this, I am signing this object:

@yarick
yarick / search_aws_s3_recursivelly.sh
Created March 10, 2020 14:50
Search all AWS S3 buckets in account recursively for a folder or a file recursive recursion
#!/bin/bash
for i in $(aws s3api list-buckets --query "Buckets[].Name"| grep \"| awk -F\" '{print $2}'); do echo; echo $i; aws s3api list-objects --bucket $i --query "Contents[?contains(Key, 'i-my_super_secret_result_filie.json')]" ; done
#!/bin/bash
for i in {1..10}; do
echo $i
curl -s "https://api.github.com/orgs/mitre/repos?page=$i&per_page=100" | ruby -rrubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone --recurse-submodules --recurse #{repo["ssh_url"]} ]}'
done
@yarick
yarick / gist:c375cf753930710b708d16a7e2a8b17d
Created August 19, 2018 21:21
find and replace with sed
find baseline/controls/* -name *\.rb -type f -exec sed -i '' 's/"4"\]/"Rev_4"\]/' {} \;
@yarick
yarick / notes.ps1
Created August 3, 2018 13:21
powershell
# View Markdown
ConvertFrom-Markdown -Path '.\_posts\2018-8-1-PowerShell-Markdown.md' -AsVT100EncodedString | Show-Markdown
@yarick
yarick / sortLines.py
Created July 30, 2018 16:13
Python one-liner
for i in $(ls *.txt); do python -c "import sys; lines = sys.stdin.readlines(); print ''.join(sorted(set(lines)))" < $i > $i.sorted.de_dupped; done
@yarick
yarick / searchFile.py
Last active July 30, 2018 16:14
Fast Search for text or pattern in memory mapped file
#!/usr/bin/python2.7
import re, mmap, os, contextlib, sys
#print "Usage: ./s1.py file regex(to print)"
# print "Example: ./s1.py /tmp/a.log 10.213.194.\S+:http://([^/]+)/"
myString = str(sys.argv[2])
print "Searching file: " , str(sys.argv[1])
fn = sys.argv[1]
size = os.stat(fn).st_size
### Powershell on OSX or win32
$location = "USGov Virginia"
$resourceGroupName = "CAAS-MGMT-DEPARTMENT-01"
$vaultname = "CAAS-MGMT-VLT"
$secret = "super-secret-password-that-they-will-never-guess-2018-!"
$secretName = "CAAS-MGMT-INSTANCE-PASSWORD"
New-AzureRmResourceGroup -Name $resourceGroupName -Location $location
New-AzureRmKeyVault `
-VaultName $vaultname `
-----> Starting Kitchen (v1.21.2)
-----> Creating <azure-demo-baseline-centos>...
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>> Failed to complete #create action: [uninitialized constant MsRestAzure::AzureEnvironments::AzureUSGovernment
Did you mean? MsRestAzure::AzureEnvironments::AzureEnvironment] on azure-demo-baseline-centos
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration