-
Notifications
You must be signed in to change notification settings - Fork 2
171 lines (142 loc) · 8.53 KB
/
generate_stable.yml
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Generate Stable Database
on:
workflow_dispatch:
schedule:
- cron: '0 1 */2 * *'
jobs:
generate:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Dependency Setup
run: |
sudo apt-get update -y
sudo apt install maven unzip git dos2unix -y
- name: Start ClamAV daemon clamd
uses: toblux/[email protected]
with:
db_main: true
db_daily: true
- name: Organize Directories & Static Sources
run: |
mkdir -p "${{ github.workspace }}/raw/"
mkdir -p "${{ github.workspace }}/exclusions/"
mkdir -p "${{ github.workspace }}/various/"
cp ${{ github.workspace }}/static/* "${{ github.workspace }}/raw/"
- name: DATABASE PREPARATION - ClamAV
run: |
mkdir /tmp/mss
cd /tmp/mss
cp /var/lib/clamav/main.c*d .
cp /var/lib/clamav/daily.c*d .
sigtool -u main.c*d
sigtool -u daily.c*d
mv /tmp/mss/*.fp* "${{ github.workspace }}/exclusions/"
mv /tmp/mss/*.hsb "${{ github.workspace }}/raw/"
mv /tmp/mss/*.hdb "${{ github.workspace }}/raw/"
mv /tmp/mss/*.hdu "${{ github.workspace }}/raw/"
mv /tmp/mss/*.hsu "${{ github.workspace }}/raw/"
- name: DATABASE PREPARATION - ESET
run: |
git clone https://github.com/eset/malware-ioc "${{ github.workspace }}/various/eset-sources/"
processHashes() {
local name=$(basename $1);
if [ -f $1/samples.$2 ]; then
dos2unix $1/samples.$2
while IFS= read -r line
do
echo "$line" >> "${{ github.workspace }}/various/eset.$2";
done < "$1/samples.$2";
fi;
}
export -f processHashes;
find "${{ github.workspace }}/various/eset-sources/" -maxdepth 2 -mindepth 1 -type d -exec bash -c 'processHashes "{}" md5 hdb' \;
find "${{ github.workspace }}/various/eset-sources/" -maxdepth 2 -mindepth 1 -type d -exec bash -c 'processHashes "{}" sha1 hsb' \;
find "${{ github.workspace }}/various/eset-sources/" -maxdepth 2 -mindepth 1 -type d -exec bash -c 'processHashes "{}" sha256 hsb' \;
cp "${{ github.workspace }}/various/eset.md5" "${{ github.workspace }}/raw"
cp "${{ github.workspace }}/various/eset.sha1" "${{ github.workspace }}/raw"
cp "${{ github.workspace }}/various/eset.sha256" "${{ github.workspace }}/raw"
- name: DATABASE PREPARATION - Signature-Base
run: |
wget https://raw.githubusercontent.com/Neo23x0/signature-base/refs/heads/master/iocs/hash-iocs.txt -O "${{ github.workspace }}/raw/signature-base.loki"
wget https://raw.githubusercontent.com/Neo23x0/signature-base/refs/heads/master/iocs/otx-hash-iocs.txt -O "${{ github.workspace }}/raw/signature-base-otx.loki"
- name: DATABASE PREPARATION - ThreatView
run: |
wget "https://threatview.io/Downloads/MD5-HASH-ALL.txt" -O - | sed 's/MD5 of //' >> "${{ github.workspace }}/various/threatview.md5"
wget "https://threatview.io/Downloads/SHA-HASH-FEED.txt" -O - >> "${{ github.workspace }}/various/threatview.sha1"
sort -u -o "${{ github.workspace }}/raw/threatview.md5" "${{ github.workspace }}/various/threatview.md5"
sort -u -o "${{ github.workspace }}/raw/threatview.sha1" "${{ github.workspace }}/various/threatview.sha1"
- name: DATABASE PREPARATION - ThreatFox
run: |
wget "https://threatfox.abuse.ch/export/csv/sha256/full/" -O "${{ github.workspace }}/various/download_threatfox.zip"
unzip "${{ github.workspace }}/various/download_threatfox.zip" -d "${{ github.workspace }}/various/"
tail -n +10 "${{ github.workspace }}/various/full_sha256.csv" | awk '{ print $4 } ' | sed 's/^"//' | sed 's/",$//' > "${{ github.workspace }}/raw/threatfox.sha256"
- name: DATABASE PREPARATION - MalwareBazaar
run: |
wget "https://bazaar.abuse.ch/export/txt/sha256/full/" -O "${{ github.workspace }}/various/download_bazaar.zip"
unzip "${{ github.workspace }}/various/download_bazaar.zip" -d "${{ github.workspace }}/various/"
mv "${{ github.workspace }}/various/full_sha256.txt" "${{ github.workspace }}/raw/malware_bazaar.sha256"
- name: DATABASE PREPARATION - CyberCure
run: |
wget "https://api.cybercure.ai/feed/get_hash?type=csv" -O - | sed 's/,/\n/g' >> "${{ github.workspace }}/various/cybercure.md5"
sort -u -o "${{ github.workspace }}/raw/cybercure.md5" "${{ github.workspace }}/various/cybercure.md5"
- name: DATABASE PREPARATION - Stalkerware
run: |
wget "https://raw.githubusercontent.com/AssoEchap/stalkerware-indicators/refs/heads/master/samples.csv" -O "${{ github.workspace }}/various/stalkerware.csv"
while IFS=, read -r col1SHA col2Package col3Certificate col4Version col5Name
do
if [ -n "$col1SHA" ] && [ -n "$col5Name" ]; then
echo "$col1SHA:0:$col5Name" >> "${{ github.workspace }}/raw/stalkerware.hsb";
fi;
done < "${{ github.workspace }}/various/stalkerware.csv";
sed -i '1d' "${{ github.workspace }}/raw/stalkerware.hsb";
- name: DATABASE PREPARATION - Sanesecurity
run: |
mkdir -p "${{ github.workspace }}/various/sanesecurity-real/"
cd "${{ github.workspace }}/various/sanesecurity-real/"
rsync -av rsync://rsync.sanesecurity.net/sanesecurity .
for f in *.hsb; do
echo "" >> "${{ github.workspace }}/raw/sanesecurity-$f";
cat "$f" >> "${{ github.workspace }}/raw/sanesecurity-$f";
sort -u -o "${{ github.workspace }}/raw/sanesecurity-$f" "${{ github.workspace }}/raw/sanesecurity-$f";
done
for f in *.hdb; do
echo "" >> "${{ github.workspace }}/raw/sanesecurity-$f";
cat "$f" >> "${{ github.workspace }}/raw/sanesecurity-$f";
sort -u -o "${{ github.workspace }}/raw/sanesecurity-$f" "${{ github.workspace }}/raw/sanesecurity-$f";
done
rm -v ${{ github.workspace }}/raw/sanesecurity-crdfam.clamav.hdb ${{ github.workspace }}/raw/sanesecurity-doppelstern.hdb ${{ github.workspace }}/raw/sanesecurity-malware.expert.hdb
- name: GENERATE HYPATIA SIGNATURE DATABASES
run: |
mvn -q -B --no-transfer-progress clean compile exec:java -Dexec.mainClass="org.maintainteam.hypatiadatabases.App" -Dexec.args="${{ github.workspace }}/raw/" > "${{ github.workspace }}/various/generation_report.txt"
cat "${{ github.workspace }}/various/generation_report.txt"
echo "<pre>" >> "${{ github.workspace }}/various/generation_report.html"
cat "${{ github.workspace }}/various/generation_report.txt" >> "${{ github.workspace }}/various/generation_report.html"
echo "</pre>" >> "${{ github.workspace }}/various/generation_report.html"
echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}">"${{ github.workspace }}/various/database_generation_ci.txt"
- name: Debug Info
run: |
ls -hla "${{ github.workspace }}/various/"
ls -hla "${{ github.workspace }}/raw/"
ls -hla "${{ github.workspace }}/exclusions/"
tree -a "${{ github.workspace }}"
- name: Select files to use
run: |
mkdir -p "${{ github.workspace }}/deploy"
cp "${{ github.workspace }}/raw/hypatia-domains-bloom.bin" "${{ github.workspace }}/deploy"
cp "${{ github.workspace }}/raw/hypatia-md5-bloom.bin" "${{ github.workspace }}/deploy"
cp "${{ github.workspace }}/raw/hypatia-sha1-bloom.bin" "${{ github.workspace }}/deploy"
cp "${{ github.workspace }}/raw/hypatia-sha256-bloom.bin" "${{ github.workspace }}/deploy"
cp "${{ github.workspace }}/various/generation_report.html" "${{ github.workspace }}/deploy"
cp "${{ github.workspace }}/various/database_generation_ci.txt" "${{ github.workspace }}/deploy"
cp "${{ github.workspace }}/static/template.html" "${{ github.workspace }}/deploy"
date > "${{ github.workspace }}/deploy/generation_time.html"
- name: Deploy to unsigned branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: "${{ github.workspace }}/deploy"
force_orphan: true
publish_branch: unsigned