

Seattle Band 'netcat' Releases Album as a Linux Kernel Module - usrbinnc
https://github.com/usrbinnc/netcat-cpi-kernel-module

======
nemasu
Had to up my VM RAM to 7GB to get it to compile. Very cool though.

------
cordite
Dumping a hex string into a `#include`d header let me down

~~~
dbalatero
Sorry about that! Any good alternatives?

~~~
cnvogel
Instead of letting the C-compiler compile a huge array, you can use objcopy.

    
    
        objcopy -I binary -O elf32-littlearm -B arm /etc/passwd passwd.o
        cc    -c -o testme.o testme.c
        cc   testme.o passwd.o   -o testme
    

\--- testme.c ---

    
    
        #include <unistd.h>
        #include <stdlib.h>
        #include <stdio.h>
        
        /* "address" of symbol _size is the size of the objcopied file */
        extern void    _binary__etc_passwd_size;
        /* ..._start is the first byte of data */
        extern char    _binary__etc_passwd_start;
        /* ..._end is the one following the last byte of data */
        extern char    _binary__etc_passwd_end;
        
        int
        main(int argc, char **argv)
        {
            /* "address" of the symbol ..._size is the size */
            /* you could also do size = &..._end - &..._start; */
        	size_t size = &_binary__etc_passwd_size;
        
        	printf("Dumping /etc/passwd, in memory @%p, size is %ld.\n",
        		&_binary__etc_passwd_start, size);
        	write(1,&_binary__etc_passwd_start,size);
        	exit(0);
        }
    

\--- demo ---

    
    
        chris@raspberrypi ~/tmp/objcopy_to_carray $ ./testme 
        Dumping /etc/passwd, in memory @0x106b0, size is 607.
        root:x:0:0:root:/root:/bin/bash
        bin:x:1:1:bin:/bin:/bin/false
        daemon:x:2:2:daemon:/sbin:/bin/false
        mail:x:8:12:mail:/var/spool/mail:/bin/false
        (...remaining data omitted...)
    

\--- dumping headers of the passwd.o file ---

    
    
        chris@raspberrypi ~/tmp/objcopy_to_carray $ objdump -x passwd.o
     
        passwd.o:     file format elf32-littlearm
        passwd.o
        architecture: arm, flags 0x00000010:
        HAS_SYMS
        start address 0x00000000
        private flags = 0: [APCS-32] [FPA float format]
        
        Sections:
        Idx Name          Size      VMA       LMA       File off  Algn
          0 .data         0000025f  00000000  00000000  00000034  2**0
                          CONTENTS, ALLOC, LOAD, DATA
        SYMBOL TABLE:
        00000000 l    d  .data	00000000 .data
        00000000 g       .data	00000000 _binary__etc_passwd_start
        0000025f g       .data	00000000 _binary__etc_passwd_end
        0000025f g       *ABS*	00000000 _binary__etc_passwd_size

