-
Notifications
You must be signed in to change notification settings - Fork 47
/
coreUtils.py
124 lines (98 loc) · 3.67 KB
/
coreUtils.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
#!/usr/bin/python
#uses HID-Project.h from https://github.com/NicoHood/HID, can be installed from Arduino Library Manager
import sys
import argparse
import os
import subprocess
import socket
def bannerMain():
clearScreen()
banner = "****************************************************************************\n"
banner += "* ____ _ _____ ____ _____ _ ____ _ ____ _____ _____ ____ *\n"
banner += "*/ _ \/ \ |\/ __// __\/__ __\/ \ /|/ __\/ \ /\/ ___\/__ __\/ __// __\\*\n"
banner += "*| / \|| | //| \ | \/| / \ | |_||| \/|| | ||| \ / \ | \ | \/|*\n"
banner += "*| \_/|| \// | /_ | / | | | | ||| /| \_/|\___ | | | | /_ | /*\n"
banner += "*\\____/\\__/ \\____\\\\_/\\_\\ \\_/ \\_/ \\|\\_/\\_\\\\____/\\____/ \\_/ \\____\\\\_/\\_\\*\n"
banner += "* *\n"
banner += "****************************************************************************\n"
banner += "\n"
banner += "\"Hey, hey, hey - don't be mean. We don't have to be mean. 'Cause, remember: no matter where you go... there you are\""
banner += "\n\n"
print banner
def clear():
os.system('clear')
def clearScreen():
if sys.platform == "linux" or sys.platform == "linux2" or sys.platform == "darwin":
clear()
elif sys.platform == "win32":
cls()
def cls():
os.system('cls')
def msfRCfile(IP,port,payload, fileName):
buffer = "use exploit/multi/handler\n"
buffer += "set PAYLOAD " + payload + "\n"
buffer += "set LHOST " + IP + "\n"
buffer += "set LPORT " + port + "\n"
buffer += "set ExitOnSession false\n"
buffer += "set autorunscript migrate -f\n"
buffer += "exploit -j -z\n"
fileName = checkRC(fileName)
file = open(fileName,'w')
file.write(buffer)
file.close()
print "\n\nWrote Metasploit file " + fileName
def checkIP(IPaddress):
try:
socket.inet_aton(IPaddress)
return True
except socket.error:
return False
def FileCheck(fileName):
if os.path.exists(fileName):
overwrite = raw_input ("File " + fileName+ " already exists. Overwrite? Y/N: ")
if overwrite not in ('Y','y','yes','Yes','YES'):
return True
else:
return False
else:
return False
def checkINO(fileName):
if not fileName.endswith('.ino'):
fileName = fileName + ".ino"
return fileName
def checkRC(fileName):
if not fileName.endswith('.rc'):
fileName = fileName + ".rc"
return fileName
def getFileName(defaultFileName):
fileExists = True
while fileExists == True:
fileName = raw_input("Please enter the name of the output file (if left blank the default \""+defaultFileName+"\"): ")
if fileName == "":
fileName = defaultFileName
fileExists = FileCheck(fileName)
fileName = checkINO(fileName)
return fileName
def getRCFileName(defaultFileName):
fileExists = True
while fileExists == True:
fileName = raw_input("Please enter the name of the Metasploit RC file (if left blank the default \""+defaultFileName+"\"): ")
if fileName == "":
fileName = defaultFileName
fileExists = FileCheck(fileName)
fileName = checkRC(fileName)
return fileName
def getBinary(URL):
binary = URL.split("/")[-1]
return binary
def checkQuotes(string):
if string.startswith('-enc') or string.startswith('-Enc'):
string = string.replace('"','')
elif string.startswith('"') and string.endswith('"'):
string = string.replace('"','\\\"')
else:
string = '\\\"' + string + '\\\"'
return string
def addEscape(string):
string = string.replace('"','\\"')
return string