-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathxorsearch.py
More file actions
37 lines (30 loc) · 826 Bytes
/
xorsearch.py
File metadata and controls
37 lines (30 loc) · 826 Bytes
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
import binascii
import sys
def XORdata (filename, xor):
file = open (filename, "rb")
byte = file.read(1)
newdata = ""
while byte != "":
newdata += chr(ord(byte) ^ xor)
if option == "-a":
if ((ord(byte) ^ xor) > 127) or ((ord(byte) ^ xor < 32)):
return null
byte = file.read(1)
file.close()
return newdata
try:
fn = sys.argv[1]
except:
print "Simple XOR key search v1.0 - @bbaskin"
print "Specify file with binary data to XOR"
print sys.argv[0] + " <filename> [-a]"
print "-a will avoid printing unprintable characters"
quit()
try:
option = sys.argv[2]
except:
option = "z"
for xor in range (1,255,1):
result = XORdata(fn, xor)
if result:
print "%s : %s" % (hex(xor), result)