1
1
#! /bin/bash
2
2
# $1 : Folder containing .git directory to scan
3
3
# $2 : Folder to put files to
4
+ function init_header() {
5
+ cat << EOF
6
+ ###########
7
+ # Extractor is part of https://github.com/internetwache/GitTools
8
+ #
9
+ # Developed and maintained by @gehaxelt from @internetwache
10
+ #
11
+ # Use at your own risk. Usage might be illegal in certain circumstances.
12
+ # Only for educational purposes!
13
+ ###########
14
+ EOF
15
+ }
16
+
17
+ init_header
4
18
5
19
if [ $# -ne 2 ]; then
6
- echo " USAGE: extractor.sh GIT-DIR DEST-DIR" ;
20
+ echo -e " \e[33m[*] USAGE: extractor.sh GIT-DIR DEST-DIR\e[0m " ;
7
21
exit 1;
8
22
fi
9
23
10
24
if [ ! -d " $1 /.git" ]; then
11
- echo " There's no .git folder" ;
25
+ echo -e " \e[31m[-] There's no .git folder\e[0m " ;
12
26
exit 1;
13
27
fi
14
28
15
29
if [ ! -d " $2 " ]; then
16
- echo " Destination folder does not exist" ;
17
- echo " Creating..."
30
+ echo -e " \e[33m[*] Destination folder does not exist\e[0m " ;
31
+ echo -e " \e[32m[*] Creating...\e[0m "
18
32
mkdir " $2 "
19
33
fi
20
34
@@ -37,10 +51,10 @@ function traverse_tree() {
37
51
fi
38
52
39
53
if [ " $type " = " blob" ]; then
40
- echo " Found file: $path /$name "
54
+ echo -e " \e[32m[+] Found file: $path /$name \e[0m "
41
55
git cat-file -p $hash > " $path /$name "
42
56
else
43
- echo " Found folder: $path /$name "
57
+ echo -e " \e[32m[+] Found folder: $path /$name \e[0m "
44
58
mkdir -p " $path /$name " ;
45
59
# Recursively traverse sub trees
46
60
traverse_tree $hash " $path /$name " ;
@@ -55,7 +69,7 @@ function traverse_commit() {
55
69
local count=$3
56
70
57
71
# Create folder for commit data
58
- echo " Found commit: $commit " ;
72
+ echo -e " \e[32m[+] Found commit: $commit \e[0m " ;
59
73
path=" $base /$count -$commit "
60
74
mkdir -p $path ;
61
75
# Add meta information
@@ -95,6 +109,4 @@ find ".git/objects" -type f |
95
109
96
110
done ;
97
111
98
- cd $OLDDIR ;
99
-
100
- echo " Finished" ;
112
+ cd $OLDDIR ;
0 commit comments