Created
July 16, 2016 03:04
-
-
Save neon12345/298b095e5ae3e0890f8f9a73c606537a to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
py_script=' | |
import mmap, base64, sys, getopt | |
def main(argv): | |
inputfile = "" | |
needle = b"" | |
try: | |
opts, args = getopt.getopt(argv,"hi:n:",["ifile=","needle="]) | |
except getopt.GetoptError: | |
print "findbytes.sh -i <inputfile> -n <needle>" | |
sys.exit(2) | |
for opt, arg in opts: | |
if opt == "-h": | |
print "findbytes.sh -i <inputfile> -n <needle>" | |
sys.exit() | |
elif opt in ("-i", "--ifile"): | |
inputfile = arg | |
elif opt in ("-n", "--needle"): | |
needle = base64.b64decode(arg) | |
with open(inputfile, "rw+b") as f: | |
mm = mmap.mmap(f.fileno(), 0) | |
print mm.find(needle) | |
if __name__ == "__main__": | |
main(sys.argv[1:]) | |
' | |
python -c "$py_script" "$@" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment