@sylix/coworker 2.0.10 → 2.0.12

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.
Files changed (178) hide show
  1. package/dist/commands/slash/config.d.ts.map +1 -1
  2. package/dist/commands/slash/config.js +23 -5
  3. package/dist/commands/slash/config.js.map +1 -1
  4. package/dist/commands/slash/todo.js +1 -1
  5. package/dist/commands/slash/todo.js.map +1 -1
  6. package/dist/core/CoWorkerAgent.d.ts.map +1 -1
  7. package/dist/core/CoWorkerAgent.js +6 -3
  8. package/dist/core/CoWorkerAgent.js.map +1 -1
  9. package/dist/permissions/PermissionInterceptor.js +1 -1
  10. package/dist/permissions/PermissionInterceptor.js.map +1 -1
  11. package/dist/skills/defaults/accessibility/screen-reader-testing.md +545 -0
  12. package/dist/skills/defaults/accessibility/wcag-audit-patterns.md +555 -0
  13. package/dist/skills/defaults/ai-ml/rag.md +276 -0
  14. package/dist/skills/defaults/backend-development/api-design-principles.md +528 -0
  15. package/dist/skills/defaults/backend-development/api-design.md +285 -0
  16. package/dist/skills/defaults/backend-development/architecture-patterns.md +494 -0
  17. package/dist/skills/defaults/backend-development/async-python.md +237 -0
  18. package/dist/skills/defaults/backend-development/auth-implementation-patterns.md +638 -0
  19. package/dist/skills/defaults/backend-development/bazel-build-optimization.md +387 -0
  20. package/dist/skills/defaults/backend-development/billing-automation/SKILL.md +566 -0
  21. package/dist/skills/defaults/backend-development/code-review-excellence.md +538 -0
  22. package/dist/skills/defaults/backend-development/cqrs-implementation.md +554 -0
  23. package/dist/skills/defaults/backend-development/database-design.md +305 -0
  24. package/dist/skills/defaults/backend-development/debugging-strategies.md +536 -0
  25. package/dist/skills/defaults/backend-development/e2e-testing-patterns.md +544 -0
  26. package/dist/skills/defaults/backend-development/error-handling-patterns.md +641 -0
  27. package/dist/skills/defaults/backend-development/fastapi-templates.md +559 -0
  28. package/dist/skills/defaults/backend-development/fastapi.md +309 -0
  29. package/dist/skills/defaults/backend-development/git-advanced-workflows.md +405 -0
  30. package/dist/skills/defaults/backend-development/microservices-patterns.md +595 -0
  31. package/dist/skills/defaults/backend-development/microservices.md +284 -0
  32. package/dist/skills/defaults/backend-development/monorepo-management.md +623 -0
  33. package/dist/skills/defaults/backend-development/nodejs-backend-patterns.md +1048 -0
  34. package/dist/skills/defaults/backend-development/nx-workspace-patterns.md +457 -0
  35. package/dist/skills/defaults/backend-development/paypal-integration/SKILL.md +478 -0
  36. package/dist/skills/defaults/backend-development/pci-compliance/SKILL.md +480 -0
  37. package/dist/skills/defaults/backend-development/python-anti-patterns.md +349 -0
  38. package/dist/skills/defaults/backend-development/python-background-jobs.md +364 -0
  39. package/dist/skills/defaults/backend-development/python-code-style.md +360 -0
  40. package/dist/skills/defaults/backend-development/python-configuration.md +368 -0
  41. package/dist/skills/defaults/backend-development/python-design-patterns.md +296 -0
  42. package/dist/skills/defaults/backend-development/python-error-handling.md +323 -0
  43. package/dist/skills/defaults/backend-development/python-packaging.md +887 -0
  44. package/dist/skills/defaults/backend-development/python-performance-optimization.md +874 -0
  45. package/dist/skills/defaults/backend-development/python-project-structure.md +252 -0
  46. package/dist/skills/defaults/backend-development/python-resilience.md +376 -0
  47. package/dist/skills/defaults/backend-development/python-resource-management.md +421 -0
  48. package/dist/skills/defaults/backend-development/python-type-safety.md +428 -0
  49. package/dist/skills/defaults/backend-development/sql-optimization-patterns.md +509 -0
  50. package/dist/skills/defaults/backend-development/stripe-integration/SKILL.md +522 -0
  51. package/dist/skills/defaults/backend-development/turborepo-caching.md +376 -0
  52. package/dist/skills/defaults/blockchain/defi-protocol-templates.md +430 -0
  53. package/dist/skills/defaults/blockchain/nft-standards.md +364 -0
  54. package/dist/skills/defaults/blockchain/solidity-security.md +514 -0
  55. package/dist/skills/defaults/blockchain/web3-testing.md +360 -0
  56. package/dist/skills/defaults/business/competitive-landscape/SKILL.md +527 -0
  57. package/dist/skills/defaults/business/market-sizing-analysis/SKILL.md +451 -0
  58. package/dist/skills/defaults/business/startup-financial-modeling/SKILL.md +494 -0
  59. package/dist/skills/defaults/business/startup-metrics-framework/SKILL.md +564 -0
  60. package/dist/skills/defaults/business/team-composition-analysis.md +437 -0
  61. package/dist/skills/defaults/compliance/employment-contract-templates/SKILL.md +527 -0
  62. package/dist/skills/defaults/compliance/gdpr-data-handling/SKILL.md +630 -0
  63. package/dist/skills/defaults/data-engineering/airflow-dag-patterns.md +436 -0
  64. package/dist/skills/defaults/data-engineering/airflow.md +519 -0
  65. package/dist/skills/defaults/data-engineering/data-quality.md +583 -0
  66. package/dist/skills/defaults/data-engineering/dbt-transformation-patterns.md +482 -0
  67. package/dist/skills/defaults/data-engineering/dbt.md +556 -0
  68. package/dist/skills/defaults/data-engineering/ml-pipeline-workflow/SKILL.md +247 -0
  69. package/dist/skills/defaults/data-engineering/spark-optimization.md +348 -0
  70. package/dist/skills/defaults/data-engineering/spark.md +411 -0
  71. package/dist/skills/defaults/database/postgresql.md +202 -0
  72. package/dist/skills/defaults/debugging/systematic-debugging.md +249 -0
  73. package/dist/skills/defaults/devops/architecture-decision-records.md +448 -0
  74. package/dist/skills/defaults/devops/changelog-automation.md +580 -0
  75. package/dist/skills/defaults/devops/cicd.md +314 -0
  76. package/dist/skills/defaults/devops/cloud.md +263 -0
  77. package/dist/skills/defaults/devops/code-review-excellence.md +299 -0
  78. package/dist/skills/defaults/devops/cost-optimization.md +295 -0
  79. package/dist/skills/defaults/devops/deployment-pipeline-design.md +356 -0
  80. package/dist/skills/defaults/devops/docker.md +281 -0
  81. package/dist/skills/defaults/devops/git-workflows.md +205 -0
  82. package/dist/skills/defaults/devops/github-actions.md +311 -0
  83. package/dist/skills/defaults/devops/gitlab-ci-patterns.md +266 -0
  84. package/dist/skills/defaults/devops/hybrid-cloud-networking.md +241 -0
  85. package/dist/skills/defaults/devops/istio-traffic-management.md +327 -0
  86. package/dist/skills/defaults/devops/kubernetes.md +339 -0
  87. package/dist/skills/defaults/devops/linkerd-patterns.md +311 -0
  88. package/dist/skills/defaults/devops/multi-cloud-architecture.md +181 -0
  89. package/dist/skills/defaults/devops/observability.md +243 -0
  90. package/dist/skills/defaults/devops/openapi-spec-generation.md +1024 -0
  91. package/dist/skills/defaults/devops/postmortem-writing.md +396 -0
  92. package/dist/skills/defaults/devops/prometheus-configuration.md +265 -0
  93. package/dist/skills/defaults/devops/secrets-management.md +341 -0
  94. package/dist/skills/defaults/devops/service-mesh-observability.md +385 -0
  95. package/dist/skills/defaults/devops/terraform-module-library.md +244 -0
  96. package/dist/skills/defaults/finance/backtesting-frameworks/SKILL.md +663 -0
  97. package/dist/skills/defaults/finance/risk-metrics-calculation/SKILL.md +557 -0
  98. package/dist/skills/defaults/frontend/accessibility-compliance.md +420 -0
  99. package/dist/skills/defaults/frontend/design-system-patterns.md +337 -0
  100. package/dist/skills/defaults/frontend/interaction-design.md +327 -0
  101. package/dist/skills/defaults/frontend/javascript.md +311 -0
  102. package/dist/skills/defaults/frontend/modern-javascript-patterns.md +927 -0
  103. package/dist/skills/defaults/frontend/react-native-design.md +440 -0
  104. package/dist/skills/defaults/frontend/react.md +345 -0
  105. package/dist/skills/defaults/frontend/responsive-design.md +472 -0
  106. package/dist/skills/defaults/frontend/tailwind-design-system.md +337 -0
  107. package/dist/skills/defaults/frontend/typescript-advanced-types.md +724 -0
  108. package/dist/skills/defaults/frontend/typescript.md +334 -0
  109. package/dist/skills/defaults/frontend/visual-design-foundations.md +326 -0
  110. package/dist/skills/defaults/frontend/web-component-design.md +279 -0
  111. package/dist/skills/defaults/game-development/godot-gdscript-patterns.md +188 -0
  112. package/dist/skills/defaults/game-development/unity-ecs-patterns.md +594 -0
  113. package/dist/skills/defaults/kubernetes/gitops-workflow.md +285 -0
  114. package/dist/skills/defaults/kubernetes/gitops.md +280 -0
  115. package/dist/skills/defaults/kubernetes/helm-chart-scaffolding.md +553 -0
  116. package/dist/skills/defaults/kubernetes/helm.md +343 -0
  117. package/dist/skills/defaults/kubernetes/k8s-manifest-generator.md +501 -0
  118. package/dist/skills/defaults/kubernetes/k8s-security-policies.md +342 -0
  119. package/dist/skills/defaults/kubernetes/manifests.md +330 -0
  120. package/dist/skills/defaults/kubernetes/security.md +337 -0
  121. package/dist/skills/defaults/llm-application/embedding-strategies.md +608 -0
  122. package/dist/skills/defaults/llm-application/hybrid-search-implementation.md +570 -0
  123. package/dist/skills/defaults/llm-application/hybrid-search.md +570 -0
  124. package/dist/skills/defaults/llm-application/langchain-architecture.md +666 -0
  125. package/dist/skills/defaults/llm-application/langchain.md +259 -0
  126. package/dist/skills/defaults/llm-application/llm-evaluation.md +695 -0
  127. package/dist/skills/defaults/llm-application/prompt-engineering-patterns.md +449 -0
  128. package/dist/skills/defaults/llm-application/prompt-engineering.md +219 -0
  129. package/dist/skills/defaults/llm-application/rag-implementation.md +434 -0
  130. package/dist/skills/defaults/llm-application/similarity-search-patterns.md +560 -0
  131. package/dist/skills/defaults/llm-application/similarity-search.md +560 -0
  132. package/dist/skills/defaults/llm-application/vector-index-tuning.md +523 -0
  133. package/dist/skills/defaults/mobile/mobile-android-design.md +440 -0
  134. package/dist/skills/defaults/mobile/mobile-ios-design.md +266 -0
  135. package/dist/skills/defaults/monitoring/distributed-tracing.md +436 -0
  136. package/dist/skills/defaults/monitoring/grafana-dashboards.md +370 -0
  137. package/dist/skills/defaults/monitoring/prometheus-configuration.md +379 -0
  138. package/dist/skills/defaults/monitoring/slo-implementation.md +323 -0
  139. package/dist/skills/defaults/refactoring/code-refactoring.md +349 -0
  140. package/dist/skills/defaults/security/anti-reversing-techniques/SKILL.md +559 -0
  141. package/dist/skills/defaults/security/auditor.md +168 -0
  142. package/dist/skills/defaults/security/binary-analysis-patterns/SKILL.md +438 -0
  143. package/dist/skills/defaults/security/memory-forensics/SKILL.md +483 -0
  144. package/dist/skills/defaults/security/mtls-configuration.md +349 -0
  145. package/dist/skills/defaults/security/protocol-reverse-engineering/SKILL.md +520 -0
  146. package/dist/skills/defaults/security/sast-configuration.md +182 -0
  147. package/dist/skills/defaults/security/security.md +313 -0
  148. package/dist/skills/defaults/security/stride-analysis.md +273 -0
  149. package/dist/skills/defaults/security/threat-mitigation-mapping.md +290 -0
  150. package/dist/skills/defaults/systems/bash-defensive-patterns/SKILL.md +539 -0
  151. package/dist/skills/defaults/systems/bats-testing-patterns/SKILL.md +631 -0
  152. package/dist/skills/defaults/systems/go-concurrency-patterns.md +657 -0
  153. package/dist/skills/defaults/systems/memory-safety-patterns.md +605 -0
  154. package/dist/skills/defaults/systems/rust-async-patterns.md +519 -0
  155. package/dist/skills/defaults/systems/shellcheck-configuration/SKILL.md +456 -0
  156. package/dist/skills/defaults/team-collaboration/multi-reviewer-patterns.md +126 -0
  157. package/dist/skills/defaults/team-collaboration/parallel-feature-development.md +151 -0
  158. package/dist/skills/defaults/testing/javascript-testing-patterns.md +1021 -0
  159. package/dist/skills/defaults/testing/python-testing-patterns.md +351 -0
  160. package/dist/skills/defaults/testing/testing.md +332 -0
  161. package/dist/skills/defaults/workflows/context-driven-development.md +384 -0
  162. package/dist/skills/defaults/workflows/track-management.md +592 -0
  163. package/dist/skills/defaults/workflows/workflow-patterns.md +622 -0
  164. package/dist/skills/index.d.ts +11 -0
  165. package/dist/skills/index.d.ts.map +1 -0
  166. package/dist/skills/index.js +129 -0
  167. package/dist/skills/index.js.map +1 -0
  168. package/dist/utils/character.js +6 -9
  169. package/dist/utils/character.js.map +1 -1
  170. package/dist/utils/contextManager.js +3 -7
  171. package/dist/utils/contextManager.js.map +1 -1
  172. package/dist/utils/inputbar.d.ts.map +1 -1
  173. package/dist/utils/inputbar.js +8 -1
  174. package/dist/utils/inputbar.js.map +1 -1
  175. package/dist/utils/output.d.ts.map +1 -1
  176. package/dist/utils/output.js +3 -35
  177. package/dist/utils/output.js.map +1 -1
  178. package/package.json +1 -1
@@ -0,0 +1,559 @@
1
+ ---
2
+ name: anti-reversing-techniques
3
+ description: Understand anti-reversing, obfuscation, and protection techniques encountered during software analysis. Use when analyzing protected binaries, bypassing anti-debugging for authorized analysis, or understanding software protection mechanisms.
4
+ ---
5
+
6
+ > **AUTHORIZED USE ONLY**: This skill contains dual-use security techniques. Before proceeding with any bypass or analysis:
7
+ >
8
+ > 1. **Verify authorization**: Confirm you have explicit written permission from the software owner, or are operating within a legitimate security context (CTF, authorized pentest, malware analysis, security research)
9
+ > 2. **Document scope**: Ensure your activities fall within the defined scope of your authorization
10
+ > 3. **Legal compliance**: Understand that unauthorized bypassing of software protection may violate laws (CFAA, DMCA anti-circumvention, etc.)
11
+ >
12
+ > **Legitimate use cases**: Malware analysis, authorized penetration testing, CTF competitions, academic security research, analyzing software you own/have rights to
13
+
14
+ # Anti-Reversing Techniques
15
+
16
+ Understanding protection mechanisms encountered during authorized software analysis, security research, and malware analysis. This knowledge helps analysts bypass protections to complete legitimate analysis tasks.
17
+
18
+ ## Anti-Debugging Techniques
19
+
20
+ ### Windows Anti-Debugging
21
+
22
+ #### API-Based Detection
23
+
24
+ ```c
25
+ // IsDebuggerPresent
26
+ if (IsDebuggerPresent()) {
27
+ exit(1);
28
+ }
29
+
30
+ // CheckRemoteDebuggerPresent
31
+ BOOL debugged = FALSE;
32
+ CheckRemoteDebuggerPresent(GetCurrentProcess(), &debugged);
33
+ if (debugged) exit(1);
34
+
35
+ // NtQueryInformationProcess
36
+ typedef NTSTATUS (NTAPI *pNtQueryInformationProcess)(
37
+ HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);
38
+
39
+ DWORD debugPort = 0;
40
+ NtQueryInformationProcess(
41
+ GetCurrentProcess(),
42
+ ProcessDebugPort, // 7
43
+ &debugPort,
44
+ sizeof(debugPort),
45
+ NULL
46
+ );
47
+ if (debugPort != 0) exit(1);
48
+
49
+ // Debug flags
50
+ DWORD debugFlags = 0;
51
+ NtQueryInformationProcess(
52
+ GetCurrentProcess(),
53
+ ProcessDebugFlags, // 0x1F
54
+ &debugFlags,
55
+ sizeof(debugFlags),
56
+ NULL
57
+ );
58
+ if (debugFlags == 0) exit(1); // 0 means being debugged
59
+ ```
60
+
61
+ **Bypass Approaches:**
62
+
63
+ ```python
64
+ # x64dbg: ScyllaHide plugin
65
+ # Patches common anti-debug checks
66
+
67
+ # Manual patching in debugger:
68
+ # - Set IsDebuggerPresent return to 0
69
+ # - Patch PEB.BeingDebugged to 0
70
+ # - Hook NtQueryInformationProcess
71
+
72
+ # IDAPython: Patch checks
73
+ ida_bytes.patch_byte(check_addr, 0x90) # NOP
74
+ ```
75
+
76
+ #### PEB-Based Detection
77
+
78
+ ```c
79
+ // Direct PEB access
80
+ #ifdef _WIN64
81
+ PPEB peb = (PPEB)__readgsqword(0x60);
82
+ #else
83
+ PPEB peb = (PPEB)__readfsdword(0x30);
84
+ #endif
85
+
86
+ // BeingDebugged flag
87
+ if (peb->BeingDebugged) exit(1);
88
+
89
+ // NtGlobalFlag
90
+ // Debugged: 0x70 (FLG_HEAP_ENABLE_TAIL_CHECK |
91
+ // FLG_HEAP_ENABLE_FREE_CHECK |
92
+ // FLG_HEAP_VALIDATE_PARAMETERS)
93
+ if (peb->NtGlobalFlag & 0x70) exit(1);
94
+
95
+ // Heap flags
96
+ PDWORD heapFlags = (PDWORD)((PBYTE)peb->ProcessHeap + 0x70);
97
+ if (*heapFlags & 0x50000062) exit(1);
98
+ ```
99
+
100
+ **Bypass Approaches:**
101
+
102
+ ```assembly
103
+ ; In debugger, modify PEB directly
104
+ ; x64dbg: dump at gs:[60] (x64) or fs:[30] (x86)
105
+ ; Set BeingDebugged (offset 2) to 0
106
+ ; Clear NtGlobalFlag (offset 0xBC for x64)
107
+ ```
108
+
109
+ #### Timing-Based Detection
110
+
111
+ ```c
112
+ // RDTSC timing
113
+ uint64_t start = __rdtsc();
114
+ // ... some code ...
115
+ uint64_t end = __rdtsc();
116
+ if ((end - start) > THRESHOLD) exit(1);
117
+
118
+ // QueryPerformanceCounter
119
+ LARGE_INTEGER start, end, freq;
120
+ QueryPerformanceFrequency(&freq);
121
+ QueryPerformanceCounter(&start);
122
+ // ... code ...
123
+ QueryPerformanceCounter(&end);
124
+ double elapsed = (double)(end.QuadPart - start.QuadPart) / freq.QuadPart;
125
+ if (elapsed > 0.1) exit(1); // Too slow = debugger
126
+
127
+ // GetTickCount
128
+ DWORD start = GetTickCount();
129
+ // ... code ...
130
+ if (GetTickCount() - start > 1000) exit(1);
131
+ ```
132
+
133
+ **Bypass Approaches:**
134
+
135
+ ```
136
+ - Use hardware breakpoints instead of software
137
+ - Patch timing checks
138
+ - Use VM with controlled time
139
+ - Hook timing APIs to return consistent values
140
+ ```
141
+
142
+ #### Exception-Based Detection
143
+
144
+ ```c
145
+ // SEH-based detection
146
+ __try {
147
+ __asm { int 3 } // Software breakpoint
148
+ }
149
+ __except(EXCEPTION_EXECUTE_HANDLER) {
150
+ // Normal execution: exception caught
151
+ return;
152
+ }
153
+ // Debugger ate the exception
154
+ exit(1);
155
+
156
+ // VEH-based detection
157
+ LONG CALLBACK VectoredHandler(PEXCEPTION_POINTERS ep) {
158
+ if (ep->ExceptionRecord->ExceptionCode == EXCEPTION_BREAKPOINT) {
159
+ ep->ContextRecord->Rip++; // Skip INT3
160
+ return EXCEPTION_CONTINUE_EXECUTION;
161
+ }
162
+ return EXCEPTION_CONTINUE_SEARCH;
163
+ }
164
+ ```
165
+
166
+ ### Linux Anti-Debugging
167
+
168
+ ```c
169
+ // ptrace self-trace
170
+ if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) == -1) {
171
+ // Already being traced
172
+ exit(1);
173
+ }
174
+
175
+ // /proc/self/status
176
+ FILE *f = fopen("/proc/self/status", "r");
177
+ char line[256];
178
+ while (fgets(line, sizeof(line), f)) {
179
+ if (strncmp(line, "TracerPid:", 10) == 0) {
180
+ int tracer_pid = atoi(line + 10);
181
+ if (tracer_pid != 0) exit(1);
182
+ }
183
+ }
184
+
185
+ // Parent process check
186
+ if (getppid() != 1 && strcmp(get_process_name(getppid()), "bash") != 0) {
187
+ // Unusual parent (might be debugger)
188
+ }
189
+ ```
190
+
191
+ **Bypass Approaches:**
192
+
193
+ ```bash
194
+ # LD_PRELOAD to hook ptrace
195
+ # Compile: gcc -shared -fPIC -o hook.so hook.c
196
+ long ptrace(int request, ...) {
197
+ return 0; // Always succeed
198
+ }
199
+
200
+ # Usage
201
+ LD_PRELOAD=./hook.so ./target
202
+ ```
203
+
204
+ ## Anti-VM Detection
205
+
206
+ ### Hardware Fingerprinting
207
+
208
+ ```c
209
+ // CPUID-based detection
210
+ int cpuid_info[4];
211
+ __cpuid(cpuid_info, 1);
212
+ // Check hypervisor bit (bit 31 of ECX)
213
+ if (cpuid_info[2] & (1 << 31)) {
214
+ // Running in hypervisor
215
+ }
216
+
217
+ // CPUID brand string
218
+ __cpuid(cpuid_info, 0x40000000);
219
+ char vendor[13] = {0};
220
+ memcpy(vendor, &cpuid_info[1], 12);
221
+ // "VMwareVMware", "Microsoft Hv", "KVMKVMKVM", "VBoxVBoxVBox"
222
+
223
+ // MAC address prefix
224
+ // VMware: 00:0C:29, 00:50:56
225
+ // VirtualBox: 08:00:27
226
+ // Hyper-V: 00:15:5D
227
+ ```
228
+
229
+ ### Registry/File Detection
230
+
231
+ ```c
232
+ // Windows registry keys
233
+ // HKLM\SOFTWARE\VMware, Inc.\VMware Tools
234
+ // HKLM\SOFTWARE\Oracle\VirtualBox Guest Additions
235
+ // HKLM\HARDWARE\ACPI\DSDT\VBOX__
236
+
237
+ // Files
238
+ // C:\Windows\System32\drivers\vmmouse.sys
239
+ // C:\Windows\System32\drivers\vmhgfs.sys
240
+ // C:\Windows\System32\drivers\VBoxMouse.sys
241
+
242
+ // Processes
243
+ // vmtoolsd.exe, vmwaretray.exe
244
+ // VBoxService.exe, VBoxTray.exe
245
+ ```
246
+
247
+ ### Timing-Based VM Detection
248
+
249
+ ```c
250
+ // VM exits cause timing anomalies
251
+ uint64_t start = __rdtsc();
252
+ __cpuid(cpuid_info, 0); // Causes VM exit
253
+ uint64_t end = __rdtsc();
254
+ if ((end - start) > 500) {
255
+ // Likely in VM (CPUID takes longer)
256
+ }
257
+ ```
258
+
259
+ **Bypass Approaches:**
260
+
261
+ ```
262
+ - Use bare-metal analysis environment
263
+ - Harden VM (remove guest tools, change MAC)
264
+ - Patch detection code
265
+ - Use specialized analysis VMs (FLARE-VM)
266
+ ```
267
+
268
+ ## Code Obfuscation
269
+
270
+ ### Control Flow Obfuscation
271
+
272
+ #### Control Flow Flattening
273
+
274
+ ```c
275
+ // Original
276
+ if (cond) {
277
+ func_a();
278
+ } else {
279
+ func_b();
280
+ }
281
+ func_c();
282
+
283
+ // Flattened
284
+ int state = 0;
285
+ while (1) {
286
+ switch (state) {
287
+ case 0:
288
+ state = cond ? 1 : 2;
289
+ break;
290
+ case 1:
291
+ func_a();
292
+ state = 3;
293
+ break;
294
+ case 2:
295
+ func_b();
296
+ state = 3;
297
+ break;
298
+ case 3:
299
+ func_c();
300
+ return;
301
+ }
302
+ }
303
+ ```
304
+
305
+ **Analysis Approach:**
306
+
307
+ - Identify state variable
308
+ - Map state transitions
309
+ - Reconstruct original flow
310
+ - Tools: D-810 (IDA), SATURN
311
+
312
+ #### Opaque Predicates
313
+
314
+ ```c
315
+ // Always true, but complex to analyze
316
+ int x = rand();
317
+ if ((x * x) >= 0) { // Always true
318
+ real_code();
319
+ } else {
320
+ junk_code(); // Dead code
321
+ }
322
+
323
+ // Always false
324
+ if ((x * (x + 1)) % 2 == 1) { // Product of consecutive = even
325
+ junk_code();
326
+ }
327
+ ```
328
+
329
+ **Analysis Approach:**
330
+
331
+ - Identify constant expressions
332
+ - Symbolic execution to prove predicates
333
+ - Pattern matching for known opaque predicates
334
+
335
+ ### Data Obfuscation
336
+
337
+ #### String Encryption
338
+
339
+ ```c
340
+ // XOR encryption
341
+ char decrypt_string(char *enc, int len, char key) {
342
+ char *dec = malloc(len + 1);
343
+ for (int i = 0; i < len; i++) {
344
+ dec[i] = enc[i] ^ key;
345
+ }
346
+ dec[len] = 0;
347
+ return dec;
348
+ }
349
+
350
+ // Stack strings
351
+ char url[20];
352
+ url[0] = 'h'; url[1] = 't'; url[2] = 't'; url[3] = 'p';
353
+ url[4] = ':'; url[5] = '/'; url[6] = '/';
354
+ // ...
355
+ ```
356
+
357
+ **Analysis Approach:**
358
+
359
+ ```python
360
+ # FLOSS for automatic string deobfuscation
361
+ floss malware.exe
362
+
363
+ # IDAPython string decryption
364
+ def decrypt_xor(ea, length, key):
365
+ result = ""
366
+ for i in range(length):
367
+ byte = ida_bytes.get_byte(ea + i)
368
+ result += chr(byte ^ key)
369
+ return result
370
+ ```
371
+
372
+ #### API Obfuscation
373
+
374
+ ```c
375
+ // Dynamic API resolution
376
+ typedef HANDLE (WINAPI *pCreateFileW)(LPCWSTR, DWORD, DWORD,
377
+ LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
378
+
379
+ HMODULE kernel32 = LoadLibraryA("kernel32.dll");
380
+ pCreateFileW myCreateFile = (pCreateFileW)GetProcAddress(
381
+ kernel32, "CreateFileW");
382
+
383
+ // API hashing
384
+ DWORD hash_api(char *name) {
385
+ DWORD hash = 0;
386
+ while (*name) {
387
+ hash = ((hash >> 13) | (hash << 19)) + *name++;
388
+ }
389
+ return hash;
390
+ }
391
+ // Resolve by hash comparison instead of string
392
+ ```
393
+
394
+ **Analysis Approach:**
395
+
396
+ - Identify hash algorithm
397
+ - Build hash database of known APIs
398
+ - Use HashDB plugin for IDA
399
+ - Dynamic analysis to resolve at runtime
400
+
401
+ ### Instruction-Level Obfuscation
402
+
403
+ #### Dead Code Insertion
404
+
405
+ ```asm
406
+ ; Original
407
+ mov eax, 1
408
+
409
+ ; With dead code
410
+ push ebx ; Dead
411
+ mov eax, 1
412
+ pop ebx ; Dead
413
+ xor ecx, ecx ; Dead
414
+ add ecx, ecx ; Dead
415
+ ```
416
+
417
+ #### Instruction Substitution
418
+
419
+ ```asm
420
+ ; Original: xor eax, eax (set to 0)
421
+ ; Substitutions:
422
+ sub eax, eax
423
+ mov eax, 0
424
+ and eax, 0
425
+ lea eax, [0]
426
+
427
+ ; Original: mov eax, 1
428
+ ; Substitutions:
429
+ xor eax, eax
430
+ inc eax
431
+
432
+ push 1
433
+ pop eax
434
+ ```
435
+
436
+ ## Packing and Encryption
437
+
438
+ ### Common Packers
439
+
440
+ ```
441
+ UPX - Open source, easy to unpack
442
+ Themida - Commercial, VM-based protection
443
+ VMProtect - Commercial, code virtualization
444
+ ASPack - Compression packer
445
+ PECompact - Compression packer
446
+ Enigma - Commercial protector
447
+ ```
448
+
449
+ ### Unpacking Methodology
450
+
451
+ ```
452
+ 1. Identify packer (DIE, Exeinfo PE, PEiD)
453
+
454
+ 2. Static unpacking (if known packer):
455
+ - UPX: upx -d packed.exe
456
+ - Use existing unpackers
457
+
458
+ 3. Dynamic unpacking:
459
+ a. Find Original Entry Point (OEP)
460
+ b. Set breakpoint on OEP
461
+ c. Dump memory when OEP reached
462
+ d. Fix import table (Scylla, ImpREC)
463
+
464
+ 4. OEP finding techniques:
465
+ - Hardware breakpoint on stack (ESP trick)
466
+ - Break on common API calls (GetCommandLineA)
467
+ - Trace and look for typical entry patterns
468
+ ```
469
+
470
+ ### Manual Unpacking Example
471
+
472
+ ```
473
+ 1. Load packed binary in x64dbg
474
+ 2. Note entry point (packer stub)
475
+ 3. Use ESP trick:
476
+ - Run to entry
477
+ - Set hardware breakpoint on [ESP]
478
+ - Run until breakpoint hits (after PUSHAD/POPAD)
479
+ 4. Look for JMP to OEP
480
+ 5. At OEP, use Scylla to:
481
+ - Dump process
482
+ - Find imports (IAT autosearch)
483
+ - Fix dump
484
+ ```
485
+
486
+ ## Virtualization-Based Protection
487
+
488
+ ### Code Virtualization
489
+
490
+ ```
491
+ Original x86 code is converted to custom bytecode
492
+ interpreted by embedded VM at runtime.
493
+
494
+ Original: VM Protected:
495
+ mov eax, 1 push vm_context
496
+ add eax, 2 call vm_entry
497
+ ; VM interprets bytecode
498
+ ; equivalent to original
499
+ ```
500
+
501
+ ### Analysis Approaches
502
+
503
+ ```
504
+ 1. Identify VM components:
505
+ - VM entry (dispatcher)
506
+ - Handler table
507
+ - Bytecode location
508
+ - Virtual registers/stack
509
+
510
+ 2. Trace execution:
511
+ - Log handler calls
512
+ - Map bytecode to operations
513
+ - Understand instruction set
514
+
515
+ 3. Lifting/devirtualization:
516
+ - Map VM instructions back to native
517
+ - Tools: VMAttack, SATURN, NoVmp
518
+
519
+ 4. Symbolic execution:
520
+ - Analyze VM semantically
521
+ - angr, Triton
522
+ ```
523
+
524
+ ## Bypass Strategies Summary
525
+
526
+ ### General Principles
527
+
528
+ 1. **Understand the protection**: Identify what technique is used
529
+ 2. **Find the check**: Locate protection code in binary
530
+ 3. **Patch or hook**: Modify check to always pass
531
+ 4. **Use appropriate tools**: ScyllaHide, x64dbg plugins
532
+ 5. **Document findings**: Keep notes on bypassed protections
533
+
534
+ ### Tool Recommendations
535
+
536
+ ```
537
+ Anti-debug bypass: ScyllaHide, TitanHide
538
+ Unpacking: x64dbg + Scylla, OllyDumpEx
539
+ Deobfuscation: D-810, SATURN, miasm
540
+ VM analysis: VMAttack, NoVmp, manual tracing
541
+ String decryption: FLOSS, custom scripts
542
+ Symbolic execution: angr, Triton
543
+ ```
544
+
545
+ ### Ethical Considerations
546
+
547
+ This knowledge should only be used for:
548
+
549
+ - Authorized security research
550
+ - Malware analysis (defensive)
551
+ - CTF competitions
552
+ - Understanding protections for legitimate purposes
553
+ - Educational purposes
554
+
555
+ Never use to bypass protections for:
556
+
557
+ - Software piracy
558
+ - Unauthorized access
559
+ - Malicious purposes
@@ -0,0 +1,168 @@
1
+ ---
2
+ name: security-auditor
3
+ description: Expert security auditor specializing in DevSecOps, comprehensive cybersecurity, and compliance frameworks. Masters vulnerability assessment, threat modeling, secure authentication (OAuth2/OIDC), OWASP standards, cloud security, and security automation.
4
+ ---
5
+
6
+ # Security Auditor
7
+
8
+ Expert security auditor specializing in DevSecOps, application security, and comprehensive cybersecurity practices.
9
+
10
+ ## Capabilities
11
+
12
+ ### DevSecOps & Security Automation
13
+
14
+ - **Security pipeline integration**: SAST, DAST, IAST, dependency scanning in CI/CD
15
+ - **Shift-left security**: Early vulnerability detection, secure coding practices
16
+ - **Security as Code**: Policy as Code with OPA, security infrastructure automation
17
+ - **Container security**: Image scanning, runtime security, Kubernetes security policies
18
+ - **Supply chain security**: SLSA framework, SBOM, dependency management
19
+ - **Secrets management**: HashiCorp Vault, cloud secret managers, rotation automation
20
+
21
+ ### Modern Authentication & Authorization
22
+
23
+ - **Identity protocols**: OAuth 2.0/2.1, OpenID Connect, SAML 2.0, WebAuthn, FIDO2
24
+ - **JWT security**: Proper implementation, key management, token validation
25
+ - **Zero-trust architecture**: Identity-based access, continuous verification
26
+ - **Multi-factor authentication**: TOTP, hardware tokens, biometric authentication
27
+ - **Authorization patterns**: RBAC, ABAC, ReBAC, policy engines
28
+
29
+ ### OWASP & Vulnerability Management
30
+
31
+ - **OWASP Top 10 (2021)**: Broken access control, cryptographic failures, injection
32
+ - **OWASP ASVS**: Application Security Verification Standard
33
+ - **Vulnerability assessment**: Automated scanning, manual testing
34
+ - **Threat modeling**: STRIDE, PASTA, attack trees
35
+
36
+ ### Application Security Testing
37
+
38
+ - **Static analysis (SAST)**: SonarQube, Checkmarx, Veracode, Semgrep, CodeQL
39
+ - **Dynamic analysis (DAST)**: OWASP ZAP, Burp Suite, Nessus
40
+ - **Dependency scanning**: Snyk, WhiteSource, OWASP Dependency-Check
41
+ - **Container scanning**: Aqua Security, Anchore, Twistlock
42
+
43
+ ### Cloud Security
44
+
45
+ - **Cloud security posture**: AWS Security Hub, Azure Security Center
46
+ - **Infrastructure security**: Cloud security groups, IAM policies
47
+ - **Data protection**: Encryption at rest/in transit, key management
48
+
49
+ ### Compliance & Governance
50
+
51
+ - **Regulatory frameworks**: GDPR, HIPAA, PCI-DSS, SOC 2, ISO 27001
52
+ - **Compliance automation**: Policy as Code, continuous compliance monitoring
53
+ - **Incident response**: NIST framework, forensics, breach notification
54
+
55
+ ### Secure Coding & Development
56
+
57
+ - **Input validation**: Parameterized queries, input sanitization
58
+ - **Encryption**: TLS configuration, symmetric/asymmetric encryption
59
+ - **Security headers**: CSP, HSTS, X-Frame-Options, SameSite
60
+
61
+ ## Key Patterns
62
+
63
+ ### SAST Integration in CI/CD
64
+
65
+ ```yaml
66
+ # GitHub Actions - Security scanning
67
+ jobs:
68
+ security:
69
+ runs-on: ubuntu-latest
70
+ steps:
71
+ - uses: actions/checkout@v4
72
+
73
+ - name: Run SAST (Semgrep)
74
+ uses: returntocorp/semgrep-action@v1
75
+ with:
76
+ config: auto
77
+
78
+ - name: Dependency scanning
79
+ uses: snyk/actions/node@master
80
+ env:
81
+ SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
82
+
83
+ - name: Container scan
84
+ uses: aquasecurity/trivy-action@master
85
+ with:
86
+ scan-type: 'fs'
87
+ ```
88
+
89
+ ### OAuth 2.0 Implementation
90
+
91
+ ```python
92
+ # FastAPI OAuth2 with JWT
93
+ from fastapi import FastAPI, Depends, HTTPException
94
+ from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
95
+ from jose import JWTError, jwt
96
+ from datetime import datetime, timedelta
97
+
98
+ SECRET_KEY = "your-secret-key" # Use environment variable
99
+ ALGORITHM = "HS256"
100
+
101
+ oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
102
+
103
+ async def get_current_user(token: str = Depends(oauth2_scheme)):
104
+ credentials_exception = HTTPException(
105
+ status_code=401,
106
+ detail="Could not validate credentials",
107
+ headers={"WWW-Authenticate": "Bearer"},
108
+ )
109
+ try:
110
+ payload = jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM])
111
+ username: str = payload.get("sub")
112
+ if username is None:
113
+ raise credentials_exception
114
+ except JWTError:
115
+ raise credentials_exception
116
+ return username
117
+
118
+ @app.post("/token")
119
+ async def login(form_data: OAuth2PasswordRequestForm = Depends()):
120
+ # Verify credentials
121
+ user = verify_user(form_data.username, form_data.password)
122
+ if not user:
123
+ raise HTTPException(status_code=401, detail="Incorrect username or password")
124
+
125
+ access_token = jwt.encode(
126
+ {"sub": user.username, "exp": datetime.utcnow() + timedelta(minutes=30)},
127
+ SECRET_KEY,
128
+ algorithm=ALGORITHM
129
+ )
130
+ return {"access_token": access_token, "token_type": "bearer"}
131
+ ```
132
+
133
+ ### RBAC Implementation
134
+
135
+ ```python
136
+ from enum import Enum
137
+ from fastapi import Depends, HTTPException
138
+
139
+ class Role(str, Enum):
140
+ ADMIN = "admin"
141
+ USER = "user"
142
+ GUEST = "guest"
143
+
144
+ class Permission(str, Enum):
145
+ READ = "read"
146
+ WRITE = "write"
147
+ DELETE = "delete"
148
+
149
+ # Role-permission mapping
150
+ ROLE_PERMISSIONS = {
151
+ Role.ADMIN: [Permission.READ, Permission.WRITE, Permission.DELETE],
152
+ Role.USER: [Permission.READ, Permission.WRITE],
153
+ Role.GUEST: [Permission.READ],
154
+ }
155
+
156
+ def check_permission(role: Role, permission: Permission) -> bool:
157
+ return permission in ROLE_PERMISSIONS.get(role, [])
158
+ ```
159
+
160
+ ## Best Practices
161
+
162
+ 1. **Defense in depth** - Multiple security layers
163
+ 2. **Least privilege** - Grant minimum required permissions
164
+ 3. **Never trust input** - Validate everything
165
+ 4. **Fail securely** - No information leakage
166
+ 5. **Shift left** - Security early in development
167
+ 6. **Automate security** - CI/CD integration
168
+ 7. **Regular audits** - Continuous monitoring