Skip to content

Instantly share code, notes, and snippets.

@moranned
Last active December 2, 2015 19:51
Show Gist options
  • Save moranned/1aaf16812f672b649898 to your computer and use it in GitHub Desktop.
Save moranned/1aaf16812f672b649898 to your computer and use it in GitHub Desktop.
__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