<s> import argparse <EOL> import os <EOL> import re <EOL> import sys <EOL> import pwnlib . log <EOL> import pwnlib . term . text as text <EOL> from pwnlib . util . fiddling import hexdump_iter <EOL> pwnlib . log . install_default_handler ( ) <EOL> parser = argparse . ArgumentParser ( <EOL> description = '<STR_LIT>' <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT:file>' , <EOL> metavar = '<STR_LIT:file>' , <EOL> nargs = '<STR_LIT:?>' , <EOL> help = '<STR_LIT>' , <EOL> type = argparse . FileType ( '<STR_LIT:r>' ) , <EOL> default = sys . stdin <EOL> ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> help = "<STR_LIT>" , <EOL> default = '<STR_LIT>' , <EOL> ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> help = "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" , <EOL> nargs = "<STR_LIT:*>" , <EOL> ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> help = "<STR_LIT>" , <EOL> default = '<STR_LIT:0>' , <EOL> ) <EOL> parser . add_argument ( <EOL> "<STR_LIT:-c>" , "<STR_LIT>" , <EOL> help = "<STR_LIT>" , <EOL> default = '<STR_LIT>' , <EOL> ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> help = "<STR_LIT>" , <EOL> default = '<STR_LIT:0>' , <EOL> ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , <EOL> nargs = '<STR_LIT:?>' , <EOL> help = "<STR_LIT>" , <EOL> choices = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> default = '<STR_LIT>' , <EOL> ) <EOL> def asint ( s ) : <EOL> if s . startswith ( '<STR_LIT>' ) : <EOL> return int ( s , <NUM_LIT:16> ) <EOL> elif s . startswith ( '<STR_LIT:0>' ) : <EOL> return int ( s , <NUM_LIT:8> ) <EOL> else : <EOL> return int ( s , <NUM_LIT:10> ) <EOL> def main ( ) : <EOL> args = parser . parse_args ( ) <EOL> infile = args . file <EOL> width = asint ( args . width ) <EOL> skip = asint ( args . skip ) <EOL> count = asint ( args . count ) <EOL> offset = asint ( args . offset ) <EOL> color = args . color or '<STR_LIT>' <EOL> text . when = color <EOL> if skip : <EOL> if infile == sys . stdin : <EOL> infile . read ( skip ) <EOL> else : <EOL> infile . seek ( skip , os . SEEK_CUR ) <EOL> if args . highlight : <EOL> def canon ( hl ) : <EOL> out = [ ] <EOL> i = <NUM_LIT:0> <EOL> while i < len ( hl ) : <EOL> c = hl [ i ] <EOL> if c == '<STR_LIT:\\>' and len ( hl ) > i + <NUM_LIT:1> : <EOL> c2 = hl [ i + <NUM_LIT:1> ] <EOL> if c2 == '<STR_LIT:x>' : <EOL> try : <EOL> b = chr ( int ( hl [ i + <NUM_LIT:2> : i + <NUM_LIT:4> ] , <NUM_LIT:16> ) ) <EOL> except : <EOL> print '<STR_LIT>' , hl [ i : ] <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> out . append ( b ) <EOL> i += <NUM_LIT:3> <EOL> elif c2 in '<STR_LIT>' : <EOL> out . append ( c2 ) <EOL> i += <NUM_LIT:1> <EOL> else : <EOL> out . append ( c ) <EOL> elif c == '<STR_LIT:?>' : <EOL> out . append ( None ) <EOL> else : <EOL> out . append ( c ) <EOL> i += <NUM_LIT:1> <EOL> return out <EOL> highlight = map ( canon , args . highlight ) <EOL> else : <EOL> highlight = [ ] <EOL> try : <EOL> for line in hexdump_iter ( infile , width , highlight = highlight , begin = offset + skip ) : <EOL> print line <EOL> except ( KeyboardInterrupt , IOError ) : <EOL> pass <EOL> if __name__ == '<STR_LIT:__main__>' : main ( ) </s>
