Skip to content

Commit 21fdbcf

Browse files
committed
Merge remote-tracking branch 'origin/master' into merge
2 parents 70ee361 + 27ea7f0 commit 21fdbcf

File tree

6 files changed

+89
-15
lines changed

6 files changed

+89
-15
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ hosts/
44
users/
55
services/
66
index.md
7-
Makefile
87
.DS_Store
98
.vscode/.command_history
10-
zsh_history
9+
zsh_history
10+
weapon_test
11+
test*

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
build:
2+
@echo "Building the project..."
3+
uv run ./craft.py
4+
uv run ./completion_creator.py
5+
@echo "Build complete."
6+
7+
install: build
8+
@echo "Preparing the environment..."
9+
WEAPON_LOCATION=$(shell pwd)/weapon_test ./installer.sh
10+
@echo "Installation complete."
11+
12+
install-trace: build
13+
@echo "Preparing the environment with trace..."
14+
WEAPON_LOCATION=$(shell pwd)/weapon_test ./installer.sh --trace-mode
15+
@echo "Installation with trace complete."
16+
17+
clean:
18+
rm -rf ./hosts ./users ./weapon_test ./createhackenv.sh ./zsh_history

completion_indexer/impacket

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ dcomexec.py -hashes :"$NT_HASH" "$DOMAIN"/"$USER"@"$TARGET"
6868
atexec.py -hashes :"$NT_HASH" "$DOMAIN"/"$USER"@"$TARGET"
6969
changepasswd.py -newpass '123Pentest!!!' "$DOMAIN"/"$USER":"$PASS"@"$DC_HOST"
7070
changepasswd.py -newpass '123Pentest!!!' -hashes :"$NT_HASH" "$DOMAIN"/"$USER"@"$TARGET"
71+
owneredit.py -action write -new-owner "$USER" -target "$TARGET_OBJECT" "$DOMAIN"/"$USER":"$PASS"
7172
owneredit.py -action write -new-owner "$NEW_OWNER" -target "$TARGET_OBJECT" "$DOMAIN"/"$USER":"$PASS"
7273
mssqlclient.py "$DOMAIN"/"$USER":"$PASS"@"$TARGET"
7374
describeTicket.py "$KRB5CCNAME"

installer.sh

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ function check_command() {
1212
function check_requirements() {
1313
check_command "awk" "awk is required for parsing the output of commands, please install it." || return 2
1414
check_command "sed" "sed is required for parsing the output of commands, please install it." || return 2
15+
check_command "grep" "grep is required for parsing the output of commands, please install it." || return 2
16+
check_command "tr" "tr is required for parsing the output of commands, please install it." || return 2
1517
check_command "zsh" "zsh is core to WeaponizedVSCode integrated shell." || return 2
1618
check_command "vim" "vim is required for task edit /etc/hosts, please install it or change it." || return 2
1719
check_command "nc" "nc is core for netcat shell session handling or u can't use it, please install it." || return 2
@@ -27,44 +29,92 @@ function check_requirements() {
2729
check_command "uv" "uv is optional but recommended for better performance, install it with 'pip install uv'. Their script is useful"
2830
}
2931

32+
export INSTALL_IDENTIFIER="WeaponizedVSCode installation script. The following commands are generated by WeaponizedVSCode installer."
33+
34+
function args() {
35+
while [[ "$#" -gt 0 ]]; do
36+
case "$1" in
37+
(--trace-mode)
38+
export WEAPON_TRACE_MODE=true
39+
shift
40+
;;
41+
(--force-install)
42+
export WEAPON_FORCE_INSTALL=true
43+
shift
44+
;;
45+
*)
46+
echo "Unknown option: $1"
47+
exit 1
48+
;;
49+
esac
50+
done
51+
}
52+
3053
function main() {
3154
check_requirements
3255
if [[ $? -ne 0 && "$FORCE_INSTALL" != "true" ]]; then
3356
echo "Please install the required commands to continue."
3457
echo "If you want to force install without checking requirements, run the script with FORCE_INSTALL=true ./installer.sh"
3558
exit 1
3659
fi
37-
38-
if [[ -z "$WEAPON_LOCATON" ]]; then
60+
61+
if [[ -z "$WEAPON_LOCATION" ]]; then
3962
echo "WEAPON_LOCATION is not set. set to default ~/.local/weapon"
4063
export WEAPON_LOCATION=~/.local/weapon
4164
echo "You can set it by exporting WEAPON_LOCATION=your_desired_path before running this script."
4265
fi
4366

4467
if [[ -d "$WEAPON_LOCATION" ]]; then
4568
echo "Weapon already installed."
69+
if [[ "$WEAPON_FORCE_INSTALL" == "true" ]]; then
70+
echo "Force install mode enabled, removing existing Weapon directory at $WEAPON_LOCATION."
71+
rm -rf "$WEAPON_LOCATION"
72+
else
73+
echo "If you want to reinstall Weapon, please remove the existing directory at $WEAPON_LOCATION or use --force-install option."
74+
exit 0
75+
fi
4676
exit 0
4777
fi
78+
4879
export LOCATION="$WEAPON_LOCATION"
4980
echo "Weapon will be installed to $LOCATION, Press Enter key to continue or Ctrl+C to cancel..."
5081
read
5182
echo "Installing Weapon..."
5283
mkdir -p $LOCATION && echo "Weapon directory created at $LOCATION."
53-
cp -f ./createhackenv.sh $LOCATION && echo "createhackenv.sh copied to $LOCATION."
54-
echo "" >>$LOCATION/createhackenv.sh
55-
echo "export WEAPON_LOCATION=$LOCATION" >>$LOCATION/createhackenv.sh # overwrite if exists
84+
cat ./createhackenv.sh |sed -e "s#__REPLACE__#$LOCATION#g" > $LOCATION/createhackenv.sh && echo "createhackenv.sh copied to $LOCATION."
5685
cp -f ./zsh_history $LOCATION && echo "zsh_history copied to $LOCATION."
5786

58-
grep -zq "source $LOCATION/createhackenv.sh" ~/.zshrc
87+
if [[ "$WEAPON_TRACE_MODE" == "true" ]];then
88+
cp -f ./zsh_preformance_tracer.sh $LOCATION && echo "zsh_performance_tracer is copied to $LOCATION."
89+
fi
90+
91+
grep -zq "${INSTALL_IDENTIFIER}" ~/.zshrc
5992
if [[ $? -eq 0 ]]; then
6093
echo "createhackenv.sh already sourced in ~/.zshrc. sktpping..."
6194
else
6295
echo "Sourcing createhackenv.sh in ~/.zshrc..."
63-
echo "source $LOCATION/createhackenv.sh" >>~/.zshrc
96+
cp ~/.zshrc ~/.zshrc.pre-weaponized-vscode && echo "Backup ~/.zshrc to ~/.zshrc.pre-weaponized-vscode"
97+
98+
if [[ "$WEAPON_TRACE_MODE" == "true" ]]; then
99+
cat<<EOF >> ~/.zshrc
100+
101+
# ${INSTALL_IDENTIFIER}
102+
[[ -f $LOCATION/zsh_preformance_tracer.sh ]] && source $LOCATION/zsh_preformance_tracer.sh && zsh_trace_start
103+
[[ -f $LOCATION/createhackenv.sh ]] && source $LOCATION/createhackenv.sh
104+
[[ -f $LOCATION/zsh_preformance_tracer.sh ]] && zsh_trace_end
105+
EOF
106+
else
107+
cat<<EOF >> ~/.zshrc
108+
109+
# ${INSTALL_IDENTIFIER}
110+
[[ -f $LOCATION/createhackenv.sh ]] && source $LOCATION/createhackenv.sh
111+
EOF
112+
fi
113+
64114
fi
65115

66116
echo "Weaponized VSCode installation completed."
67-
68117
}
69118

70-
main "$@"
119+
args "$@"
120+
main

launch_helper.zsh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
export WEAPON_LOCATION=__REPLACE__
2+
13
weapon_vscode_launch_helper () {
2-
if [ -f ~/.local/weapon/zsh_history ]; then
3-
export HIST_COMMAND_INDEXER=~/.local/weapon/zsh_history
4+
if [ -f ${WEAPON_LOCATION}/zsh_history ]; then
5+
export HIST_COMMAND_INDEXER=${WEAPON_LOCATION}/zsh_history
46
fi
57
if [ -n "$PROJECT_FOLDER" ]; then
68
if [ -f "$PROJECT_FOLDER/.vscode/.zshrc" ]; then

zsh_preformance_tracer.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export WEAPON_TRACE_LOG=/tmp/weapon_trace_log.$$
2+
13
zsh_trace_start() {
24
echo "starting zsh tracing"
35
# set the trace prompt to include seconds, nanoseconds, script name and line number
@@ -11,7 +13,7 @@ zsh_trace_start() {
1113
fi
1214
# save file stderr to file descriptor 3 and redirect stderr (including trace
1315
# output) to a file with the script's PID as an extension
14-
exec 3>&2 2>/tmp/startlog.$$
16+
exec 3>&2 2>$WEAPON_TRACE_LOG
1517
# set options to turn on tracing and expansion of commands contained in the prompt
1618
setopt xtrace prompt_subst
1719
trap 'setopt xtrace' EXIT
@@ -22,7 +24,7 @@ zsh_trace_end() {
2224
unsetopt xtrace
2325
# restore stderr to the value saved in FD 3
2426
exec 2>&3 3>&-
25-
echo "zsh tracing done. See /tmp/startlog.$$"
27+
echo "zsh tracing done. See $WEAPON_TRACE_LOG for details."
2628
trap 'unsetopt xtrace' EXIT
2729
}
2830

0 commit comments

Comments
 (0)