Skip to content

Commit e182e07

Browse files
authored
Create In-Spectre_meltdown.py
Python code for the Spectre Meltdown. Python version 3.6.3 used and tested.
1 parent 30796b7 commit e182e07

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed

In-Spectre_meltdown.py

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/python
2+
'''
3+
This tool allows to check speculative execution side-channel attacks that affect many modern processors and operating systems designs. CVE-2017-5754 (Meltdown) and CVE-2017-5715 (Spectre) allows unprivileged processes to steal secrets from privileged processes. These attacks present 3 different ways of attacking data protection measures on CPUs enabling attackers to read data they shouldn't be able to. This tool is originally based on Microsoft: https://support.microsoft.com/en-us/help/4073119/protect-against-speculative-execution-side-channel-vulnerabilities-in
4+
Author: Viral Maniar
5+
Twitter: https://twitter.com/maniarviral
6+
Github: https://github.com/Viralmaniar
7+
LinkedIn: https://au.linkedin.com/in/viralmaniar
8+
'''
9+
import os, sys
10+
import subprocess
11+
from subprocess import check_output
12+
import time
13+
14+
def logo():
15+
logo = '''
16+
_____ _____ _ __ __ _ _ _
17+
|_ _| / ____| | | | \/ | | | | | |
18+
| | _ __ _____| (___ _ __ ___ ___| |_ _ __ ___ ______| \ / | ___| | |_ __| | _____ ___ __
19+
| | | '_ |______\___ \| '_ \ / _ \/ __| __| '__/ _ |______| |\/| |/ _ | | __/ _` |/ _ \ \ /\ / | '_ \
20+
_| |_| | | | ____) | |_) | __| (__| |_| | | __/ | | | | __| | || (_| | (_) \ V V /| | | |
21+
|_____|_| |_| |_____/| .__/ \___|\___|\__|_| \___| |_| |_|\___|_|\__\__,_|\___/ \_/\_/ |_| |_|
22+
| |
23+
|_|
24+
[+] Author: Viral Maniar
25+
[+] Twitter: @ManiarViral
26+
[+] Description: This tool allows to check speculative execution side-channel attacks that affect many modern processors and operating systems designs. CVE-2017-5754 (Meltdown) and CVE-2017-5715 (Spectre) allows unprivileged processes to steal secrets from privileged processes. These attacks present 3 different ways of attacking data protection measures on CPUs enabling attackers to read data they shouldn't be able to. This tool is originally based on Microsoft: https://support.microsoft.com/en-us/help/4073119/protect-against-speculative-execution-side-channel-vulnerabilities-in
27+
[+] Note: Administrator privileges required
28+
[+] Python version: 3.6.3
29+
[+] PowerShell version: 5.1
30+
'''
31+
return logo
32+
33+
OPTIONS = '''
34+
1. Set Execution Policy to Unrestricted
35+
2. Import PowerShell Module
36+
3. Install Spectre related Module
37+
4. Inspect Speculation control Setting for CVE-2017-5715 [branch target injection] & CVE-2017-5754 [rogue data cache load]
38+
5. Exit
39+
'''
40+
41+
def menu():
42+
while True:
43+
try:
44+
choice = str(input('\n[?] Do you want to continue? \n> ')).lower()
45+
if choice[0] == 'y':
46+
return
47+
if choice[0] == 'n':
48+
sys.exit(0)
49+
break
50+
except ValueError:
51+
sys.exit(0)
52+
53+
def checkHostWindows():
54+
if os.name == "nt":
55+
print ('[+] All good....')
56+
else:
57+
print ('[!] Please run the application on Windows machine')
58+
sys.exit(0)
59+
60+
def cmd_exectionPolicy():
61+
62+
process=subprocess.Popen(["powershell","Set-ExecutionPolicy Unrestricted"], shell=False);
63+
result=process.communicate()[0]
64+
print(result)
65+
print ("Execution Policy is now set to unrestricted...")
66+
67+
def cmd_importModule():
68+
69+
process=subprocess.Popen(["powershell","Import-Module PowerShellGet"], shell=False);
70+
result1=process.communicate()[0]
71+
print(result1)
72+
print ("Module Imported Successfully...")
73+
74+
def cmd_specModule():
75+
76+
process=subprocess.Popen(["powershell","Install-Module SpeculationControl"], shell=False);
77+
result2=process.communicate()[0]
78+
print(result2)
79+
print ("Spectre Module Imported Successfully...")
80+
81+
def cmd_showSpeculationControl():
82+
83+
process=subprocess.Popen(["powershell","Get-SpeculationControlSettings"], shell=False);
84+
result3=process.communicate()[0]
85+
print(result3)
86+
print ("Output printed successfully...")
87+
88+
cmds = {
89+
"1" : cmd_exectionPolicy,
90+
"2" : cmd_importModule,
91+
"3" : cmd_specModule,
92+
"4" : cmd_showSpeculationControl,
93+
"5" : lambda: sys.exit(0)
94+
}
95+
96+
def main():
97+
os.system('cls')
98+
print (logo())
99+
checkHostWindows()
100+
try:
101+
while True:
102+
choice = input("\n%s" % OPTIONS)
103+
if choice not in cmds:
104+
print ('[!] Invalid Choice')
105+
continue
106+
cmds.get(choice)()
107+
except KeyboardInterrupt:
108+
print ('[!] Ctrl + C detected\n[!] Exiting')
109+
sys.exit(0)
110+
except EOFError:
111+
print ('[!] Ctrl + D detected\n[!] Exiting')
112+
sys.exit(0)
113+
114+
if __name__ == "__main__":
115+
main()

0 commit comments

Comments
 (0)