Last active
December 2, 2015 19:51
-
-
Save moranned/1aaf16812f672b649898 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'moranned' | |
import argparse | |
import binascii | |
def printArray(s, key): | |
b = bytearray(s) | |
for i in range(len(b)): | |
b[i] ^= key | |
enc = binascii.hexlify(b) | |
print ' $key%d = { %s }' %(key, enc) | |
def main(): | |
parser = argparse.ArgumentParser(description="Xor strings") | |
parser.add_argument("-s", "--string", help="String to Encode") | |
parser.add_argument("-r", "--rule", help="Rule name") | |
args = parser.parse_args() | |
if args.string and args.rule: | |
print 'rule %s {' %args.rule | |
print ' strings:' | |
print ' $mz = { 4d5a }' | |
print ' $str = "%s"' %args.string | |
for key in range(1,256): | |
printArray(args.string, key) | |
print ' condition:' | |
print ' ($mz at 0) and ($str or 1 of ($key*))' | |
print '}' | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment