BX2trace 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bx2trace-1.0.0/BX2trace.egg-info/PKG-INFO +156 -0
- bx2trace-1.0.0/BX2trace.egg-info/SOURCES.txt +41 -0
- bx2trace-1.0.0/BX2trace.egg-info/dependency_links.txt +1 -0
- bx2trace-1.0.0/BX2trace.egg-info/requires.txt +1 -0
- bx2trace-1.0.0/BX2trace.egg-info/top_level.txt +1 -0
- bx2trace-1.0.0/LICENSE +21 -0
- bx2trace-1.0.0/PKG-INFO +156 -0
- bx2trace-1.0.0/README.md +138 -0
- bx2trace-1.0.0/bx2trace/__init__.py +70 -0
- bx2trace-1.0.0/bx2trace/core/__init__.py +0 -0
- bx2trace-1.0.0/bx2trace/core/api_hooker.py +192 -0
- bx2trace-1.0.0/bx2trace/core/constants.py +124 -0
- bx2trace-1.0.0/bx2trace/core/debug_thread.py +543 -0
- bx2trace-1.0.0/bx2trace/core/memory_scanner.py +173 -0
- bx2trace-1.0.0/bx2trace/core/models.py +183 -0
- bx2trace-1.0.0/bx2trace/core/process_launcher.py +135 -0
- bx2trace-1.0.0/bx2trace/core/win_structs.py +250 -0
- bx2trace-1.0.0/bx2trace/extractors/__init__.py +0 -0
- bx2trace-1.0.0/bx2trace/extractors/entropy.py +51 -0
- bx2trace-1.0.0/bx2trace/extractors/strings.py +59 -0
- bx2trace-1.0.0/bx2trace/memory/__init__.py +0 -0
- bx2trace-1.0.0/bx2trace/memory/reader.py +180 -0
- bx2trace-1.0.0/pyproject.toml +38 -0
- bx2trace-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: BX2trace
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: bx2trace (TraceBox) — High-performance Stealth Behavioral Analysis Framework for Windows
|
|
5
|
+
Author: FBX2
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/fareed1-ataf/Bxtracer
|
|
8
|
+
Project-URL: Repository, https://github.com/fareed1-ataf/Bxtracer.git
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
11
|
+
Classifier: Topic :: Security
|
|
12
|
+
Classifier: Intended Audience :: Information Technology
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: yara-python>=4.5.0
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# bx2trace (TraceBox)
|
|
20
|
+
|
|
21
|
+
**Developed by FBX2**
|
|
22
|
+
|
|
23
|
+
GitHub Repository: [https://github.com/fareed1-ataf/Bxtracer](https://github.com/fareed1-ataf/Bxtracer)
|
|
24
|
+
|
|
25
|
+
`bx2trace` is an advanced, high-performance behavioral analysis framework for Windows, specifically designed for
|
|
26
|
+
cybersecurity analysts and malware researchers. It provides deep visibility into process behavior, live memory changes,
|
|
27
|
+
and stealth debugging capabilities.
|
|
28
|
+
|
|
29
|
+
## Overview
|
|
30
|
+
|
|
31
|
+
Unlike standard debuggers, `bx2trace` is built for **automated analysis** and **stealth**. It monitors process creation,
|
|
32
|
+
DLL loading, and thread activity while simultaneously scanning live memory for indicators of compromise (IoCs),
|
|
33
|
+
self-unpacking behavior, and encrypted payloads using YARA and entropy analysis.
|
|
34
|
+
|
|
35
|
+
## Key Features
|
|
36
|
+
|
|
37
|
+
* **Stealth Engine:** Automatically patches the PEB (Process Environment Block) to clear `BeingDebugged` and
|
|
38
|
+
`NtGlobalFlag`, effectively evading many anti-debugging tricks used by modern malware.
|
|
39
|
+
* **Hardware Breakpoints (DR0-DR3):** Monitor execution without modifying the target's code, making detection much
|
|
40
|
+
harder for packers.
|
|
41
|
+
* **Dynamic Memory Scanner:** Periodically scans committed memory regions to detect newly appeared strings and code
|
|
42
|
+
decryption in real-time.
|
|
43
|
+
* **YARA Integration:** Scan live memory against custom YARA rules to identify specific malware families or behaviors
|
|
44
|
+
instantly.
|
|
45
|
+
* **Entropy Analysis:** Detect packed or encrypted memory regions by calculating Shannon entropy at the page level.
|
|
46
|
+
* **Child Process Tracking:** Automatically follows process trees to catch "Process Hollowing" and multi-stage
|
|
47
|
+
execution.
|
|
48
|
+
* **SQLite Storage:** All events are recorded in a structured database for post-mortem analysis and correlation.
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install bx2trace
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
> **Important:** `bx2trace` requires **Administrator privileges** to function correctly as it needs `SeDebugPrivilege` to
|
|
57
|
+
> monitor other processes.
|
|
58
|
+
|
|
59
|
+
## Requirements
|
|
60
|
+
|
|
61
|
+
* Windows 10/11 (x64)
|
|
62
|
+
* Python 3.11+
|
|
63
|
+
* Administrator rights
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Usage Guide
|
|
68
|
+
|
|
69
|
+
The `bx2trace` package is a library. While it includes internal components to build complex analysis engines, most users
|
|
70
|
+
will interact with the high-level components or build their own tools using the provided modules.
|
|
71
|
+
|
|
72
|
+
### Python API Usage
|
|
73
|
+
|
|
74
|
+
Analysts can build their own custom analysis tools by leveraging the core components of `bx2trace`.
|
|
75
|
+
|
|
76
|
+
#### 1. Basic Process Monitoring
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from queue import Queue
|
|
80
|
+
from bx2trace.core.debug_thread import DebugThread
|
|
81
|
+
from bx2trace.core.models import TraceMode
|
|
82
|
+
|
|
83
|
+
# Event queue for collecting data
|
|
84
|
+
event_queue = Queue()
|
|
85
|
+
|
|
86
|
+
# Initialize and start the debugger thread
|
|
87
|
+
debug_thread = DebugThread(
|
|
88
|
+
exe_path="malware.exe",
|
|
89
|
+
mode=TraceMode.FULL_TRACE,
|
|
90
|
+
raw_event_queue=event_queue
|
|
91
|
+
)
|
|
92
|
+
debug_thread.start()
|
|
93
|
+
|
|
94
|
+
try:
|
|
95
|
+
while debug_thread.is_alive():
|
|
96
|
+
event = event_queue.get()
|
|
97
|
+
print(f"[{event.severity.value}] {event.category}/{event.action}: {event.payload}")
|
|
98
|
+
except KeyboardInterrupt:
|
|
99
|
+
debug_thread.request_stop()
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### 2. Advanced Memory Scanning with YARA
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from queue import Queue
|
|
106
|
+
from bx2trace.core.debug_thread import DebugThread
|
|
107
|
+
from bx2trace.core.memory_scanner import MemoryScannerThread
|
|
108
|
+
from bx2trace.core.models import TraceMode
|
|
109
|
+
|
|
110
|
+
event_queue = Queue()
|
|
111
|
+
|
|
112
|
+
debug_thread = DebugThread("malware.exe", TraceMode.FULL_TRACE, event_queue)
|
|
113
|
+
debug_thread.start()
|
|
114
|
+
debug_thread.started_ok.wait() # Wait for the process to launch
|
|
115
|
+
|
|
116
|
+
# Setup scanner to read tracked handles from DebugThread
|
|
117
|
+
scanner = MemoryScannerThread(
|
|
118
|
+
get_tracked_handles=lambda: {p.pid: p.handle for p in debug_thread.tracked.values()},
|
|
119
|
+
event_queue=event_queue,
|
|
120
|
+
interval=2.0,
|
|
121
|
+
yara_rules_path="rules.yar"
|
|
122
|
+
)
|
|
123
|
+
scanner.start()
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Building Custom Detectors
|
|
127
|
+
|
|
128
|
+
You can extend the framework by creating custom detection logic that consumes events from the `event_queue`. This allows
|
|
129
|
+
you to implement specialized behavioral rules (e.g., detecting specific API call sequences or network patterns).
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Technical Assessment
|
|
134
|
+
|
|
135
|
+
### Strengths
|
|
136
|
+
|
|
137
|
+
1. **Architecture:** Decoupled design using a thread-safe event queue allows adding new detection modules (Detectors)
|
|
138
|
+
without touching the core engine.
|
|
139
|
+
2. **Performance:** Memory scanning is optimized with shared buffers and batch SQLite writes to ensure minimal impact on
|
|
140
|
+
the host system.
|
|
141
|
+
3. **Accuracy:** Correlating high-entropy memory regions with the appearance of new strings provides a high-confidence
|
|
142
|
+
signal for self-unpacking.
|
|
143
|
+
|
|
144
|
+
### Potential Weaknesses
|
|
145
|
+
|
|
146
|
+
1. **Polling Latency:** Very fast fileless malware might execute between scan intervals. (Planned: Event-driven scanning
|
|
147
|
+
via API hooks).
|
|
148
|
+
2. **Architecture Mismatch:** Currently focused on x64 targets; 32-bit (WOW64) support is limited.
|
|
149
|
+
|
|
150
|
+
## Disclaimer
|
|
151
|
+
|
|
152
|
+
This tool is intended for educational and research purposes only. The authors are not responsible for any misuse or
|
|
153
|
+
damage caused by this software. Use it only on systems you own or have explicit permission to analyze.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
**Developed for Security Engineers who need precision and stealth.**
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
./bx2trace/__init__.py
|
|
5
|
+
./bx2trace/core/__init__.py
|
|
6
|
+
./bx2trace/core/api_hooker.py
|
|
7
|
+
./bx2trace/core/constants.py
|
|
8
|
+
./bx2trace/core/debug_thread.py
|
|
9
|
+
./bx2trace/core/memory_scanner.py
|
|
10
|
+
./bx2trace/core/models.py
|
|
11
|
+
./bx2trace/core/process_launcher.py
|
|
12
|
+
./bx2trace/core/win_structs.py
|
|
13
|
+
./bx2trace/extractors/__init__.py
|
|
14
|
+
./bx2trace/extractors/entropy.py
|
|
15
|
+
./bx2trace/extractors/strings.py
|
|
16
|
+
./bx2trace/memory/__init__.py
|
|
17
|
+
./bx2trace/memory/reader.py
|
|
18
|
+
BX2trace.egg-info/PKG-INFO
|
|
19
|
+
BX2trace.egg-info/SOURCES.txt
|
|
20
|
+
BX2trace.egg-info/dependency_links.txt
|
|
21
|
+
BX2trace.egg-info/requires.txt
|
|
22
|
+
BX2trace.egg-info/top_level.txt
|
|
23
|
+
bx2trace/__init__.py
|
|
24
|
+
bx2trace.egg-info/PKG-INFO
|
|
25
|
+
bx2trace.egg-info/SOURCES.txt
|
|
26
|
+
bx2trace.egg-info/dependency_links.txt
|
|
27
|
+
bx2trace.egg-info/requires.txt
|
|
28
|
+
bx2trace.egg-info/top_level.txt
|
|
29
|
+
bx2trace/core/__init__.py
|
|
30
|
+
bx2trace/core/api_hooker.py
|
|
31
|
+
bx2trace/core/constants.py
|
|
32
|
+
bx2trace/core/debug_thread.py
|
|
33
|
+
bx2trace/core/memory_scanner.py
|
|
34
|
+
bx2trace/core/models.py
|
|
35
|
+
bx2trace/core/process_launcher.py
|
|
36
|
+
bx2trace/core/win_structs.py
|
|
37
|
+
bx2trace/extractors/__init__.py
|
|
38
|
+
bx2trace/extractors/entropy.py
|
|
39
|
+
bx2trace/extractors/strings.py
|
|
40
|
+
bx2trace/memory/__init__.py
|
|
41
|
+
bx2trace/memory/reader.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
yara-python>=4.5.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bx2trace
|
bx2trace-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FBX2
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
bx2trace-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: BX2trace
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: bx2trace (TraceBox) — High-performance Stealth Behavioral Analysis Framework for Windows
|
|
5
|
+
Author: FBX2
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/fareed1-ataf/Bxtracer
|
|
8
|
+
Project-URL: Repository, https://github.com/fareed1-ataf/Bxtracer.git
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
11
|
+
Classifier: Topic :: Security
|
|
12
|
+
Classifier: Intended Audience :: Information Technology
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: yara-python>=4.5.0
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# bx2trace (TraceBox)
|
|
20
|
+
|
|
21
|
+
**Developed by FBX2**
|
|
22
|
+
|
|
23
|
+
GitHub Repository: [https://github.com/fareed1-ataf/Bxtracer](https://github.com/fareed1-ataf/Bxtracer)
|
|
24
|
+
|
|
25
|
+
`bx2trace` is an advanced, high-performance behavioral analysis framework for Windows, specifically designed for
|
|
26
|
+
cybersecurity analysts and malware researchers. It provides deep visibility into process behavior, live memory changes,
|
|
27
|
+
and stealth debugging capabilities.
|
|
28
|
+
|
|
29
|
+
## Overview
|
|
30
|
+
|
|
31
|
+
Unlike standard debuggers, `bx2trace` is built for **automated analysis** and **stealth**. It monitors process creation,
|
|
32
|
+
DLL loading, and thread activity while simultaneously scanning live memory for indicators of compromise (IoCs),
|
|
33
|
+
self-unpacking behavior, and encrypted payloads using YARA and entropy analysis.
|
|
34
|
+
|
|
35
|
+
## Key Features
|
|
36
|
+
|
|
37
|
+
* **Stealth Engine:** Automatically patches the PEB (Process Environment Block) to clear `BeingDebugged` and
|
|
38
|
+
`NtGlobalFlag`, effectively evading many anti-debugging tricks used by modern malware.
|
|
39
|
+
* **Hardware Breakpoints (DR0-DR3):** Monitor execution without modifying the target's code, making detection much
|
|
40
|
+
harder for packers.
|
|
41
|
+
* **Dynamic Memory Scanner:** Periodically scans committed memory regions to detect newly appeared strings and code
|
|
42
|
+
decryption in real-time.
|
|
43
|
+
* **YARA Integration:** Scan live memory against custom YARA rules to identify specific malware families or behaviors
|
|
44
|
+
instantly.
|
|
45
|
+
* **Entropy Analysis:** Detect packed or encrypted memory regions by calculating Shannon entropy at the page level.
|
|
46
|
+
* **Child Process Tracking:** Automatically follows process trees to catch "Process Hollowing" and multi-stage
|
|
47
|
+
execution.
|
|
48
|
+
* **SQLite Storage:** All events are recorded in a structured database for post-mortem analysis and correlation.
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install bx2trace
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
> **Important:** `bx2trace` requires **Administrator privileges** to function correctly as it needs `SeDebugPrivilege` to
|
|
57
|
+
> monitor other processes.
|
|
58
|
+
|
|
59
|
+
## Requirements
|
|
60
|
+
|
|
61
|
+
* Windows 10/11 (x64)
|
|
62
|
+
* Python 3.11+
|
|
63
|
+
* Administrator rights
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Usage Guide
|
|
68
|
+
|
|
69
|
+
The `bx2trace` package is a library. While it includes internal components to build complex analysis engines, most users
|
|
70
|
+
will interact with the high-level components or build their own tools using the provided modules.
|
|
71
|
+
|
|
72
|
+
### Python API Usage
|
|
73
|
+
|
|
74
|
+
Analysts can build their own custom analysis tools by leveraging the core components of `bx2trace`.
|
|
75
|
+
|
|
76
|
+
#### 1. Basic Process Monitoring
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from queue import Queue
|
|
80
|
+
from bx2trace.core.debug_thread import DebugThread
|
|
81
|
+
from bx2trace.core.models import TraceMode
|
|
82
|
+
|
|
83
|
+
# Event queue for collecting data
|
|
84
|
+
event_queue = Queue()
|
|
85
|
+
|
|
86
|
+
# Initialize and start the debugger thread
|
|
87
|
+
debug_thread = DebugThread(
|
|
88
|
+
exe_path="malware.exe",
|
|
89
|
+
mode=TraceMode.FULL_TRACE,
|
|
90
|
+
raw_event_queue=event_queue
|
|
91
|
+
)
|
|
92
|
+
debug_thread.start()
|
|
93
|
+
|
|
94
|
+
try:
|
|
95
|
+
while debug_thread.is_alive():
|
|
96
|
+
event = event_queue.get()
|
|
97
|
+
print(f"[{event.severity.value}] {event.category}/{event.action}: {event.payload}")
|
|
98
|
+
except KeyboardInterrupt:
|
|
99
|
+
debug_thread.request_stop()
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### 2. Advanced Memory Scanning with YARA
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from queue import Queue
|
|
106
|
+
from bx2trace.core.debug_thread import DebugThread
|
|
107
|
+
from bx2trace.core.memory_scanner import MemoryScannerThread
|
|
108
|
+
from bx2trace.core.models import TraceMode
|
|
109
|
+
|
|
110
|
+
event_queue = Queue()
|
|
111
|
+
|
|
112
|
+
debug_thread = DebugThread("malware.exe", TraceMode.FULL_TRACE, event_queue)
|
|
113
|
+
debug_thread.start()
|
|
114
|
+
debug_thread.started_ok.wait() # Wait for the process to launch
|
|
115
|
+
|
|
116
|
+
# Setup scanner to read tracked handles from DebugThread
|
|
117
|
+
scanner = MemoryScannerThread(
|
|
118
|
+
get_tracked_handles=lambda: {p.pid: p.handle for p in debug_thread.tracked.values()},
|
|
119
|
+
event_queue=event_queue,
|
|
120
|
+
interval=2.0,
|
|
121
|
+
yara_rules_path="rules.yar"
|
|
122
|
+
)
|
|
123
|
+
scanner.start()
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Building Custom Detectors
|
|
127
|
+
|
|
128
|
+
You can extend the framework by creating custom detection logic that consumes events from the `event_queue`. This allows
|
|
129
|
+
you to implement specialized behavioral rules (e.g., detecting specific API call sequences or network patterns).
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Technical Assessment
|
|
134
|
+
|
|
135
|
+
### Strengths
|
|
136
|
+
|
|
137
|
+
1. **Architecture:** Decoupled design using a thread-safe event queue allows adding new detection modules (Detectors)
|
|
138
|
+
without touching the core engine.
|
|
139
|
+
2. **Performance:** Memory scanning is optimized with shared buffers and batch SQLite writes to ensure minimal impact on
|
|
140
|
+
the host system.
|
|
141
|
+
3. **Accuracy:** Correlating high-entropy memory regions with the appearance of new strings provides a high-confidence
|
|
142
|
+
signal for self-unpacking.
|
|
143
|
+
|
|
144
|
+
### Potential Weaknesses
|
|
145
|
+
|
|
146
|
+
1. **Polling Latency:** Very fast fileless malware might execute between scan intervals. (Planned: Event-driven scanning
|
|
147
|
+
via API hooks).
|
|
148
|
+
2. **Architecture Mismatch:** Currently focused on x64 targets; 32-bit (WOW64) support is limited.
|
|
149
|
+
|
|
150
|
+
## Disclaimer
|
|
151
|
+
|
|
152
|
+
This tool is intended for educational and research purposes only. The authors are not responsible for any misuse or
|
|
153
|
+
damage caused by this software. Use it only on systems you own or have explicit permission to analyze.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
**Developed for Security Engineers who need precision and stealth.**
|
bx2trace-1.0.0/README.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# bx2trace (TraceBox)
|
|
2
|
+
|
|
3
|
+
**Developed by FBX2**
|
|
4
|
+
|
|
5
|
+
GitHub Repository: [https://github.com/fareed1-ataf/Bxtracer](https://github.com/fareed1-ataf/Bxtracer)
|
|
6
|
+
|
|
7
|
+
`bx2trace` is an advanced, high-performance behavioral analysis framework for Windows, specifically designed for
|
|
8
|
+
cybersecurity analysts and malware researchers. It provides deep visibility into process behavior, live memory changes,
|
|
9
|
+
and stealth debugging capabilities.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
Unlike standard debuggers, `bx2trace` is built for **automated analysis** and **stealth**. It monitors process creation,
|
|
14
|
+
DLL loading, and thread activity while simultaneously scanning live memory for indicators of compromise (IoCs),
|
|
15
|
+
self-unpacking behavior, and encrypted payloads using YARA and entropy analysis.
|
|
16
|
+
|
|
17
|
+
## Key Features
|
|
18
|
+
|
|
19
|
+
* **Stealth Engine:** Automatically patches the PEB (Process Environment Block) to clear `BeingDebugged` and
|
|
20
|
+
`NtGlobalFlag`, effectively evading many anti-debugging tricks used by modern malware.
|
|
21
|
+
* **Hardware Breakpoints (DR0-DR3):** Monitor execution without modifying the target's code, making detection much
|
|
22
|
+
harder for packers.
|
|
23
|
+
* **Dynamic Memory Scanner:** Periodically scans committed memory regions to detect newly appeared strings and code
|
|
24
|
+
decryption in real-time.
|
|
25
|
+
* **YARA Integration:** Scan live memory against custom YARA rules to identify specific malware families or behaviors
|
|
26
|
+
instantly.
|
|
27
|
+
* **Entropy Analysis:** Detect packed or encrypted memory regions by calculating Shannon entropy at the page level.
|
|
28
|
+
* **Child Process Tracking:** Automatically follows process trees to catch "Process Hollowing" and multi-stage
|
|
29
|
+
execution.
|
|
30
|
+
* **SQLite Storage:** All events are recorded in a structured database for post-mortem analysis and correlation.
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install bx2trace
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
> **Important:** `bx2trace` requires **Administrator privileges** to function correctly as it needs `SeDebugPrivilege` to
|
|
39
|
+
> monitor other processes.
|
|
40
|
+
|
|
41
|
+
## Requirements
|
|
42
|
+
|
|
43
|
+
* Windows 10/11 (x64)
|
|
44
|
+
* Python 3.11+
|
|
45
|
+
* Administrator rights
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Usage Guide
|
|
50
|
+
|
|
51
|
+
The `bx2trace` package is a library. While it includes internal components to build complex analysis engines, most users
|
|
52
|
+
will interact with the high-level components or build their own tools using the provided modules.
|
|
53
|
+
|
|
54
|
+
### Python API Usage
|
|
55
|
+
|
|
56
|
+
Analysts can build their own custom analysis tools by leveraging the core components of `bx2trace`.
|
|
57
|
+
|
|
58
|
+
#### 1. Basic Process Monitoring
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from queue import Queue
|
|
62
|
+
from bx2trace.core.debug_thread import DebugThread
|
|
63
|
+
from bx2trace.core.models import TraceMode
|
|
64
|
+
|
|
65
|
+
# Event queue for collecting data
|
|
66
|
+
event_queue = Queue()
|
|
67
|
+
|
|
68
|
+
# Initialize and start the debugger thread
|
|
69
|
+
debug_thread = DebugThread(
|
|
70
|
+
exe_path="malware.exe",
|
|
71
|
+
mode=TraceMode.FULL_TRACE,
|
|
72
|
+
raw_event_queue=event_queue
|
|
73
|
+
)
|
|
74
|
+
debug_thread.start()
|
|
75
|
+
|
|
76
|
+
try:
|
|
77
|
+
while debug_thread.is_alive():
|
|
78
|
+
event = event_queue.get()
|
|
79
|
+
print(f"[{event.severity.value}] {event.category}/{event.action}: {event.payload}")
|
|
80
|
+
except KeyboardInterrupt:
|
|
81
|
+
debug_thread.request_stop()
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### 2. Advanced Memory Scanning with YARA
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from queue import Queue
|
|
88
|
+
from bx2trace.core.debug_thread import DebugThread
|
|
89
|
+
from bx2trace.core.memory_scanner import MemoryScannerThread
|
|
90
|
+
from bx2trace.core.models import TraceMode
|
|
91
|
+
|
|
92
|
+
event_queue = Queue()
|
|
93
|
+
|
|
94
|
+
debug_thread = DebugThread("malware.exe", TraceMode.FULL_TRACE, event_queue)
|
|
95
|
+
debug_thread.start()
|
|
96
|
+
debug_thread.started_ok.wait() # Wait for the process to launch
|
|
97
|
+
|
|
98
|
+
# Setup scanner to read tracked handles from DebugThread
|
|
99
|
+
scanner = MemoryScannerThread(
|
|
100
|
+
get_tracked_handles=lambda: {p.pid: p.handle for p in debug_thread.tracked.values()},
|
|
101
|
+
event_queue=event_queue,
|
|
102
|
+
interval=2.0,
|
|
103
|
+
yara_rules_path="rules.yar"
|
|
104
|
+
)
|
|
105
|
+
scanner.start()
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Building Custom Detectors
|
|
109
|
+
|
|
110
|
+
You can extend the framework by creating custom detection logic that consumes events from the `event_queue`. This allows
|
|
111
|
+
you to implement specialized behavioral rules (e.g., detecting specific API call sequences or network patterns).
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Technical Assessment
|
|
116
|
+
|
|
117
|
+
### Strengths
|
|
118
|
+
|
|
119
|
+
1. **Architecture:** Decoupled design using a thread-safe event queue allows adding new detection modules (Detectors)
|
|
120
|
+
without touching the core engine.
|
|
121
|
+
2. **Performance:** Memory scanning is optimized with shared buffers and batch SQLite writes to ensure minimal impact on
|
|
122
|
+
the host system.
|
|
123
|
+
3. **Accuracy:** Correlating high-entropy memory regions with the appearance of new strings provides a high-confidence
|
|
124
|
+
signal for self-unpacking.
|
|
125
|
+
|
|
126
|
+
### Potential Weaknesses
|
|
127
|
+
|
|
128
|
+
1. **Polling Latency:** Very fast fileless malware might execute between scan intervals. (Planned: Event-driven scanning
|
|
129
|
+
via API hooks).
|
|
130
|
+
2. **Architecture Mismatch:** Currently focused on x64 targets; 32-bit (WOW64) support is limited.
|
|
131
|
+
|
|
132
|
+
## Disclaimer
|
|
133
|
+
|
|
134
|
+
This tool is intended for educational and research purposes only. The authors are not responsible for any misuse or
|
|
135
|
+
damage caused by this software. Use it only on systems you own or have explicit permission to analyze.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
**Developed for Security Engineers who need precision and stealth.**
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# bx2trace - Windows Process Tracer & Live Memory Extractor
|
|
2
|
+
# =========================================================
|
|
3
|
+
|
|
4
|
+
# Core contracts & data types
|
|
5
|
+
from bx2trace.core.models import (
|
|
6
|
+
TraceEvent,
|
|
7
|
+
TraceMode,
|
|
8
|
+
Severity,
|
|
9
|
+
EngineConfig,
|
|
10
|
+
BaseDetector,
|
|
11
|
+
CURRENT_SCHEMA_VERSION,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
# Execution engines
|
|
15
|
+
from bx2trace.core.debug_thread import DebugThread, TrackedProcess
|
|
16
|
+
from bx2trace.core.memory_scanner import MemoryScannerThread
|
|
17
|
+
from bx2trace.core.process_launcher import (
|
|
18
|
+
create_process_debug,
|
|
19
|
+
ArchitectureMismatchError,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
# Raw memory access
|
|
23
|
+
from bx2trace.memory.reader import (
|
|
24
|
+
open_process_for_dump,
|
|
25
|
+
enumerate_regions,
|
|
26
|
+
read_region,
|
|
27
|
+
read_committed_regions,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Extractors (platform-agnostic)
|
|
31
|
+
from bx2trace.extractors.strings import (
|
|
32
|
+
extract_strings,
|
|
33
|
+
extract_ascii_strings,
|
|
34
|
+
extract_utf16le_strings,
|
|
35
|
+
diff_new_strings,
|
|
36
|
+
URL_PATTERN,
|
|
37
|
+
IPV4_PATTERN,
|
|
38
|
+
)
|
|
39
|
+
from bx2trace.extractors.entropy import (
|
|
40
|
+
shannon_entropy,
|
|
41
|
+
entropy_by_page,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
# Useful constants
|
|
45
|
+
from bx2trace.core.constants import (
|
|
46
|
+
PAGE_EXECUTE_READWRITE,
|
|
47
|
+
PAGE_EXECUTE_READ,
|
|
48
|
+
PAGE_READWRITE,
|
|
49
|
+
PAGE_READONLY,
|
|
50
|
+
MEM_COMMIT,
|
|
51
|
+
PROTECTIONS_OF_INTEREST,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
__version__ = "0.1.0"
|
|
55
|
+
__author__ = "bx2trace contributors"
|
|
56
|
+
|
|
57
|
+
__all__ = [
|
|
58
|
+
"TraceEvent", "TraceMode", "Severity", "EngineConfig", "BaseDetector",
|
|
59
|
+
"CURRENT_SCHEMA_VERSION",
|
|
60
|
+
"DebugThread", "TrackedProcess", "MemoryScannerThread",
|
|
61
|
+
"create_process_debug", "ArchitectureMismatchError",
|
|
62
|
+
"open_process_for_dump", "enumerate_regions",
|
|
63
|
+
"read_region", "read_committed_regions",
|
|
64
|
+
"extract_strings", "extract_ascii_strings", "extract_utf16le_strings",
|
|
65
|
+
"diff_new_strings", "URL_PATTERN", "IPV4_PATTERN",
|
|
66
|
+
"shannon_entropy", "entropy_by_page",
|
|
67
|
+
"PAGE_EXECUTE_READWRITE", "PAGE_EXECUTE_READ",
|
|
68
|
+
"PAGE_READWRITE", "PAGE_READONLY",
|
|
69
|
+
"MEM_COMMIT", "PROTECTIONS_OF_INTEREST",
|
|
70
|
+
]
|
|
File without changes
|