Skip to content

Commit

Permalink
update: workspaced zshrc and documents
Browse files Browse the repository at this point in the history
  • Loading branch information
Esonhugh committed Apr 24, 2024
1 parent c8a830c commit fc13d05
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 13 deletions.
17 changes: 17 additions & 0 deletions .vscode/.zshrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# POST executed after the shell is loaded
# This file is loaded after .zshrc

# This file can be empty of deleted if not needed
# Loading Order
# vscode ==(inject PROJECT_FOLDER and check settings.json)==> source.zsh (PreHandling)
# source.zsh ==(source env.zsh)==> env.zsh
# source.zsh ==(Check Mode)==> Do any IF condition or keep continue
# source.zsh ==(exec zsh -i)==> ~/.zshrc
# ~/.zshrc ==(contains weapon_vscode_launch_helper function)==> launch_helper.zsh
# ~/.zshrc ==(if set, PROJECT_FOLDER and .vscode/.zshrc exists, source it)==> .vscode/.zshrc

# you can define any function

if [ -d "$PROJECT_FOLDER/venv" ]; then
source $PROJECT_FOLDER/venv/bin/activate
fi
23 changes: 13 additions & 10 deletions documents/CUSTOM.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

> like `vscode setting.json tasks.json` and metasploit workspace rcfile `workspace_metasploit.rc`
3. Check [LaunchOrder.md](./LaunchOrder.md) for the launch order of zsh files and it will explain how they works.

### How to customize it?

#### in disk temporary
Expand Down Expand Up @@ -55,8 +57,12 @@
> `tasks.json` defines commands which will run just once.
>
> current task is msfvenom payload fast generate task.
>
> `extension.json` defines the extension you'd better to install in vscode.
>
> it extends vscode with other strong features like code analysis, code completion, etc.
- `env.zsh` for environments variables you want to set. it should be sourced at first line in `source_*.zsh` and `source.zsh`. (recommended to source it in every .zsh file under .vscode folder)
- `env.zsh` for environments variables you want to set. it should be sourced `source*.zsh`. (recommended to source it in every .zsh file under .vscode folder)

> e.g. `export RHOST=11.45.1.4`
>
Expand All @@ -67,15 +73,12 @@
> e.g. `cd $PROJECT_FOLDER` switch the pwd back to the project
>
- `source_*.zsh` files for you to source your own scripts
- `source.zsh` file will control the zsh shell behavior in vscode terminal with mode

> e.g. `source_web-delivery.zsh` will be used when you use `web-delivery` mode in your new vscode terminal.
> e.g. `source.zsh` will be used when you set env varoiable `WEB_DELIVERY_MODE` in your new vscode terminal.
>
> and you can put your own script in it
> you will launched a new zsh shell and execute the WEB_DELIVERY_MODE command in the block

> `zsh-shell` will create a new zsh shell with sourcing `source.zsh` file
>
> `meterpreter-handler` will launch up a new msfconsole with the metasploit rcfile
> this terminal will called with msfconsole command in `source source_metasploit.zsh` file
>
Expand All @@ -84,13 +87,13 @@
> `web-delivery` will cd into the $PROJECT_WEB_DELIVERY folder and start a python http server for you to delivery web files. It based on `source source_web-delivery.zsh` file.
> > you can use pdteam's simplehttpserver to replace it.
>
> `kali-orbstack` will launch orbstack virtual machine - kalilinx, source `source _kali-orbstack.zsh` and process env variables in `env.zsh` file inside env.
>
- `kali-orbstack` file will launch orbstack virtual machine - kalilinx, source `source_kali-orbstack.zsh` and process env variables in `env.zsh` file inside env. it will also control the zsh behavior but in kali vm.

> > you can easily inject environment variables into the kali vm with this mode. and reuse command outside.
> >
> > like `evil-winrm -i $RHOST -u $RUSER -p $RPASS` will work in kali vm and host machine. and you just need set the env variables in `env.zsh` file once.

- metasploit rcfile `metasploit_handler.rc` for you to use in vscode terminal (meterpreter-handler mode)

> it launched as `msfconsole -r this.rc`
Expand Down
11 changes: 11 additions & 0 deletions documents/LaunchOrder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# all zsh file launch order

```mermaid
graph TD;
vscode ==(inject PROJECT_FOLDER and check settings.json)==> source.zsh(.vscode/source.zsh)
source.zsh ==(1.source env.zsh)==> source.zsh_enved(.vscode/source.zsh) ==(2.Check Mode)==> source.zsh_mode(.vscode/source.zsh) ==> source.zsh_call_zsh(.vscode/source.zsh) & node(execute other commands like netcat handler)
source.zsh_call_zsh(.vscode/source.zsh) ==(exec zsh -i)==> home_zshrc(~/.zshrc)
home_zshrc ==(contains weapon_vscode_launch_helper function)==> home_zshrc_call_helper(~/.zshrc)
home_zshrc_call_helper ==(if set env PROJECT_FOLDER and file .vscode/.zshrc exists, source it)==> execute_project_folder_zshrc(.vscode/.zshrc)
```
5 changes: 2 additions & 3 deletions launch_helper.zsh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
weapon_vscode_launch_helper () {
if [ -n "$PROJECT_FOLDER" ]; then
# do anything if PROJECT_FOLDER is set
if [ -d "$PROJECT_FOLDER/venv" ]; then
source $PROJECT_FOLDER/venv/bin/activate
if [ -f "$PROJECT_FOLDER/.vscode/.zshrc" ]; then
source $PROJECT_FOLDER/.vscode/.zshrc
fi
fi
}
Expand Down

0 comments on commit fc13d05

Please sign in to comment.