FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ret2shell/.devcontainer/devtools/ret2dev at main · ret2shell/ret2shell · GitHub
ret2shell
ret2shell
Repository navigation
Code
Issues
19
(19)
Pull requests
5
(5)
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ret2shell
/
.devcontainer
/
devtools
/
ret2dev
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
109 lines (99 loc) · 2.33 KB
Breadcrumbs
ret2shell
/
.devcontainer
/
devtools
/
ret2dev
Copy path
File metadata and controls
executable file
·
109 lines (99 loc) · 2.33 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!
/bin/bash
if
[
-f
"
$HOME
/.ret2shell/.env.development
"
]
;
then
source
"
$HOME
/.ret2shell/.env.development
"
fi
function
eprintln()
{
echo
"
$@
"
1>&2
}
function
print_usage()
{
echo
"
Usage:
$0
[OPTIONS] <COMMAND>
"
echo
"
"
echo
"
Commands:
"
echo
"
database, db Enter the database shell (psql)
"
echo
"
cache, redis, redis-cli Enter the cache shell (redis-cli)
"
echo
"
help, -h, --help Show this help message and exit
"
echo
"
"
echo
"
Options:
"
echo
"
--name, -n NAME Specify the service name prefix (default:
${DOCKER_SVC_NAME
:-
ret2shell}
)
"
echo
"
--container-name NAME Specify the exact container name to connect to
"
}
rest_args=()
function
parse_rest_args()
{
while
[
"
$#
"
-gt
0 ]
;
do
arg=
"
$1
"
shift
rest_args+=(
"
$arg
"
)
done
}
opt_cmd=
"
"
opt_name=
"
${DOCKER_SVC_NAME
:-
ret2shell}
"
opt_container_name=
"
"
function
parse_args()
{
while
[
"
$#
"
-gt
0 ]
;
do
arg=
"
$1
"
shift
case
"
$arg
"
in
database|db)
opt_cmd=
"
database
"
break
;;
cache|redis|redis-cli)
opt_cmd=
"
cache
"
break
;;
--name|-n)
if
[
"
$#
"
-gt
0 ]
;
then
opt_name=
"
$1
"
shift
else
eprintln
"
Option --name requires an argument.
"
exit
1
fi
;;
--container-name)
if
[
"
$#
"
-gt
0 ]
;
then
opt_container_name=
"
$1
"
shift
else
eprintln
"
Option --container-name requires an argument.
"
exit
1
fi
;;
help|-h|--help)
print_usage
exit
0
;;
-
*
)
eprintln
"
Unknown option:
$arg
"
exit
1
;;
*
)
eprintln
"
Unknown command:
$arg
"
exit
1
;;
esac
done
parse_rest_args
"
$@
"
}
parse_args
"
$@
"
function
build_container_name()
{
if
[
-n
"
$opt_container_name
"
]
;
then
echo
"
$opt_container_name
"
else
echo
"
${opt_name}
-
$1
-1
"
fi
}
function
enter_database_shell()
{
docker
exec
-it
"
$(
build_container_name database
)
"
psql -U ret2shell -d ret2shell
}
function
enter_cache_shell()
{
docker
exec
-it
"
$(
build_container_name cache
)
"
redis-cli
}
if
[
"
$opt_cmd
"
=
"
database
"
]
;
then
enter_database_shell
elif
[
"
$opt_cmd
"
=
"
cache
"
]
;
then
enter_cache_shell
else
eprintln
"
No command specified. Use --help for usage information.
"
exit
1
fi
Back
|
FazBrowse Home
|
New Git URL