Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Mohan Balasundaram tuxfight3r

🏠
Working from home
View GitHub Profile
View vim-shortcuts.md

VIM KEYBOARD SHORTCUTS

MOVEMENT

h        -   Move left
j        -   Move down
k        -   Move up
l        -   Move right
$        -   Move to end of line
0        -   Move to beginning of line (including whitespace)
@tuxfight3r
tuxfight3r / 01.bash_shortcuts_v2.md
Last active Apr 11, 2021
Bash keyboard shortcuts
View 01.bash_shortcuts_v2.md

Bash Shortcuts

visual cheetsheet

Moving

command description
ctrl + a Goto BEGINNING of command line
@tuxfight3r
tuxfight3r / tcp_flags.txt
Last active Apr 10, 2021
tcpdump - reading tcp flags
View tcp_flags.txt
##TCP FLAGS##
Unskilled Attackers Pester Real Security Folks
==============================================
TCPDUMP FLAGS
Unskilled = URG = (Not Displayed in Flag Field, Displayed elsewhere)
Attackers = ACK = (Not Displayed in Flag Field, Displayed elsewhere)
Pester = PSH = [P] (Push Data)
Real = RST = [R] (Reset Connection)
Security = SYN = [S] (Start Connection)
@tuxfight3r
tuxfight3r / python_webserver.py
Last active Apr 8, 2021
python3 HTTP Echo Server with directory browsing
View python_webserver.py
#!/usr/bin/env python3
# Author: Mohan Balasundaram
# Date: 02/05/2019
# Purpose: HTTP Echo server with directory browsing
# To run a http server and return all request headers in / path
# and to allow directory browsing in any other path prefix
from http.server import BaseHTTPRequestHandler, SimpleHTTPRequestHandler
import urllib.parse
@tuxfight3r
tuxfight3r / .bash_profile
Last active Mar 31, 2021
bash history log all commands to syslog
View .bash_profile
#log all your bash command to syslog
function log2syslog
{
declare COMMAND
COMMAND=$(fc -ln -0)
logger -p local1.notice -t bash -i -- "${USER}:${COMMAND}"
}
trap log2syslog DEBUG
#moredetails can be found here
@tuxfight3r
tuxfight3r / inventory.sh
Created Mar 10, 2016
Ansible dynamic inventory bash demo
View inventory.sh
#!/bin/bash
if [ "$1" == "--list" ] ; then
cat<<EOF
{
"bash_hosts": {
"hosts": [
"10.220.21.24",
"10.220.21.27"
],
@tuxfight3r
tuxfight3r / s3_upload.sh
Last active Mar 18, 2021
AWS - Upload files to S3 via curl
View s3_upload.sh
#!/bin/bash -x
#Date: 21/7/2017
#Author: Mohan
#Purpose: To upload files to AWS S3 via Curl
#Uploads file at the top level folder by default
#S3 parameters
S3KEY="XXXXXXXXXXX"
S3SECRET="XXXXXXXXXXXXXXXX"
@tuxfight3r
tuxfight3r / 1.my_filter.py
Created Mar 14, 2017
ansible custom filters demo
View 1.my_filter.py
#place the file in your ansible playbook director under filter_plugins
#/home/user/my_playbook.yml
#/home/user/filter_plugins/my_filters.py
#!/usr/bin/python
class FilterModule(object):
def filters(self):
return {
'a_filter': self.a_filter,
'another_filter': self.b_filter
@tuxfight3r
tuxfight3r / notes.md
Last active Mar 17, 2021
validating EC2 pem / ssh key pairs
View notes.md
## Get private key fingerprint for AWS generated key ( will match the id in AWS Console)
$ openssl pkcs8 -in test_key.pem -inform PEM -outform DER -topk8 -nocrypt | openssl sha1 -c
(stdin)= f6:38:9c:53:9c:64:a8:b3:40:23:9f:6c:ed:0e:3d:bf:bf:16:bb:1c

## Get fingerpint from Openssh public key only md5 / sha1
$ ssh-keygen -f test_key.pub -e -m PKCS8 | openssl pkey -pubin -outform DER | openssl md5 -c
(stdin)= 55:b6:90:db:34:29:da:60:68:c9:08:24:f1:9f:c8:4b

(or)
@tuxfight3r
tuxfight3r / 01.trust_policy.MD
Last active Mar 11, 2021
Importing a VM into AWS EC2 from S3 Bucket
View 01.trust_policy.MD

NOTE: Assuming .vhd image is already uploaded to s3 bucket, the following is the process to import the image when the vmimport role is missing

#create a role policy json file

{
   "Version":"2012-10-17",
   "Statement":[
      {
         "Sid":"",
         "Effect":"Allow",