File size: 7,655 Bytes
dd3f80b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7960cd3
dd3f80b
 
 
 
 
 
 
 
 
 
 
 
 
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
---
license: mit
task_categories:
- text-generation
- feature-extraction
language:
- en
tags:
- system-calls
- strace
- linux
- syscalls
- operating-systems
- code
pretty_name: Linux Strace Traces Dataset
size_categories:
- n<1K
---

# Linux Strace Traces Dataset

A comprehensive collection of strace traces from common Linux utilities, designed for training AI models on system call patterns, program behavior analysis, and operating system interactions.

## Dataset Description

This dataset contains **357 strace traces** captured from 119 different Linux command-line utilities, with each utility executed 3 times to capture runtime variations. Each trace includes detailed system call information with timestamps, arguments, and execution times.

### Dataset Statistics

- **Total traces**: 357 (119 unique commands × 3 runs each)
- **Categories**: 8
- **Format**: Parquet (Hugging Face native)
- **Raw size**: ~40 MB
- **Compressed size**: ~5 MB (Parquet)
- **License**: MIT

### Runtime Diversity

Each command was executed 3 times to capture natural variations in program execution:
- Different process IDs (PIDs)
- Different memory addresses (ASLR randomization)
- Different timestamps with microsecond precision
- Slight variations in syscall timing

This diversity helps train more robust AI models that can generalize across different execution contexts.

### Categories

1. **File I/O Operations** (75 traces = 25 commands × 3 runs)
   - File reading: `cat`, `head`, `tail`, `less`
   - File manipulation: `cp`, `mv`, `touch`, `rm`
   - Directory operations: `mkdir`, `rmdir`, `find`
   - File information: `stat`, `file`, `ls`, `du`, `df`

2. **Text Processing** (69 traces = 23 commands × 3 runs)
   - Pattern matching: `grep` (simple, case-insensitive, recursive, count)
   - Text transformation: `sed`, `awk`, `tr`
   - Sorting & filtering: `sort`, `uniq`, `cut`, `paste`
   - Analysis: `wc`, `diff`, `cmp`

3. **Process & System Info** (51 traces = 17 commands × 3 runs)
   - Process listing: `ps`, `top`, `pgrep`
   - System information: `uptime`, `who`, `whoami`, `id`, `uname`, `hostname`
   - Environment: `env`, `printenv`
   - Time: `date`, `cal`
   - Resources: `free`, `vmstat`

4. **Networking** (33 traces = 11 commands × 3 runs)
   - Network requests: `ping`, `curl`, `wget`
   - DNS queries: `host`, `dig`, `nslookup`
   - Network info: `ip`, `ss`, `netstat`

5. **Compression & Archives** (36 traces = 12 commands × 3 runs)
   - Tar operations: create, extract, list (with/without gzip)
   - Compression: `gzip`, `bzip2`
   - Zip operations: `zip`, `unzip`

6. **Scripting & Execution** (45 traces = 15 commands × 3 runs)
   - Shell execution: `bash`, `sh`
   - Python execution: scripts and inline commands
   - Utilities: `sleep`, `echo`, `printf`, `yes`, `seq`
   - Tests: `true`, `false`, `test`, `expr`

7. **Permissions & Ownership** (18 traces = 6 commands × 3 runs)
   - Permission modification: `chmod` (numeric, symbolic, recursive)
   - Permission viewing: `ls -l`
   - Umask operations

8. **Data Operations** (30 traces = 10 commands × 3 runs)
   - Random data: `dd` with `/dev/urandom` and `/dev/zero`
   - Encoding: `base64` (encode/decode)
   - Hashing: `md5sum`, `sha1sum`, `sha256sum`
   - Binary analysis: `hexdump`, `od`, `strings`

## Dataset Structure

### Data Fields

- `id` (string): Unique identifier for the trace (e.g., "cat_simple_run1")
- `category` (string): Category of the utility (e.g., "file_io")
- `command` (string): Full command executed (e.g., "cat test.txt")
- `strace` (string): Complete strace output with system calls
- `duration` (float): Execution time in seconds
- `timestamp` (string): ISO 8601 timestamp of trace capture
- `num_lines` (int): Number of lines in the strace output
- `size_bytes` (int): Size of the strace output in bytes
- `run_number` (int): Run iteration (1, 2, or 3)

### Data Splits

This dataset contains a single split:
- `train`: 357 examples (119 unique commands × 3 runs)

### Example

```python
from datasets import load_dataset

dataset = load_dataset("YOUR_USERNAME/strace-dataset")

# View first example
example = dataset['train'][0]
print(f"Command: {example['command']}")
print(f"Category: {example['category']}")
print(f"Duration: {example['duration']}s")
print(f"Strace output (first 500 chars):\n{example['strace'][:500]}")
```

## Dataset Creation

### Source Data

All traces were generated in a controlled, isolated environment using the `strace` utility with the following flags:
- `-f`: Follow child processes
- `-s 256`: Capture up to 256 bytes of string arguments
- `-tt`: Absolute timestamps with microsecond precision
- `-T`: Show time spent in each syscall

### Data Collection Process

1. Temporary workspace created with test files (text, binary, CSV, etc.)
2. Each utility executed with typical arguments/use cases
3. Strace captured all system calls during execution
4. Test data cleaned up after collection
5. No sensitive information or system-specific paths included

### Safety & Privacy

- ✅ No sensitive data (passwords, keys, tokens)
- ✅ No user-specific information
- ✅ No production system paths
- ✅ All operations performed in temporary directories
- ✅ Safe for open-source release

## Use Cases

### Training AI Models

- **System call prediction**: Predict next system calls based on program behavior
- **Anomaly detection**: Identify unusual syscall patterns
- **Program behavior modeling**: Learn normal execution patterns
- **Security analysis**: Detect potential malicious behavior

### Analysis & Research

- Understanding program execution flows
- Comparing syscall patterns across utilities
- Educational resource for OS concepts
- Benchmark for trace analysis tools

### Code Examples

#### Load and explore the dataset

```python
from datasets import load_dataset
import pandas as pd

# Load dataset
ds = load_dataset("andrew000/straces")

# Convert to pandas for analysis
df = pd.DataFrame(ds['train'])

# Group by category
print(df.groupby('category').size())

# Find longest-running commands
print(df.nlargest(5, 'duration')[['command', 'duration']])

# Analyze strace patterns
for example in ds['train']:
    if 'openat' in example['strace']:
        print(f"{example['command']} opens files")
```

#### Extract specific syscalls

```python
import re

def extract_syscalls(strace_output):
    """Extract syscall names from strace output."""
    pattern = r'\d+\s+[\d:.]+\s+(\w+)\('
    return list(set(re.findall(pattern, strace_output)))

# Find all syscalls used by cat
cat_example = [ex for ex in ds['train'] if ex['id'] == 'cat_simple'][0]
syscalls = extract_syscalls(cat_example['strace'])
print(f"cat uses these syscalls: {syscalls}")
```

## Limitations

- Traces captured on a specific Linux system (kernel version may affect syscalls)
- Limited to common command-line utilities
- No multi-threaded or complex concurrent workloads
- Dataset size: 357 traces (medium-sized dataset)

## Future Work

- Add more utilities and use cases
- Include long-running processes
- Multi-threaded application traces
- Different input sizes for scalability analysis
- Traces from different Linux distributions/kernels

## Citation

If you use this dataset in your research, please cite:

```bibtex
@dataset{strace_traces_2025,
  title={Linux Strace Traces Dataset},
  author={Andrew Fasano},
  year={2025},
  publisher={Hugging Face},
  howpublished={\url{https://huggingface.co/datasets/andrew000/straces}}
}
```

## License

MIT License - See LICENSE file for details

## Acknowledgments

Generated using the `strace` utility on Linux. All traces are from standard open-source utilities.