Skip to content

Commit 5408fee

Browse files
committed
merge v0.1.0 patch2
1 parent b63acef commit 5408fee

30 files changed

Lines changed: 1180 additions & 8813 deletions

File tree

.github/workflows/generate.yaml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
- name: Checkout code
6363
uses: actions/checkout@v4
6464
with:
65-
token: ${{ secrets.GITHUB_TOKEN }}
65+
token: ${{ secrets.GH_PAT }}
6666
submodules: recursive
6767

6868
- name: Judge target_triple is win
@@ -73,11 +73,6 @@ jobs:
7373
echo "is_win=0" >> $GITHUB_ENV
7474
fi
7575
76-
- name: Install win kit lib
77-
run: |
78-
wget https://github.com/chainreactors/malefic/releases/latest/download/resources.zip
79-
unzip resources.zip -d resources
80-
8176
- name: Generate config.yaml
8277
if : ${{ github.event.inputs.malefic_config_yaml != null }}
8378
run: |
@@ -133,4 +128,4 @@ jobs:
133128
with:
134129
name: malefic-${{matrix.target}}-${{ github.run_id }}
135130
path: output/*
136-
retention-days: 3 # you can change this value
131+
retention-days: 3 # you can change this value

.github/workflows/release.yml

Lines changed: 46 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
name: release
1+
name: release_config_and_modules
22

33
on:
44
push:
55
tags:
66
- 'v*.*.*'
7-
workflow_dispatch:
8-
inputs:
9-
tag_name:
10-
description: 'The tag name for the release'
11-
required: true
12-
default: 'v0.0.1'
13-
draft:
14-
description: 'Create a draft release'
15-
required: false
16-
default: 'true'
177

188
permissions:
199
contents: write
@@ -28,107 +18,96 @@ jobs:
2818
uses: actions/checkout@v4
2919
with:
3020
submodules: recursive
21+
token: ${{ secrets.GH_PAT }}
3122

3223
- name: Set Version
3324
id: set_version
3425
run: |
35-
if [ "${{ github.event_name }}" == "push" ]; then
36-
VERSION=${GITHUB_REF#refs/tags/}
37-
else
38-
VERSION=${{ inputs.tag_name }}
39-
fi
40-
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
26+
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
4127
4228
- name: Create release
4329
id: create_release
4430
uses: actions/create-release@v1
4531
env:
46-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
4733
with:
4834
tag_name: ${{ steps.set_version.outputs.VERSION }}
4935
release_name: Release ${{ steps.set_version.outputs.VERSION }}
5036
body: |
5137
Release ${{ steps.set_version.outputs.VERSION }}
52-
draft: true
38+
draft: false
5339
prerelease: false
5440

55-
- name: Download win-kit resources
56-
uses: robinraju/release-downloader@v1.11
57-
with:
58-
repository: "chainreactors/malefic-win-kit"
59-
latest: true
60-
fileName: "community_resource.zip"
61-
token: ${{ secrets.PAT_TOKEN }}
62-
63-
- name: Download rem lib
64-
uses: robinraju/release-downloader@v1.11
65-
with:
66-
repository: "chainreactors/rem-community"
67-
latest: true
68-
fileName: "rem_lib.zip"
69-
token: ${{ secrets.PAT_TOKEN }}
70-
71-
- name: Extract zip
72-
run: |
73-
unzip community_resource.zip -d community_resource
74-
unzip rem_lib.zip -d rem_lib
75-
mkdir resources_dir
76-
mv community_resource/* resources_dir/
77-
mv rem_lib/dist/lib/*.a resources_dir/
78-
cd resources_dir
79-
zip -r ../resources.zip ./*
80-
cd ..
81-
82-
- name: Upload resources
83-
env:
84-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85-
run : |
86-
gh release upload ${{ steps.set_version.outputs.VERSION }} resources.zip
87-
88-
release-mutant:
41+
config-release:
8942
needs: create-release
9043
runs-on: ubuntu-22.04
9144
continue-on-error: true
9245
strategy:
9346
matrix:
9447
target:
95-
- x86_64-pc-windows-gnu
96-
# - i686-pc-windows-msvc
48+
- x86_64-pc-windows-msvc
49+
- i686-pc-windows-msvc
9750
- x86_64-unknown-linux-musl
98-
# - i686-unknown-linux-musl
51+
- i686-unknown-linux-musl
9952
- x86_64-apple-darwin
10053
- aarch64-apple-darwin
10154
steps:
102-
- name: Checkout
55+
- name: Checkout code
10356
uses: actions/checkout@v4
10457
with:
10558
submodules: recursive
59+
token: ${{ secrets.GH_PAT }}
60+
61+
- name: Create output directory
62+
run: |
63+
mkdir -p output/
10664
10765
- name: Build malefic-mutant for ${{matrix.target}}
10866
shell: 'script --return --quiet --log-out /dev/null --command "bash -e {0}"'
10967
run: |
110-
mkdir -p output/
68+
69+
docker run -v "$(pwd):/root/src" --rm -it ghcr.io/chainreactors/${{matrix.target}}:nightly-2024-08-16-latest \
70+
cargo build --release -p malefic-mutant --target ${{matrix.target}}
71+
sudo chmod -R 777 target
72+
73+
target_dir="target/${{matrix.target}}/release"
11174
binary_name="malefic-mutant"
112-
release_dir="release"
113-
target_dir="target/${{matrix.target}}/${release_dir}"
114-
docker run -v "$(pwd):/root/src" --rm -it ghcr.io/chainreactors/malefic-builder:v0.0.4 \
115-
cargo build --release -p malefic-mutant --target ${{matrix.target}}
11675
117-
sudo chmod 777 -R target/
11876
if [[ -f ${target_dir}/${binary_name}.exe ]]; then
11977
mv ${target_dir}/${binary_name}.exe output/${binary_name}-${{matrix.target}}.exe
12078
else
12179
mv ${target_dir}/${binary_name} output/${binary_name}-${{matrix.target}}
12280
fi
12381
82+
- name: Build malefic-modules for ${{matrix.target}}
83+
if: ${{ contains(matrix.target, 'windows') }}
84+
shell: 'script --return --quiet --log-out /dev/null --command "bash -e {0}"'
85+
run: |
86+
docker run -v "$(pwd):/root/src" --rm -it ghcr.io/chainreactors/${{matrix.target}}:nightly-2024-08-16-latest bash -c "\
87+
cargo build --release -p malefic-mutant && \
88+
./target/release/malefic-mutant generate modules "base" && \
89+
cargo build --release -p malefic-modules --features "base" --target ${{matrix.target}} &&
90+
mv target/${{matrix.target}}/release/modules.dll output/modules-base-${{matrix.target}}.dll && \
91+
./target/release/malefic-mutant generate modules "extend" && \
92+
cargo build --release -p malefic-modules --features "extend" --target ${{matrix.target}} &&
93+
mv target/${{matrix.target}}/release/modules.dll output/modules-extend-${{matrix.target}}.dll && \
94+
./target/release/malefic-mutant generate modules "full" && \
95+
cargo build --release -p malefic-modules --features "full" --target ${{matrix.target}} &&
96+
mv target/${{matrix.target}}/release/modules.dll output/modules-full-${{matrix.target}}.dll "
97+
98+
- name: Chmod output
99+
run: |
100+
sudo chmod -R 777 output
101+
124102
- name: Release ${{ matrix.target }}
125103
env:
126104
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127105
run: |
128-
cd output
129-
for file in *; do
106+
for file in output/*; do
130107
filename=$(basename "$file")
131-
echo "Uploading $filename"
132-
gh release upload ${{ needs.create-release.outputs.VERSION }} $filename
108+
echo "Uploading $file"
109+
sha256sum $file >> $file.sha256
110+
gh release upload ${{ needs.create-release.outputs.VERSION }} $file.sha256
111+
gh release upload ${{ needs.create-release.outputs.VERSION }} $file
133112
done
134113
shell: bash

.github/workflows/test.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: validate
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
generate:
14+
runs-on: ubuntu-22.04
15+
strategy:
16+
matrix:
17+
target: ["x86_64-pc-windows-gnu", "x86_64-unknown-linux-musl", "aarch64-apple-darwin"]
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
token: ${{ secrets.GH_PAT }}
24+
submodules: recursive
25+
26+
- name: Authorize Git
27+
run: |
28+
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
29+
git config --global user.name "$GITHUB_ACTOR"
30+
31+
- name: Update submodule
32+
run: |
33+
git submodule update --init --recursive --remote -f
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
36+
37+
- name: Build for ${{matrix.target}})
38+
shell: 'script --return --quiet --log-out /dev/null --command "bash -e {0}"'
39+
run: |
40+
docker run -v $(pwd):/root/src ghcr.io/chainreactors/malefic-builder:latest \
41+
bash -c "cargo build --release -p malefic-mutant && ./target/release/malefic-mutant generate beacon -s && ./target/release/malefic-mutant build malefic --target ${{matrix.target}}"
42+
43+
- name: Build completed
44+
run: |
45+
echo "Build for ${{matrix.target}} completed successfully"

config.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ basic:
44
- "127.0.0.1:5001"
55
protocol: "tcp"
66
tls: false
7-
proxy:
7+
proxy:
88
interval: 5
99
jitter: 0.2
1010
ca:
@@ -14,11 +14,12 @@ basic:
1414
link:
1515
http:
1616
method: "POST"
17-
path: "/pulse"
17+
path: "/jquery.js"
1818
host: "127.0.0.1"
1919
version: "1.1"
2020
headers:
2121
User-Agent: "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0"
22+
Content-Type: "application/octet-stream"
2223
#any-header: any-value
2324
build:
2425
zigbuild: false

malefic-core/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ register_info = []
1313
tcp = []
1414
tls = ["async-tls", "rustls", "rustls-pemfile"]
1515

16+
proxy = []
17+
http_proxy = ["httparse"]
18+
socks5_proxy = []
19+
1620
# export transport feature
1721
transport_http = ["httparse", "tcp"]
1822
transport_tcp = ["tcp"]
@@ -30,7 +34,8 @@ lazy_static = "1.5.0"
3034
anyhow = "1.0.86"
3135
thiserror = "1.0.64"
3236
obfstr = "0.4.3"
33-
httparse = { version = "1.8", optional = true }
37+
httparse = { version = "1.8" , optional = true}
38+
3439

3540
# Runtime
3641
async-std = { version = "1.13.0", features = ["unstable", "attributes"], optional = true }
@@ -48,4 +53,5 @@ malefic-helper = { path= "../malefic-helper", features = [ "default" ] }
4853
malefic-proto = { path = "../malefic-proto" }
4954
malefic-modules = { path = "../malefic-modules"}
5055
malefic-3rd = { path = "../malefic-3rd" , optional = true}
56+
base64 = "0.22"
5157

malefic-core/src/manager/internal.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ pub enum InternalModule {
3333
Sleep,
3434
#[strum(serialize = "suicide")]
3535
Suicide,
36-
#[strum(serialize = "login")]
37-
Login,
36+
#[strum(serialize = "switch")]
37+
Switch,
3838
}
3939

4040
impl InternalModule {
@@ -55,7 +55,7 @@ impl InternalModule {
5555
InternalModule::ListTask,
5656
InternalModule::Sleep,
5757
InternalModule::Suicide,
58-
InternalModule::Login,
58+
InternalModule::Switch,
5959
]
6060
.iter()
6161
.map(|m| m.to_string()) // Display 自动提供 to_string() 方法

malefic-core/src/transport/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ pub mod http;
55
#[cfg(feature = "transport_rem")]
66
pub mod rem;
77

8+
#[cfg(feature = "proxy")]
9+
pub mod proxie;
10+
811
use anyhow::Result;
912
use async_trait::async_trait;
1013
use futures::lock::Mutex;

0 commit comments

Comments
 (0)