-
-
Save vrosnet/8b4b0a3efa2fa688c479496fa7974f60 to your computer and use it in GitHub Desktop.
Converts wide string to string
This file contains 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
#!/usr/bin/python | |
# CC-BY: hasherezade | |
"""Convert wchar string to char string""" | |
import argparse | |
def convert(data): | |
maxlen = len(data) | |
decoded = bytearray() | |
i = 0 | |
while i < maxlen: | |
dec = data[i] | |
decoded.append(dec) | |
i += 2 | |
return decoded | |
def main(): | |
parser = argparse.ArgumentParser(description="Converts wchar string to char string") | |
parser.add_argument('--file', dest="file", default=None, help="Input file", required=True) | |
args = parser.parse_args() | |
fp = open(args.file, 'rb') | |
if fp is None: | |
print "[-] Failed to open file" | |
return (-1) | |
data = fp.read() | |
fp.close() | |
decoded = convert(data) | |
print decoded | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment