$ x='() { :;}; echo vulnerable' /bin/bash -c /bin/true
vulnerable
$ x='() { :;}; echo vulnerable' /bin/bash -c /bin/true
vulnerable
$ /bin/bash -c "/bin/echo hello"
hello
$ x='() { :;}; echo vulnerable' /bin/bash -c /bin/true
vulnerable
$ x='foobar' /bin/bash -c "echo $foobar"
foobar
$ my_func () { echo "hello"; } $ my_func hello $ env | grep -i my_func $ bash -c "my_func" bash: my_func: command not found $ export -f my_func $ env | grep -i my_func my_func=() { echo "hello"; } $ bash -c "my_func" hello
$ x='() { :;}; echo vulnerable' /bin/bash -c /bin/true
vulnerable
$ :
$ my_func () { : ;}
$ my_func
$
$ my_func () { echo "hello"; } $ export -f my_func $ env | grep -i my_func my_func=() { echo "hello"; } $ bash -c "my_func" hello
$ x='() { :;}; echo vulnerable' /bin/bash -c /bin/true
vulnerable
$tree .git/
.git/ ├── HEAD ├── objects │ ├── 54 │ │ └── b450dd7d7c │ └── ac │ └── 0797189547 └── refs └── heads ├── master └── newbranch
$cat .git/HEAD
ref: refs/heads/master $cat .git/refs/heads/master
ac0797189547f3f0cdcf39cb170b16d2344aeaf3
$ cat .git/refs/heads/newbranch
ac0797189547f3f0cdcf39cb170b16d2344aeaf3
$tree .git/
.git/ ├── HEAD ( -> refs/heads/master ) ├── objects │ ├── 54 │ │ └── b450dd7d7c │ └── ac │ └── 0797189547 ( 親: -> objects/54/b450dd7d7c ) └── refs └── heads ├── master ( -> objects/ac/0797189547 ) └── newbranch ( -> objects/ac/0797189547 )
$echo foobar >> README
$git add README
$git commit -m "Second child commit."
[master 22c3956] Second child commit. 1 file changed, 1 insertion(+)
$ git log --graph --decorate --all
* commit 22c39561 (HEAD, master)
| Date: Fri Jul 18 18:25:20 2014 +0900
| Second child commit.
|
* commit ac079718 (newbranch)
| Date: Fri Jul 11 14:51:49 2014 +0900
| Child commit.
|
* commit 54b450dd
Date: Tue Jul 8 18:36:36 2014 +0900
Initial commit.
$cat .git/refs/heads/newbranch
ac0797189547f3f0cdcf39cb170b16d2344aeaf3 $cat .git/refs/heads/master
22c395616a88b1e845057ad2775399a1853d4010
$git checkout newbranch
Switched to branch 'newbranch' $cat .git/HEAD
ref: refs/heads/newbranch $cat .git/refs/heads/newbranch
ac0797189547f3f0cdcf39cb170b16d2344aeaf3 $cat .git/refs/heads/master
22c395616a88b1e845057ad2775399a1853d4010
$echo testtest >> README
$git add README
$git commit -m "Commit on newbranch."
[newbranch 163e533] Commit on newbranch. 1 file changed, 1 insertion(+)
$cat .git/HEAD
ref: refs/heads/newbranch $cat .git/refs/heads/newbranch
163e533db99cf9c8bc1f30222e47975840ae2883 $cat .git/refs/heads/master
22c395616a88b1e845057ad2775399a1853d4010
ブランチだけじゃなくて任意のコミットをcheckoutすることもできる
$git checkout 54b450dd
Note: checking out '54b450dd'. You are in 'detached HEAD' state. ... $cat .git/HEAD
54b450dd7d7c8280040569fc7b5e4637883e76c2
$git branch test
$cat .git/HEAD
ref: refs/heads/newbranch $cat .git/refs/heads/newbranch
ac0797189547f3f0cdcf39cb170b16d2344aeaf3 $cat .git/refs/heads/master
22c395616a88b1e845057ad2775399a1853d4010 $cat .git/refs/heads/test
ac0797189547f3f0cdcf39cb170b16d2344aeaf3
$git checkout test
Switched to branch 'test' $cat .git/HEAD
ref: refs/heads/test $cat .git/refs/heads/newbranch
ac0797189547f3f0cdcf39cb170b16d2344aeaf3 $cat .git/refs/heads/test
ac0797189547f3f0cdcf39cb170b16d2344aeaf3
$git reset --hard master
HEAD is now at 22c3956 Second child commit. $cat .git/HEAD
ref: refs/heads/test $cat .git/refs/heads/test
22c395616a88b1e845057ad2775399a1853d4010 $cat .git/refs/heads/master
22c395616a88b1e845057ad2775399a1853d4010
聞きたい人いますか?
$git checkout master
Switched to branch 'master' $git branch -D newbranch
Deleted branch newbranch (was 163e533). $git branch -D test
Deleted branch test (was 22c3956).
$tree .git/refs
.git/refs/ ├── heads │ └── master └── tags
$ git branch test2
$echo "hello1" >> master-test-file
$git add master-test-file
$git commit -m 'master commit 1'
[master b27026d] master commit 1 1 file changed, 1 insertion(+) create mode 100644 master-test-file $echo "hello2" >> master-test-file
$git add master-test-file
$git commit -m 'master commit 2'
[master 55970ec] master commit 2 1 file changed, 1 insertion(+)
$git checkout test2
Switched to branch 'test2' $echo "foo1" >> test2-test-file
$git add test2-test-file
$git commit -m 'test2 commit 1'
[test2 491b512] test2 commit 1 1 file changed, 1 insertion(+) create mode 100644 test2-test-file $echo "foo2" >> test2-test-file
$git add test2-test-file
$git commit -m 'test2 commit 2'
[test2 e43ab74] test2 commit 2 1 file changed, 1 insertion(+)
$git rebase master
First, rewinding head... Applying: test2 commit 1 Applying: test2 commit 2 $ls
master-test-file README test2-test-file $git log --oneline
dc2421d test2 commit 2 910a5a7 test2 commit 1 55970ec master commit 2 b27026d master commit 1 22c3956 Second child commit. ac07971 Child commit. 54b450d Initial commit.
$ git log --oneline
dc2421d test2 commit 2
910a5a7 test2 commit 1
fin
Use a spacebar or arrow keys to navigate