Skip to content

Commit 7991d90

Browse files
authored
Merge pull request #5 from tylerp96/tylerp96-patch-3
Additions
2 parents 5256822 + 23c1f8d commit 7991d90

File tree

1 file changed

+323
-0
lines changed

1 file changed

+323
-0
lines changed

hacklib.py

+323
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020

2121
import socket, httplib, threading, time, urllib2, os
2222
from Queue import Queue
23+
import logging
24+
logging.getLogger("scapy.runtime").setLevel(logging.ERROR) # Fixes scapy logging error
25+
from scapy.all import * # Required for the Probe Request Class
26+
from string import ascii_uppercase, ascii_lowercase, digits # Import for PatternCreate and PatternOffset
2327

2428
class Backdoor(object):
2529
'''Creates a persistent backdoor payload. Currently only for Mac OSX.
@@ -821,6 +825,325 @@ def userInterface():
821825
print 'Proxy connected.'
822826
time.sleep(2)
823827
pass
828+
"""
829+
830+
This Class Mangles Words specified by the user
831+
832+
Example:
833+
834+
Test = hacklib.Mangle("Test", 1, 10, 1996, 2016)
835+
836+
Test.Leet()
837+
838+
Output: T3st
839+
840+
"""
841+
842+
class Mangle:
843+
844+
def __init__(self, text, num1, num2, year1, year2):
845+
846+
self.num1 = num1
847+
self.num2 = num2
848+
self.year1 = year1
849+
self.year2 = year2
850+
self.text = text
851+
852+
853+
def Numbers(self):
854+
855+
for x in self.text.split():
856+
857+
for i in range(self.num1, self.num2):
858+
859+
print ("%s" + "%s") % (x, i)
860+
print ("%s" + "%s") % (i, x)
861+
862+
def Years(self):
863+
864+
for x in self.text.split():
865+
866+
for i in range(self.year1, self.year2):
867+
868+
print ("%s" + "%s") % (x, i)
869+
print ("%s" + "%s") % (i, x)
870+
871+
872+
def UniqueNum(self):
873+
874+
for x in self.text.split():
875+
876+
for i in range(self.num1, self.num2):
877+
878+
print ("%s" + "%s" + "%s") % (x, x, i)
879+
880+
881+
def UniqueYears(self):
882+
883+
for x in self.text.split():
884+
885+
for i in range(self.year1, self.year2):
886+
887+
print ("%s" + "%s" + "%s") % (x, x, i)
888+
889+
890+
891+
def FirstLetterCapNum(self):
892+
893+
for x in self.text.split():
894+
895+
for i in range(self.num1, self.num2):
896+
897+
print ("%s" + "%s") % (x.capitalize(), i)
898+
print ("%s" + "%s") % (i, x.capitalize())
899+
900+
def Caps(self):
901+
902+
for x in self.text.split():
903+
904+
print x.capitalize()
905+
906+
907+
def UniqueCaps(self):
908+
909+
for x in self.text.split():
910+
911+
print ("%s" + "s") % (x.capitalize(), x.capitalize())
912+
913+
914+
915+
def CapandYears(self):
916+
917+
for x in self.text.split():
918+
919+
for i in range(self.year1, self.year2):
920+
921+
print ("%s" + "%s") % (x.capitalize(), i)
922+
print ("%s" + "%s") % (i, x.capitalize())
923+
924+
925+
def Leet(self):
926+
927+
for x in self.text.split():
928+
print x.replace("e", "3").replace("i", "1").replace("O", "0").replace("I", "1").replace("E", "3").replace("o", "0").replace("l", "1").replace("L", "1").replace("g", "9").replace("G", "6").replace("b", "8").replace("B", "8")
929+
930+
931+
932+
def LeetCap(self):
933+
934+
for x in self.text.split():
935+
print x.capitalize().replace("e", "3").replace("i", "1").replace("O", "0").replace("I", "1").replace("E", "3").replace("o", "0").replace("l", "1").replace("L", "1").replace("g", "9").replace("G", "6").replace("b", "8").replace("B", "8")
936+
937+
938+
939+
def LeetYears(self):
940+
941+
for x in self.text.split():
942+
943+
for i in range(self.year1, self.year2):
944+
945+
print ("%s" + "%s") % (x.replace("e", "3").replace("i", "1").replace("O", "0").replace("I", "1").replace("E", "3").replace("o", "0").replace("l", "1").replace("L", "1").replace("g", "9").replace("G", "6").replace("b", "8").replace("B", "8"), i)
946+
print ("%s" + "%s") % (i, x.replace("e", "3").replace("i", "1").replace("O", "0").replace("I", "1").replace("E", "3").replace("o", "0").replace("l", "1").replace("L", "1").replace("g", "9").replace("G", "6").replace("b", "8").replace("B", "8"))
947+
948+
949+
def LeetNumbers(self):
950+
951+
for x in self.text.split():
952+
953+
for i in range(self.num1, self.num2):
954+
955+
print ("%s" + "%s") % (x.replace("e", "3").replace("i", "1").replace("O", "0").replace("I", "1").replace("E", "3").replace("o", "0").replace("l", "1").replace("L", "1").replace("g", "9").replace("G", "6").replace("b", "8").replace("B", "8"), i)
956+
print ("%s" + "%s") % (i, x.replace("e", "3").replace("i", "1").replace("O", "0").replace("I", "1").replace("E", "3").replace("o", "0").replace("l", "1").replace("L", "1").replace("g", "9").replace("G", "6").replace("b", "8").replace("B", "8"))
957+
958+
959+
def UniqueLeet(self):
960+
961+
for x in self.text.split():
962+
963+
print ("%s" + "%s") % (x.replace("e", "3").replace("i", "1").replace("O", "0").replace("I", "1").replace("E", "3").replace("o", "0").replace("l", "1").replace("L", "1").replace("g", "9").replace("G", "6").replace("b", "8").replace("B", "8"),(x.replace("e", "3").replace("i", "1").replace("O", "0").replace("I", "1").replace("E", "3").replace("o", "0").replace("l", "1").replace("L", "1").replace("g", "9").replace("G", "6").replace("b", "8").replace("B", "8")))
964+
965+
966+
967+
def Reverse(self):
968+
969+
for x in self.text.split():
970+
971+
print x[::-1]
972+
973+
974+
def ReverseCap(self):
975+
976+
for x in self.text.split():
977+
print x[::-1].capitalize()
978+
979+
980+
981+
def ReverseNum(self):
982+
983+
for x in self.text.split():
984+
985+
for i in range(self.num1, self.num2):
986+
987+
print ("%s" + "%s") % (x[::-1], i)
988+
print ("%s" + "%s") % (i, x[::-1])
989+
990+
991+
992+
def ReverseYears(self):
993+
994+
for x in self.text.split():
995+
996+
for i in range(self.year1, self.year2):
997+
998+
print ("%s" + "%s") % (x[::-1], i)
999+
print ("%s" + "%s") % (i, x[::-1])
1000+
1001+
1002+
def ReverseUnique(self):
1003+
1004+
for x in self.text.split():
1005+
1006+
print x[::-1] + x[::-1]
1007+
1008+
'''
1009+
This Classes Dectects Probe Requests from Wireless Devices.
1010+
1011+
Example:
1012+
1013+
Probe = Proberequests("wlan0")
1014+
1015+
Probe.startSniff()
1016+
1017+
'''
1018+
1019+
class Proberequests:
1020+
1021+
global probeReqs
1022+
1023+
probeReqs = []
1024+
1025+
def __init__(self, interface):
1026+
1027+
self.interface = interface
1028+
1029+
def sniffProbe(self, p):
1030+
1031+
if p.haslayer(Dot11ProbeReq):
1032+
netName = p.getlayer(Dot11ProbeReq).info
1033+
if netName not in probeReqs:
1034+
probeReqs.append(netName)
1035+
print '[!] Detected New Probe Request: '
1036+
print "[+] ESSID: " + netName + " BSSID: " + p.addr2
1037+
1038+
def startSniff(self):
1039+
1040+
print "[+] Scanning...\n"
1041+
1042+
sniff(iface=self.interface, prn=self.sniffProbe)
1043+
1044+
"""
1045+
1046+
This class creates a unique pattern of 20280 characters.
1047+
1048+
This is a replica of the metasploit tool called pattern_create.rb
1049+
1050+
Example:
1051+
1052+
patternTest = PatternCreate(1000)
1053+
1054+
patternTest.generate()
1055+
1056+
Creates a unique pattern of 1000 characters.
1057+
1058+
"""
1059+
1060+
class PatternCreate:
1061+
1062+
global MAX_PATTERN_LENGTH
1063+
1064+
MAX_PATTERN_LENGTH = 20280
1065+
1066+
def __init__(self, length):
1067+
1068+
self.length = length
1069+
1070+
def generate(self):
1071+
1072+
output = []
1073+
1074+
"""
1075+
Generate a pattern of a given length up to a maximum
1076+
of 20280 - after this the pattern would repeat
1077+
"""
1078+
if self.length >= MAX_PATTERN_LENGTH:
1079+
raise MaxLengthException('ERROR: Pattern length exceeds maximum of %d' % MAX_PATTERN_LENGTH)
1080+
1081+
pattern = ''
1082+
for upper in ascii_uppercase:
1083+
for lower in ascii_lowercase:
1084+
for digit in digits:
1085+
if len(pattern) < self.length:
1086+
pattern += upper+lower+digit
1087+
else:
1088+
out = pattern[:self.length]
1089+
1090+
output.append(out)
1091+
1092+
print str(output)[1:-1].replace("'", "")
1093+
1094+
1095+
"""
1096+
1097+
This class finds the offset from the PatternCreate class.
1098+
1099+
This is a replica of the metasploit tool called pattern_offset.rb
1100+
1101+
Example:
1102+
1103+
offset = PatternOffset("Aw1A")
1104+
1105+
offset.find()
1106+
1107+
Finds offset of Aw1A.
1108+
1109+
Output: [+] Offset: 663
1110+
1111+
"""
1112+
1113+
1114+
class PatternOffset:
1115+
1116+
def __init__(self, search_pattern):
1117+
1118+
self.search_pattern = search_pattern
1119+
1120+
def find(self):
1121+
1122+
offset = []
1123+
1124+
needle = self.search_pattern
1125+
1126+
try:
1127+
if needle.startswith('0x'):
1128+
# Strip off '0x', convert to ASCII and reverse
1129+
needle = needle[2:]
1130+
needle = bytes.fromhex(needle).decode('ascii')
1131+
needle = needle[::-1]
1132+
except TypeError as e:
1133+
print('Unable to convert hex input:', e)
1134+
sys.exit(1)
1135+
1136+
haystack = ''
1137+
for upper in ascii_uppercase:
1138+
for lower in ascii_lowercase:
1139+
for digit in digits:
1140+
haystack += upper+lower+digit
1141+
found_at = haystack.find(needle)
1142+
if found_at > -1:
1143+
1144+
offset = found_at
1145+
1146+
print "[+] Offset: " + str(offset)
8241147

8251148
if __name__ == '__main__':
8261149
userInterface()

0 commit comments

Comments
 (0)