Hacker News new | past | comments | ask | show | jobs | submit login
Gzip File Extraction from stdin
3 points by textmode on June 13, 2021 | hide | past | favorite | 1 comment
Note only extracts the first GZIP file. How to decompress multiple, consecutive GZIP files on stdin from the network (HTTP/1.1 pipelining)

    cat > 054.l;    
     int fileno(FILE *);
     #define jmp BEGIN
     #define echo ECHO
    
    xa "\x1f\x8b"    
     /* GZIP magic number */
    
    %s xa
    %option noyywrap noinput nounput
    %%
    {xa} echo;jmp xa;
    <xa>.|\n echo;
    \n|.
    %%
    int main(){ yylex();exit(0);}
    ^D

    flex -8Crf 054.l
    cc -pipe -static lex.yy.c -o yy054

    example usage:
    printf 'GET /file.gz\r\nHost: example.com\r\nConnection: close\r\n\r\n" |nc -vv example.com 80|yy054|zcat



Id would be better to start a blog to collect these post. Old post here have very low visibility.

Also in a blog you can classify them by subject, and are easier to link.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: