-
Notifications
You must be signed in to change notification settings - Fork 3
/
hands.py
175 lines (141 loc) · 3.21 KB
/
hands.py
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
import os
def str_substring(string, sub_str):
if (string.find(sub_str) == -1):
return 0
else:
return 1
def list_substring(lists,sub_str):
if any(sub_str in s for s in lists):
return 1
else:
return 0
def print_val(val):
if(val==0):
print '\t\t[-]\033[1;31mDetected!\033[1;m'
else:
print '\t\t \033[1;32mNo!\033[1;m'
def print_sval(name):
print '\t\t[-]\033[1;31m'+name+' Detected!\033[1;m'
def presence():
test=0
list_dir=os.listdir('/usr/bin/')
lists={"vmware-","vbox","qemu"}
for i in lists:
flag=list_substring(list_dir,i)
if(flag==1):
print_sval(i)
test=test+1
if test==0:
print '\t\t \033[1;32mNo!\033[1;m'
def flags():
if 'hypervisor' in open("/proc/cpuinfo").read():
print_val(0)
else:
print_val(1)
def scsi():
test=0
list_dir=open("/proc/scsi/scsi").read().split(" ")
lists={"VMware","VBOX"}
for i in lists:
flag=list_substring(list_dir,i)
if(flag==1):
print_sval(i)
test=test+1
if test==0:
print_val(1)
def mac():
flag=0
test=0
flag=vbox_mac()
if(flag==0):
test=vmware_mac()
if(test==0 and flag==0):
print_val(1)
def vmware_mac():
mac=['00:05:69','00:0c:29','00:0C:29','00:1C:14','00:1c:14','00:50:56']
try:
addr= open("/sys/class/net/ens33/address").read()
address=addr[0:8]
for i in mac:
#print i
if (i==address):
print "\t\t[-]\033[1;31mVMWare Detected\033[1;m"
except IOError as e:
#print "\t\t I/O error({0}): {1}".format(e.errno, e.strerror)
if(e.errno==2):
return 0
def vbox_mac():
try:
addr1= open("/sys/class/net/enp0s3/address").read()
address1=addr1[0:8]
#print address
flag=str_substring(addr1, "08:00:27")
if(flag==1):
print "\t\t[-]\033[1;31mVirtualBox Detected\033[1;m"
except IOError as e:
#print "\t\t I/O error({0}): {1}".format(e.errno, e.strerror)
if(e.errno==2):
return 0
def bios_vendor():
name=open("/sys/class/dmi/id/bios_vendor").read()
test=0
lists={"vmware","vbox","Phoenix","innotek"}
for i in lists:
flag=str_substring(name,i)
if(flag==1):
print_val(0)
test=test+1
if test==0:
print_val(1)
def product_vendor():
name=open("/sys/class/dmi/id/product_name").read()
test=0
lists={"VMware","VirtualBox","Phoenix","innotek"}
for i in lists:
flag=str_substring(name,i)
if(flag==1):
print_val(0)
test=test+1
if test==0:
print_val(1)
def sys_vendor():
name=open("/sys/class/dmi/id/sys_vendor").read()
test=0
lists={"VMware","VirtualBox","Phoenix","innotek"}
for i in lists:
flag=str_substring(name,i)
if(flag==1):
print_val(0)
test=test+1
if test==0:
print_val(1)
def board_vendor():
name=open("/sys/class/dmi/id/board_vendor").read()
test=0
lists={"VMware","VirtualBox","Phoenix","innotek","Oracle"}
for i in lists:
flag=str_substring(name,i)
if(flag==1):
print_val(0)
test=test+1
if test==0:
print_val(1)
def kernel_modules():
name=open("/proc/modules").read()
test=0
list1={"vmw_balloon","vmwfgx"}
list2={"vboxvideo","vboxguest"}
for i in list1:
flag=str_substring(name,i)
if(flag==1):
print_sval("VMWare ")
test=test+1
break
for i in list2:
flag=str_substring(name,i)
if(flag==1):
print_sval("VirtualBox")
test=test+1
break
if test==0:
print_val(1)