Skip to content

Commit

Permalink
feat(init): Adding initial workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Kris Nóva <kris@nivenly.com>
  • Loading branch information
krisnova committed Oct 10, 2020
1 parent 4ec0c90 commit 0b765f9
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
bin/*
*idea*
1 change: 1 addition & 0 deletions LICENSE
@@ -1,3 +1,4 @@

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down
23 changes: 23 additions & 0 deletions Makefile
@@ -0,0 +1,23 @@


.PHONY: build

build:
@echo ""
@echo ""
go build -o bin/hack main.go
@echo "Build Complete"
@echo ""
@echo ""

container:
@echo ""
@echo ""
docker build -t krisnova/hack:latest image/
@echo ""
@echo ""


.PHONY: help
help: ## Show help messages for make targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
Empty file added bin/.gitkeep
Empty file.
46 changes: 46 additions & 0 deletions cmd/root.go
@@ -0,0 +1,46 @@
/*
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd

import (
"fmt"
"os"

"github.com/spf13/cobra"
)

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "hack",
Short: "Utility for debugging and hacking on Kubernetes",
Long: `Use hack to debug, explore, exploit and otherwise own a Kubernetes cluster.`,
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
}

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}

func init() {
//flags
}
11 changes: 11 additions & 0 deletions image/Dockerfile
@@ -0,0 +1,11 @@
FROM ubuntu
RUN apt-get update
RUN apt-get install -y nmap net-tools iputils-ping # networking tools
RUN apt-get install -y libcap2-bin # linux capabilities
RUN apt-get install -y strace # kernel tools
#RUN apt-get install -y
RUN yes | unminimize
COPY ./home/bashrc /root/.bashrc
COPY ./home/ /root/
#EXPOSE 22
#CMD ["pdig", "-a", "./init.sh"]
89 changes: 89 additions & 0 deletions image/home/bashrc
@@ -0,0 +1,89 @@
#!/bin/bin
#
#
#
# ----------------------------------------------------------------------------------------------------------------------
#
# ,/
# ,//
# ___ /| |//
# __/\_ --(/|___/-/
# \|\_-\___ __-_ - /-/ \.
# |\_-___,-\_____--/_)' ) \
# \ -_ / __ \( ( __ \|
# \__| |\)\ ) /(/|
# ,._____., ',--//-| \ | ' /
# / __. \, / /,---| \ /
# / / _. \ \ / _/ _,' | |
# | | ( ( \ | ,/\'__/'/ | |
# | \ \ --, _/_------______/ \( )/ Kris Nóva
# | | \ \_. \, \___/\
# | | \_ \ \ \
# \ \ \_ \ \ / \
# \ \ \._ \__ \_| | \ Stay the fuck out of my .bashrc
# \ \___ \ \ | \
# \__ \__ \ \_ | \ |
# | \_____ \ ____ | |
# | \ \__ ---' .__\ | | |
# \ \__ --- / ) | \ /
# \ \____/ / ()( \ ---_ /|
# \__________/(,--__ \_________. | ./ |
# | \ \ ---_\--, \ \_,./ |
# | \ \_ \ / ---_______-\ \\ /
# \ \.___, | / \ \\ \
# \ | \_ \| \ ( |: |
# \ \ \ | / / | ;
# \ \ \ \ ( _' \ |
# \. \ \. \ __/ | |
# \ \ \. \ | |
# \ \ \ \ ( )
# \ | \ | | |
# | \ \ \ | | ----
# ( __; ( _; ('-_'; --------
# |___\ \___: \___: ---------------
#
#
#
# ----------------------------------------------------------------------------------------------------------------------

#
# -------------------------
# [ENVIRONMENTAL VARIABLES]
# -------------------------

export EDITOR=/usr/bin/emacs
export PATH="$HOME/bin:$HOME/.local/bin:$PATH"
export PS1="\[\033[38;5;12m\][\[$(tput sgr0)\]\[\033[38;5;10m\]\u\[$(tput sgr0)\]\[\033[38;5;12m\]@\[$(tput sgr0)\]\[\033[38;5;7m\]\h\[$(tput sgr0)\]\[\033[38;5;12m\]]\[$(tput sgr0)\]\[\033[38;5;15m\]: \[$(tput sgr0)\]\[\033[38;5;7m\]\w\[$(tput sgr0)\]\[\033[38;5;12m\]>\[$(tput sgr0)\]\[\033[38;5;10m\]\\$\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]"
[ -e "/etc/DIR_COLORS" ] && DIR_COLORS="/etc/DIR_COLORS"
[ -e "$HOME/.dircolors" ] && DIR_COLORS="$HOME/.dircolors"
[ -e "$DIR_COLORS" ] || DIR_COLORS=""
eval "`dircolors -b $DIR_COLORS`"

# -------------------------
# [VARS]
# -------------------------

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# -------------------------
# [SYSTEM]
# -------------------------

#ulimit -n 2048
#ssh-add ~/.ssh/id_rsa


# -------------------------
# [FUNCTIONS]
# -------------------------

# Convenience log scrapper for k8s
klog(){
PO=$(kubectl get po --all-namespaces | grep $1)
kubectl logs $(echo $PO | cut -d " " -f 2) -n $(echo $PO | cut -d " " -f 1) -f
}

. /root/probe.sh



10 changes: 10 additions & 0 deletions image/home/probe.sh
@@ -0,0 +1,10 @@
#!/bin/bin
#
#
#

echo "-----------------------------------------"
echo ""
echo "[HACK] A container image for debugging."
echo ""
echo "-----------------------------------------"
22 changes: 22 additions & 0 deletions main.go
@@ -0,0 +1,22 @@
/*
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main

import "hack/cmd"

func main() {
cmd.Execute()
}

0 comments on commit 0b765f9

Please sign in to comment.