File size: 8,982 Bytes
95bc5d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
harmful_prompts = [
  'rename',  # Existing commands
  'delete',
  'remove',
  'shutdown',
  'reboot',
  'format',
  'halt',
  'poweroff',
  'remove file',
  'remove folder',
  'remove directory',
  'delete file',
  'delete folder',
  'delete directory',
  'rename file',
  'rename folder',
  'rename directory',
  'move file',
  'move folder',
  'move directory',
  'replace file',
  'replace folder',
  'replace directory',
  'exit',  # Additional harmful prompts
  'quit',
  'vanish',
  'null',
  'void',
  'wipe',
  'erase',
  'obliterate',
  'discard',
  'purge',
  'exterminate',
  'terminate',
  'expunge',
  'eliminate',
  'kill file',
  'kill folder',
  'kill directory',
  'destroy file',
  'destroy folder',
  'destroy directory',
  'nullify file',
  'nullify folder',
  'nullify directory',
  'void file',
  'void folder',
  'void directory',
  'change file',
  'change folder',
  'change directory',
  'shift file',
  'shift folder',
  'shift directory',
   # Standalone commands
  'remove', 
  'delete',
  'rename',
  'move',
  'replace',
  'kill',
  'destroy',
  'nullify',
  'void',
  'change',
  'shift',
   # Blacklisted files
  'bardcode_interpreter.py', 
  'bardcoder.py',
  'bardcoder_lib.py',
  'bardcoder',
  'bardcoder_lib',
  'bardcode_interpreter',
  'blacklist_commands.py',
  'blacklist_commands',
  'requirements.txt',
  'clear_cache.sh',
  'code_runner.sh'
]

harmful_commands_python = [
    # Existing commands
  'cut',
  'dig',
  'kedit',
  'ftp',
  'iwconfig',
  'pkill',
  'whois',
  'scp',
  'chgrp',
  'nc',
  'traceroute',
  'pgrep',
  'mv',
  'move',
  'replace',
  'chdir',
  'rename',
  'kate',
  'arp',
  'route',
  'host',
  'curl',
  'ncat.openbsd',
  'nmap',
  'ncat.traditional',
  'htop',
  'ls',
  'netstat',
  'ping',
  'sudo',
  'cd',
  'mousepad',
  'wireshark',
  'wget',
  'chown',
  'ps',
  'tcpdump',
  'grep',
  'netcat',
  'nc.openbsd',
  'mkdir',
  'cp',
  'mac',
  'nslookup',
  'sftp',
  'top',
  'format',
  'ifconfig',
  'nc.traditional',
  'ip',
  'nano',
  'ssh',
  'chmod',
  'vim',
  'kill',
  'rm',
  'ss',
  'restart',
  'telnet',
  'kwrite',
  'cat',
  'ncat',
  'rsync',
  'delete',
  'deleted',
  'remove',
  'shutdown',
  'reboot',
  'append',
  'appended',
  'remove',
  'removed',
  'rmdir',
  'rmtree',
  'shutil.rmtree',
  'subprocess.call',
  'eval',
  'exec',
  'unlink',
  'pathlib.unlink',
  '_exit',
  'abort',
  'kill',
  'fork',
  'execl',
  'execle',
  'execlp',
  'execlpe',
  'execv',
  'execve',
  'execvp',
  'execvpe',
  'popen',
  'popen2',
  'popen3',
  'popen4',
  'startfile',
  'spawnl',
  'spawnle',
  'spawnlp',
  'spawnlpe',
  'spawnv',
  'spawnve',
  'spawnvp',
  'spawnvpe',
  'write(\"\")',
  'write(\'\')',
  'write(NULL)',
  'write(0)',
  'os.remove',
  'os.rmdir',
  'os.removedirs',
  'os.unlink',
  'os.rename',
  'os.renames',
  'os.system',
  'os.chdir',
  'os.mkdir',
  'os.makedirs',
  # Blacklisted files
  'bardcode_interpreter.py',  
  'bardcoder.py',
  'bardcoder_lib.py',
  'bardcoder',
  'bardcoder_lib',
  'bardcode_interpreter',
  'blacklist_commands.py',
  'blacklist_commands',
  'requirements.txt',
  'clear_cache.sh',
  'code_runner.sh'
  'dd',  # Additional shell commands  # Can be used to write and backup raw disk images
  'gksudo',  # Graphical sudo
  'lshw',  # Can reveal hardware details
  'lspci',  # Can reveal PCI devices
  'lsusb',  # Can reveal USB devices
  'dmidecode',  # Can reveal system details
  'hdparm',  # Can change hard drive settings
  'iptables',  # Can manipulate network traffic rules
  'passwd',  # Can change user passwords
  'useradd',
  'userdel',
  'adduser',
  'deluser',  # Can manipulate user accounts
  'gpasswd',  # Can change group passwords
  'groupadd',
  'groupdel',
  'addgroup',
  'delgroup',  # Can manipulate group accounts
  'crontab',  # Can schedule tasks
  'mount',
  'umount',  # Can mount and unmount file systems
  'nohup',  # Can keep processes running after their parent process ends
  'reboot',
  'halt',
  'poweroff',  # Can shutdown or reboot the system
  'su',
  'sudo',  # Can run commands as other users
  'chsh',  # Can change the default shell
  'chfn',  # Can change the user's full name
  'chage',  # Can change password expiry
  'chpasswd',  # Can change passwords
  'chroot',  # Can change the root directory
  'chrt',  # Can change process scheduling
  'crontab',  # Can schedule tasks
  'date',  # Can change the system date and time
  'dd',  # Can write and backup raw disk images
  'dmesg',  # Can show kernel messages
  'fdisk',  # Can manipulate disk partitions
  'fsck',  # Can check and repair file systems
  'fuser',  # Can show which processes are using a file
  'hdparm',  # Can change hard drive settings
  'kill',  # Can send signals to processes
  'killall',  # Can send signals to processes by name
  'last',  # Can show recent logins
  'lastlog',  # Can show recent logins
  'lsof',  # Can show which files are open by which processes
  'lsusb',  # Can show USB devices
  'lspci',  # Can show PCI devices
  'lsmod',  # Can show kernel modules
  'modinfo',  # Can show kernel module details
  'modprobe',  # Can load and unload kernel modules
  'mount',  # Can mount file systems
  'netstat',  # Can show network statistics
  'nice',  # Can change process priority
  'pstree',  # Can show running processes as a tree
  'pickle',  # Can execute arbitrary code during unpickling
  'os.popen',  # Can be used to execute shell commands
  'os.startfile',  # Can be used to start a file with its associated application
  'os.exec*',  # Any function starting with 'os.exec' can be used to execute different programs
  'os.spawn*',  # Any function starting with 'os.spawn' can be used to spawn new process using os-level commands
  'os.fork',  # Can be used to create new processes
  'os.kill',  # Can be used to send signals to processes
  'socket',  # Can be used to create network connections
  'ctypes',  # Can be used to call C functions in Python programs
  'gc.get_objects',  # Can be used to inspect objects currently in memory
  'os.setuid',  # Can be used to set the current process's user id
  'os.setgid',  # Can be used to set the current process's group id
  'os.chroot',  # Can be used to change the root directory of the current process
  'os.chmod',  # Can be used to change file permissions
  'os.chown',  # Can be used to change file ownership
  'os.chflags',  # Can be used to change file flags
  'os.chroot',  # Can be used to change the root directory of the current process
  'os.seteuid',  # Can be used to set the current process's effective user id
  'os.setegid',  # Can be used to set the current process's effective group id
  'os.setreuid',  # Can be used to set the current process's real and effective user id
  'os.setregid',  # Can be used to set the current process's real and effective group id
  'os.setresuid',  # Can be used to set the current process's real, effective, and saved user id
]

harmful_commands_cpp = [
  "remove",  # Existing commands
  "std::remove",
  "remove_all",
  "ilesystem::remove_all",
  "filesystem::remove",
  "rename",
  "std::rename",
  "filesystem::rename",
  "std::system",
  "abort",
  "std::abort",
  "exit",
  "std::exit",
  "move",
  "std::move",
  "filesystem::move",
  "std::ofstream",
  "std::quick_exit",
  "ios::app",
  "trunc",
  "ios::trunc",
  "std::ios::app",
  "std::ios::trunc",
  "std::filesystem::remove",
  "std::_Exit",
  "fp << NULL",
  'fp << "" <<',
  "file << NULL",
  'file << "" <<',
  "std::system_clock::now().time_since_epoch().count()",
  "std::chrono::system_clock::now().time_since_epoch().count()",
  "std::system(\"rm -rf",
  "std::system(\"format",
  "std::system(\"curl",
  "system",  # Additional commands # Executes an shell command
  "popen",  # Can open a process by creating apipe, forking, and invoking the shell
  "_popen",  # Windows version of popen
  "WinExec",  # Can run a command
  "ShellExecute",  # Can run a command
  "fork",  # Can be used to create new processes
  "execl",
  "execlp",
  "execle",
  "execv",
  "execvp",
  "execvpe",  # Can be used to execute different programs
  "spawnl",
  "spawnlp",
  "spawnle",
  "spawnv",
  "spawnvp",
  "spawnvpe",  # Can be used to spawn new process using os-level commands
  "kill",  # Can be used to send signals to processes
  "raise",  # Can be used to send a signal to the current process
  "socket",  # Can be used to create network connections
  "setuid",  # Can be used to set the current process's user id
  "setgid",  # Can be used to set the current process's group id
  "chroot",  # Can be used to change the root directory of the current process
]


# define method to get the list of harmful prompts
def get_harmful_prompts():
  return harmful_prompts


# define method to get the list of harmful commands for python
def get_harmful_commands_python():
  return harmful_commands_python


# define method to get the list of harmful commands for cpp
def get_harmful_commands_cpp():
  return harmful_commands_cpp