forked from conix-security/zer0m0n
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cuckoo.patch
1247 lines (1171 loc) · 53.2 KB
/
cuckoo.patch
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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff -rupN original/analyzer/windows/analyzer.py new/analyzer/windows/analyzer.py
--- original/analyzer/windows/analyzer.py 2014-07-11 18:20:44.773827653 +0200
+++ new/analyzer/windows/analyzer.py 2014-07-11 18:20:41.987160878 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014 Cuckoo Foundation.
+# Copyright (C) 2010-2014 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -64,6 +64,12 @@ def add_pid(pid):
log.info("Added new process to list with pid: %s", pid)
PROCESS_LIST.append(pid)
+def remove_pid(pid):
+ """Remove a process to process list."""
+ if type(pid) == long or type(pid) == int or type(pid) == str:
+ log.info("Process with pid %s has terminated", pid)
+ PROCESS_LIST.remove(pid)
+
def add_pids(pids):
"""Add PID."""
if type(pids) == list:
@@ -220,6 +226,44 @@ class PipeHandler(Thread):
response = "\x00"
else:
response = hookdll_encode(url_dlls)
+
+ # remove pid from process list because we received a notification
+ # from kernel land
+ elif command.startswith("KTERMINATE:"):
+ data = command[11:]
+ process_id = int(data)
+ if process_id:
+ if process_id in PROCESS_LIST:
+ remove_pid(process_id)
+
+ # same than below but we don't want to inject any DLLs because
+ # it's a kernel analysis
+ elif command.startswith("KPROCESS:"):
+ PROCESS_LOCK.acquire()
+ data = command[9:]
+ process_id = int(data)
+ thread_id = None
+ if process_id:
+ if process_id not in (PID, PPID):
+ if process_id not in PROCESS_LIST:
+ proc = Process(pid=process_id,thread_id=thread_id)
+ filepath = proc.get_filepath()
+ filename = os.path.basename(filepath)
+
+ if not protected_filename(filename):
+ add_pid(process_id)
+ log.info("Announce process name : %s", filename)
+ PROCESS_LOCK.release()
+
+ elif command.startswith("KERROR:"):
+ error_msg = command[7:]
+ log.error("Error : %s", str(error_msg))
+
+ # if a new driver has been loaded, we stop the analysis
+ elif command == "KSUBVERT":
+ for pid in PROCESS_LIST:
+ log.info("Process with pid %s has terminated", pid)
+ PROCESS_LIST.remove(pid)
# In case of PID, the client is trying to notify the creation of
# a new process to be injected and monitored.
@@ -612,6 +656,7 @@ class Analyzer:
pid_check = False
time_counter = 0
+ kernel_analysis = self.get_options().get("kernel_analysis", None)
while True:
time_counter += 1
@@ -630,17 +675,20 @@ class Analyzer:
# If the process monitor is enabled we start checking whether
# the monitored processes are still alive.
if pid_check:
- for pid in PROCESS_LIST:
- if not Process(pid=pid).is_alive():
- log.info("Process with pid %s has terminated", pid)
- PROCESS_LIST.remove(pid)
+ if kernel_analysis is False:
+ for pid in PROCESS_LIST:
+ if not Process(pid=pid).is_alive():
+ log.info("Process with pid %s has terminated", pid)
+ PROCESS_LIST.remove(pid)
# If none of the monitored processes are still alive, we
# can terminate the analysis.
if len(PROCESS_LIST) == 0:
- log.info("Process list is empty, "
- "terminating analysis...")
- break
+ KERNEL32.Sleep(1000)
+ if len(PROCESS_LIST) == 0:
+ log.info("Process list is empty, "
+ "terminating analysis...")
+ break
# Update the list of monitored processes available to the
# analysis package. It could be used for internal
@@ -689,14 +737,15 @@ class Analyzer:
# that we clean up remaining open handles (sockets, files, etc.).
log.info("Terminating remaining processes before shutdown...")
- for pid in PROCESS_LIST:
- proc = Process(pid=pid)
- if proc.is_alive():
- try:
- proc.terminate()
- except:
- continue
-
+ if kernel_analysis is False:
+ for pid in PROCESS_LIST:
+ proc = Process(pid=pid)
+ if proc.is_alive():
+ try:
+ proc.terminate()
+ except:
+ continue
+
# Let's invoke the completion procedure.
self.complete()
diff -rupN original/analyzer/windows/lib/api/process.py new/analyzer/windows/lib/api/process.py
--- original/analyzer/windows/lib/api/process.py 2014-07-11 18:20:44.773827653 +0200
+++ new/analyzer/windows/lib/api/process.py 2014-07-11 18:20:41.987160878 +0200
@@ -1,18 +1,22 @@
-# Copyright (C) 2010-2014 Cuckoo Foundation.
+# Copyright (C) 2010-2014 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
import os
import logging
import random
+import win32file
+import win32api
+import platform
+
from time import time
-from ctypes import byref, c_ulong, create_string_buffer, c_int, sizeof
+from ctypes import byref, c_ulong, create_string_buffer, c_int, sizeof
from shutil import copy
from lib.common.constants import PIPE, PATHS
from lib.common.defines import KERNEL32, NTDLL, SYSTEM_INFO, STILL_ACTIVE
-from lib.common.defines import THREAD_ALL_ACCESS, PROCESS_ALL_ACCESS
-from lib.common.defines import STARTUPINFO, PROCESS_INFORMATION
+from lib.common.defines import THREAD_ALL_ACCESS, PROCESS_ALL_ACCESS, TH32CS_SNAPPROCESS
+from lib.common.defines import STARTUPINFO, PROCESS_INFORMATION, PROCESSENTRY32
from lib.common.defines import CREATE_NEW_CONSOLE, CREATE_SUSPENDED
from lib.common.defines import MEM_RESERVE, MEM_COMMIT, PAGE_READWRITE
from lib.common.defines import MEMORY_BASIC_INFORMATION
@@ -21,8 +25,15 @@ from lib.common.rand import random_strin
from lib.common.results import NetlogFile
from lib.core.config import Config
+IOCTL_PID = 0x222008
+IOCTL_CUCKOO_PATH = 0x22200C
+PATH_KERNEL_DRIVER = "\\\\.\\DriverSSDT"
+
log = logging.getLogger(__name__)
+def is_os_64bit():
+ return platform.machine().endswith('64')
+
def randomize_dll(dll_path):
"""Randomize DLL name.
@return: new DLL path.
@@ -174,7 +185,7 @@ class Process:
return None
- def execute(self, path, args=None, suspended=False):
+ def execute(self, path, args=None, suspended=False, kernel_analysis=False):
"""Execute sample process.
@param path: sample path.
@param args: process args.
@@ -218,6 +229,105 @@ class Process:
self.h_thread = process_info.hThread
log.info("Successfully executed process from path \"%s\" with "
"arguments \"%s\" with pid %d", path, args, self.pid)
+
+ if kernel_analysis == True:
+ log.info("Starting kernel analysis")
+ log.info("Installing driver")
+ if is_os_64bit():
+ sys_file = os.path.join(os.getcwd(), "dll", "zer0m0n_x64.sys")
+ else:
+ sys_file = os.path.join(os.getcwd(), "dll", "zer0m0n.sys")
+ exe_file = os.path.join(os.getcwd(), "dll", "logs_dispatcher.exe")
+ if not sys_file or not exe_file or not os.path.exists(sys_file) or not os.path.exists(exe_file):
+ log.warning("No valid zer0m0n files to be used for process with pid %d, injection aborted", self.pid)
+ return False
+
+ exe_name = random_string(6)
+ service_name = random_string(6)
+ driver_name = random_string(6)
+ inf_data = '[Version]\r\nSignature = "$Windows NT$"\r\nClass = "ActivityMonitor"\r\nClassGuid = {b86dff51-a31e-4bac-b3cf-e8cfe75c9fc2}\r\nProvider= %Prov%\r\nDriverVer = 22/01/2014,1.0.0.0\r\nCatalogFile = %DriverName%.cat\r\n[DestinationDirs]\r\nDefaultDestDir = 12\r\nMiniFilter.DriverFiles = 12\r\n[DefaultInstall]\r\nOptionDesc = %ServiceDescription%\r\nCopyFiles = MiniFilter.DriverFiles\r\n[DefaultInstall.Services]\r\nAddService = %ServiceName%,,MiniFilter.Service\r\n[DefaultUninstall]\r\nDelFiles = MiniFilter.DriverFiles\r\n[DefaultUninstall.Services]\r\nDelService = %ServiceName%,0x200\r\n[MiniFilter.Service]\r\nDisplayName= %ServiceName%\r\nDescription= %ServiceDescription%\r\nServiceBinary= %12%\\%DriverName%.sys\r\nDependencies = "FltMgr"\r\nServiceType = 2\r\nStartType = 3\r\nErrorControl = 1\r\nLoadOrderGroup = "FSFilter Activity Monitor"\r\nAddReg = MiniFilter.AddRegistry\r\n[MiniFilter.AddRegistry]\r\nHKR,,"DebugFlags",0x00010001 ,0x0\r\nHKR,"Instances","DefaultInstance",0x00000000,%DefaultInstance%\r\nHKR,"Instances\\"%Instance1.Name%,"Altitude",0x00000000,%Instance1.Altitude%\r\nHKR,"Instances\\"%Instance1.Name%,"Flags",0x00010001,%Instance1.Flags%\r\n[MiniFilter.DriverFiles]\r\n%DriverName%.sys\r\n[SourceDisksFiles]\r\n'+driver_name+'.sys = 1,,\r\n[SourceDisksNames]\r\n1 = %DiskId1%,,,\r\n[Strings]\r\n'+'Prov = "'+random_string(8)+'"\r\nServiceDescription = "'+random_string(12)+'"\r\nServiceName = "'+service_name+'"\r\nDriverName = "'+driver_name+'"\r\nDiskId1 = "'+service_name+' Device Installation Disk"\r\nDefaultInstance = "'+service_name+' Instance"\r\nInstance1.Name = "'+service_name+' Instance"\r\nInstance1.Altitude = "370050"\r\nInstance1.Flags = 0x0'
+
+ new_inf = os.path.join(os.getcwd(), "dll", "{0}.inf".format(service_name))
+ new_sys = os.path.join(os.getcwd(), "dll", "{0}.sys".format(driver_name))
+ copy(sys_file, new_sys)
+ new_exe = os.path.join(os.getcwd(), "dll", "{0}.exe".format(exe_name))
+ copy(exe_file, new_exe)
+ log.info("[-] Driver name : "+new_sys)
+ log.info("[-] Inf name : "+new_inf)
+ log.info("[-] Application name : "+new_exe)
+ log.info("[-] Service : "+service_name)
+
+ fh = open(new_inf,"w")
+ fh.write(inf_data)
+ fh.close()
+
+ if is_os_64bit():
+ wow64 = c_ulong(0)
+ KERNEL32.Wow64DisableWow64FsRedirection(byref(wow64))
+
+ os.system('cmd /c "rundll32 setupapi.dll, InstallHinfSection DefaultInstall 132 '+new_inf+'"')
+ os.system("net start "+service_name)
+
+ si = STARTUPINFO()
+ si.cb = sizeof(startup_info)
+ pi = PROCESS_INFORMATION()
+ cr = CREATE_NEW_CONSOLE
+
+ ldp = KERNEL32.CreateProcessA(new_exe,
+ None,
+ None,
+ None,
+ None,
+ cr,
+ None,
+ os.getenv("TEMP"),
+ byref(si),
+ byref(pi))
+ if not ldp:
+ log.error("Failed starting "+exe_name+".exe.")
+ return False
+
+ config_path = os.path.join(os.getenv("TEMP"), "%s.ini" % self.pid)
+ with open(config_path, "w") as config:
+ cfg = Config("analysis.conf")
+
+ config.write("host-ip={0}\n".format(cfg.ip))
+ config.write("host-port={0}\n".format(cfg.port))
+ config.write("pipe={0}\n".format(PIPE))
+
+ log.info("Sending startup information")
+ hFile = win32file.CreateFile(PATH_KERNEL_DRIVER, win32file.GENERIC_READ|win32file.GENERIC_WRITE,
+ 0, None, win32file.OPEN_EXISTING, 0, None)
+ if hFile:
+ p = Process(pid=os.getpid())
+ ppid = p.get_parent_pid()
+ pid_vboxservice = 0
+ pid_vboxtray = 0
+
+ # get pid of VBoxService.exe and VBoxTray.exe
+ proc_info = PROCESSENTRY32()
+ proc_info.dwSize = sizeof(PROCESSENTRY32)
+
+ snapshot = KERNEL32.CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
+ flag = KERNEL32.Process32First(snapshot, byref(proc_info))
+ while flag:
+ if proc_info.sz_exeFile == "VBoxService.exe":
+ log.info("VBoxService.exe found !")
+ pid_vboxservice = proc_info.th32ProcessID
+ flag = 0
+ elif proc_info.sz_exeFile == "VBoxTray.exe":
+ pid_vboxtray = proc_info.th32ProcessID
+ log.info("VBoxTray.exe found !")
+ flag = 0
+ flag = KERNEL32.Process32Next(snapshot, byref(proc_info))
+ msg = str(self.pid)+"_"+str(ppid)+"_"+str(os.getpid())+"_"+str(pi.dwProcessId)+"_"+str(pid_vboxservice)+"_"+str(pid_vboxtray)+'\0'
+ win32file.DeviceIoControl(hFile, IOCTL_PID, msg, None)
+ msg = os.getcwd()+'\0'
+ win32file.DeviceIoControl(hFile, IOCTL_CUCKOO_PATH, unicode(msg), None)
+ else:
+ log.warning("Failed to access kernel driver")
+
+
return True
else:
log.error("Failed to execute process from path \"%s\" with "
@@ -316,9 +426,9 @@ class Process:
# The first time we come up with a random startup-time.
if Process.first_process:
- # This adds 1 up to 30 times of 20 minutes to the startup
- # time of the process, therefore bypassing anti-vm checks
- # which check whether the VM has only been up for <10 minutes.
+ # This adds 1 up to 30 times of 20 minutes to the startup
+ # time of the process, therefore bypassing anti-vm checks
+ # which check whether the VM has only been up for <10 minutes.
Process.startup_time = random.randint(1, 30) * 20 * 60 * 1000
config.write("host-ip={0}\n".format(cfg.ip))
@@ -372,7 +482,7 @@ class Process:
return False
else:
KERNEL32.CloseHandle(thread_handle)
-
+
return True
def wait(self):
diff -rupN original/analyzer/windows/lib/common/defines.py new/analyzer/windows/lib/common/defines.py
--- original/analyzer/windows/lib/common/defines.py 2014-07-11 18:20:44.777160985 +0200
+++ new/analyzer/windows/lib/common/defines.py 2014-07-11 18:20:41.987160878 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014 Cuckoo Foundation.
+# Copyright (C) 2010-2014 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -74,6 +74,8 @@ WM_GETTEXT = 0x0000000D
WM_GETTEXTLENGTH = 0x0000000E
BM_CLICK = 0x000000F5
+TH32CS_SNAPPROCESS = 0x02L
+
class STARTUPINFO(Structure):
_fields_ = [
("cb", DWORD),
@@ -104,6 +106,20 @@ class PROCESS_INFORMATION(Structure):
("dwThreadId", DWORD),
]
+class PROCESSENTRY32(Structure):
+ _fields_ = [
+ ("dwSize", DWORD),
+ ("cntUsage", DWORD),
+ ("th32ProcessID", DWORD),
+ ("th32DefaultHeapID", DWORD),
+ ("th32ModuleID", DWORD),
+ ("cntThreads", DWORD),
+ ("th32ParentProcessID", DWORD),
+ ("pcPriClassBase", DWORD),
+ ("dwFlags", DWORD),
+ ("sz_exeFile", c_char * 260)
+ ]
+
class LUID(Structure):
_fields_ = [
("LowPart", DWORD),
diff -rupN original/analyzer/windows/modules/packages/applet.py new/analyzer/windows/modules/packages/applet.py
--- original/analyzer/windows/modules/packages/applet.py 2014-07-11 18:20:44.773827653 +0200
+++ new/analyzer/windows/modules/packages/applet.py 2014-07-11 18:20:41.987160878 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014 Cuckoo Foundation.
+# Copyright (C) 2010-2014 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -50,6 +50,9 @@ class Applet(Package):
dll = self.options.get("dll", None)
free = self.options.get("free", False)
class_name = self.options.get("class", None)
+ kernel_analysis = self.options.get("kernel_analysis", False)
+ if kernel_analysis != False:
+ kernel_analysis = True
suspended = True
if free:
suspended = False
@@ -57,11 +60,13 @@ class Applet(Package):
html_path = self.make_html(path, class_name)
p = Process()
- if not p.execute(path=browser, args="\"%s\"" % html_path, suspended=suspended):
+ if not p.execute(path=browser, args="\"%s\"" % html_path, suspended=suspended,kernel_analysis=kernel_analysis):
raise CuckooPackageError("Unable to execute initial Internet "
"Explorer process, analysis aborted")
if not free and suspended:
+ if not kernel_analysis:
+ p.inject(dll)
p.inject(dll)
p.resume()
return p.pid
diff -rupN original/analyzer/windows/modules/packages/bin.py new/analyzer/windows/modules/packages/bin.py
--- original/analyzer/windows/modules/packages/bin.py 2014-07-11 18:20:44.773827653 +0200
+++ new/analyzer/windows/modules/packages/bin.py 2014-07-11 18:20:41.987160878 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014 Cuckoo Foundation.
+# Copyright (C) 2010-2014 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -11,8 +11,12 @@ class Shellcode(Package):
def start(self, path):
p = Process()
dll = self.options.get("dll")
- p.execute(path="bin/execsc.exe", args=path, suspended=True)
- p.inject(dll)
+ kernel_analysis = self.options.get("kernel_analysis", False)
+ if kernel_analysis != False:
+ kernel_analysis = True
+ p.execute(path="bin/execsc.exe", args=path, suspended=True,kernel_analysis=kernel_analysis)
+ if not kernel_analysis:
+ p.inject(dll)
p.resume()
return p.pid
diff -rupN original/analyzer/windows/modules/packages/cpl.py new/analyzer/windows/modules/packages/cpl.py
--- original/analyzer/windows/modules/packages/cpl.py 2014-07-11 18:20:44.773827653 +0200
+++ new/analyzer/windows/modules/packages/cpl.py 2014-07-11 18:20:41.987160878 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014 Cuckoo Foundation.
+# Copyright (C) 2010-2014 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -26,18 +26,22 @@ class CPL(Package):
dll = self.options.get("dll", None)
free = self.options.get("free", False)
+ kernel_analysis = self.options.get("kernel_analysis", False)
+ if kernel_analysis != False:
+ kernel_analysis = True
suspended = True
if free:
suspended = False
p = Process()
if not p.execute(path=control, args="\"%s\"" % path,
- suspended=suspended):
+ suspended=suspended,kernel_analysis=kernel_analysis):
raise CuckooPackageError("Unable to execute initial Control "
"process, analysis aborted")
if not free and suspended:
- p.inject(dll)
+ if not kernel_analysis:
+ p.inject(dll)
p.resume()
return p.pid
else:
diff -rupN original/analyzer/windows/modules/packages/dll.py new/analyzer/windows/modules/packages/dll.py
--- original/analyzer/windows/modules/packages/dll.py 2014-07-11 18:20:44.773827653 +0200
+++ new/analyzer/windows/modules/packages/dll.py 2014-07-11 18:20:41.987160878 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014 Cuckoo Foundation.
+# Copyright (C) 2010-2014 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -14,6 +14,9 @@ class Dll(Package):
function = self.options.get("function", "DllMain")
arguments = self.options.get("arguments", None)
dll = self.options.get("dll", None)
+ kernel_analysis = self.options.get("kernel_analysis", False)
+ if kernel_analysis != False:
+ kernel_analysis = True
suspended = True
if free:
suspended = False
@@ -23,12 +26,13 @@ class Dll(Package):
args += " {0}".format(arguments)
p = Process()
- if not p.execute(path="C:\\WINDOWS\\system32\\rundll32.exe", args=args, suspended=suspended):
+ if not p.execute(path="C:\\WINDOWS\\system32\\rundll32.exe", args=args, suspended=suspended, kernel_analysis=kernel_analysis):
raise CuckooPackageError("Unable to execute rundll32, "
"analysis aborted")
if not free and suspended:
- p.inject(dll)
+ if not kernel_analysis:
+ p.inject(dll)
p.resume()
return p.pid
else:
diff -rupN original/analyzer/windows/modules/packages/doc.py new/analyzer/windows/modules/packages/doc.py
--- original/analyzer/windows/modules/packages/doc.py 2014-07-11 18:20:44.773827653 +0200
+++ new/analyzer/windows/modules/packages/doc.py 2014-07-11 18:20:41.987160878 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014 Cuckoo Foundation.
+# Copyright (C) 2010-2014 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -37,17 +37,22 @@ class DOC(Package):
dll = self.options.get("dll", None)
free = self.options.get("free", False)
+ kernel_analysis = self.options.get("kernel_analysis", False)
+ if kernel_analysis != False:
+ kernel_analysis = True
+
suspended = True
if free:
suspended = False
p = Process()
- if not p.execute(path=word, args="\"%s\"" % path, suspended=suspended):
+ if not p.execute(path=word, args="\"%s\"" % path, suspended=suspended, kernel_analysis=kernel_analysis):
raise CuckooPackageError("Unable to execute initial Microsoft "
"Office Word process, analysis aborted")
if not free and suspended:
- p.inject(dll)
+ if not kernel_analysis:
+ p.inject(dll)
p.resume()
return p.pid
else:
diff -rupN original/analyzer/windows/modules/packages/exe.py new/analyzer/windows/modules/packages/exe.py
--- original/analyzer/windows/modules/packages/exe.py 2014-07-11 18:20:44.773827653 +0200
+++ new/analyzer/windows/modules/packages/exe.py 2014-07-11 18:20:41.987160878 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014 Cuckoo Foundation.
+# Copyright (C) 2010-2014 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -13,17 +13,21 @@ class Exe(Package):
free = self.options.get("free", False)
args = self.options.get("arguments", None)
dll = self.options.get("dll", None)
+ kernel_analysis = self.options.get("kernel_analysis", False)
+ if kernel_analysis != False:
+ kernel_analysis = True
suspended = True
if free:
suspended = False
p = Process()
- if not p.execute(path=path, args=args, suspended=suspended):
+ if not p.execute(path=path, args=args, suspended=suspended, kernel_analysis=kernel_analysis):
raise CuckooPackageError("Unable to execute initial process, "
"analysis aborted")
if not free and suspended:
- p.inject(dll)
+ if not kernel_analysis:
+ p.inject(dll)
p.resume()
p.close()
return p.pid
diff -rupN original/analyzer/windows/modules/packages/generic.py new/analyzer/windows/modules/packages/generic.py
--- original/analyzer/windows/modules/packages/generic.py 2014-07-11 18:20:44.773827653 +0200
+++ new/analyzer/windows/modules/packages/generic.py 2014-07-11 18:20:41.987160878 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014 Cuckoo Foundation.
+# Copyright (C) 2010-2014 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -14,6 +14,9 @@ class Genric(Package):
def start(self, path):
free = self.options.get("free", False)
dll = self.options.get("dll", None)
+ kernel_analysis = self.options.get("kernel_analysis", False)
+ if kernel_analysis != False:
+ kernel_analysis = True
suspended = True
if free:
suspended = False
@@ -22,12 +25,13 @@ class Genric(Package):
cmd_args = "/c start \"{0}\"".format(path)
p = Process()
- if not p.execute(path=cmd_path, args=cmd_args, suspended=suspended):
+ if not p.execute(path=cmd_path, args=cmd_args, suspended=suspended, kernel_analysis=kernel_analysis):
raise CuckooPackageError("Unable to execute initial process, "
"analysis aborted")
if not free and suspended:
- p.inject(dll)
+ if not kernel_analysis:
+ p.inject(dll)
p.resume()
p.close()
return p.pid
diff -rupN original/analyzer/windows/modules/packages/html.py new/analyzer/windows/modules/packages/html.py
--- original/analyzer/windows/modules/packages/html.py 2014-07-11 18:20:44.773827653 +0200
+++ new/analyzer/windows/modules/packages/html.py 2014-07-11 18:20:41.987160878 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014 Cuckoo Foundation.
+# Copyright (C) 2010-2014 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -14,6 +14,9 @@ class HTML(Package):
def start(self, path):
free = self.options.get("free", False)
dll = self.options.get("dll", None)
+ kernel_analysis = self.options.get("kernel_analysis", False)
+ if kernel_analysis != False:
+ kernel_analysis = True
suspended = True
if free:
suspended = False
@@ -21,12 +24,13 @@ class HTML(Package):
iexplore = os.path.join(os.getenv("ProgramFiles"), "Internet Explorer", "iexplore.exe")
p = Process()
- if not p.execute(path=iexplore, args="\"%s\"" % path, suspended=suspended):
+ if not p.execute(path=iexplore, args="\"%s\"" % path, suspended=suspended, kernel_analysis=kernel_analysis):
raise CuckooPackageError("Unable to execute initial Internet "
"Explorer process, analysis aborted")
if not free and suspended:
- p.inject(dll)
+ if not kernel_analysis:
+ p.inject(dll)
p.resume()
return p.pid
else:
diff -rupN original/analyzer/windows/modules/packages/ie.py new/analyzer/windows/modules/packages/ie.py
--- original/analyzer/windows/modules/packages/ie.py 2014-07-11 18:20:44.773827653 +0200
+++ new/analyzer/windows/modules/packages/ie.py 2014-07-11 18:20:41.987160878 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014 Cuckoo Foundation.
+# Copyright (C) 2010-2014 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -15,6 +15,9 @@ class IE(Package):
def start(self, url):
free = self.options.get("free", False)
dll = self.options.get("dll", None)
+ kernel_analysis = self.options.get("kernel_analysis", False)
+ if kernel_analysis != False:
+ kernel_analysis = True
suspended = True
if free:
suspended = False
@@ -22,12 +25,13 @@ class IE(Package):
iexplore = os.path.join(os.getenv("ProgramFiles"), "Internet Explorer", "iexplore.exe")
p = Process()
- if not p.execute(path=iexplore, args="\"%s\"" % url, suspended=suspended):
+ if not p.execute(path=iexplore, args="\"%s\"" % url, suspended=suspended, kernel_analysis=kernel_analysis):
raise CuckooPackageError("Unable to execute initial Internet "
"Explorer process, analysis aborted")
if not free and suspended:
- p.inject(dll)
+ if not kernel_analysis:
+ p.inject(dll)
p.resume()
return p.pid
else:
diff -rupN original/analyzer/windows/modules/packages/jar.py new/analyzer/windows/modules/packages/jar.py
--- original/analyzer/windows/modules/packages/jar.py 2014-07-11 18:20:44.773827653 +0200
+++ new/analyzer/windows/modules/packages/jar.py 2014-07-11 18:20:41.987160878 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014 Cuckoo Foundation.
+# Copyright (C) 2010-2014 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -33,6 +33,9 @@ class Jar(Package):
dll = self.options.get("dll", None)
free = self.options.get("free", False)
class_path = self.options.get("class", None)
+ kernel_analysis = self.options.get("kernel_analysis", False)
+ if kernel_analysis != False:
+ kernel_analysis = True
suspended = True
if free:
suspended = False
@@ -43,12 +46,13 @@ class Jar(Package):
args = "-jar \"%s\"" % path
p = Process()
- if not p.execute(path=java, args=args, suspended=suspended):
+ if not p.execute(path=java, args=args, suspended=suspended, kernel_analysis=kernel_analysis):
raise CuckooPackageError("Unable to execute initial Java "
"process, analysis aborted")
if not free and suspended:
- p.inject(dll)
+ if not kernel_analysis:
+ p.inject(dll)
p.resume()
return p.pid
else:
diff -rupN original/analyzer/windows/modules/packages/pdf.py new/analyzer/windows/modules/packages/pdf.py
--- original/analyzer/windows/modules/packages/pdf.py 2014-07-11 18:20:44.773827653 +0200
+++ new/analyzer/windows/modules/packages/pdf.py 2014-07-11 18:20:41.987160878 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014 Cuckoo Foundation.
+# Copyright (C) 2010-2014 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -34,17 +34,21 @@ class PDF(Package):
dll = self.options.get("dll", None)
free = self.options.get("free", False)
+ kernel_analysis = self.options.get("kernel_analysis", False)
+ if kernel_analysis != False:
+ kernel_analysis = True
suspended = True
if free:
suspended = False
p = Process()
- if not p.execute(path=reader, args="\"%s\"" % path, suspended=suspended):
+ if not p.execute(path=reader, args="\"%s\"" % path, suspended=suspended, kernel_analysis=kernel_analysis):
raise CuckooPackageError("Unable to execute initial Adobe Reader "
"process, analysis aborted")
if not free and suspended:
- p.inject(dll)
+ if not kernel_analysis:
+ p.inject(dll)
p.resume()
return p.pid
else:
diff -rupN original/analyzer/windows/modules/packages/ps1.py new/analyzer/windows/modules/packages/ps1.py
--- original/analyzer/windows/modules/packages/ps1.py 2014-07-11 18:20:44.773827653 +0200
+++ new/analyzer/windows/modules/packages/ps1.py 2014-07-11 18:20:41.987160878 +0200
@@ -33,6 +33,10 @@ class PS1(Package):
dll = self.options.get("dll", None)
free = self.options.get("free", False)
+ kernel_analysis = self.options.get("kernel_analysis", False)
+ if kernel_analysis != False:
+ kernel_analysis = True
+
suspended = True
if free:
suspended = False
@@ -40,11 +44,12 @@ class PS1(Package):
args = "-NoProfile -ExecutionPolicy unrestricted -File \"{0}\"".format(path)
p = Process()
- if not p.execute(path=powershell, args=args, suspended=suspended):
+ if not p.execute(path=powershell, args=args, suspended=suspended, kernel_analysis=kernel_analysis):
raise CuckooPackageError("Unable to execute initial PowerShell process, analysis aborted")
if not free and suspended:
- p.inject(dll)
+ if not kernel_analysis:
+ p.inject(dll)
p.resume()
return p.pid
else:
diff -rupN original/analyzer/windows/modules/packages/vbs.py new/analyzer/windows/modules/packages/vbs.py
--- original/analyzer/windows/modules/packages/vbs.py 2014-07-11 18:20:44.773827653 +0200
+++ new/analyzer/windows/modules/packages/vbs.py 2014-07-11 18:20:41.987160878 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014 Cuckoo Foundation.
+# Copyright (C) 2010-2014 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -33,17 +33,21 @@ class VBS(Package):
dll = self.options.get("dll", None)
free = self.options.get("free", False)
+ kernel_analysis = self.options.get("kernel_analysis", False)
+ if kernel_analysis != False:
+ kernel_analysis = True
suspended = True
if free:
suspended = False
p = Process()
- if not p.execute(path=wscript, args="\"{0}\"".format(path), suspended=suspended):
+ if not p.execute(path=wscript, args="\"{0}\"".format(path), suspended=suspended, kernel_analysis=kernel_analysis):
raise CuckooPackageError("Unable to execute initial WScript "
"process, analysis aborted")
if not free and suspended:
- p.inject(dll)
+ if not kernel_analysis:
+ p.inject(dll)
p.resume()
return p.pid
else:
diff -rupN original/analyzer/windows/modules/packages/xls.py new/analyzer/windows/modules/packages/xls.py
--- original/analyzer/windows/modules/packages/xls.py 2014-07-11 18:20:44.773827653 +0200
+++ new/analyzer/windows/modules/packages/xls.py 2014-07-11 18:20:41.987160878 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014 Cuckoo Foundation.
+# Copyright (C) 2010-2014 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -36,17 +36,21 @@ class XLS(Package):
dll = self.options.get("dll", None)
free = self.options.get("free", False)
+ kernel_analysis = self.options.get("kernel_analysis", False)
+ if kernel_analysis != False:
+ kernel_analysis = True
suspended = True
if free:
suspended = False
p = Process()
- if not p.execute(path=excel, args="\"%s\"" % path, suspended=suspended):
+ if not p.execute(path=excel, args="\"%s\"" % path, suspended=suspended, kernel_analysis=kernel_analysis):
raise CuckooPackageError("Unable to execute initial Microsoft "
"Office Excel process, analysis aborted")
if not free and suspended:
- p.inject(dll)
+ if not kernel_analysis:
+ p.inject(dll)
p.resume()
return p.pid
else:
diff -rupN original/analyzer/windows/modules/packages/zip.py new/analyzer/windows/modules/packages/zip.py
--- original/analyzer/windows/modules/packages/zip.py 2014-07-11 18:20:44.773827653 +0200
+++ new/analyzer/windows/modules/packages/zip.py 2014-07-11 18:20:41.987160878 +0200
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2014 Cuckoo Foundation.
+# Copyright (C) 2010-2014 Cuckoo Sandbox Developers.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -43,17 +43,21 @@ class Zip(Package):
dll = self.options.get("dll", None)
free = self.options.get("free", False)
args = self.options.get("arguments", None)
+ kernel_analysis = self.options.get("kernel_analysis", False)
+ if kernel_analysis != False:
+ kernel_analysis = True
suspended = True
if free:
suspended = False
p = Process()
- if not p.execute(path=file_path, args=args, suspended=suspended):
+ if not p.execute(path=file_path, args=args, suspended=suspended, kernel_analysis=kernel_analysis):
raise CuckooPackageError("Unable to execute initial process, "
"analysis aborted")
if not free and suspended:
- p.inject(dll)
+ if not kernel_analysis:
+ p.inject(dll)
p.resume()
return p.pid
else:
diff -rupN original/lib/cuckoo/common/logtbl.c new/lib/cuckoo/common/logtbl.c
--- original/lib/cuckoo/common/logtbl.c 1970-01-01 01:00:00.000000000 +0100
+++ new/lib/cuckoo/common/logtbl.c 2014-07-11 18:20:41.983827545 +0200
@@ -0,0 +1,235 @@
+#include <stdio.h>
+
+const char *logtbl[] = {
+ "__process__",
+ "__thread__",
+ "NtDeleteFile",
+ "CreateDirectoryW",
+ "CreateDirectoryExW",
+ "RemoveDirectoryA",
+ "RemoveDirectoryW",
+ "FindFirstFileExA",
+ "FindFirstFileExW",
+ "DeleteFileA",
+ "DeleteFileW",
+ "UnhookWindowsHookEx",
+ "LdrGetDllHandle",
+ "ExitWindowsEx",
+ "IsDebuggerPresent",
+ "LookupPrivilegeValueW",
+ "NtClose",
+ "URLDownloadToFileW",
+ "InternetReadFile",
+ "InternetWriteFile",
+ "InternetCloseHandle",
+ "DnsQuery_A",
+ "DnsQuery_UTF8",
+ "DnsQuery_W",
+ "getaddrinfo",
+ "GetAddrInfoW",
+ "NtTerminateProcess",
+ "ExitProcess",
+ "system",
+ "RegOpenKeyExA",
+ "RegOpenKeyExW",
+ "RegDeleteKeyA",
+ "RegDeleteKeyW",
+ "RegEnumKeyW",
+ "RegDeleteValueA",
+ "RegDeleteValueW",
+ "RegCloseKey",
+ "NtRenameKey",
+ "NtEnumerateKey",
+ "NtDeleteKey",
+ "NtDeleteValueKey",
+ "NtLoadKey",
+ "NtSaveKey",
+ "ControlService",
+ "DeleteService",
+ "NtDelayExecution",
+ "NtDelayExecution",
+ "WSAStartup",
+ "gethostbyname",
+ "socket",
+ "connect",
+ "send",
+ "sendto",
+ "recv",
+ "recvfrom",
+ "accept",
+ "bind",
+ "bind",
+ "setsockopt",
+ "listen",
+ "select",
+ "ioctlsocket",
+ "closesocket",
+ "shutdown",
+ "WSARecv",
+ "WSARecvFrom",
+ "WSASend",
+ "WSASendTo",
+ "WSASocketA",
+ "WSASocketW",
+ "ConnectEx",
+ "NtOpenMutant",
+ "NtGetContextThread",
+ "NtSetContextThread",
+ "NtResumeThread",
+ "NtTerminateThread",
+ "ExitThread",
+ "FindWindowA",
+ "FindWindowW",
+ "FindWindowExA",
+ "FindWindowExA",
+ "FindWindowExW",
+ "FindWindowExW",
+ "NtCreateFile",
+ "NtOpenFile",
+ "NtReadFile",
+ "NtWriteFile",
+ "NtDeviceIoControlFile",
+ "NtQueryDirectoryFile",
+ "NtQueryInformationFile",
+ "NtSetInformationFile",
+ "NtOpenDirectoryObject",
+ "NtCreateDirectoryObject",
+ "MoveFileWithProgressW",
+ "CopyFileA",
+ "CopyFileW",
+ "CopyFileExW",
+ "SetWindowsHookExA",
+ "SetWindowsHookExW",
+ "LdrLoadDll",
+ "LdrGetProcedureAddress",
+ "DeviceIoControl",
+ "WriteConsoleA",
+ "WriteConsoleW",
+ "InternetOpenA",
+ "InternetOpenW",
+ "InternetConnectA",
+ "InternetConnectW",
+ "InternetOpenUrlA",
+ "InternetOpenUrlW",
+ "HttpOpenRequestA",
+ "HttpOpenRequestW",
+ "HttpSendRequestA",
+ "HttpSendRequestW",
+ "NtCreateProcess",
+ "NtCreateProcessEx",
+ "NtCreateUserProcess",
+ "NtOpenProcess",
+ "NtOpenProcess",
+ "NtCreateSection",
+ "NtOpenSection",
+ "CreateProcessInternalW",
+ "ShellExecuteExW",
+ "NtAllocateVirtualMemory",
+ "NtReadVirtualMemory",
+ "ReadProcessMemory",
+ "NtWriteVirtualMemory",
+ "WriteProcessMemory",
+ "NtProtectVirtualMemory",
+ "VirtualProtectEx",
+ "NtFreeVirtualMemory",
+ "VirtualFreeEx",
+ "RegCreateKeyExA",
+ "RegCreateKeyExW",
+ "RegEnumKeyExA",
+ "RegEnumKeyExW",
+ "RegEnumValueA",
+ "RegEnumValueA",
+ "RegEnumValueW",
+ "RegEnumValueW",
+ "RegSetValueExA",
+ "RegSetValueExA",
+ "RegSetValueExW",
+ "RegSetValueExW",
+ "RegQueryValueExA",
+ "RegQueryValueExA",
+ "RegQueryValueExW",
+ "RegQueryValueExW",
+ "RegQueryInfoKeyA",